Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

www.VUSR.

net
CS401- Computer Architecture and Assembly Language
Programming
Assignment # 1
Spring 2009
Total Marks: 20
Due Date
Your assignment must be uploaded before or on 3rd April 2009.
Upload Instructions
Please view the document related to assignment submission process provided to you
by the Virtual University to upload the assignment.
Rules for Marking
Kindly note that your assignment will NOT be graded if:
§ It is submitted after due date
§ The file you uploaded does not open
§ The file you uploaded is copied from someone else
§ It is in the format other than .doc
Objective
This assignment has been designed to enable you:
SR
§ To understand how effective address is calculated
§ To understand how physical memory address is calculated
§ To write, assemble and debug a program written in Assembly
U
V

Assignment
Question_1: [marks: 6]
What is the effective address generated by each of the following instruction?
Initially BX=0x0010, label=0x0124, [label]=0x0001, and SI=0x00F1
(Offsets in part a, b and f are in decimal)

a. mov ax, [bx+30]


b. mov ax, [bx+20]
c. mov ax, [bx+label]
d. mov ax, [label+bx]
e. mov ax, [bx+si]
f. mov ax, [si+15]

Page 1 of 4

http://lms.vusr.net
www.VUSR.net
Question_2: [marks: 6]
Calculate the physical memory address generated by the following segment offset
pairs (both are hexadecimal values).
a. 0000:0100
b. 0010:0000
c. 1DAD:1234
d. 4321:FFFF
e. FFFF:4321
f. FFEF:4421
g. 1080:0200

Question_3: [marks:
5+3]
Write a program in assembly language that calculates the sum of first five odd
numbers (1, 3, 5, 7, 9) and stores the result in AX register.
You can do it with the help of loop (initialize AX register with value 0 and BX with
value 1, and then on each iteration of loop add BX into AX and add value 2 in BX).
You are NOT allowed to define the data (like num1: dw 1, 3, 5, 7, 9)
You have to submit the assembly language code for this program and screen-shot of
this program loaded in AFD debugger in which the AX register contains the result.
SR
Helping Material
U

Ø Lecture handouts:
First eight video lectures (First two chapters of the handouts)
V

http://vulms.vu.edu.pk/Courses/CS401/Downloads/cs401.zip

Ø Assembly Language tools (Assembler, Debugger, linker), Installation manual


and AFD commands:
http://vulms.vu.edu.pk/Courses/CS401/Downloads/AssmSoft.zip
http://vulms.vu.edu.pk/Courses/CS401/Downloads/NASM%20Installation%20M
anual.doc
http://vulms.vu.edu.pk/Courses/CS401/Downloads/AFD_Commands.doc

Ø Website links for Number systems and Hexadecimal Arithmetic:


http://www.emu8086.com/assembly_language_tutorial_assembler_reference/
numbering_systems_tutorial.html
http://www.melabs.com/resources/articles/hexnumbers.htm
http://www.erikoest.dk/hex.htm
http://www.web-colors-explained.com/hex_04.php
http://www.tpub.com/content/neets/14185/css/14185_46.htm
http://www.ib-computing.com/program/topic_4/binhex.html

Page 2 of 4

http://lms.vusr.net
www.VUSR.net

Solution
Question_1:
a. mov ax, [bx+30]
Effective Address = bx + 30
= 0010 + 001E
= 002E
Question_2:
a. 0000:0100
16-bit Segment Address: 0000
16-bit Offset Address: 0100
Step1: Converting these to 20-bit addresses
20-bit Segment Address: 00000
20-bit Offset Address: 00100
Step2: Performing hexadecimal addition:
20-bit Physical address (in hexadecimal): 00000 + 00100 = 00100
20-bit Physical address (in decimal): 0000 0000 0001 0000 0000
[Each hexadecimal digit can be represented in its 4-bit equivalent binary (as
shown above)]
SR
Question_3:

Ø Assembly language code:


[org 0x0100]
U

; your program here


mov ax, 0x4c00 ; terminate program
int 0x21
V

Ø Sample Screen-shot displaying result in AX register (On AFD window, press the
key combination Alt + PrintScreen to take screen-shot and paste it here)

Page 3 of 4

http://lms.vusr.net
www.VUSR.net

SR
U
V

Page 4 of 4

http://lms.vusr.net

You might also like