Computer Architecture and Assembly Language Programming - CS401 Fall 2007 Assignment 01 Solution
Computer Architecture and Assembly Language Programming - CS401 Fall 2007 Assignment 01 Solution
PK
Q#1.
Identify the problems in the following instructions and correct them by replacing
them with one or two instruction having the same effect.
v. mov bx,[bs+bp+200]
; Addition of two based register in one memory access is disallowed. We
can do this operation by addition of index and base register.
mov ax,[bp+ si+100]
Q#2.
Write a program to calculate the square of 10 by using a loop that adds 10 to the
accumulator 10 times.
Solution:
[org 0x0100]
mov bx,10
mov cx,10
mov ax,0
l1:
add ax, bx
sub cx, 1
jnz l1
mov [total], ax
mov ax,0x4c00
int 0x21
total: dw 0
Q#3.
b. If AX=8FFF and BX=0FFF and “cmp ax, bx” is executed, which of the
following jumps will be taken? Each part is independent of others. Also give the
value of Z, S, and C flags.
i. jg greater
ii. jl smaller
iii. ja above
iv. jb below
Instructions Jump ZF SF CF
Jg greater Not taken 0 1 0
Jl smaller Taken 0 1 0
Ja above Taken 0 1 0
Jb below Not taken 0 1 0