You are on page 1of 4

Cairo University

Faculty of Engineering
Elec. And Comm. Department

Microprocessors
Second year
Fall 2011

Sheet 5
(8088/8086 microprocessors)
All numbers used in this sheet are in hexadecimal format
1. What is the actual 20 bits address corresponding to the following logical addresses:
(i) 8000:0100
(ii) 8010:0000
(iii) 4FE5:23E6
2. What is the result of execution for following instruction(s)
A. MOV AX, 8
ADD
AX, 8
AAA
What will be the final value in AX?
B. MUL CL
c. IMUL CL
Initial values AL=20H, CL=80H
What will be the final value in AX?
C. MUL AX
What will be the final values in AX and DX?
Initial value AX=A064H
D. PUSH AX
PUSH CX
PUSH BX
POP
DX
POP
AX
POP
BX
Initial values AX=1122, BX=3344, CX=5566, DX=7788, SS = 32B0, SP=FFE4
What will be the final values in AX, BX, CX, and DX ?
Specify the exact address and data written or read from the stack memory.
3. Assume 8088 microprocessor; find the missing bytes marked xx for each of the
Following instructions. Find also the number of memory read or write cycles needed
during the Execution phase of each instruction. For each memory cycle determine
the address and the data and its origin or destination in the microprocessor. Also,
find the status of the flags.
260A:02B5 81 5C xx xx xx
SBB WORD PTR [ SI-0A],4404
SI=4CD CF=1
memory data DS:04C0 12 33 42 33 46 EF F0 F1
188E :18F 3B 87 xx xx
CMP AX , [ BX + 1234 ]
DS=188E, BX = 0DCD, AX=0000
memory data 188E: 2000 22 AE EA BD DE 45 66 78188E : 30F 51
PUSH CX
CX = 5BC5, SS =188E, SP = FEEE
188E:10E
E2 xx
LOOP 106
260A : 203 FF 27
JMP [ BX ]
DS= 3000 , BX =0ABC
memory data 3000 :0AB0 00 00 00 01 20 30 ED 3E23 34 AA BC 0A BC BB DD
2100:24C AD
LODSW
SI =1003 , DS = 3000 ,DF=1
memory data 3100:0000 00 12 2b 23 32 34 45 54

2000:0103 FF 17
CALL [BX]
BX=0200, DS = 3000, SS=32A0, SP=FFF0
Memory data 3000:0200 50 01 60 01
0B17:0100
C3
RET
SS = 32A0, SP= FFD2
Memory data 32A0:FFD0 3F F2 00 03 B2 B3 35

4. Find the missing bytes marked xx for each of the following instructions. Find
also the number of I/O read or write cycles needed during the execution phase of
each instruction. For each I/O cycle determine the address and the data and its
origin or destination in the microprocessor.
(a) 188E:0100
EC
IN AL, DX
DX=O3FB
(b) 188E:0100
ED
IN AX, DX
DX=0301
(c) 188E:0100
E4 xx
IN AL, 21
(d) 188E:0100
EF
OUT DX, AX
DX=30F, AX=1122
5. The lower byte of the flag register contains 95H. which of the following instructions
will actually jump.
a. JZ
d. JA
b. JNC
e. JGE
c. JP
f. JLE
Low byte of the flag register is

[SF] [ZF] [0] [AF] [0] [PF] [0] [CF]

Bits 1, 3, 5 are reserved


6. How many times does the NOP instruction execute in the following sequence
A.
MOV CX, 20H
XYZ: PUSH CX
MOV CX, 9
ABC:
NOP
LOOP ABC
POP
CX
LOOP XYZ
B.
0B1F:010A
MOV CX, 5
0B1F:010D
CALL 150

.
0B1F:0150
0B1F:0151
0B1F:0154
0B1F:0157
0B1F:0158
0B1F:015A
0B1F:015B

PUSH CX
MOV CX, 0100H
CALL 200
DEC CX
JNZ 0154
POP CX
RET

.
0B1F:0200
0B1F:0201
0B1F:0204
0B1F:0205
0B1F:0206
0B1F:0208
0B1F:0209

PUSH CX
MOV CX, 0FFFFH
NOP
DEC CX
JNZ 0204
POP CX
RET

7. What do you imagine are some of the problems with these two interrupt service
routines:
ISR1: PUSH AX
ISR2: PUSH AX
PUSH BX
PUSH CX
;
;
Body
body
;
;
POP
AX
POP
BX
IRET
POP
AX
RET
8. For the following program, what will be the values of AX , DI , CX and the flags
CF, OF, AF, ZF at the end of the program ( IP = 25F ). Find also the total number
of memory cycles from the start of the fetch of the first instruction till the end of the
execution of the last instruction.
2150:250
STD
:251
PUSH CS
:252
POP ES
:253
MOV CX ,0005
:256
MOV DI,1008
:259
MOV AX , 08FF
:25C
SCASW
:25D
LOOPE 25C
:25F
Note: SCASW is Compare AX, [ES: DI] then INC or DEC DI twice depending on DF.
Memory data 2150:1000 FF 08 FF 08 FE 08 FF 08 FF 08 FF 08 FE 08 FF 08

9. Write a routine to swap nibbles in AL. For example, if AL contains 3E, then it well
contain E3 after execution.
10. Write a subroutine that sets the zero flag if AH is in the range 30 to 212. and clears
the zero flag otherwise.
11. A data at location STATUS controls the calling of four subroutines. If bit 7 is set,
ROUT1 is called. If bit 5 is clear, ROUT2 is called. ROUT3 is called when bits 2 and 3
are high, and ROUT4 is called if bit 0 is clear and bit 1 is set. These conditions may all
exist at one time, so prioritize the routines in this way: ROUT1, ROUT3, ROUT2, and
ROUT4.
12. Write a subroutine that determines the largest number contained in BX, CX, and DX.
The number should be placed in AX when found.
13. Write a subroutine that input two numbers from keyboard and display the sum of
these two numbers on the screen.
14. Write a subroutine that input two numbers from port 300H and display the larger of
the two numbers on the screen.
15. Write a subroutine that keep inputting numbers from keyboard until a 0. Output the
number of numbers entered.
16. Write a subroutine that check the MSB of port 37AH if it changes from low to high
set the LSB of port 378H.

Notes:
INT 16h / AH = 00h - get keystroke from keyboard (no echo).
Return:
AH = BIOS scan code.
AL = ASCII character.
INT 10h/AH=0AH write character only at cursor position
Input:
AL = character to display
CX = number of times to write character.
INT 10h / AH = 0Eh - teletype output.
input:
AL = character to write.
This function displays a character on the screen, advancing the cursor and scrolling the
screen as necessary.
INT 21h / AH=01h -read character from standard input, with echo, result is stored in AL.
INT 21h / AH=02h -write character to standard output, DL = character to write, after
execution AL = DL.

You might also like