Created
June 18, 2011 15:57
-
-
Save nathanpc/1033216 to your computer and use it in GitHub Desktop.
Dividing By Negative Numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ******************** | |
; * DIVIDE.ASM * | |
; ******************** | |
.model small | |
.stack 512d | |
.data | |
a dw -9d | |
b db 2d | |
x db 0, '$' | |
.code | |
mov ax, @data | |
mov ds, ax | |
mov ax, a | |
mov bl, b | |
idiv bl | |
mov x, al | |
sub bx, bx | |
mov bl, x | |
mov ah, 02h | |
mov dl, bl | |
mov cl, 04h | |
shr dl, cl | |
add dl, 030h | |
cmp dl, 039h | |
jle value1 | |
add dl, 07h | |
value1: | |
int 021h | |
mov dl, bl | |
and dl, 0Fh | |
add dl, 030h | |
cmp dl, 039h | |
jle value2 | |
add dl, 07h | |
value2: | |
int 021h | |
mov ah, 04Ch | |
int 021h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment