qa.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
IdivLong
   Example  Back  Contents  Index
──────────────────────────────────────────────────────────────────────────────
 
;* IdivLong - Divides a signed long integer by a signed short integer.
;* The procedure does not check for overflow or divide-by-zero.
;*
;* Shows:   Instruction - idiv
;*
;* Params:  long1 - First integer (dividend)
;*          short2 - Second integer (divisor)
;*          remn - Pointer to remainder
;*
;* Return:  Quotient as short integer
 
IdivLong PROC \
        USES di, \
        long1:DWORD, short2:WORD, remn:PTR WORD
 
        mov     ax, WORD PTR long1[0]   ; AX = low word of dividend
        mov     dx, WORD PTR long1[2]   ; DX = high word of dividend
        idiv    short2                  ; Divide by short integer
        LoadPtr es, di, remn            ; ES:DI = remainder
        mov     es:[di], dx             ; Copy remainder
        ret                             ; Return with AX = quotient
 
IdivLong ENDP
                                    -♦-