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
/
OUTNUM1.LIB
< prev
next >
Wrap
Text File
|
1984-04-29
|
1KB
|
46 lines
;++++++++++++++++++++++++++++++++++++++++++++++
;
; VARIABLE RADIX NUMBER OUTPUT
;
; OUTNUM1.LIB - Version 0.1 - 14 SEP 77
;
; J.W. SHOOK, P.O. BOX 185, ROCKY POINT, NY 11778
;
;++++++++++++++++++++++++++++++++++++++++++++++
; Convert 16 bit binary number to a
; character string and print on console in
; any radix from 2 to 16.
; The converted digits are first pushed
; on the stack before printing, thus 2 bytes
; per digit of stack space are required.
; CALL with:
; HL = value to be converted
; C = Radix
OUTNUM: MVI D,0 ; Set stack count = 0
OUTNU1: CALL DIVIDE ; Perform modulus function
PUSH D ; Save remainder
INR D ; Count digit
MOV A,H ; Test for quotient = 0
ORA L
JNZ OUTNU1
OUTNU2: POP PSW ; Get digit from stack
CALL CONHEX ; Convert digit to ASCII
CALL OUTCH ; Print it
DCR B ; Count digit
JNZ OUTNU2 ; Do another digit?
RET
; Convert hex digit in A to ASCII character
CONHEX: ANI 0FH ; Mask hex digit
ADI 30H ; Convert to ASCII
CPI '9'+1 ; Need alpha bias?
RC ; Skip bias
ADI '@'-'9' ; Add bias
RET