; TITLE "SSHLFDC - Syslib 4.0" NAME ('SHLFDC') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SSHLFDC.Z80 by Richard Conn ; Date : 5 Jul 89 ; Version : 1.2 ; Module : SSHLFDC ; Abstract: This module contains the routine SHLFDC which prints ; the contents of the HL register pair in a one to five char- ; acter field on the CON:/LST: (switched) devices. Only the ; valid characters are printed. No registers are affected. ; Revision: ; 1.3 8 Dec 89 Joe Wright ; Add SHL4 entry for SHL4DC. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC SHLFDC, SHLD, SHL4 ; From SYSLIB Get.. EXT SOUT .Z80 CSEG ;=============================================================== ; NAME - SHLFDC ; Entry: HL - Contains the value to be printed ; Exit : - Nothing returned, digits are printed to CON: or LST: ; Uses : - None ; Special Requirements: None ;=============================================================== SHLFDC: PUSH BC ; Save BC register LD B,-1 ; Set for Floating width print SHLD: PUSH DE ; Save the rest of the registers PUSH AF PUSH HL LD DE,10000 ; Print 10000's CALL PHDC1 JR SHL0 SHL4: PUSH DE PUSH AF PUSH HL SHL0: LD DE,1000 ; Print 1000's CALL PHDC1 LD DE,100 ; Print 100's CALL PHDC1 LD DE,10 ; Print 10's CALL PHDC1 LD A,L ; Print 1's CALL DIV0 ; Convert to Ascii and print POP HL ; Restore all regs POP AF POP DE POP BC RET ; Divide HL by DE and print quotient with leading 0 suppression PHDC1: OR -1 ; Clear flag & Set initial count DIV: SBC HL,DE ; Divide by subtraction INC A ; .adjust counter JR NC,DIV ; ..loop til done ADD HL,DE ; Compensate for underflow JR NZ,DIV0 ; ..jump if Non-zero div result OR B ; Else check for previous print RET M ; ..return if No prev char & Zero result LD A,' ' ; Else set for leading space JR Z,SO ; ..jump if Zero result w/leading sp XOR A ; Otherwise print a Zero DIV0: ADD A,'0' ; Convert to Ascii digit LD B,A ; Set flag for subsequent passes SO: JP SOUT ; ..Jump to physical device END