0 Replies - 1331 Views - Last Post: 04 December 2009 - 07:19 AM

#1 nathanpc   User is offline

  • SCIENCE!
  • member icon

Reputation: 113
  • View blog
  • Posts: 1,171
  • Joined: 31-July 09

Dividing By Negative Numbers

Posted 04 December 2009 - 07:19 AM

Description: Shows how to divide by negative numbers using Fasm.
; ********************
; *    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


Is This A Good Question/Topic? 0
  • +

Page 1 of 1