Global labels... clearup =$c84e a =$0057 stdout =$9069 stdin =$9066 base =$c800 cleanup =$c84e die =$c848 ------------------------------------------------------------ *** FILE ".cat.0" base: ; cat v2.0 @1#0 @1#1 @1#2 @1#0 ; 64 stack 87..89 zeropage @1#64 @1#87 @1#3 @1#0 a=#87 ; pointer to start @1$1c @2$40 use3;null1;null2;null3;null4;null5 jmp userbreak jmp killedparent use3;null8;null9;null10;null11 use3;null12;null13;null14;null15 text "cat" @1#0 use4;null start: lda #>base jsr $9051 jmp 64738 userbreak: killedparent: die: jsr cleanup jmp $901b cleanup: lda base+4 beq skip jsr $ffcc lda #1 jsr $ffc3 ldx #0 jsr $9042 cl i skip: rts stdout=$9069 stdin=$9066 #add catlab a stdout stdin base cleanup die #next cat.1 ------------------------------------------------------------ *** FILE ".cat.1" ; cat.1 #include catlab strout=$905d lock=$903f unlock=$9042 pipechk=$906f st=#144 use2;fname use1;flen use3;rpos use1;flag pjp ovv howto.txt:text "usage-" @1#13 text " cat file{" @1#44 text "type}" @1#13 text " type=p" @1#44 text "u or s (default)" @1#13 @1#0 iofault.txt: text "cat" @1#58 text " io-error" @1#13 @1#0 ovv: init: lda base+8 beq noargs sta fname+1 sta a+1 ldy #0 sty a nx: iny beq howto lda (a),y beq noargs cmp #32 beq nx sty fname ; set file typeat the end nxx: iny beq howto lda (a),y bne nxx dey dey lda (a),y iny iny cmp #44 beq typok lda #44 sta (a),y iny lda #asc("s") sta (a),y iny lda #0 sta (a),y typok: lda #44 sta (a),y iny lda #asc("r") sta (a),y iny lda #0 sta (a),y tya se c sbc fname sta flen jmp go noargs: howto: ldx base+3 jsr strout bit howto.txt jmp $901b go: lda #0 sta rpos sta rpos+1 sta rpos+2 *: ; open file for reading ldx #0 stx a stx a+1 stx a+2 stx flag lock cl i lda flen ldx fname ldy fname+1 jsr $ffbd lda #1 ldx #8 ldy #2 jsr $ffba jsr $ffc0 bcs iofault ldx #1 jsr $ffc6 bcs iofault ; check readptr l*: lda a cmp rpos bne read lda a+1 cmp rpos+1 bne read lda a+2 cmp rpos+2 beq posok read: jsr $ffcf bcs iofault lda st bne iofault inc a bne l* inc a+1 bne l* inc a+2 bne l* iofault: ldx base+3 jsr strout bit iofault.txt jmp hangup chkst: txa and #$bf bne iofault eof: jsr cleanup jmp $9018 posok: ldx base+2 jsr pipechk bcs hangup bmi wait jsr $ffcf bcs iofault inc a bne ov0 inc a+1 bne ov0 inc a+2 ov0: jsr stdout ldx st bne chkst stx flag bcc posok hangup: jmp die wait: jsr $9012 ldx flag inx stx flag cpx #8 bne posok jsr cleanup lda a sta rpos lda a+1 sta rpos+1 lda a+2 sta rpos+2 waitp2: lda #0 sta flag jsr $9012 ldx base+2 jsr pipechk bcs hangup beq to* bmi waitp2 ldx flag inx stx flag cmp #4 bne waitp2+5 to*: jmp * @1#2 Written by Poldi 17.3.1996 <(dan.da at gmx.de)>