In: Computer Science
1- Assume that the state of the 8086 registers and memory just
prior to the execution of each instruction is given as below:
(AX) = 0010 H
(BX) = 0020 H
(CX) = 0030 H (DX) = 0040 H (SI) = 0100 H
(DI) = 0200 H (CF) = 1 (DS:100H) = 10 H (DS:101H) = 00 H (DS:120H)
= FF H (DS:121H) = FF H (DS:130H) = 08 H (DS:131H) = 00 H (DS:150H)
= 02 H (DS:151H) = 00 H (DS:200H) = 30 H (DS:201H) = 00 H (DS:210H)
= 40 H (DS:211H) = 00 H (DS:220H) = 30 H (DS:221H) = 00 H
Note: (DS:100H) = 10 H ; this means that the data written in the address that is obtained by combining DS register (as base address) and 100H(offset) , is 10H.
Which result is produced in the destination operand in each of the following cases (instructions are independent): (32 points)
a) ADDAX,00FFH
b) ADC SI, AX
c) INCBYTEPTR[0100H]
d) SUB DL, BL
e) SBB DL, [0200H]
f) MUL DX
g) IMULBYTEPTR[SI]
h) IDIV BX
a) ADD AX,00FFH
AX= 0010H = 0000 0000 0001 0000 +
0000 0000 1111 1111
They are added together and we will get 0000 0001 0000 1111 = 010F H
b) ADC SI, AX
ADC will work with the syntax operand1 = operand1 + operand2 + CF so here it wil be
SI = SI +AX+CF
= 0100H+0010H+1
= 0111 H
c) INCBYTEPTR[0100H] hope you mean INC BYTE PTR[0100H]
INC BYTE PTR [0100H]; This indicates the size of memory data addressed by thememory pointer
Here the value at location [0100] is given as 10H but as we increment it by using INC instruction it will become 11H
INC BYTE PTR[0100H] = 11H
d) SUB DL, BL - This instruction performs subtraction of lower 8-bits in both DX and BX registers . The lowe part of these registers are DL and BL respectively. Now thier values become.
DX = 0040H So DL = 40H
BX = 0020H So BL = 20 H
Now SUB DL, BL 40H - 20H and result will store in DL register
DL = 40H = 0100 0000
BL = 20H = 0010 0000
So SUB DL, BL = 0010 0000 = 20H
e) SBB DL, [0200H]
Solution:Value in DL = DL – (byte at DS:0200) – CF = 40H – 30H – 1 = 0FH
To understand better you can try to convert these Hexadecimalnumber to binary and solve it
that is 40H = 64 , 30H = 48 and 1 remains same. So 64-48-1 = 64 - 49 = 15 = 0FH
f) MUL DX - The MUL instruction will multiply the value in AX with DX and result will be stored in DXAX
So here Multiply AX= 10H with DX = 0040H and result will stored in DXAX = 10H * 40H = 400H
DX = upper 16 bits of result = 0000H; AX = lower 16 bits of result = 0400H
g) IMUL BYTE PTR[SI]
Anser Will be : AX = AL * byte at address DS:SI (signed multiplication of 8-bit values)
Here DS:SI = 0010H Al = 0010H
AX = 10H * 10H = 100H
h) IDIV BX
As this this a division with 16 bit register and uses IDIV it will perform signed divion of BX register with values in DXAX together as 32 bit register
DIV BX = DX AX/BX = 0040H 0010H / 0020H = 20000H
Since it is a word IDIV divides double-word value in DX:AX bysource, returning quotient in AX and the remainder in DX.
In Decimal = 4194320 / 32 = 131072
Here in the cases of 'g' and 'h' we are not using any signed numbers so all the operations will work similar to the unsigned operations