You are on page 1of 5

Exercise 1

Assume the following register contents:

AX = 4A30H BP = 0008H CS = 8000H

BX = 0010H SP = 0040H DS = 8000H

CX = 1800H DI = 0006H SS = 8002H

DX = 1234H SI = 0040H ES = 9000H

Given the following program segment:

PUSH CX
PUSH BX
PUSH DX

Assume that each instruction is dependent on one another.

CX = 1800H BX = 0010H DX = 1234H


SS = 8002H SP = 0040H

Bottom of the Stack = SS x 10H + FFFFH


= 80020H + FFFFH
= 9001FH

Stack Segment = 80020H up to 9001FH

Top of the Stack = SS x 10H + SP


= 8002H + 0040H
= 8042H

PUSH CX; 8041H (CH) = 18H


8040H (CL) = 00H

NEW SP = SP – 2
= 0040H – 2H
= 003EH

New Top of Stack = 8040H

<---- 8042H TOS

CH 8041H-----> 18H

CL 8040H----->
00H <---- 8040H New TOS
PUSH BX; 803FH (BH) = 00H
803EH (BL) = 10H

NEW SP = SP – 2
= 003EH – 2H
= 003CH

New Top of Stack = 803EH

<---- 8042H

CH 8041H-----> 18H

CL 8040H----->
00H <---- 8040H TOS

00H
BH 803FH----->
10H
BL 803EH-----> <---- 803EH New TOS

PUSH DX; 803DH (DH) = 12H


803CH (DL) = 34H

NEW SP = SP – 2
= 003CH – 2H
= 003AH

New Top of Stack = 803CH

<---- 8042H

CH 8041H-----> 18H

CL 8040H----->
00H <---- 8040H

00H
BH 803FH----->
10H
BL 803EH-----> <---- 803EH TOS

DH 803DH-----> 12H

34H
DL 803CH-----> <---- 803CH New TOS
Assume the following register contents:

AX = 4A30H BP = 0008H CS = 8000H

BX = 0010H SP = 0040H DS = 8000H

CX = 1800H DI = 0006H SS = 8002H

DX = 1234H SI = 0040H ES = 9000H

Given the following program segment:

POP BX
POP BP
POP SI

Assume that instructions are dependent on one another.

BX = 0010H BP = 0008H SI = 0040H


SS = 8002H SP = 0040H

Bottom of the Stack = SS x 10H + FFFFH


= 80020H + FFFFH
= FFFFH
= 9001F

Stack Segment = 80020H up to 9001F

Top of the Stack = SS x 10H + SP


= 80020H + 0040H
= 80060H

POP BX; BL (80060H)


BH (80061H)

NEW SP = SP + 2
= 0040H + 2H
= 0042H

New top of Stack = 80062H

<---- 80066H

SI 80065H-----> 00H

SI 80064H----->
40H <---- 80064H

00H
BP 80063H----->
08H
BP 80062H-----> <---- 80062H New TOS

BH 80061H----->
00H

10H
BL 80060H-----> <---- 80060H TOS
POP BP; BP (80062H)
BP (80063H)

NEW SP = SP + 2
= 0042H + 2H
= 0044H

New top of Stack = 80064H

<---- 80066H

SI 80065H-----> 00H

SI 80064H----->
40H <---- 80064H New TOS

00H
BP 80063H----->
08H
BP 80062H-----> <---- 80062H TOS

POP SI; SI (80062H)


SI (80063H)

NEW SP = SP + 2
= 0044H + 2H
= 0046H

New top of Stack = 80066H

<---- 80066H New TOS

SI 80065H-----> 00H

SI 80064H----->
40H <---- 80064H TOS
Exercise 2

Identify the addressing mode of the following instructions:

1) ADD AX, FADEH <------ Immediate Addressing


2) CMP FADE, AX <------ Direct Addressing
3) INC DH <------ Immediate Addressing
4) ADC [BP+1800H], BX <------ Base Addressing
5) AND AGAIN [BP+SI], DS <------ Base-Plus-Index Addressing
6) OR DX, [DI] <------ Register Indirect Addressing
7) ADC AX, [BP+SI] <------ Base-Plus-Index Addressing

You might also like