extrn bufinit,hwl2phy,phy2log\r
extrn fifolst\r
\r
- include config.inc\r
- include z180reg.inc\r
+ maclib z180reg.inc\r
+ maclib config.inc\r
\r
\r
dseg\r
cp (ix+o.in_idx) ;\r
jr z,bg.wait\r
\r
- push hl ;\r
- push ix\r
- pop hl\r
+ push ix ;\r
+ ex (sp),hl ;\r
add a,l\r
ld l,a\r
jr nc,bg.nc\r
; TODO: result code\r
\r
msg.recv:\r
- push de\r
-\r
-mr_wait_start:\r
call msg.in\r
cp 0AEh\r
- jr nz,mr_wait_start\r
-\r
+ jr nz,msg.recv\r
call msg.in ; get message length\r
ld c,a\r
inc c\r
jr mr_do\r
-\r
mr_next:\r
- dec c\r
- jr z,mr_exit ; while chars in input buffer\r
+ dec c ; while chars in input buffer\r
+ ret z\r
call msg.in ; get next\r
mr_do:\r
- ld e,a\r
- ld a,b\r
- or a ; if room in output buffer\r
- jr z,mr_skip\r
- ld (hl),e ; store char\r
- inc hl\r
dec b\r
-mr_skip:\r
+ jp p,mr_store\r
+ inc b\r
+ jr mr_next\r
+mr_store:\r
+ ld (hl),a ; store char\r
+ inc hl\r
jr mr_next ;\r
\r
-mr_exit:\r
- pop de\r
- ret\r
-\r
;--------------------------------------------------------------\r
\r
msgo.st:\r
push ix\r
ld ix,(fifolst+itx) ;\r
\r
- push hl ;\r
push bc\r
push ix\r
- pop hl\r
+ ex (sp),hl ;\r
ld c,(ix+o.in_idx) ;\r
ld b,0\r
add hl,bc\r
\r
ld a,b\r
out (AVRINT5),a\r
- pop bc\r
pop hl\r
+ pop bc\r
pop ix\r
ret\r
\r
ld b,(hl) ; 6\r
inc hl ; 4\r
ex de,hl ; 3\r
-ms.ol: ; \\r
+ms.ol: ;\r
push ix ;14\r
pop hl ; 9\r
ld c,(ix+o.in_idx) ;14\r
\r
buf.put:\r
push ix ;15\r
- push bc ;11\r
+ ex (sp),hl ;16\r
ld a,(ix+o.in_idx) ;19\r
- ld c,a ;4\r
- ld b,0 ;7\r
- add ix,bc ;11\r
- pop bc ;10\r
- ld (ix),c ;7\r
- pop ix ;14\r
+ add a,l ; 4\r
+ ld l,a ; 4\r
+ jr nc,bufp.1 ;12/7\r
+ inc h ; 4\r
+bufp.1:\r
+ ld (hl),c ; 7\r
+ pop hl ;10\r
\r
+ ld a,(ix+o.in_idx) ;19\r
inc a ;4\r
- and (ix+o.mask) ;19 =121\r
+ and (ix+o.mask) ;19 =129\r
bufp.wait:\r
cp (ix+o.out_idx) ;19\r
jr z,bufp.wait ;12/7\r
\r
out (AVRINT5),a ;11\r
ld a,c ;4\r
- ret ;10 =191\r
-\r
+ ret ;10 =199\r
\r
;----------------------------------------------------------------------\r
; Send message MEMORY\r