;2CON.ASM DUAL-CONSOLE SOFTWARE INTERFACE. ;11/4/86 [] Assembles with ASM.COM. ;Roy Lipscomb [] No separate .DOC file provided. ; [] Customized for Kaypro 8-bit machines. ; [] Customizable for other 8-bit machines. ; ; *********************************************************************** ; * Copyright 1986, Logic Associates, 1433 W. Thome, Chicago, IL 60660 * ; * (312) 274-0531. (Contact us about our other packages for CP/M.) * ; * * ; * Permission is hereby granted to distribute free copies of this * ; * software. All other rights are reserved. * ; *********************************************************************** ; ;Allows for dual-console operation of your computer, through a serial or ;parallel link to a 2nd console. The 2nd console becomes an exact work-alike ;image of the first, and may be a modem, a printer, a video terminal, a ;computer emulating a video terminal, etc. ; ;2CON is like a "Baby BYE" ("picobye"?), stripped down to the bare essentials. ;2CON is designed to be small, unobstrusive, and easy to install and use. ; ; [] Unlike BYE, 2CON does not diminish space for other programs. ; ; 2CON loads itself into the interrupt-vector area, normally ; unused. (Does not interfere with DDT, ZSID, or other debugger.) ; ; [] If you need to initialize a serial port for 2CON, this should ; be done via other software. For instance, execute MDM740 (or ; MEX, IMP, etc.), set the desired baud rate, exit, and run 2CON. ; This can be accomplished easily via a batch job. ; ; [] If the second console drops characters when 2CON is active, set ; the second console and its serial link to a lower baud rate. ; ; [] Cursor control may not operate correctly from the 2nd console. ; ; This depends on the cursor-control protocol of the 2nd console ; and (if it's a computer) its modem/terminal-emulation program. ; In terminal-emulation mode, some modem programs filter out ; received control codes instead of sending them to the console. ; ; [] Using a modem program on the same computer that has 2CON ; installed may produce unexpected results. De-install 2CON before ; starting up your modem program, reinstall 2CON after exiting your ; modem program. ; ; [] To de-install 2CON, press reset. ; org 100h jmp start logon db 0dh,0ah,'2CON 1.0 Copyright 1986, Logic Associates, (312) 274-0531$' FALSE EQU 0 TRUE EQU NOT FALSE ;---------------------------------------------------------------- ; customizable variables. ; ;---------------------------------------------------------------- KAYPRO EQU TRUE ;Is this for a Kaypro? (TRUE or FALSE) ;KAYPRO EQU FALSE ;Is this for a Kaypro? (TRUE or FALSE) ;If KAYPRO EQU TRUE, no further customization is needed. ;If KAYPRO EQU FALSE, then customize the next six equates for the ; port that will be used by your 2nd console. The appropriate hex ; values may be found in the overlay for your system provided by ; MDM740, MEX, IMP, BYE, or other public-access terminal emulator. IF NOT KAYPRO ser$ctl1 equ 000h ;control port ;;3P+S values. ser$data equ 001h ;data port ; in$bit$ equ 040h ;"input received" control bit in$rdy equ 040h ;"input received" value ; out$bit equ 080h ;"ok to output" control bit out$rdy equ 080h ;"ok to output" value ENDIF ;End of customization section. ;---------------------------------------------------------------- ; constants ; ;---------------------------------------------------------------- boot equ 0 ;warm boot vector. base equ 0008h ;load point for resident portion ; of this module. IF KAYPRO ser$ctl1 equ 06h ;control port. ser$data equ 04h ;data port. ; in$bit equ 01h ;"input received" control bit. in$rdy equ 01h ;"input received" value. ; out$bit equ 04h ;"ok to output" control bit. out$rdy equ 04h ;"ok to output" value. ENDIF ;---------------------------------------------------------------- ; installation routines ; ;---------------------------------------------------------------- start: ;is 2CON already active? call test jz noload ;yes, quit. ;move traps into place. call load ;patch the traps into the operating system. call customz ;display logon message. (Now visible to 2nd console as well.) lxi d,logon mvi c,9 call 5 ;exit to system. ret ;---------------------------------------------------------------- ;test if 2con already installed and active. ;if yes, return z = yes. (that is, set zero flag on.) test: ;initialize test flag to say "traps not already loaded." mvi a,0ffh sta tstflag ;build and patch in routine to catch whether 2con already installed. lhld trapout+base+1 shld tsttrpx+1 lxi h,tsttrap shld trapout+base+1 ;output anything to the console. mvi e,0 mvi c,6 call 5 ;restore original values. lhld tsttrpx+1 shld trapout+base+1 ;remove test trap, restore old value. ;was character trapped? lda tstflag ora a ret ;if already installed, return z = yes. ;else return z = no. ;............................................................... ;set flag if 2con already active. tsttrap: xra a sta tstflag tsttrpx: jmp $-$ ;patched at run time for BIOS console-out routine. tstflag: db 0ffh ;if turned to null, trap active. ;---------------------------------------------------------------- ;move traps into place. (Skip 3 bytes in middle, to preserve DDT.) load: lxi h,part1+adjust lxi d,base mvi b,part1len call move lxi h,part2+adjust lxi d,base+part2 mvi b,part2len call move ret ;............................................................... ;move (hl) to (de) for length b move: mov a,m stax d inx d inx h dcr b jnz move ret ;---------------------------------------------------------------- ;adapt trap addresses to the present operating system. customz: lhld boot+1 mvi l,0ch lxi d,trapout+base call patch mvi l,9 lxi d,trapin+base call patch mvi l,6 lxi d,trapst+base call patch ret ;............................................................... ;patch addresses into trap routines and into bios jumptable. patch: inx h mov c,m ;get contents of bios jentry into bc. inx h mov b,m push h ;save bios pointer. lxi h,4 ;address trap exit dad d mov m,c ;insert continuation addr into trap exit. inx h mov m,b pop h mov m,d ;change contents of bios jentry to de. dcx h ;(Note: Comment out these three instructs mov m,e ;to bypass patch of bios jumptable. This ;might be useful during a test.) ret ;---------------------------------------------------------------- ;don't load 2CON. Already loaded. noload: lxi d,logon ;display logon message. mvi c,9 call 5 lxi d,badload ;display "not loaded" message. mvi c,9 call 5 ret ;exit to system. badload db 7,0dh,0ah,' --> 2CON already active. No action. <--$' ;**************************************************** ; co-resident routines * ;**************************************************** adjust equ $ part1 equ $-adjust ;----------------------------------------------------; ; Modified jump-table for console. ; ;----------------------------------------------------; trapout equ $-adjust jmp trapout2+base coutmod equ $-adjust jmp $-$ ;to bios console out. ;---------------------------------------------------- trapin equ $-adjust jmp trapin2+base cinmod equ $-adjust jmp $-$ ;to bios console in. ;---------------------------------------------------- trapst equ $-adjust jmp trapst2+base const equ $-adjust jmp $-$ ;to bios console status. ;----------------------------------------------------; ; Trap all console operations ; ;----------------------------------------------------; ;console output. trapout2 equ $-adjust push b call coutmod+base ;output to standard console first. pop b trapot2 equ $-adjust in ser$ctl1 ;serial ready for next output char? ani out$bit cpi out$rdy jnz trapot2+base ; no, go test again. mov a,c ; yes, output the char to serial... ani 7fh out ser$data ret ;----------------------------------------------------; ;console in. trapin2 equ $-adjust call const+base ;is bios console-input ready? inr a ; (if yes, set A=0) jz cinmod+base ; yes, exit to get it. jmp part2+base ;jump over the DDT vector at 38h. part1len equ $-adjust-part1 ds 3 ;leave space for DDT vector at 38h. part2 equ $-adjust call trapsm+base ;is serial-input ready? inr a ; (if yes, set A=0) jnz trapin2+base ; no, go test console again. in ser$data ; yes, get it and exit. ani 7fh ret ;----------------------------------------------------; ;console status. trapst2 equ $-adjust call const+base ;bios console input status = empty? ora a ; (if yes, A=0) rnz ; no, return. trapsm equ $-adjust IF KAYPRO mvi a,10h ;switch to input. out ser$ctl1 ENDIF in ser$ctl1 ;does serial-input-status = ready? ani in$bit cpi in$rdy mvi a,0 ; no, say "not ready" (A=0) rnz dcr a ; yes, say "ready" (A=ff) ret ;----------------------------------------------------; part2len equ $-adjust-part2 end