;PORTCHK.ASM v1.00 ;By S. Kluger ; ; Inputs from a port and continually displays ; the input value in hex, binary and ASCII. ; ; Uses SYSLIB calls ; cr equ 0dh lf equ 0ah null equ 0 ; bankp equ 1 ;1=banked port (Interfacer 3/4 etc) ;0=normal direct port ; extrn print,condin,cin,cout,pa2hc,bbline,eval16 ; begin: lxi h,0 dad sp shld stack lxi sp,stack call print db cr,lf db 'PORTCHK v1.00',cr,lf db 'This program, after requesting a port address,',cr,lf db 'will continually IN from that port and display',cr,lf db 'the input data on the console in hex, binary',cr,lf db 'and ASCII. CONTROL-C at any point will abort',cr,lf db 'execution.',cr,lf,null ; restrt: call print db cr,lf,null if bankp call print db 'SELECT PORT :',null call getprt call eval16 mov a,e sta selp ;save select port endif call print db cr,lf db 'DATA PORT :',null call getprt call eval16 ;return binary in DE mov a,e ;get low byte of result sta port ;store the port away call print db cr,lf,null loop: call condin jz nochar cpi 3 jz break cpi 'S'-40H jnz nochar call cin cpi 3 jnz nochar ; break: call print db cr,lf,lf db '*** INTERRUPTED ***',cr,lf db 'Display another port (Y/N) ? ',null mvi a,1 ;capitalize response call bbline mov a,m cpi 'Y' ;yes? jz restrt call print db cr,lf,lf db '*** END OF EXECUTION ***',cr,lf,null lhld stack sphl ret ; nochar: call pportn ;print port number call ioblk ;call the I/O block call pa2hc ;print acc push psw ;save acc call print db ' = ',null mvi b,8 ;8 bits to print bin: rlc ;msb into CY push psw ;save byte mvi a,'0' ;default to 0 jnc putit ;skip if 0 inr a ;make 1 putit: call cout ;print the digit pop psw ;get rotated data back dcr b ;decrement the counter jnz bin ;do it 8 times call print db ' = ',null pop psw ora a jp co ;if <7f then out normally push psw mvi a,'~' ;META-prefix call cout pop psw co: ani 7fh ;make 7-bit just in case cpi ' ' jnc co1 ;no control char push psw mvi a,'^' call cout pop psw adi 40h co1: call cout jmp loop ;do it until ^C typed ; pportn: call print db cr,lf db 'Port number ',null lda port call pa2hc ;print the port # in hex call print db ' returns : ',null ret ; getprt: call print db cr,lf db 'Enter the HEX port value now : ',null mvi a,1 ;capitalize call bbline ;get buffered input line cpi 2 ;2 characters typed? rz ;yes, go on call print db cr,lf,lf db 'ERROR - type only TWO HEX DIGITS',cr,lf,null jmp getprt ; if bankp ; ; if banked I/O is used (as in CompuPro IF3/4) then you ; can specify both the relative port AND the input port. ; (example: IF4, relative port 7 is RS-232, data port 10H is data in) ; the NOPs are included for field patching without reassembly. ; ioblk: mvi a,0 ;select port selp equ $-1 out 17h ;hardcoded command port address nop ! nop ! nop ;some room... in 0 port equ $-1 nop ! nop ! nop ret ; else ; ioblk: nop ! nop ! nop in 0 port equ $-1 nop ! nop ! nop ret ; endif ; ds 40 ;20-level stack stack: dw 0 end