Sei sulla pagina 1di 5

QUESTIONS:

1. Supply the appropriate instruction for the given program to accomplish the given
task.
3010h - 20h + (20h * 40h) - (100h / 40h)
PROGRAM:
XOR AX, AX; to clear register AX, XOR is used for 16-bit size of info
XOR CX, CX (1);to clear register CX, XOR is used for 16-bit size
PLUS:

MOV CL, 40H; to move 40 hexa into the register CL

ADD AX, 20H (2); to add register AX content with 0020 hexa
DEC CL; to subtract 1 from CL content
JNZ PLUS (3) ;to check if CL is not yet equal to zero, and if true, it will go to PLUS
and execute ADD AX, 20H again.
3010H; to move 3010 hexa to register BX

MOV BX,
ADD AX, BX; to add content of register AX with the content of register BX
PUSH AX (4); to put the result of the instruction ADD AX,BX unto the stack
XOR AX, AX; to clear register AX, XOR is used for 16-bit size of info
XOR BX, BX; to clear register X, XOR is used for 16-bit size of info
XOR CX, CX OR MOV AX, 0100H(5) ; to clear register CX, XOR is used for 16-bit
size of info OR move data 0100 hexa into register AX

MOV BX, 0040H; to move 0040 hexa into register BX


MOV AX, 0100H OR XOR CX, CX(6) ; to move 0100 hexa into register AX or
MINUS:

clear register CX, XOR is used for 16-bit size of info


to subtract BX content from AX, the result will be stored in register AX

SUB AX, BX;


INC CL (7) ; to add 1 to the content of register CL
CMP AX, 0H; to compare register AX content to zero, if not equal to zero zero flag will
remain the same, if equal to zero, zero flag will become 1
to compare zero flag if equal to 1, if yes it will go to the MINUS and
execute the instruction SUB AX, BX otherwise, the next instruction will be executed.
MOV DL, 20(8) ; to move 20 hexa into register DL

JNZ MINUS;

ADD DL, CL ;
XOR AX, AX;
POP AX (9) ;

to add content of register DL with the content of the register CL, the
result will be stored into the register DL
to clear register AX, XOR is used for 16-bit size of info

to save the current content of register AX unto the stack, assuming


stack is empty
0H; to load 0 hexa to register DH

MOV DH,
SUB AX, DX (10) ;

to subtract the content of register DX from the content of


register AX

LINE AX
NO.
1
0000
2
3
4
0020
5
0040
0060
0080
00A0
00C0
00E0
0100
0120
0140
0160
0180
01A0
01C0
01E0
0200
0220
0240
0260
0280
02A0
02C0
02E0
0300
.
.
.
.
.
.
0760
0780
07A0
07C0
07E0
0800
7
8
9
10
11

BX

CX
DX
CHCL

STACK

0000
0040
003F
003D
003E
003D
003C
003B
003A
0039
0038
0037
0036
0035
0034
0033
0032
0031
0030
002F
002E
002D
002C
002B
002A
0029
0028
.
.
.
.
.
0006
0005
0004
0003
0002
0001
0000
3010

3810
3810
0000
0000

12
13
14

15
16
17
18
19
20

0000
0040
0100
00C0
0080
0040
0000

0001
0002
0003
0004
20
24

0000
3810
0024
37EC

ANSWER:
AX=37EC
BX=0040
CX=0004
DX=0024
STACK=NONE

INSTRUCTION

BACK:

MOV AX, 1234H


MOV DS, AX
MOV SI, 0400H
MOV DI, 0500H
MOV CX, 000A
MOV AX, [SI]
MOV [DI], AX
INC SI
INC DI
DEC CX
JNZ BACK
HLT

MOV AX, 1234


SR R/M
MOV DS, AX

CONTENT/S

ADDRESS/ES

B8 34 12
8E D8
BE 00 04
BF 00 05
B9 0A 00
8B 04
89 05
46
47
49
75F7
F4

0000-0002
0003-0004
0005-0007
0008-000A
000B-000D
000E-000F
0010-0011
0012
0013
0014
0015-0016
0017

1011 W REG DATA


1011 1 000 3412== B83412
10001110 MOD 0 SR R/M
10001110 11 0 11 000== 8ED8

MOV SI, 0400

1011 W REG DATA


1011 1 110 0004== BE0004

MOV DI, 0500

1011 W REG DATA


1011 1 111 0005 == BF0005

MOV CX, 000A

1011 W REG DATA


1011 1 001 0A00 == B90A00

REG R/M
MOV AX, [SI]

R/M REG
MOV [DI], AX

100010 D W MOD REG R/M


100010 1 1 00 000 100== 8B04

100010 D W MOD REG R/M


100010 0 1 00 000 101 == 8905

INC SI

01000 REG
01000 110 == 46

INC DI

01000 REG
01000 111 == 47

DEC CX

01001 REG
01001 001 == 49

JNZ BACK

01110101 DISP
01110101 ==75 F7

PL=0015
DL=000E
BACKWARD BRANCHING
DL=PL+2-X
000E=0015+2-X
X=0017-000E
X= 0009; GET THE 2S COMPLENT
X= FFFF-0009=FFF6+1=FFF7
LOWER DISPLACEMENT =F7
HIGHER DISPLACEMENT = FF

FORWARD BRANCHING (PL<DL)


DL=PL+2+X
BACKWARD BRANCHING (PL>DL)
DL=PL+2-X
WHERE:
X=DISPLACEMENT
DL=DESTINATION LOCATION
PL=PRESENT LOCATION
2= BECAUSE MOST OF THE JUMP INSTRUCTIONS ARE TWO-BYTE SIZE
*TAKE NOTE THAT THERE ARE 3-BYTE SIZE JUMP INSTRUCTIONS
HLT

11110100 == F4

Potrebbero piacerti anche