* Packer/Depacker›* Jaskier/Taquart›› opt 5+32› org $2000››* strona 0››dest equ $80›srce equ $82›ends equ $84›addr equ $86›word equ $88›byte equ $8a›bajt equ $8b›swsk equ $8c›lbajt equ $8d››* Wywolanie››start lda #'0'› ora $301› sta dnam+1› lda #0› sta 82››s1 jsr close› ldx #1› jsr dspmsg› jsr getkey› cmp #''› bne *+5› jmp (10)› cmp #'p'› beq s2› cmp #'u'› bne s1›› jsr nultxt› ldx #2› jsr gettxt› bmi s1› jsr read› bmi s1› lda $358› ldx $359› ldy <lap+3› jsr pwor› jsr nultxt› ldx #7› jsr dspmsg› lda <pocz› sta dest› lda >pocz› sta dest+1› lda <konc› sta srce› lda >konc› sta srce+1› jsr dpck› sec› lda dest› sbc <pocz› tay› lda dest+1› sbc >pocz› tax› tya› ldy <lbp+3› jsr pwor› jsr nultxt› ldx #6› jsr dspmsg› jsr nultxt› ldx #3› jsr gettxt› bmi s2-3› jsr write› jmp s1››s2 jsr nultxt› ldx #2› jsr gettxt› bmi s2-3› jsr read› bmi s2-3› lda $358› ldx $359› ldy <lbp+3› jsr pwor› jsr nultxt› ldx #6› jsr dspmsg› jsr nultxt› ldx #3› jsr gettxt› bmi s2-3› jsr nultxt› lda #8› jsr open› bmi s2-3›› jsr pack›› lda lbajt› and #7› beq lpop› eor #7› tax› inx› sec› adc lbajt› sta lbajt› bcc *+8› inc lbajt+1› bne *+4› inc lbajt+2› lda #0› jsr wypxbt›lpop lsr lbajt+2› ror lbajt+1› ror lbajt› lsr lbajt+2› ror lbajt+1› ror lbajt› lsr lbajt+2› ror lbajt+1› ror lbajt› lda lbajt› ldx lbajt+1› ldy <lap+3› jsr pwor› ldx #7› jsr dspmsg› jsr close› lda #34› sta $22f› jsr getkey› jmp s1››* Procedury››nultxt ldx #0›dspmsg ldy #0›fm0 dex› bmi mout›fmes lda data,y› iny› cmp #$9b› bne fmes› beq fm0›mout txa› inx› sta $348› clc› tya› adc <data› sta $344› lda #0› sta $349› adc >data› sta $345› lda #9› sta $342› jmp $e456››gettxt jsr dspmsg› ldx #0› lda #5› sta $342› lda <text› sta $344› lda >text› sta $345› sta $349› jmp $e456››getkey lda #$ff› sta $2fc› ldy $2fc› cpy #$ff› beq *-5› sta $2fc› lda ($79),y› rts››open ldx #16› sta $35a› lda #3› sta $352› ldy #':'› cpy text+1› beq seti› cpy text+2› beq seti› lda #0›seti clc› adc <dnam› sta $354› lda #0› adc >dnam› sta $355› lda $d20f› and #8› eor #8› asl @› asl @› asl @› asl @› sta $35b› jsr $e456› bmi error› lda $35a› ora #3› sta $352› lda <pocz› sta $354› lda >pocz› sta $355› tya› rts››mcio jsr $e456› bpl mcio-1› cpy #136› beq mcio-2›error ldx #4› jsr dspmsg› jsr getkey› ldy #255› rts››read lda #4› jsr open› bmi read-1› lda #0› sta $358› lda #$80› sta $359› jsr mcio› bmi rret› ldx #5› bne error+2›rret cpy #136› bne error› clc› lda $358› adc <pocz› sta ends› lda $359› adc >pocz› sta ends+1››close ldx #16› lda #12› sta $352› jsr $e456› lda #3› sta $d20f› tya› bmi error› rts››write lda #8› jsr open› bmi write-1› sec› lda dest› sbc <pocz› sta $358› lda dest+1› sbc >pocz› sta $359› jmp mcio››pwor jsr phex› txa›phex pha› jsr pxdig› pla› lsr @› lsr @› lsr @› lsr @›pxdig and #15› ora #'0'› cmp #'9'+1› bcc *+4› adc #6› sta stat,y› dey› rts››* Packer››pack lda <pocz› sta srce› lda >pocz› sta srce+1› lda #8› sta swsk› lda #0› sta lbajt› sta lbajt+1› sta lbajt+2››l0 ldx #0› lda $d20f› and #8› bne *+4› ldx #34› stx $22f›› sec› lda srce› sbc <pocz› sta lzm5+1› lda srce+1› sbc >pocz› sta lzm6+1›› ldx #15›e1 lda typyl-1,x›lzm5 cmp #0› lda typyh-1,x›lzm6 sbc #0› bcc e2› dex› bne e1›e2 stx e3+1›› lda #1› sta byte› sec› lda ends› sbc srce› tax› lda ends+1› sbc srce+1› beq *+4› ldx #$ff› stx e4+1› lda <pocz› sta dest› lda >pocz› sta dest+1››l1 lda dest› cmp srce› lda dest+1› sbc srce+1› bcs kon›› ldy #0›l2 lda (dest),y› cmp (srce),y› bne l3› iny›e4 cpy #$ff› bcc l2››l3 cpy byte› bcc l4› lda dest› sta addr› lda dest+1› sta addr+1› sty byte›l4 clc› tya› bne *+3› sec› adc dest› sta dest› bcc l1› inc dest+1› bne l1››kon lda byte› cmp #2› bcs l5› jsr wypbit› ldx #8› ldy #0› lda (srce),y› jsr wypxbt› inc srce› bne *+4› inc srce+1› lda srce› cmp ends› lda srce+1› sbc ends+1› bcs wypbit-1› jmp l0››l5 lda byte› pha› dec byte›l6 sec› jsr wypbit› dec byte› bne l6› clc› jsr wypbit› clc› lda srce› sbc addr› tax› lda srce+1› sbc addr+1› tay› txa›e3 ldx #9› beq *+5› jsr wypxbt› clc› pla› adc srce› sta srce› bcc *+4› inc srce+1› lda srce› cmp ends› lda srce+1› sbc ends+1› bcs wypbit-1› jmp l0››wypxbt sta word› sty word+1› stx bajt› txa› eor #15› tax›zap3 asl word› rol word+1› dex› bpl zap3›zap2 asl word› rol word+1› jsr wypbit› dec bajt› bne zap2› rts››wypbit inc $d01a› inc lbajt› bne *+8› inc lbajt+1› bne *+4› inc lbajt+2› ror zap1+1› dec swsk› bne wypbit-1› lda #8› sta swsk› ldx #16› lda $357› pha› lda $356› pha›zap1 lda #0› rts››* Depacker››dpck lda srce› pha› lda srce+1› pha›› ldy #0›dpck1 lda srce› bne *+4› dec srce+1› dec srce› lda ends› bne *+4› dec ends+1› dec ends› lda (ends),y› sta (srce),y› lda dest› cmp ends› lda dest+1› sbc ends+1› bcc dpck1›› pla› sta ends+1› pla› sta ends› lda dest› sta lzm1+1› lda dest+1› sta lzm2+1› iny› sty bajt› tsx› stx swsk››loop sec› lda dest›lzm1 sbc #0› sta lzm3+1› lda dest+1›lzm2 sbc #0› sta lzm4+1›› ldx #15›loop3 lda typyl-1,x›lzm3 cmp #0› lda typyh-1,x›lzm4 sbc #0› bcc loop4› dex› bne loop3›loop4 stx pobzk+1› jsr pobbit› bcs loop1››pobb ldx #8› jsr pobxbt› sta (dest),y› inc dest› bne loop› inc dest+1› bne loop››loop1 lda #1› sta byte›loop2 jsr pobbit› inc byte› bcs loop2›pobzk ldx #9› txa› beq *+5› jsr pobxbt› eor #$ff› adc dest› sta addr› txa› eor #$ff› adc dest+1› sta addr+1›pobz lda (addr),y› sta (dest),y› inc addr› bne *+4› inc addr+1› inc dest› bne *+4› inc dest+1› dec byte› bne pobz› beq loop››pobxbt lda #0› sta pob3+1› sta pob4+1›pob2 jsr pobbit› rol pob3+1› rol pob4+1› dex› bne pob2›pob3 lda #0›pob4 ldx #0› rts››pobbit lda bajt› bne pob1› inc srce› bne *+4› inc srce+1› lda srce› cmp ends› lda srce+1› sbc ends+1› lda #1› sta bajt› bcc pob1› ldx swsk› txs›pob1 ldy #0› asl bajt› clc› and (srce),y› beq *+3› sec› rts››typyl dta l(1),l(2),l(4),l(8)› dta l(16),l(32),l(64),l(128)› dta l(256),l(512),l(1024),l(2048)› dta l($1000),l($2000),l($4000)›typyh dta h(1),h(2),h(4),h(8)› dta h(16),h(32),h(64),h(128)› dta h(256),h(512),h(1024),h(2048)› dta h($1000),h($2000),h($4000)››* dane››data dta b($9b)› dta c' }'› dta c'   РбглетЇДербглет вщ КБУЛЙЕТЇФБСХБТФ   '› dta c'    жпт бмм¬ опф ДПУ мпбдбвме¬ жймеу    '› dta c' P- Packing   U- Unpacking   Esc- Exit. ',b($9b)› dta c'Source:',b($9b)› dta c'Target:',b($9b)› dta c'I/O error!',b($9b)› dta c'Out of memory!',b($9b)›stat dta c'Lenght before packing:$'›lbp equ *-stat› dta c'....',b($9b)› dta c'Lenght after packing:$'›lap equ *-stat› dta c'....',b($9b)››dnam dta c'D0:'›text org *+120››pocz equ *›konc equ $bc20›› org $2e0› dta a(start)›› end›