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

write an asm code fragment that performs the indicated task or function: copy th

ID: 3577931 • Letter: W

Question

write an asm code fragment that performs the indicated task or function:
copy the higher order 4 bits from the AL register and the lower order 4 bits from the AH register into the DL register. use only the SHIFT /ROTATE instructions write an asm code fragment that performs the indicated task or function:
copy the higher order 4 bits from the AL register and the lower order 4 bits from the AH register into the DL register. use only the SHIFT /ROTATE instructions
copy the higher order 4 bits from the AL register and the lower order 4 bits from the AH register into the DL register. use only the SHIFT /ROTATE instructions

Explanation / Answer

mov dl,al ;Copy al data into dl
shr dl,4 ;Shift right by 4 bits so that only most significant 4 bits remain, everything else will be 0
shl ah,4 ;Shift left ah register by 4 bits so that least significant 4 bits become most significant bits
shl ah,1 ;Move the significant bit to carry bit
rcl dl,1 ;Move the carry bit into least significant bit of dl
shl ah,1 ;repeat this cycle for 4 bits
rcl dl,1
shl ah,1
rcl dl,1
shl ah,1
rcl dl,1