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
/
ZSYS
/
SIMTEL20
/
SYSLIB
/
SLIB2.LBR
/
SLAFDC.Z80
< prev
next >
Wrap
Text File
|
2000-06-30
|
1KB
|
60 lines
;
; SYSLIB Module Name: SLAFDC
; Author: Richard Conn
; SYSLIB Version Number: 3.6
; Module Version Number: 1.1
public lafdc
EXT LOUT
;
; LAFDC --
; PRINT REG A AS DECIMAL CHARACTERS IN N-CHAR FIELD ON LST:
; FLOATING PRINT, WHERE 1-3 CHARS ARE USED
;
LAFDC:
PUSH BC ; SAVE REGS
PUSH DE
PUSH AF ; SAVE A
LD D,1 ; TURN ON LEADING <SP> FLAG
;
; PRINT ROUTINE
;
LD B,100 ; PRINT HUNDREDS
CALL PAC ; PRINT A CHAR
LD B,10 ; PRINT TENS
CALL PAC
ADD '0' ; CONVERT TO ASCII
CALL LOUT ; PRINT
POP AF ; RESTORE A
POP DE ; RESTORE REGS
POP BC
RET
;
; PRINT RESULT OF DIVISION OF A BY B W/LEADING <SP> (INTEGER DIVISION)
;
PAC: LD C,0 ; SET COUNT
PACL: SUB B ; COMPUTE COUNT
JP C,PACD
INC C ; INCR COUNT
JP PACL
PACD: ADD A,B ; ADD B BACK IN
LD E,A ; SAVE A
LD A,C ; GET COUNT
OR A ; ZERO?
JP NZ,PACD1
OR D ; 0 MEANS NO LEADING <SP> (A=0, A OR D = 0 MEANS D=0)
JP Z,PACD1
LD A,E ; RESTORE A
RET
PACD1: LD D,0 ; D=0 FOR NO LEADING <SP>
LD A,C ; GET COUNT
ADD '0' ; CONVERT TO DECIMAL
CALL LOUT ; PRINT IT
LD A,E ; RESTORE A
RET
END