summaryrefslogtreecommitdiff
path: root/z180/chario.180
diff options
context:
space:
mode:
authorLeo C2014-10-28 10:29:13 +0100
committerLeo C2014-10-28 10:29:13 +0100
commit30d1329e8e5c029a87f657baace698d1d7031f9e (patch)
tree8968e54145c1212cbaad6938e3da86cb42bf3707 /z180/chario.180
parent8a7deceacd30529e5c32082b2c719eb055841d0d (diff)
downloadz180-stamp-30d1329e8e5c029a87f657baace698d1d7031f9e.zip
CP/M 3 compatible character i/o handling
Diffstat (limited to 'z180/chario.180')
-rw-r--r--z180/chario.180103
1 files changed, 103 insertions, 0 deletions
diff --git a/z180/chario.180 b/z180/chario.180
new file mode 100644
index 0000000..6632690
--- /dev/null
+++ b/z180/chario.180
@@ -0,0 +1,103 @@
+ page 255
+ .z80
+
+
+; CP/M 3 compatible character i/o
+
+ public ?cinit,?ci,?co,?cist,?cost
+ public @ctbl
+
+ extrn ff.init,ff.i.st,ff.in,ff.o.st,ff.out
+ extrn ser.init,ser.ist,ser.in,ser.ost,ser.out
+
+ include config.inc
+ include z180reg.inc
+ include modebaud.inc ; define mode bits and baud eqautes
+
+
+max$device equ 2
+
+ cseg
+
+; c = device
+
+?cinit: ; init devices
+ ld b,c
+ call vector$io
+ dw ff.init
+ dw ser.init
+ dw rret
+
+; b = device, c = output char, a = input char
+
+?ci: ; character input
+ call vector$io
+ dw ff.in
+ dw ser.in
+ dw null$input
+
+?cist: ; character input status
+ call vector$io
+ dw ff.i.st
+ dw ser.ist
+ dw null$status
+
+?co: ; character output
+ call vector$io
+ dw ff.out
+ dw ser.out
+ dw rret
+
+?cost: ; character output status
+ call vector$io
+ dw ff.o.st
+ dw ser.ost
+ dw ret$true
+
+vector$io:
+ ld a,max$device
+ ld e,b
+vector:
+ pop hl
+ ld d,0
+ cp e
+ jr nc,exist
+ ld e,a ; use null device if a >= max$device
+exist: add hl,de
+ add hl,de
+ ld a,(hl)
+ inc hl
+ ld h,(hl)
+ ld l,a
+ jp (hl)
+
+
+null$input:
+ ld a,1Ah
+rret:
+ ret
+ret$true:
+ or 0FFh
+ ret
+
+null$status:
+ xor a
+ ret
+
+;--------------------------------------------------------------
+
+
+@ctbl:
+ db 'HOST ' ; device 0
+ db mb$output
+ db baud$none
+
+ db 'ASCI1 ' ; device 0
+ db mb$in$out+mb$serial+mb$soft$baud
+ser1$baud:
+ db baud$19200
+
+ db 0 ; table terminator
+
+ end
+