public
Created

Dividing By Negative Numbers

  • Download Gist
div_neg.asm
Assembly
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
; ********************
; * 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.