Consider the following assembly program fragment : stc mov al, 11010110b mov…
2017
Consider the following assembly program fragment :
stc
mov al, 11010110b
mov cl, 2
rcl al, 3
rol al, 4
shr al, cl
mul cl
The contents of the destination register ax (in hexadecimal) and the status of Carry Flag (CF) after the execution of above instructions, are :
- A.
𝑎𝑥=003𝐶𝐻;𝐶𝐹=0
- B.
𝑎𝑥=001𝐸𝐻;𝐶𝐹=0
- C.
𝑎𝑥=007𝐵𝐻;𝐶𝐹=1
- D.
𝑎𝑥=00𝐵7𝐻;𝐶𝐹=1
Attempted by 33 students.
Show answer & explanation
Correct answer: A
Given: AL = 11010110b (0xD6), CF = 1 (from stc), CL = 2
rcl al, 3: treat CF:AL as a 9-bit value (1:0xD6 = 0x1D6). Rotate left 3 bits → new combined = 0xB7, so AL = 0xB7 and CF = 0.
rol al, 4: rotate AL (0xB7) left 4 bits → AL = 0x7B. The last bit rotated out sets CF = 1.
shr al, cl (cl=2): logical right shift 0x7B by 2 → AL = 0x1E. CF becomes the last bit shifted out (original bit1), so CF = 1.
mul cl: unsigned multiply AL * CL = 0x1E * 2 = 0x3C. Result is stored in AX = 0x003C. Since AH = 0, CF = 0 (and OF = 0).
Final result: AX = 003Ch; CF = 0