Question

# Assume that the state of the 8086 registers and memory just prior to the execution of...

Assume that the state of the 8086 registers and memory just prior to the execution of each instruction is given as below:

(AX) = 0000 H

(BX) = 0010 H

(CX) = 0105 H

(DX) = 1111 H

(SI) = 0100 H

(DI) = 0200 H

(CF)= 0

(DS:100H) = 0F H

(DS:200H) = 22 H

(DS:220H) = AA H

(DS:221H) = 55 H

(DS:400H) = AA H

(DS:401H) = 55 H

Examine the following instructions independently and calculate the result in each case: (28 points)

a) SHL DX, CL

b) SAR BX, 1

c) SHL BYTE PTR [400H], 1

d) SAL BYTE PTR [DI], 1

e) ROL DX, CL

f) ROR BYTE PTR [DI], 1

g) RCL BYTE PTR [400H], CL

a) SHL DX, CL

SHL instruction is used to shift the data towards left and stores the msb into the Carry flag (CF)

DX = 0h 1111

0b 0001 0001 0001 0001

CL = 0h 05
0b 0000 0101 = 0d 5
So, shifting the DX towards left 5 times and storing the shifted bit into CF.

C DX
0 0010001000100010
0 0100010001000100
0 1000100010001000
1 0001000100010000
0 0010001000100000

So, DX = 0b 0010 0010 0010 0000
0h 2220

CF = 0

DX = 0h 2220

CF = 0

b) SAR BX, 1

SAR instruction is used to shift the content of register to the right but the MSB is restored. And LSB is transferred to the CF.

BX = 0h 0010
0b 0000 0000 0001 0000

MSb is shifted to itself and LSB(Left- most bit is stored in CF)
Shifting the BX to right and restoring the MSB and LSB into CF

0000 0000 0001 0000--|
|                    |
0000 0000 0000 1000  0

CF = 0
BX = 0h 0008

ANS =
CF = 0
BX = 0h 0008

c) SHL BYTE PTR [400H], 1

Byte at the memory location pointed by pointer [400H] = AAH

Here address is calculated by DS(data segment) + Offset(in this case 400h)

0h AA
0b 1010 1010

Shifting AA 1 time and storing the MSB into cf

1010 1010
1 0101 0100

CF = 1
PTR[400H] = 0b 0101 0100 = 0h 54

ANS = CF = 1
PTR[400H] = 0b 0101 0100 = 0h 54

d) SAL BYTE PTR [DI], 1

DI = 0200H

BYTE PTR [DI] is equivalent to BYTE PTE [200H].

So, Byte at the memory location pointed by pointer [200H] = 22H

SAL is the same instruction as SHL.

0h 22
0b 0010 0010

Shifting AA 1 time and storing the MSB into cf

0010 0010
1 0100 0100

CF = 0
PTR[200H] = 0b 0100 0100 = 0h 44

ANS = CF = 0
PTR[200H] = 0b 0100 0100 = 0h 44

e) ROL DX, CL

ROL (rotate left) instruction is used to rotate the content of register towards left and MSB is put into the place of LSB as well as CF.

DX = 0h 2220

0b 0010 0010 0010 0000

CL = 0h 05
0b 0000 0101 = 0d 5
So, shifting the DX towards left 5 times and storing the shifted bit into CF.

C DX
0 0100010001000000
0 1000100010000000
1 0001000100000001
0 0010001000000010
0 0100010000000100

So, DX = 0b 0100 0100 0000 0100
0h 4404

CF = 0

DX = 0h 4404

CF = 0

f) ROR BYTE PTR [DI], 1

DI = 0200H

BYTE PTR [DI] is equivalent to BYTE PTE [200H].

So, Byte at the memory location pointed by pointer [200H] = 44H

ROR (rotate right) instruction is used to rotate the content of register towards right and LSB is put into the place of MSB as well as CF.

0h 44
0b 0100 0100

Shifting AA 1 time to right and rotating the LSB into MSB and cf

0100 0100__
________|  |
|          |
0010 0010  0

CF = 0
PTR[200H] = 0b 0010 0010 = 0h 22

ANS = CF = 0
PTR[200H] = 0b 0010 0010 = 0h 22

g) RCL BYTE PTR [400H], CL

RCL (Rotate left with carry), in this the MSB is stored into the CF and CF is stored as LSB.

Byte at PTR[400H] = 54H

54 = 0101 0100
CL = 0h 05
0b 0000 0005 = 0d 5

Shifting the MSB into CF and CF into LSB 5 times

CF PTR[400H]
0  10101000
1  01010000
0  10100001
1  01000010
0  10000101

CF = 0
PTR[400h] = 0b 1000 0101 = 0h 85

ANS =CF = 0

PTR[400h] = 0b 1000 0101 = 0h 85

#### Earn Coins

Coins can be redeemed for fabulous gifts.