; TITLE "SCATH - Syslib 4.0" NAME ('CATH') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SCATH.Z80 Ver 1.1 by Richard Conn ; Date : 17 Sep 89 ; Version : 1.2 ; Module : SCATH ; Abstract: This module contains the routine CATH which returns ; the 4-bit binary (Hexidecimal) value of the character ; passed to it, or a space if the character is not '0'-'9' ; or 'A'-'F'. Note that this routine will NOT accept ; lower case letters, so CAPS should be passed to enable ; both cases to work. ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC CATH .Z80 CSEG ;=============================================================== ; NAME - CATH ; Entry: A - Contains the character to convert ; Exit : A = 0000B to 1111B if Valid character entered ; A = ' ' (20H) if invalid character ; Uses : AF ; Special Requirements: None ;=============================================================== CATH: SUB '0' ; Convert 0-9 JR C,ERROR ; Invalid char CP 10 ; 0-9? RET C SUB 7 ; Convert A-F CP 10 JR C,ERROR CP 16 ; A-F? RET C ; Return if valid ; ..Fall thru on error ERROR: LD A,' ' ; Error char RET END