Epson HX-20 Terminal Program
To be able to convert the Epson HX-20 into to a terminal using its RS-232C port, I made this assembly program which can be assembled with dasm:
processor hd6303
; Kernel routines:
DSPSCR equ $FF4F
RSMST equ $FF88
RSONOF equ $FF85
RSOPEN equ $FF82
RSGET equ $FF79
RSPUT equ $FF76
RSCLOS equ $FF7F
KEYIN equ $FF9A
KEYSTS equ $FF9D
MENU equ $FF25
SCRFNC equ $FF5E
; Kernel variables:
RSDCNT equ $01C2
org $1000 ; Run from HX-20 RAM.
; Program:
start
; Set virtual screen size.
ldx #packet
jsr SCRFNC
jmp endpack
packet
dc.b $87 ; Screen size function
dc.b 19 ; Columns
dc.b 3 ; Rows
dc.w $1300 ; Buffer address
endpack
; Clear the virtual screen.
ldaa #$0C
jsr DSPSCR
; Set RS-232 parameters.
ldaa #%11110101 ; No parity, 1 stop bit, flow control off.
;ldab #%01001000 ; 1200bps, 8 data bits.
ldab #%00101000 ; 300bps, 8 data bits.
jsr RSMST
; Turn on RS-232.
ldaa #1
jsr RSONOF
; Setup RS-232 buffer.
ldd #200
ldx #$1100
jsr RSOPEN
rschk
; Get one character from RS-232.
ldd RSDCNT
beq keychk
jsr RSGET
; Output on virtual screen.
jsr DSPSCR
keychk
; Check for keyboard activity.
jsr KEYSTS
beq rschk
jsr KEYIN
; Terminate on 'ESC' press.
cmpa #$1B
beq end
; Check for swap between lowercase and uppercase.
cmpa #$41 ; 'A'
blt cdone
cmpa #$5A ; 'Z'
ble cutol
cmpa #$61 ; 'a'
blt cdone
cmpa #$7A ; 'z'
bgt cdone
; Covert from lowercase to uppercase.
anda #%11011111
jsr cdone
cutol
; Covert from uppercase to lowercase.
oraa #%00100000
cdone
; Put one character on RS-232.
jsr RSPUT
jmp rschk
end
; Shut down RS-232.
jsr RSCLOS
ldaa #0
jsr RSONOF
; Go back to main menu.
jmp MENU
It is only a "dumb" terminal supporting a few of the basic ASCII control codes, which happens to be handled automatically by the "virtual screen" routines in the HX-20 ROM code. It's best to run the communication at 300 baud, which is hard-coded into this program. Running faster baudrates will cause the receive buffer to overflow because writing to the LCD screen and scrolling it is too slow.
For convenience, here is a BASIC representation of the program:
1 DATA 206,16,9,189,255,94,126,16,14,135,19,3,19,0,134,12
2 DATA 189,255,79,134,245,198,40,189,255,136,134,1,189,255,133,204
3 DATA 0,200,206,17,0,189,255,130,252,1,194,39,6,189,255,121
4 DATA 189,255,79,189,255,157,39,240,189,255,154,129,27,39,29,129
5 DATA 65,45,19,129,90,47,13,129,97,45,11,129,122,46,7,132
6 DATA 223,189,16,86,138,32,189,255,118,126,16,40,189,255,127,134
7 DATA 0,189,255,133,126,255,37
8 FOR I=4096 TO 4198
9 READ A
10 POKE I,A
11 NEXT I
12 EXEC 4096
Before loading this BASIC program, the "MEMSET 8192" BASIC command must be run to move the program area, to avoid corrupting anything.
Here is a YouTube demo video of the terminal program in action against a Linux host to do some rudimentary web browsing.