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
/
SLADC.Z80
< prev
next >
Wrap
Text File
|
2000-06-30
|
1KB
|
72 lines
;
; SYSLIB Module Name: SLADC
; Author: Richard Conn
; SYSLIB Version Number: 3.6
; Module Version Number: 1.2
public la3dc,ladc
EXT LOUT
;
; LA3DC --
; PRINT REG A AS 3 DECIMAL CHARACTERS ON LST:
;
LA3DC:
PUSH BC ; SAVE REGS
PUSH DE
PUSH AF ; SAVE A
LD D,0 ; TURN OFF LEADING <SP> FLAG
JP LADC1
;
; LADC --
; PRINT REG A AS DECIMAL CHARACTERS W/LEADING <SP> IN 3-CHAR FIELD
; ON LST:
;
LADC:
PUSH BC ; SAVE REGS
PUSH DE
PUSH AF ; SAVE A
LD D,1 ; TURN ON LEADING <SP> FLAG
;
; PRINT ROUTINE
;
LADC1: 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, SO A OR D = 0 IF D=0)
JP Z,PACD1
LD A,' ' ; PRINT <SP>
CALL LOUT
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