home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
SIMTEL
/
CPMUG
/
CPMUG008.ARK
/
DIVIDE1.LIB
< prev
next >
Wrap
Text File
|
1984-04-29
|
931b
|
41 lines
;++++++++++++++++++++++++++++++++++++++++++++++
;
; UNSIGNED BINARY DIVIDE
;
; DIVIDE1.LIB - Version 0.1 - 14 SEP 77
;
; J.W. SHOOK, P.O. BOX 185, ROCKY POINT, NY 11778
;
;++++++++++++++++++++++++++++++++++++++++++++++
; Divides 16 bit dividend by 8 bit
; divisor producing a 16 bit quotient
; and an 8 bit remainder.
; CALL with:
; HL = Dividend
; C = Divisor
; RETURN with:
; HL = Quotient
; C = Divisor
A = Remainder
; CARRY = Set on divide by zero
DIVIDE: XRA A ; Clear extension of dividend reg
CMP C ; Check if divisor = 0
STC ; Mark divide error
RZ ; Return on / by 0
MVI B,16 ; Set loop counter
DIVID1: DAD H ; Shift dividend left into
RAL ; dividend extension reg.
CMP C ; Extension >= divisor?
JC DIVID2 ; Quotient bit = 0?
SUB C ; Subtract divisor from extension
INX H ; Set least bit of quotient
DIVID2: DCR B ; Test loop count
JNZ DIVID1 ; Done?
RET