;************************************************************************** ; BYTEIO. Character IO High-Level Routines. (MUSt be in Common Memory) ; Calling parameters apply to both High and Low-Level routines. ; ; Output Routines - Enter: C = Character to be sent ; Exit : None ; ; Input Routines - Enter: None ; Exit : A = Character received from driver ; ; Status Routines - Enter: None ; Exit : A = 0FFH if I/O Ready, 0 if Not Ready ; ; Routines may Use: AF,DE. All other registers preserved/unaffected ; NOTE: Low-Level routines MUST preserve HL and BC. ; ; 1.1a- 26 Feb 93 - Remove Char Jump table. Integrate in IIO-xx. HFB ; 1.1 - 31 Aug 92 - General Release. Mod to work from other banks. HFB ; 1.0 - 3 Jul 92 - First General Release. HFB ; 0.0 - 12 Jun 91 - Initial Test Release. HFB ;************************************************************************** DEVINP EQU 10000000B ; Input data request DEVIST EQU 11000000B ; Input status request DEVOUT EQU 00000000B ; Output data request DEVOST EQU 01000000B ; Output status request CONFLD EQU 0 ; Iobyte offset for CONsole field AUIFLD EQU 2 ; Iobyte offset for AUX input field AUOFLD EQU 4 ; Iobyte offset for AUX output field LSTFLD EQU 6 ; Iobyte offset for LIST field IOBYTE EQU 0003H ; Address of CP/M 2.2 IOBYTE CSEG ;..... ; Auxiliary Input AUXIN: LD A,DEVINP ; AUX IN (reader) DEFB 11H ; ..Junk DE and fall thru AUXIST: LD A,DEVIST ; AUX Input Status OR AUIFLD ; Identify logical device JR GODEV ; Go to redirection code ;..... ; Auxiliary Output AUXOUT: LD A,DEVOUT ; AUX OUT (punch) DEFB 11H ; ..Junk DE and fall thru AUXOST: LD A,DEVOST ; AUX Output Status OR AUOFLD ; Identify logical device JR GODEV ; Go to redirection code ;..... ; List (Printer) LIST: LD A,DEVOUT ; LIST Output (Printer) DEFB 11H ; ..junk DE and fall thru LISTST: LD A,DEVOST ; LIST Output Status OR LSTFLD ; Identify logical device JR GODEV ; Go to redirection code ;..... ; Console CONOUT: LD A,DEVOUT ; CONsole Output DEFB 11H ; ..Junk DE and fall thru CONOST: LD A,DEVOST ; CONsole Output Status DEFB 11H ; ..junk DE and fall thru CONIN: LD A,DEVINP ; CONsole Input DEFB 11H ; ..Junk DE and fall thru CONST: LD A,DEVIST ; CONsole Input Status ;..Fall thru to.. ;..... ; Redirection Code GODEV: PUSH HL ; Save HL through here PUSH AF ; Save service type AND 7 ; Save only shift count LD L,A IF BANKED PUSH HL ; Save Regs used PUSH BC LD A,(TPABNK) ; IOByte always in TPA Bank LD C,A ; .so set to access TPA LD HL,IOBYTE ; ..point to IOByte CALL FRGETB ; ...and fetch POP BC ; Restore regs POP HL INC L ; Restore Zero Flag DEC L ; ..as on Entry ELSE LD A,(IOBYTE) ; Get IOBYTE value ENDIF JR Z,GODEV2 ; If console selected GODEV1: RRCA ; Shift device number into D0,D1 DEC L ; .using L as counter JR NZ,GODEV1 ; ..looping til shifted GODEV2: AND 0011B ; Mask for device ADD A,A ; .double count LD L,A ; Save in L (00000dd0) POP AF ; Get service type AND 11000000B ; Mask input and status bits (tt000000) OR L ; Add service request to device # (tt000dd0) RLCA RLCA RLCA ; D0=0, D1-D2=service, D4-D5=device (00dd0tt0) OR 00001000B ; Bypass Device Config/ID bytes (00dd1tt0) LD HL,DEVCFG ; .offset from base of Device Config Table VECTA: CALL ADDAHL ; Offset HL by A forming pointer in table LD A,(HL) ; Fetch routine address INC HL LD H,(HL) LD L,A ; ..in HL EX (SP),HL ; Swap with (HL) on Stack top ;..... ; Return A=False w/Flags Set ISFALSE: XOR A RET ;..... ; Print routine prints to console the Null or Zero-terminated string at (SP) PRINT: EX (SP),HL ; Print inline 0 or Hi-bit terminated PSTR: LD A,(HL) ; General purpose print 0 or Hi-bit INC HL ; Terminated string pointed to by HL OR A JR Z,PSTRX ; Exit if null found in string LD C,A PUSH BC PUSH DE PUSH HL CALL CONOUT ; Send to console device POP HL POP DE POP BC BIT 7,C ; Test for Hi-bit terminator JR Z,PSTR ; ..loop if Not finished PSTRX: EX (SP),HL ; Else swap Ptr to next instr for entry HL val RET ; ..and return to caller ;========================== End of BYTEIO ================================