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

For each part of this problem, assume the Before values when the given Instructi

ID: 3558645 • Letter: F

Question

For each part of this problem, assume the Before values when the given Instruction is executed. Give the requested After values:

Before BX : FA 75 CX : 31 02 Instruction and bx, cx After BX,SF,ZF b. Before BX : FA 75 CX 31 02 Instruction or bx, cx After BX, SF, ZF c. Before AX: FA 75 Instruction test ax, 0004h After AX, SF, ZF d. Before AX: A8 B5 CL: 04 Instruction sal ax, cl After AX, CF e. Before AX : A8 B5 Instruction shr ax, 4 After AX, CF f. Before AX: A8 B5 CL: 04 Instruction sar ax, cl After AX, CF

Explanation / Answer

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)

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

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

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


AX = FA 75 = 1111 1010 0111 0101 in binary
imm = 0004 = 0000 0000 0000 0100 in binary

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

AND(ax,imm) = 0000 0000 0000 0100

AX = FA 75

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

AX = A8 B5 = 1010 1000 1011 0101
Cl = 4

sal ax,cl -> shift left by the amount specified in cl the contents of ax

ax = 1000 1011 0101 0000 after shiting by 4 left
CF = 0 as the last shifted bit 0

shr ax,4 -> shift right by 4 the contents in ax

ax = 0000 1010 1000 1011
CF = 0(unchanged)

sar ax,cl -> shift right(signed) by amount mentioned in cl the contents of ax

ax = 1111 1010 1000 1011 (to restore the sign the bits that are added is same as the MSB)
CF = 0(unchanged)