0% found this document useful (0 votes)
15 views9 pages

AIET (Examples+Solution) 7!12!2019-2020

Uploaded by

vevocrs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views9 pages

AIET (Examples+Solution) 7!12!2019-2020

Uploaded by

vevocrs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

Revision (7-12-2019)

a - Write a short sequence of instructions that: save data 4321H in AX


register, the data 5432H in BX register, then ADD BX to AX, save the
result in DX register, resets the right least six bits of DX, set the left
most four bits of DX; and invert the bits number (8, 9) of DX without
changing the remaining bits of DX. Finally state and save the final value
of DX in CX register.

MOV AX, 4321H


MOV BX, 5432H
ADD AX, BX AX= 9753H
MOV DX, AX DX=9753H
AND DX, FFC0H resets the right least six bits of DX
OR DX, F000H set the left most four bits of DX
XOR DX, 0300H invert the bits number (8, 9) of DX
MOV CX, DX

The final value of DX, CX is F440H

b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0


DX=9753H 1 0 0 1 0 1 1 1 0 1 0 1 0 0 1 1
AND DX, FFC0H MUSK 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0
DX=9740H 1 0 0 1 0 1 1 1 0 1 0 0 0 0 0 0
OR DX, F000H MUSK 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
DX=F740H 1 1 1 1 0 1 1 1 0 1 0 0 0 0 0 0
XOR DX, 0300H MUSK 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0
DX=F440H 1 1 1 1 0 1 0 0 0 1 0 0 0 0 0 0

The final value of DX is F440H


b- If the initial values of 8086 mP registers are AX = AD07H,
BX = 298AH, DX=0200H, CX = 00A0H, DS=8808H,
CS=0800H, SS=769FH, SP=892CH, BP=4568H,
SI=5678H, and DI= 456BH. Show the stack memory
contents after this short sequence of instructions executes?
PUSH AX
PUSH DX
PUSH CX
PUSH BX

The stack segment memory location addressed by


The stack pointer= SS*10 + SP
= 769F0H+892CH=7F31C H

LOWER HIGHR
SP 7F31CH 7F31DH
PUSH AX 7F31AH 07H 7F31BH ADH
PUSH DX 7F318H 00H 7F319H 02H
PUSH CX 7F316H A0H 7F317H 00H
PUSH BX 7F314H 8AH 7F315H 29H
EVEN ODD
c - Suppose that the content of 80386 µP registers as the following:
DS = A200H, BX = 020BH, SS=1400H, BP=1500H,
SI=05D0H, DI= 8B2CH and LIST = 02C0H,
Determine:
(1) The physical address accessed by each of the following
instructions, assuming real mode operation?
(2) State the addressing mode for each of the following
instructions?
(3) State the number of memory locations will be copied in each
instruction?

(a) MOV LIST[BP+DI], CX


(b) MOV [EBX+2*ESI], AX
(c) MOV CL,[BX+4H]

the number of
The physical address addressing memory
mode locations
Base
(a) MOV LIST[BP+DI], CX SS*10+LIST+BP+DI= relative- 2 memory
14000H+02C0H+1500H+8B2CH=1E2ECH plus- index locations
addressing
Scaled-
DS*10+ EBX+2*ESI= 2 memory
(b) MOV [EBX+2*ESI],AX index
A2000H+0000020BH+2*000005D0H=A2DABH locations
addressing
Register
DS*10+BX+4H= 1 memory
(c) MOV CL,[BX+4H] relative
A2000H+020BH+4H=A220FH location
addressing
10-12-2019

d- Write an assembly language program to divide 0CD4H by 2BH


(unsigned numbers), Store the quotient at the beginning of memory
location 1230H and the reminder at the beginning of memory location
1232H in the data segment 0800H, Finally show the contents of each
memory location?

MOV AX, 0CD4H AX=0CD4 H


MOV BL, 2BH BL= 2BH
DIV BL AX= 104CH
MOV [1230H], AL
MOV [1232H], AH
The physical address for storing the quotient=
DS*10+1230H=08000H+1230H=09230H
The physical address for storing the reminder=
DS*10+1232H= 08000H+1232H=09232H

09233H
09232H 10 H
09231H 00 H
09230H 4C H

e - Write a short sequence of instructions that, subtracts the data stored in


DI, SI, and BP registers from the data stored in AX register. Finally
save the difference in CX register.

SUB AX, DI
SBB AX, SI
SBB AX, BP
MOV CX, AX
F - Write a short sequence of instructions that: save data 1234H in AX
register, the data CDEFH in DX register, then add the stored data in
DX register, and in AX register make sure that the result saved in AX
register, then for the data stored in DX register, resets the right least
three bits, set the leftmost five bits, and invert the bits numbers
(6, 8, 9, 15) without changing the remaining bits of DX register.
Finally store, and show the final value of the data in DX register in
the data segment memory location addressed by data stored in AX
register, for the used data segment 0808H

MOV AX, 1234H


MOV DX, CDEFH
ADD AX, DX AX= E023H
AND DX, FFF8H
OR DX, F800H
XOR DX, 8340H
MOV [AX], DX

b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0


DX= CDEFH 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1
AND DX, FFF8H MUSK 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0
New DX= CDE8H 1 1 0 0 1 1 0 1 1 1 1 0 1 0 0 0
OR DX, F800H MUSK 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
New DX= FDE8 1 1 1 1 1 1 0 1 1 1 1 0 1 0 0 0
XOR DX, 8340H MUSK 1 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0
Final DX= 7EA8H 0 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0
DX 7 E A 8
The memory location addressed by AX = DS*10H+AX= 8080+E023H= 160A3H

160A5H
160A4H 7EH
160A3H A8H
160A2H
G -If the initial values of 80486 µP registers are EAX =FDEC8765H,
EBX = 4321ABCDH, EDX = 9876FEDCH and, ECX = 76598877H,
DS=8808H, CS=0800H, SS=543FH, SP=786CH, BP = 4567H,
SI = 5678H, DI = 456BH. Show the stack memory contents after this
short sequence of instructions executes?
1( PUSH EAX
2( PUSH DX
3( PUSH ECX
4) PUSH BX

The memory location in the stack segments=


SS*10H+SP= 543F0+786C=5BC5CH

Lower Higher
SP 5BC5CH
5BC5AH ECH 5BC5BH FDH
5BC58H 65H 5BC59H 87H
5BC56H DCH 5BC57H FEH
5BC54H 59H 5BC55H 76H
5BC52H 77H 5BC53H 88H
5BC50H CDH 5BC51H ABH
EVEN ODD
f- Describe the operation of each of the following instructions:

(1) POP AX : Remove a 16-bit number from the stack and


places it into the AX register.

(2) PUSH ESI : Pushes the contents of ESI onto the stack.

(3) PUSH WORD PTR [SI]: copies the (Word) 16-bit contents
of the data segment memory location addressed by
SI onto the stack.

(4) PUSH A : (push all) copies the 16-bit registers to the stack in
the following order: AX, CX, DX, BX, SP, BP, DI,
and SI.

DI

SI
H – In 8086 microprocessor, if the multipurpose registers AX, and
DX has values of 1001H and 20FFH respectively, and CF=1.
Find the sum (ADC AX, DX) and the contents of each flag
register bit (C, A, S, Z, and O) after the instruction is executed

AX 1001 H 0001000000000001
+ DX 20FF H 0010000011111111
+ CF 1H 0000000000000001
The result 3101 H 0011000100000001

C= 0 H, A= 1 H, S = 0 H, Z= 0 H, O = 0 H

I- Write an instruction to represent the following addressing


modes?

(1) Immediate addressing mode : MOV CH, 3AH

(2) Direct addressing mode : MOV [1234H], AX

(3) Register relative addressing : MOV CL,[BX+4H]

(4) Direct program memory addressing : JMP [10000H]


i- Write an instruction to perform each of the following
tasks:

(1) Shift AX right five places, with zeros moved into the
leftmost bit: SHR AX, 5

(2) Move all bits in AX left three places, making sure that a 0
move into the rightmost bit position

SHL AX, 3

(3) Rotate all the bits of CX right six places


ROR CX, 6
(4) Rotate carry right eleven places through EDX
ROC EDX, 11

(5) Shift the BX register right seven place, making sure that the
sign of the result is the same as the sign of the original
number:
SAR BX, 7

You might also like