Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. For each part of this problem, assume the \"before\" values when the given in

ID: 3558693 • Letter: 1

Question

1.     For each part of this problem, assume the "before" values when the given instruction is executed. Give the requested "after" values.

                                                                                      

Before

Instruction

After

(a)

BX: FA 75
  CX: 31 02

and

bx,cx

BX, SF, ZF

(b)

BX FA 75
  CX 31 02

or

bx,cx

BX, SF, ZF

(c)

BX FA 75
  CX 31 02

xor

bx,cx

BX, SF, ZF

(d)

BX FA 75

not

bx

BX

(e)

AX FA 75

and

ax,000fh

AX, SF, ZF

(f)

AX FA 75

or

ax,0fff0h

AX, SF, ZF

(g)

AX FA 75

xor

ax,0ffffh

AX, SF, ZF

(h)

AX FA 75

test

ax,0004h

AX, SF, ZF

  

Before

     

Instruction

     

After

     

(a)

     

BX: FA 75
  CX: 31 02

     

and

     

bx,cx

     

BX, SF, ZF

     

(b)

     

BX FA 75
  CX 31 02

     

or

     

bx,cx

     

BX, SF, ZF

     

(c)

     

BX FA 75
  CX 31 02

     

xor

     

bx,cx

     

BX, SF, ZF

     

(d)

     

BX FA 75

     

not

     

bx

     

BX

     

(e)

     

AX FA 75

     

and

     

ax,000fh

     

AX, SF, ZF

     

(f)

     

AX FA 75

     

or

     

ax,0fff0h

     

AX, SF, ZF

     

(g)

     

AX FA 75

     

xor

     

ax,0ffffh

     

AX, SF, ZF

     

(h)

     

AX FA 75

     

test

     

ax,0004h

     

AX, SF, ZF

  

Explanation / Answer

a)

BX = FA75 = 1111 1010 0111 0101 in binary
CX = 3102 = 0011 0001 0000 0010 in binary

and bx,cx -> bx = (bx & cx) = 0011 0000 0000 0000 (anding the contents of bx and cx) = 3000

SF=0 as the sign bit(MSB) is 0
ZF=0 as the result is not zero

b)

BX = FA75 = 1111 1010 0111 0101 in binary
CX = 3102 = 0011 0001 0000 0010 in binary

or bx,cx -> bx = (bx | cx) = 1111 1011 0111 0111 (oring the contents of bx and cx) = FB77

SF=1 as the sign bit(MSB) is 1
ZF=0 as the result is not zero

c)

BX = FA75 = 1111 1010 0111 0101 in binary
CX = 3102 = 0011 0001 0000 0010 in binary
xor bx,cx -> bx = (bx XOR cx) = 1100 1011 0111 0111 = CB77

SF=1 as the sign bit(MSB) is 1
ZF=0 as the result is not zero

d)

BX = FA75 = 1111 1010 0111 0101 in binary

not bx -> bx = ~bx = 0000 0101 1000 1010 = 058A

e)

AX = FA75 = 1111 1010 0111 0101 in binary

and ax,000fh -> ax = ax & 0000 0000 0000 1111 = 0000 0000 0000 0101 = 0005


SF=0 as the sign bit(MSB) is 0
ZF=0 as the result is not zero

f)
AX = FA75 = 1111 1010 0111 0101 in binary

or ax,0fff0h -> ax = ax | 1111 1111 1111 0000 = 1111 1111 1111 0101 = FA75
SF=1 as the sign bit(MSB) is 1
ZF=0 as the result is not zero

g)

AX = FA75 = 1111 1010 0111 0101 in binary

xor ax,0fff0h -> ax = ax XOR 1111 1111 1111 1111 = 0000 0101 1000 1010 = 058A

SF=0 as the sign bit(MSB) is 0
ZF=0 as the result is not zero

f)

AX = FA75 = 1111 1010 0111 0101 in binary

test ax,0004h -> AND(ax,imm) and set the flags accordingly...no other registers are altered
AND(ax,imm) = ax & 0000 0000 0000 0100 = 0000 0000 0000 0100


SF=0 as the sign bit(MSB) is 0
ZF=0 as the result is not zero