*************************************************************** * * * Module ID: CPMIO.LIB By: GLH/W6BSK * * Last Updated: 27 Apr 85 * * Function : Console IO Version : 1.00 * * Subroutines * * Entry: * * Exit : * * * *************************************************************** ; *** EQU Tables *** cr equ 0dh ; Carriage return lf equ 0ah ; Line feed ctrlz equ 1ah ; Operator interrupt rconf equ 01h ; Dump input from console wconf equ 02h ; Write A contents to console cstaf equ 0bh ; Check con: status drive equ 04h ; Current drive number rbuff equ 0ah ; Read a console line tbuff equ 80h ; Base page default buffer bdos equ 05h ; BDOS entry point org 100h ; TPA start address begin: lxi h,0 ; Clear HL before loading dad sp ; old stack pointer shld cpmsp ; and save it. lxi sp, stak ; Set new stack lda drive ; Get current drive sta drsav ; and save it mvi c,cstaf ; Get console status call bdos ora a jz begin1 ; No input, get some. mvi c,rconf ; Ignore any if present. begin1: call ccrlf call spmsg db ' Put your message here ',0 call ccrlf jmp start ; Go to main program entry point. ; Display message to console spmsg: xthl ; Load phony RET to HL regs xra a ; Clear flags etc. add m ; Move one message character inx h ; and point to next. xthl ; restore stack to return if done. rz ; Done if 00 in A. call conout ; If not done, display it jmp spmsg ; and continue. ; Do a CR/LF to console twocr: call ccrlf ccrlf: mvi a,cr call conout mvi a,lf co: equ $ ; Allow two names conout: push b ; Display one character push d ; Push all regs push h mvi c,wconf ; Select the write function mov e,a ; and put in correct reg call bdos ; Do the function pop h pop d ; Pop all back. pop b ret ; Show spaces spaces: push b ; Enter with count in C mov c,a ; Save temp reg for count ora a ; Test for none jz space2 ; and quit if so. space1: mvi a, ' ' ; Load a space call conout dcr c jnz space1 ; Test countdown space2: pop b ; Clear stack ret ; Console operator interrupt opint: mvi c,cstaf ; Check for operator kill call bdos ora a ; Test if keypress rz ; Return if none. mvi c,rconf ; Was, check it. call bdos cpi ctrlz rnz done: lda drsav ; All done, check out. sta drive ; Restore current drive lhld cpmsp ; Get old stack pointer sphl ; load it, and go ret ; Input console message into buffer- cimsg: push b push d ; Push all regs push h lxi h,inbuf+1 ; Point to message start mvi m,0 ; and zero counter dcx h ; Back to length cell Š mvi m,80 ; and set max line xchg ; Input pointer to DE- mvi c,rbuff ; Set read buffer function call bdos ; and do it. lxi h,inbuf+1 ; Point to counter mov e,m ; and save it mvi d,0 ; Clear upper byte dad d ; and add length to start inx h ; add one more for end mvi m,0 ; and set 00 to end it. pop h pop d ; Restore them all pop b ret ; (Y)es or (N)o from console getyn: call spmsg ; Prompt for input db ' (Y/N)?: ',0 ; This is the prompt. call cimsg ; Read an input line call ccrlf ; and do a CR/LF lda inbuf+2 ; Use first character only. ani 5fh ; Make upper case only cpi 'Y' rz cpi 'N' jnz getyn cpi 0 ret ; Message out to console comsg: mov a,m ora a ; Test for 00 rz call conout inx h jmp comsg ; Local storage area drsav db 0 ; Current drive storage cpmsp dw 0 ; Old stack pointer inbuf ds 83 ; Line input buffer org 200h stak: equ $ start: call opint ; Return to CP/M? jmp start ; No, loop forever. Phony Phony