mult_div_example_solns

# mult_div_example_solns - • Divide word variable WHITE by...

This preview shows pages 1–2. Sign up to view the full content.

In class February 13, we did not have time to work through examples for multiplication and division. The slide asked you to write 8086 assembly code to: Multiply BX and CX, store the doubleword product to memory at word variable BLACK Divide word variable WHITE by 38, store quotient to byte variable GRAY RED (WHITE * BLUE) / GOLD ; all variables are bytes RED (WHITE / GOLD) * BLUE ; all variables are bytes My solutions are on the next page. Try to write code for these problems before looking at my solutions. Compare your solutions with mine and ask me any questions that you have.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Assume that all integers are unsigned. Multiply BX and CX, store the doubleword product to memory at word variable BLACK MOV AX, BX ; move one operand into AX MUL CX MOV BLACK, AX ; product is in DX—AX MOV BLACK+2, DX
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: • Divide word variable WHITE by 38, store quotient to byte variable GRAY MOV AX, WHITE ; word dividend must be in AX MOV BH, 38 ; no immediate division, so move 38 into a register DIV BH ; places quotient in AL MOV GRAY, AL • RED ← (WHITE * BLUE) / GOLD ; all variables are bytes MOV AL, WHITE MUL AL, BLUE ; places product WHITE * BLUE in AX DIV GOLD ; dividend is already word size, already in AX; DIV places quotient in AL MOV RED, AL • RED ← (WHITE / GOLD) * BLUE ; all variables are bytes MOV AL, WHITE MOV AH, 0 ; need word size dividend, so pad out AH ; would use CBW if data was signed DIV GOLD ; places quotient in AL MUL BLUE ; one operand is already in AL, places product in AX MOV RED, AL ; note that the high order byte is in AH, could do in addition: MOV RED+1, AH...
View Full Document

## This note was uploaded on 01/25/2012 for the course EE 3750 taught by Professor Desouza during the Fall '08 term at LSU.

### Page1 / 2

mult_div_example_solns - • Divide word variable WHITE by...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online