; TITLE "SLHLFDC - Syslib 4.0" NAME ('LHLFDC') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SLHLFDC.Z80 by Richard Conn ; Date : 11 Jun 89 ; Version : 1.2 ; Module : SLHLFDC ; Abstract: This module contains the routine LHLFDC which prints ; the contents of the HL register pair in a one to five char- ; acter field on the LST: device. Only the valid characters ; are printed. No registers are affected. ; Revision: ; 1.3 8 Dec 89 Joe Wright ; Add LHL4 entry to be used by LHL4HC. Costs three bytes. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC LHLFDC, LHLD, LHL4 ; From SYSLIB Get.. EXT LOUT .Z80 CSEG ;=============================================================== ; NAME - LHLFDC ; Entry: HL - Contains the value to be printed ; Exit : - Nothing returned, the digits are printed to LST: ; Uses : - None ; Special Requirements: None ;=============================================================== LHLFDC: PUSH BC ; Save BC register LD B,-1 ; Set flag for variable-width print LHLD: PUSH DE ; Save the rest of the registers PUSH AF PUSH HL LD DE,10000 ; Print 10000's CALL HDVD JR LHL LHL4: PUSH DE ; Save the rest of the registers PUSH AF PUSH HL LHL: LD DE,1000 ; Print 1000's CALL HDVD LD DE,100 ; Print 100's CALL HDVD LD DE,10 ; Print 10's CALL HDVD 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 HDVD: OR -1 ; Clear carry and set initial count HDVD0: SBC HL,DE ; Divide by subtraction INC A ; .accumulate count JR NC,HDVD0 ; ..and loop while more to go ADD HL,DE ; Then compensate for underflow JR NZ,DIV0 ; ..jump if Number other than Zero remains OR B ; What was the previous status? RET M ; ..return if No char (suppress print) LD A,' ' ; Else prepare for Space JR Z,LO ; ..jump to print if Leading Space (0) XOR A ; Otherwise print a Zero DIV0: ADD A,'0' ; Convert to Ascii digit LD B,A ; .and set flag for next pass LO: JP LOUT ; ..Jump to LST: device END