Sheet 2 Solution
Sheet 2 Solution
University of Alexandria
Faculty of Engineering
Division of Communications & Electronics
1-Review questions:
3- Assume that BX = 4F56H, SP = 0100H and SS = 0200H. Explain what happens when
the PUSH BX is executed.
PUSH BX decrements the stack pointer (SP) by two then places BX at the two bytes
pointed by the new SP.
After execution:
SP = 0FEH
[020FE] = 56H
[020FF] = 4FH
2
4- Suppose that DS = 0200H, BX = 0200H and DI = 0300H. Determine the data memory
address accessed by each of the following instructions:
8- If CS=FFFFH, find the physical address of the lower range and upper range of the
code segment.
Lower range = CS x 10 + 0 = FFFF0 + 0 = FFFF0H
Upper range = CS x 10 + FFFF = FFFF0 + FFFF = 0FFEFH
remember that the address is restricted to 20 bits only, the result of the previous addition is
10FFEFH but the 1 on the left is removed because it doesn't fit in the 20 bits. This is called
Wrap Around.
3
9- If SS=0C00H and SP=FF00H, how many words of data are currently held in the
stack if SP=0000H at the start of a certain program?
The stack has been decremented from 0000H to FF00H, therefore, we have stored a
number of
FFFF (first byte stored) – FF00 (last byte stored) + 1 (to count the subtracted byte) = 100H
bytes
100H = 256d
But we want to find the number of words; the number of words is 256/2 = 128 because
each word is two bytes.
11-If AX=3245H, BX=5632H, CX=672BH, CS=2000H, SI=62F4H, find the result of each
line of the following program :( the memory map is shown below)
a-MOV DS,AX
DS = AX
DS = 3245H
b-MOV SI,100H
SI = 0100H
c-MOV BX,04H
BX = 0004H
d-ADD AX, [SI]
AX = AX + [SI]
AX = 3245 + [DS x 10 + SI]
AX = 3245 + [3245 x 10 + 0100]
AX = 3245 + [32550]
AX = 3245 + 6A34 = 9C79
32551H 6AH
32550H 34H
CS:
start = 1200 x 10 + 0 = 12000
end = 12000 + FFFF = 21FFFH
Similarly
DS:
start = 10000, end = 1FFFFH
SS:
start = 10600, end = 205FFH
ES:
start = 10300, end = 202FFH
Note that the bottom of the stack is the address of the first byte stored in the stack, not
the lower range of the stack segment.
As example 9:
Number = Bottom – Top + 1 = 205FF - 10A00 +1 = FC00H
FC00H = 64512 bytes
13- Convert the following decimal numbers to IEEE-754 short and long-form real
numbers:
a) 10
10 = 1010b = 1.01 x 23
Sign = 0, Mantissa = 01, Exponent = 3+ 127 = 130
0 1000 000 0100 0000 0000 0000 0000 000
b) - 11
- 11 = - 1011b = - 1.011 x 23
Sign = 1, Mantissa = 011, Exponent = 3+127 = 130
c) 101.125
5
14- Identify the addressing modes, the source, and the destination operands in the
following instructions:
a) MOV DL, BL
Mode: Register, Source: BL, Destination: DL
b) MOV AX, 00FFH
Mode: Immediate, Source: Immediate = 00FFH, Destination: AX
c) MOV [DI], AX
Mode: Register Indirect, Source: AX, Destination: DS:DI and DS:DI+1
d) MOV DI, [SI]
Mode: Register Indirect, Source: DS:SI and DS:DI+1, Destination: DI
e) MOV [BX] + XYZ, CX
Mode: Register Relative, Source: CX, Destination: DS:BX + XYZ and DS:BX + XYZ+ 1
f) MOV [DI] XYZ, AH
Mode: Register Relative, Source: AH, Destination: DS:DI + XYZ
g) MOV [BX][DI]XYZ, AL
Mode: Base Relative Plus Index, Source: AL, Destination: DS:BX + DI + XYZ
15- Identify the addressing modes, the source, and the destination operands in the
following instructions:
a)MOV AX,CX
Mode: Register, Source: CX, Destination: AX
b)MOV AX, 1234H
Mode: Immediate , Source: Immediate = 1234H, Destination: AX
c)MOV AL,’A’
Mode: Immediate , Source: Immediate = `A' , Destination: AL
d)MOV AL,[200H]
Mode: Direct , Source: DS:200 , Destination: AL
e)MOV [300H],BL
Mode: Direct, Source: BL, Destination: DS:300
f)MOV [SI],BX
Mode: Register Indirect , Source: BX, Destination: DS:SI and DS:SI+1
g)MOV [BX+10H],AX
Mode: Register Relative, Source: AX, Destination: DS:BX+10 and DS:BX+10+1
h)MOV CX,[BP]+98H
Mode: Register Relative, Source: SS:SP+98 and SS:SP+98+1, Destination: CX
i)MOV [BP][DI],AH
Mode: Base Plus Index, Source: AH, Destination: SS:BP+DI
j)MOV AX,[DI][SI]
Illegal (it's index plus index!)
k)MOV BX,[SI+20][BP]
Mode: Base Relative Plus Index, Source: SS:BP+SI+20 and SS:BP+SI+20+1,
Destination: BX
6
l)PUSH CX
Mode: Stack memory, Source: CX, Destination: SS:SP-2 and SS:SP-1
r)POP CS
Illegal
17) Given that: DS = 1100H, BX = 0200H, LIST = 0250H and SI = 0500H. Determine the
data memory addresses and the addressing modes for each of the following
instructions:
a) MOV LIST[SI], DX
Mode: Register Relative
Address: DS:SI+LIST = 11000+0500+0250 = 11750H and DS:SI+LIST+1 = 11751H
b) MOV BL, [BX][SI]+LIST
Mode Base Relative Plus Index
Address: DS:BX+SI+LIST =11000+0200+0500+0250 = 11950H
c) MOV BH, [BX]+LIST
Mode: Register Relative
Address: DS:BX+LIST = 11000+0200+0250 = 11450H