

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Fall 2009
yellow (a) all variables are signed words, (b) all variables are unsigned words, and (c) all variables are unsigned bytes. (a) MOV AX, BLACK ; one operand of word multiplication must be in AX IMUL GREEN ; IMUL because signed; product in DX—AX MOV BX, AX ; store product so that can sign-extend white MOV CX, DX MOV AX, WHITE CWD ; DX—AX now holds 32-bit version of white SUB BX, AX SBB CX, DX ; subtract with borrow for high word MOV AX, BX ; put difference back into DX—AX before division MOV DX, CX IDIV YELLOW ; IDIV because signed; quotient in AX MOV BLUE, AX
(b) MOV AX, BLACK MUL GREEN ; MUL because unsigned; product in DX—AX SUB AX, WHITE SBB DX, 0 ; pad high word of white with 0’s because unsigned DIV YELLOW ; DIV because unsigned; quotient in AX MOV BLUE, AX (c) MOV AL, BLACK ; one operand of byte multiplication must be in AL MUL GREEN ; MUL because unsigned; product in AX MOV BL, WHITE MOV BH, 0 ; pad high byte of white with 0’s because unsigned SUB AX, BX ; single word subtraction; could also do SUB and SBB on bytes analogously to part (b) DIV YELLOW ; DIV because unsigned; quotient in AL MOV BLUE, AL