; ; Module name : CONSOLE.ASM ; Author : James Whorton ; Date written: 09/26/84 ; ; ; This sample module illustrates how to write an RSX for the 22RSX ; environment. While it is rather simple, it does give you an idea ; on how to proceed with your own modules. Have fun. JHW <-- ; This module records the number of times that the following BDOS ; functions have been called since last check: 1,2,5,6,9 and 10. ; When a request is made by using the accompanying program CONSTAT, ; the recorded ; cin: equ 1 cout: equ 2 lst: equ 5 dio: equ 6 lout: equ 9 lin: equ 10 request:equ 255 ;this is the request character that ;causes a display of the recorded ;values. fcb: equ 05Ch ;FCB address ; ; RSX prefix (standard DRI format) ; serial: db 0,0,0,0,0,0 ;Space for serial # (CP/M 3.0) start: jmp rsxstrt ;Jump to beginning of actual module next: jmp $-$ ;Jump to next RSX in line or BDOS jump table prev: dw 0 ;The loader will patch the address of the ;previous module here. remove: db 0 ;Remove flag (0=remain, 0FFh=remove at warm boot) nonbank:db 0 ;Nonbank flag name: db 'CONSOLE ' ;This is the name of the RSX. It MUST be ; ^^^^^^^^ ;8 bytes, pad with blanks if needed. loader: db 0 ;Loader flag db 0,0 ;Reserved for system use ; ;Module starts here ; rsxstrt:mov a,c ;save function # sta fnc lxi h,0 ;save user's stack pointer dad sp shld userstk lxi sp,rstack ;set local stack push d ;save regs. push b ; ;check function and branch if one of ours ; cpi cin ;input? jz input ;yes cpi cout ;output? jz output ;yes cpi lst ;list output? jz list ;yes cpi dio ;direct I/O? jz direct ;yes cpi lout ;line out? jz linout ;yes cpi lin ;line in? jz linin ;yes jmp passon ;the function call wasn't one of ours, ; ;BDOS function 1 (console in) ; input: lhld incnt ;get counter inx h ;bump it one shld incnt ;put it back jmp passon ;continue ; ;BDOS function 2 (console out) ; output: lhld outcnt ;get pointer inx h ;bump it one shld outcnt ;update it ; ;check for a status request ; lda fcb ;get check char cpi request ;is it a request? jnz passon ;no, so pass call on ; ;A request has been made, so report stats... ; report: lxi h,in$msg ;console in call ilprnt lhld incnt call outhex lxi h,out$msg ;console out call ilprnt lhld outcnt call outhex lxi h,lst$msg ;list out call ilprnt lhld lstcnt call outhex lxi h,din$msg ;direct I/O in call ilprnt lhld dincnt call outhex lxi h,dout$msg ;direct I/O out call ilprnt lhld doutcnt call outhex lxi h,lout$msg ;line out call ilprnt lhld loutcnt call outhex lxi h,lin$msg ;line in call ilprnt lhld lincnt call outhex ;now reset our counters and exit lxi h,0 shld incnt shld outcnt shld lstcnt shld dincnt shld doutcnt shld loutcnt shld lincnt mvi a,0 ;set FCB to something innocent sta fcb exit: pop b ;restore regs pop d lhld userstk ;restore stack sphl ret ;back to caller ; ;BDOS function 5 (list out) ; list: lhld lstcnt ;get counter inx h ;bump on shld lstcnt ;update it jmp passon ;continue ; ;BDOS function 6 ; direct: pop b ;get regs for compar. pop d push d ;put them back push b ;determine whether in or out and act accordingly mov a,e cpi 0FFh ;direct I/O in? jnz direct2 ;no, must be out lhld dincnt ;get counter inx h ;bump one shld dincnt ;update it jmp passon ;continue ; direct2:lhld doutcnt ;get counter inx h ;bump one shld doutcnt ;update it jmp passon ;continue ; ;BDOS function 9 (line out) ; linout: lhld loutcnt ;get counter inx h ;bump one shld loutcnt ;update it jmp passon ;continue ; ;BDOS function 10 (line in) ; linin: lhld lincnt ;get counter inx h ;bump one shld lincnt ;update it ; ;Restore all regs. and stack pointer and pass call up the line ; passon: pop b ;restore regs. pop d lhld userstk ;restore stack sphl jmp next ;later... ; ; Data storage area ; fnc: ds 1 ;function call incnt: dw 0 ;console in counter outcnt: dw 0 ;console out counter lstcnt: dw 0 ;list counter dincnt: dw 0 ;direct I/O in counter doutcnt:dw 0 ;direct I/O out counter loutcnt:dw 0 ;line output counter lincnt: dw 0 ;line input counter temp: ds 1 ;temp. storage userstk:dw 0 ;old stack pointer ds 20 ;local stack space rstack: dw 0 in$msg: db cr,lf,' 1 Console In ',0 out$msg:db cr,lf,' 2 Console Out ',0 lst$msg:db cr,lf,' 5 List Out ',0 din$msg:db cr,lf,' 6 Direct I/O In ',0 dout$msg:db cr,lf,' 6 Direct I/O Out ',0 lout$msg:db cr,lf,' 9 Line Out ',0 lin$msg:db cr,lf,' 10 Line In ',0 ; ;== Utility Routines == ; ;This routine outputs the contents of in hex format ; outhex: push h ;save value mov a,h ;get MSB call outhex1 ;print it pop h ;get value back push h mov a,l ;get LSB call outhex1 ;print it mvi e,'h' ;put h on end of address mvi c,cout call next pop h ret outhex1:mov b,a ;save number rar rar rar rar call outhex2 ;print half of it mov a,b ;get number back outhex2:ani 0Fh ;get LSN to send out adi 090h ;convert to ASCII daa aci 040h daa push b mvi c,cout mov e,a call next pop b ret ; ; ;Inline print routine ; ilprnt: push psw push h push d push b ; ilp: mov e,m mvi c,cout push h ilp1: call next pop h inx h mov a,m ora a jnz ilp pop b pop d pop h pop psw ret ; link '22INSTB'