SECTION "wee",HOME[\$0] ; this all needs to be PIC! st: ld sp, \$CFFF xor a ld hl, \$FF60 ld [hli], a ld [hli], a ld [hli], a nak: ld a, \$15 ; NAK call putc+\$FF80 .ack: call getc+\$FF80 cp \$01 ;SOH jr z,.soh cp \$04 ;EOT jr z, .eot cp \$18 ;CAN jr z, .rst jr .donak .eot: ld A, \$06 ; Ack the EOT call putc+\$FF80 .rst: rst \$00 .soh: call getc+\$FF80 ; blk call getc+\$FF80 ; iblk xor a ld b, a ld l, a ld h, \$C0 .lp: call getc+\$FF80 ld [hli], a add b ld b, a bit 7, l jr z, .lp .cksm: call getc+\$FF80 cp b jr nz, .donak ld hl, \$C000 .lp2: jr z, .doack ld a, [hli] ld [\$FF63], A bit 7, l jr z,.lp2 .doack: ld A, \$06 call putc+\$FF80 jr .ack .donak: call getc+\$FF80 ; Wait until the line clears, and then once jr .donak ; that happens, getc will cause a NAK. getc: xor d xor e .dgetc: dec de xor a cp d jr z, .timeout ld a, [\$FF53] and \$02 jr z, .dgetc ld a, [\$FF52] ret .timeout: ld hl, \$D000 ld a, [hl] inc a ld [hl], a ld [\$FF51], a jr nak putc: ld c, \$53 push af .waitport: ld a,[c] and \$01 jr nz,.waitport pop af ld [\$FF52],a ret section "a", HOME[\$7F] nop