mirror of
https://github.com/A2osX/A2osX.git
synced 2024-06-20 11:29:29 +00:00
Kernel 0.9.1 : ASM rewrite....Addressing Modes
This commit is contained in:
parent
ff0efac421
commit
bb8b8f1bd8
Binary file not shown.
|
@ -2,8 +2,13 @@ NEW
|
||||||
PREFIX /A2OSX.BUILD
|
PREFIX /A2OSX.BUILD
|
||||||
AUTO 4,1
|
AUTO 4,1
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
* U-Operators :
|
* EXP.Modifiers:
|
||||||
* B-Operators :
|
* # : 8b,Byte 1
|
||||||
|
* / : 8b,Byte 2
|
||||||
|
* ^ : 8b,Byte 3
|
||||||
|
* < : 24b,Byte 1,2,3
|
||||||
|
* > : 32b
|
||||||
|
*---------------------------------------
|
||||||
* Num Format : 0-9 -> decimal
|
* Num Format : 0-9 -> decimal
|
||||||
* $ = Hex
|
* $ = Hex
|
||||||
* % = binary
|
* % = binary
|
||||||
|
@ -11,11 +16,11 @@ AUTO 4,1
|
||||||
* * = PC
|
* * = PC
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
EXP.Eval lda #2
|
EXP.Eval lda #2
|
||||||
sta SRC.ACC.SIZE Assume WORD (2 bytes)
|
sta SRC.ACC.SIZE Default To WORD (2 bytes)
|
||||||
|
|
||||||
stz EXP.Modifier
|
>STZ.G EXP.Modifier
|
||||||
|
>STZ.G EXP.Prefix
|
||||||
stz EXP.Operator
|
>STZ.G EXP.Operator
|
||||||
|
|
||||||
jsr SRC.GetChar
|
jsr SRC.GetChar
|
||||||
bcs EXP.Eval.Missing
|
bcs EXP.Eval.Missing
|
||||||
|
@ -23,7 +28,11 @@ EXP.Eval lda #2
|
||||||
jsr SRC.IsMODReserved
|
jsr SRC.IsMODReserved
|
||||||
bcs EXP.Eval.Next1
|
bcs EXP.Eval.Next1
|
||||||
|
|
||||||
stx EXP.Modifier
|
txa
|
||||||
|
>STA.G EXP.Modifier
|
||||||
|
lda #'#'
|
||||||
|
>STA.G EXP.Prefix
|
||||||
|
|
||||||
bra EXP.Eval.Next
|
bra EXP.Eval.Next
|
||||||
|
|
||||||
EXP.Eval.Missing lda #ERR.MISSING.EXP
|
EXP.Eval.Missing lda #ERR.MISSING.EXP
|
||||||
|
@ -123,7 +132,12 @@ EXP.Eval.Next1 cmp #'.' Local Label?
|
||||||
bcs EXP.EvalExitUND
|
bcs EXP.EvalExitUND
|
||||||
bra EXP.EvalOperator
|
bra EXP.EvalOperator
|
||||||
|
|
||||||
EXP.EvalExitOK clc
|
EXP.EvalExitOK >LDA.G EXP.Modifier
|
||||||
|
beq .8
|
||||||
|
asl
|
||||||
|
tax
|
||||||
|
jmp (J.EXP.MOD,x)
|
||||||
|
.8 clc
|
||||||
EXP.EvalExitRTS rts
|
EXP.EvalExitRTS rts
|
||||||
|
|
||||||
EXP.EvalExitSYN lda #ERR.SYNTAX.ERROR
|
EXP.EvalExitSYN lda #ERR.SYNTAX.ERROR
|
||||||
|
@ -134,7 +148,7 @@ EXP.EvalExitUND lda #ERR.UNDEF.SYMBOL
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
|
|
||||||
EXP.EvalOperator lda EXP.Operator
|
EXP.EvalOperator >LDA.G EXP.Operator
|
||||||
beq .7
|
beq .7
|
||||||
|
|
||||||
jsr EXP.Compute
|
jsr EXP.Compute
|
||||||
|
@ -151,8 +165,8 @@ EXP.EvalOperator lda EXP.Operator
|
||||||
|
|
||||||
jsr SRC.IsEXPReserved
|
jsr SRC.IsEXPReserved
|
||||||
bcs EXP.EvalExitSYN
|
bcs EXP.EvalExitSYN
|
||||||
|
txa
|
||||||
stx EXP.Operator
|
>STA.G EXP.Operator
|
||||||
|
|
||||||
ldx #3
|
ldx #3
|
||||||
|
|
||||||
|
@ -213,6 +227,23 @@ EXP.Compute dec
|
||||||
.8 clc
|
.8 clc
|
||||||
rts
|
rts
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
|
EXP.MOD.8.3 lda SRC.ACC+2
|
||||||
|
bra EXP.MOD.8
|
||||||
|
EXP.MOD.8.2 lda SRC.ACC+1
|
||||||
|
EXP.MOD.8 sta SRC.ACC
|
||||||
|
EXP.MOD.8.1 lda #1
|
||||||
|
sta SRC.ACC.SIZE
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
EXP.MOD.24 lda #3
|
||||||
|
sta SRC.ACC.SIZE
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
EXP.MOD.32 lda #4
|
||||||
|
sta SRC.ACC.SIZE
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
*---------------------------------------
|
||||||
EXP.OP.EOR ldx #3
|
EXP.OP.EOR ldx #3
|
||||||
|
|
||||||
.1 lda SRC.ARG,x
|
.1 lda SRC.ARG,x
|
||||||
|
|
|
@ -76,7 +76,6 @@ OUT.PrintLine.9 rts
|
||||||
OUT.PrintLineOn clc
|
OUT.PrintLineOn clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
>LDA.G ASM.LI.ON
|
>LDA.G ASM.LI.ON
|
||||||
bpl .9
|
bpl .9
|
||||||
|
|
||||||
|
@ -147,11 +146,11 @@ OUT.PrintLineAcc ldx SRC.ACC.SIZE
|
||||||
dex
|
dex
|
||||||
bne .1
|
bne .1
|
||||||
|
|
||||||
.2 lda SRC.ACC.SIZE
|
lda SRC.ACC.SIZE
|
||||||
asl
|
asl
|
||||||
tax
|
tax
|
||||||
|
|
||||||
ldy L.MSG.EQU0,x
|
.2 ldy L.MSG.EQU0,x
|
||||||
lda L.MSG.EQU0+1,x
|
lda L.MSG.EQU0+1,x
|
||||||
>SYSCALL PrintF.YA
|
>SYSCALL PrintF.YA
|
||||||
rts
|
rts
|
||||||
|
|
|
@ -178,7 +178,7 @@ SRC.ParseLine.LABEL lda #0
|
||||||
bit #SYM.F.RESOLVED
|
bit #SYM.F.RESOLVED
|
||||||
bne SRC.ParseLine.Redef
|
bne SRC.ParseLine.Redef
|
||||||
|
|
||||||
.2 jsr SYM.UpdateGlobal
|
.2 jsr SYM.UpdateGlobalPC
|
||||||
bra SRC.ParseLine.DirOp
|
bra SRC.ParseLine.DirOp
|
||||||
|
|
||||||
.3 jsr SYM.LookupGlobal Pass #2: should be already defined...
|
.3 jsr SYM.LookupGlobal Pass #2: should be already defined...
|
||||||
|
@ -243,7 +243,7 @@ SRC.ParseLine.ExecMacro
|
||||||
rts
|
rts
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
SRC.ParseLine.OpCode
|
SRC.ParseLine.OpCode
|
||||||
stz SRC.AM.ID
|
stz SRC.AM.StrBuf
|
||||||
|
|
||||||
>LDYA ZPOPtr
|
>LDYA ZPOPtr
|
||||||
>STYA ZPPtr1
|
>STYA ZPPtr1
|
||||||
|
@ -310,20 +310,23 @@ SRC.ParseLine.OpCode
|
||||||
sta ZPPtr1+1
|
sta ZPPtr1+1
|
||||||
bra .1
|
bra .1
|
||||||
|
|
||||||
.8 clc
|
.8 jmp SRC.ParseLine.AMCheck
|
||||||
rts
|
|
||||||
|
|
||||||
.9 lda #ERR.INV.OPCODE
|
.9 lda #ERR.INV.OPCODE
|
||||||
sec
|
sec
|
||||||
.99 rts
|
.99 rts
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
SRC.ParseLine.AM stz SRC.AM.StrBuf
|
SRC.ParseLine.AM >LDA.G EXP.Prefix
|
||||||
|
beq .1
|
||||||
|
inc SRC.AM.StrBuf
|
||||||
|
ldx SRC.AM.StrBuf
|
||||||
|
sta SRC.AM.StrBuf,x
|
||||||
|
|
||||||
.1 jsr SRC.GetChar
|
.1 jsr SRC.GetChar
|
||||||
bcs .8
|
bcs SRC.ParseLine.AMCheck
|
||||||
|
|
||||||
.10 cmp #' ' another space ?
|
.10 cmp #' ' another space ?
|
||||||
beq .8 ignore end of line (comment)
|
beq SRC.ParseLine.AMCheck ignore end of line (comment)
|
||||||
|
|
||||||
jsr SRC.IsAMReserved
|
jsr SRC.IsAMReserved
|
||||||
bcs .2
|
bcs .2
|
||||||
|
@ -333,18 +336,7 @@ SRC.ParseLine.AM stz SRC.AM.StrBuf
|
||||||
sta SRC.AM.StrBuf,x
|
sta SRC.AM.StrBuf,x
|
||||||
bra .7
|
bra .7
|
||||||
|
|
||||||
.2 jsr SRC.IsMODReserved
|
.2 jsr SRC.IsLetter Any register?
|
||||||
bcs .3
|
|
||||||
|
|
||||||
lda #'#'
|
|
||||||
inc SRC.AM.StrBuf
|
|
||||||
ldx SRC.AM.StrBuf
|
|
||||||
sta SRC.AM.StrBuf,x
|
|
||||||
|
|
||||||
jsr SRC.GetNextChar
|
|
||||||
bcs .9
|
|
||||||
|
|
||||||
.3 jsr SRC.IsLetter Any register?
|
|
||||||
bcs .6 no, try something else
|
bcs .6 no, try something else
|
||||||
|
|
||||||
>LDYA ZPRPtr Check in register table
|
>LDYA ZPRPtr Check in register table
|
||||||
|
@ -394,14 +386,23 @@ SRC.ParseLine.AM stz SRC.AM.StrBuf
|
||||||
|
|
||||||
.7 jsr SRC.GetNextChar
|
.7 jsr SRC.GetNextChar
|
||||||
bcc .10
|
bcc .10
|
||||||
|
|
||||||
|
jmp SRC.ParseLine.AMCheck
|
||||||
|
|
||||||
.8 clc
|
|
||||||
rts
|
|
||||||
|
|
||||||
.9 lda #ERR.INV.AM.SYN
|
.9 lda #ERR.INV.AM.SYN
|
||||||
sec
|
sec
|
||||||
.99 rts
|
.99 rts
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
|
SRC.ParseLine.AMCheck
|
||||||
|
jsr OUT.PrintLine.1
|
||||||
|
>PUSHW L.SRC.AM.StrBuf
|
||||||
|
>LDYA L.MSG.PSTRCRLF
|
||||||
|
>SYSCALL PrintF.YA
|
||||||
|
|
||||||
|
>DEBUG
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
*---------------------------------------
|
||||||
SRC.GetDecimal jsr SRC.GetChar
|
SRC.GetDecimal jsr SRC.GetChar
|
||||||
beq .99
|
beq .99
|
||||||
|
|
||||||
|
@ -618,9 +619,11 @@ SRC.GetBinary jsr SRC.GetNextChar skip '%'
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
SRC.GetKeyword >STYA ZPPtr1 KeyWord table
|
SRC.GetKeyword >STYA ZPPtr1 KeyWord table
|
||||||
|
|
||||||
stz SRC.Keyword.ID
|
lda #0 Keyword.ID
|
||||||
|
|
||||||
|
.1 pha
|
||||||
|
|
||||||
.1 lda (ZPPtr1)
|
lda (ZPPtr1)
|
||||||
beq .9 End Of table
|
beq .9 End Of table
|
||||||
|
|
||||||
tax KW len
|
tax KW len
|
||||||
|
@ -628,14 +631,14 @@ SRC.GetKeyword >STYA ZPPtr1 KeyWord table
|
||||||
.2 ldy #0
|
.2 ldy #0
|
||||||
|
|
||||||
.3 lda (ZPLinePtr),y
|
.3 lda (ZPLinePtr),y
|
||||||
beq .5
|
beq .6
|
||||||
|
|
||||||
jsr SRC.IsKeywordLetterUC
|
jsr SRC.IsKeywordLetterUC
|
||||||
bcs .5
|
bcs .6
|
||||||
|
|
||||||
iny
|
iny
|
||||||
cmp (ZPPtr1),y
|
cmp (ZPPtr1),y
|
||||||
bne .5
|
bne .6
|
||||||
|
|
||||||
dex
|
dex
|
||||||
bne .3
|
bne .3
|
||||||
|
@ -644,31 +647,34 @@ SRC.GetKeyword >STYA ZPPtr1 KeyWord table
|
||||||
beq .4 End of Line ?
|
beq .4 End of Line ?
|
||||||
|
|
||||||
jsr SRC.IsKeywordLetterUC
|
jsr SRC.IsKeywordLetterUC
|
||||||
bcc .5 Additional letters...
|
bcc .6 Additional letters...
|
||||||
|
|
||||||
.4 lda ZPLinePtr
|
.4 lda ZPLinePtr
|
||||||
clc
|
clc
|
||||||
adc (ZPPtr1)
|
adc (ZPPtr1)
|
||||||
sta ZPLinePtr
|
sta ZPLinePtr
|
||||||
bcc .41
|
bcc .5
|
||||||
inc ZPLinePtr+1
|
inc ZPLinePtr+1
|
||||||
.41 ldx SRC.Keyword.ID
|
|
||||||
|
.5 pla Keyword.ID
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.5 lda (ZPPtr1)
|
.6 lda (ZPPtr1)
|
||||||
sec Add keyword Len+1
|
sec Add keyword Len+1
|
||||||
adc ZPPtr1
|
adc ZPPtr1
|
||||||
sta ZPPtr1
|
sta ZPPtr1
|
||||||
bcc .6
|
bcc .7
|
||||||
|
|
||||||
inc ZPPtr1+1
|
inc ZPPtr1+1
|
||||||
|
|
||||||
.6 inc SRC.Keyword.ID
|
.7 pla Keyword.ID
|
||||||
inc SRC.Keyword.ID
|
inc
|
||||||
|
inc
|
||||||
bra .1
|
bra .1
|
||||||
|
|
||||||
.9 sec
|
.9 plx
|
||||||
|
sec
|
||||||
rts
|
rts
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
SRC.IsAMReserved ldx SRC.AM.RESERVED
|
SRC.IsAMReserved ldx SRC.AM.RESERVED
|
||||||
|
|
|
@ -66,19 +66,13 @@ SYM.Dump stz ZPLinePtr
|
||||||
>PUSHW ZPLinePtr
|
>PUSHW ZPLinePtr
|
||||||
>PUSHW ZPTmpBuf
|
>PUSHW ZPTmpBuf
|
||||||
>SYSCALL SListGetByID
|
>SYSCALL SListGetByID
|
||||||
pha
|
|
||||||
txa
|
|
||||||
sta ZPLinePtr
|
|
||||||
tya
|
|
||||||
sta ZPLinePtr+1
|
|
||||||
pla
|
|
||||||
bcs .8
|
bcs .8
|
||||||
|
stx ZPLinePtr Save Next ID
|
||||||
|
sty ZPLinePtr+1
|
||||||
|
|
||||||
>LDA.G ASM.LI.ON
|
>LDA.G ASM.LI.ON
|
||||||
bpl .1
|
bpl .1
|
||||||
|
|
||||||
>PUSHW ZPTmpBuf Label (PString)
|
|
||||||
|
|
||||||
lda (ZPTmpBuf)
|
lda (ZPTmpBuf)
|
||||||
sec
|
sec
|
||||||
adc ZPTmpBuf
|
adc ZPTmpBuf
|
||||||
|
@ -87,8 +81,15 @@ SYM.Dump stz ZPLinePtr
|
||||||
adc #0
|
adc #0
|
||||||
sta ZPPtr1+1
|
sta ZPPtr1+1
|
||||||
|
|
||||||
ldx #4
|
ldy #SYM.F Get Symbol Size
|
||||||
ldy #2
|
lda (ZPPtr1),y
|
||||||
|
and #3
|
||||||
|
beq .3
|
||||||
|
|
||||||
|
pha
|
||||||
|
tax
|
||||||
|
|
||||||
|
iny SYM.V
|
||||||
|
|
||||||
.2 lda (ZPPtr1),y
|
.2 lda (ZPPtr1),y
|
||||||
>PUSHA
|
>PUSHA
|
||||||
|
@ -96,18 +97,26 @@ SYM.Dump stz ZPLinePtr
|
||||||
dex
|
dex
|
||||||
bne .2
|
bne .2
|
||||||
|
|
||||||
>LDYA L.MSG.GSYMBOL
|
pla
|
||||||
|
asl
|
||||||
|
|
||||||
|
.3 tax
|
||||||
|
ldy L.MSG.EQU0,x
|
||||||
|
lda L.MSG.EQU0+1,x
|
||||||
>SYSCALL PrintF.YA
|
>SYSCALL PrintF.YA
|
||||||
|
|
||||||
|
>PUSHW ZPTmpBuf Label (PString)
|
||||||
|
|
||||||
|
>LDYA L.MSG.PSTRCRLF
|
||||||
|
>SYSCALL PrintF.YA
|
||||||
bcc .1
|
bcc .1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.8 clc
|
.8 clc
|
||||||
rts
|
rts
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
SYM.AddGlobalPC jsr SYM.PC2Global
|
SYM.AddGlobalPC jsr SYM.PC2Global A=SYM.Len
|
||||||
|
ora #SYM.F.RESOLVED PC is always known
|
||||||
lda #SYM.F.RESOLVED
|
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
SYM.AddGlobal >STA.G SYM.Global+SYM.F
|
SYM.AddGlobal >STA.G SYM.Global+SYM.F
|
||||||
|
|
||||||
|
@ -170,8 +179,19 @@ SYM.UpdateGlobalAcc ldx #3
|
||||||
dey
|
dey
|
||||||
dex
|
dex
|
||||||
bpl .1
|
bpl .1
|
||||||
|
|
||||||
|
ldx #4
|
||||||
|
ldy #3
|
||||||
|
|
||||||
|
.3 lda SRC.ACC,y
|
||||||
|
bne .4
|
||||||
|
dex
|
||||||
|
dey
|
||||||
|
bne .3
|
||||||
|
|
||||||
|
.4 txa
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
SYM.UpdateGlobal lda #SYM.F.RESOLVED
|
SYM.UpdateGlobal ora #SYM.F.RESOLVED
|
||||||
>STA.G SYM.Global+SYM.F
|
>STA.G SYM.Global+SYM.F
|
||||||
|
|
||||||
lda #5 F+DWORD
|
lda #5 F+DWORD
|
||||||
|
@ -203,6 +223,18 @@ SYM.PC2Global ldx #4
|
||||||
dey
|
dey
|
||||||
dex
|
dex
|
||||||
bne .2
|
bne .2
|
||||||
|
|
||||||
|
ldx #4
|
||||||
|
ldy #ASM.PC+3
|
||||||
|
|
||||||
|
.3 lda (pData),y
|
||||||
|
bne .4
|
||||||
|
dex
|
||||||
|
dey
|
||||||
|
bne .3
|
||||||
|
|
||||||
|
.4 txa
|
||||||
|
|
||||||
rts
|
rts
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
SYM.AddLocalPC tax Save ID
|
SYM.AddLocalPC tax Save ID
|
||||||
|
|
|
@ -90,7 +90,7 @@ L.MSG.EQU0 .DA MSG.EQU0
|
||||||
L.MSG.SRCLINE .DA MSG.SRCLINE
|
L.MSG.SRCLINE .DA MSG.SRCLINE
|
||||||
L.MSG.ERROR .DA MSG.ERROR
|
L.MSG.ERROR .DA MSG.ERROR
|
||||||
L.MSG.SYMBOLS .DA MSG.SYMBOLS
|
L.MSG.SYMBOLS .DA MSG.SYMBOLS
|
||||||
L.MSG.GSYMBOL .DA MSG.GSYMBOL
|
L.MSG.PSTRCRLF .DA MSG.PSTRCRLF
|
||||||
L.MSG.SUMMARY .DA MSG.SUMMARY
|
L.MSG.SUMMARY .DA MSG.SUMMARY
|
||||||
L.MSG.PASS .DA MSG.PASS
|
L.MSG.PASS .DA MSG.PASS
|
||||||
L.MSG.SRC.FILE .DA MSG.SRC.FILE
|
L.MSG.SRC.FILE .DA MSG.SRC.FILE
|
||||||
|
@ -150,7 +150,12 @@ J.LI .DA DIR.LI.ON
|
||||||
.DA DIR.LI.MOFF
|
.DA DIR.LI.MOFF
|
||||||
.DA DIR.LI.XON
|
.DA DIR.LI.XON
|
||||||
.DA DIR.LI.XOFF
|
.DA DIR.LI.XOFF
|
||||||
J.EXP.OP .DA EXP.OP.EOR ^!|&<=>+-*/
|
J.EXP.MOD .DA EXP.MOD.8.1
|
||||||
|
.DA EXP.MOD.8.2
|
||||||
|
.DA EXP.MOD.8.3
|
||||||
|
.DA EXP.MOD.24
|
||||||
|
.DA EXP.MOD.32
|
||||||
|
J.EXP.OP .DA EXP.OP.EOR ^!|&<=>+-*/
|
||||||
.DA EXP.OP.ORA
|
.DA EXP.OP.ORA
|
||||||
.DA EXP.OP.ORA
|
.DA EXP.OP.ORA
|
||||||
.DA EXP.OP.AND
|
.DA EXP.OP.AND
|
||||||
|
@ -239,7 +244,7 @@ CS.RUN >SYSCALL GetChar
|
||||||
>PUSHA
|
>PUSHA
|
||||||
>LDYA L.MSG.PASS
|
>LDYA L.MSG.PASS
|
||||||
>SYSCALL PrintF.YA
|
>SYSCALL PrintF.YA
|
||||||
|
|
||||||
ldy #SRC.hFILENAME
|
ldy #SRC.hFILENAME
|
||||||
lda (pData),y
|
lda (pData),y
|
||||||
|
|
||||||
|
@ -383,43 +388,38 @@ T.LI >PSTR "ON"
|
||||||
>PSTR "XOFF"
|
>PSTR "XOFF"
|
||||||
.HS 00
|
.HS 00
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
MSG.HELP >CSTR "A2osX-Macro Assembler (S-C MASM 3.0 Based)\r\nUsage : ASM <src file> [type TXT ($04) or S-C/BAS ($FA)]\r\n"
|
ASM.6502 .AZ "6502"
|
||||||
MSG.PASS >CSTR "Pass:#%d\r\n"
|
MSG.HELP .AZ "A2osX-Macro Assembler (S-C MASM 3.0 Based)\r\nUsage : ASM <src file> [type TXT ($04) or S-C/BAS ($FA)]\r\n"
|
||||||
MSG.SRC.FILE >CSTR "Reading SRC File:%s\r\n"
|
MSG.PASS .AZ "Pass:#%d\r\n"
|
||||||
MSG.OBJ.FILE >CSTR "Writing OBJ File:%s, Type=%02x\r\n"
|
MSG.SRC.FILE .AZ "Reading SRC File:%s\r\n"
|
||||||
MSG.T.FILE >CSTR "Loading CPU File:%s\r\n"
|
MSG.OBJ.FILE .AZ "Writing OBJ File:%s, Type=%02x\r\n"
|
||||||
MSG.OUT0 >CSTR "%H- "
|
MSG.T.FILE .AZ "Loading CPU File:%s\r\n"
|
||||||
MSG.OUT1 >CSTR "%H-%h "
|
MSG.OUT0 .AZ "%H- "
|
||||||
MSG.OUT2 >CSTR "%H-%h %h "
|
MSG.OUT1 .AZ "%H-%h "
|
||||||
MSG.OUT3 >CSTR "%H-%h %h %h"
|
MSG.OUT2 .AZ "%H-%h %h "
|
||||||
MSG.EQU0 >CSTR "[ ]"
|
MSG.OUT3 .AZ "%H-%h %h %h"
|
||||||
MSG.EQU1 >CSTR "[ %h]"
|
MSG.EQU0 .AZ "[ ?]"
|
||||||
MSG.EQU2 >CSTR "[ %h%h]"
|
MSG.EQU1 .AZ "[ %h]"
|
||||||
MSG.EQU3 >CSTR "[ %h%h%h]"
|
MSG.EQU2 .AZ "[ %h%h]"
|
||||||
MSG.EQU4 >CSTR "[ %h%h%h%h]"
|
MSG.EQU3 .AZ "[ %h%h%h]"
|
||||||
MSG.SRCLINE >CSTR " %05D %s\r\n"
|
MSG.EQU4 .AZ "[ %h%h%h%h]"
|
||||||
MSG.ERROR >CSTR "*** Fatal Error $%h "
|
MSG.SRCLINE .AZ " %05D %s\r\n"
|
||||||
MSG.SYMBOLS >CSTR "Symbol Table:\r\n"
|
MSG.ERROR .AZ "*** Fatal Error $%h "
|
||||||
MSG.GSYMBOL >CSTR "$%h%h%h%h:%S\r\n"
|
MSG.SYMBOLS .AZ "Symbol Table:\r\n"
|
||||||
MSG.SUMMARY >CSTR "\r\nSymbol Table Size : %5D Bytes.\r\nEnd Of Assembly.\r\n"
|
MSG.PSTRCRLF .AZ " %S\r\n"
|
||||||
SRC.AM.RESERVED >PSTR "[](),"
|
MSG.SUMMARY .AZ "\r\nSymbol Table Size : %5D Bytes.\r\nEnd Of Assembly.\r\n"
|
||||||
SRC.MOD.RESERVED >PSTR "#/<>"
|
SRC.MOD.RESERVED >PSTR "#/^<>"
|
||||||
SRC.EXP.RESERVED >PSTR "^!|&<=>+-*/"
|
SRC.EXP.RESERVED >PSTR "^!|&<=>+-*/"
|
||||||
ASM.6502 >CSTR "6502"
|
SRC.AM.RESERVED >PSTR "[](),"
|
||||||
*---------------------------------------
|
*---------------------------------------
|
||||||
ASM.T.FILENAME .BS 65
|
ASM.T.FILENAME .BS 65
|
||||||
|
|
||||||
FIO.Stat .BS S.STAT
|
FIO.Stat .BS S.STAT
|
||||||
|
|
||||||
EXP.Modifier .BS 1
|
|
||||||
EXP.Operator .BS 1
|
|
||||||
|
|
||||||
SRC.Keyword.ID .BS 1
|
|
||||||
SRC.ACC.SIZE .BS 1
|
SRC.ACC.SIZE .BS 1
|
||||||
SRC.ACC .BS 4
|
SRC.ACC .BS 4
|
||||||
SRC.ACCTMP .BS 4
|
SRC.ACCTMP .BS 4
|
||||||
SRC.ARG .BS 4
|
SRC.ARG .BS 4
|
||||||
SRC.AM.ID .BS 1
|
|
||||||
SRC.AM.StrBuf .BS 32
|
SRC.AM.StrBuf .BS 32
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.DUMMY
|
.DUMMY
|
||||||
|
@ -446,6 +446,11 @@ ASM.T.hMem .BS 1
|
||||||
DIR.Word .BS 2
|
DIR.Word .BS 2
|
||||||
DIR.Byte .BS 1
|
DIR.Byte .BS 1
|
||||||
|
|
||||||
|
EXP.Modifier .BS 1
|
||||||
|
EXP.Prefix .BS 1
|
||||||
|
EXP.Operator .BS 1
|
||||||
|
|
||||||
|
|
||||||
ASM.PASS .BS 1
|
ASM.PASS .BS 1
|
||||||
ASM.DO.StackPtr .BS 1
|
ASM.DO.StackPtr .BS 1
|
||||||
ASM.DO.Stack .BS SRC.DO.MAXDEPTH
|
ASM.DO.Stack .BS SRC.DO.MAXDEPTH
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
PR#3
|
|
||||||
PREFIX /A2OSX.BUILD
|
|
||||||
NEW
|
NEW
|
||||||
INC 1
|
PREFIX /A2OSX.BUILD
|
||||||
AUTO 6
|
AUTO 4,1
|
||||||
.LIST OFF
|
|
||||||
.OP 65C02
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
* File Header :
|
* File Header :
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
|
@ -14,17 +10,12 @@ S.PAKFILE.VER .EQ 8
|
||||||
S.PAKFILE.TF .EQ 9 Target File (C-String)
|
S.PAKFILE.TF .EQ 9 Target File (C-String)
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
* Shunk Header :
|
* Shunk Header :
|
||||||
* WORD : !Target UNCompressed Length
|
* WORD : Target UNCompressed Length
|
||||||
* USED TO STOP UNPACK
|
* !!! USED TO STOP UNPACK,NO EOF TOKEN!!!
|
||||||
* !!!NO EOF TOKEN!!!
|
|
||||||
* Short3 : [0..7]
|
|
||||||
* Short4 : [0..15]
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
S.PAKHDR.LEN .EQ 0
|
S.PAKSHK.ULEN .EQ 0 Uncompressed length
|
||||||
S.PAKHDR.SHORT3 .EQ 2
|
|
||||||
S.PAKHDR.SHORT4 .EQ 10
|
|
||||||
*
|
*
|
||||||
S.PAKHDR .EQ 26
|
S.PAKSHK .EQ 26
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
S.PAKSTAT.PASS1 .EQ 0
|
S.PAKSTAT.PASS1 .EQ 0
|
||||||
S.PAKSTAT.PASS2 .EQ 2
|
S.PAKSTAT.PASS2 .EQ 2
|
||||||
|
|
10
LIB/LIBPAK.S.AC.txt
Normal file
10
LIB/LIBPAK.S.AC.txt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
NEW
|
||||||
|
PREFIX /A2OSX.BUILD
|
||||||
|
AUTO 4,1
|
||||||
|
.LIST OFF
|
||||||
|
*--------------------------------------
|
||||||
|
|
||||||
|
*--------------------------------------
|
||||||
|
MAN
|
||||||
|
SAVE /A2OSX.SRC/LIB/LIBPAK.S.AC
|
||||||
|
ASM
|
71
LIB/LIBPAK.S.IN.txt
Normal file
71
LIB/LIBPAK.S.IN.txt
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
NEW
|
||||||
|
PREFIX /A2OSX.BUILD
|
||||||
|
AUTO 4,1
|
||||||
|
.LIST OFF
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.In.Init >LDYA Pak.SrcPtr
|
||||||
|
>STYA ZPSrcPtr
|
||||||
|
|
||||||
|
lda Pak.Hdr+S.PAKHDR.LEN
|
||||||
|
eor #$ff
|
||||||
|
sta Pak.SrcCnt
|
||||||
|
|
||||||
|
lda Pak.Hdr+S.PAKHDR.LEN+1
|
||||||
|
eor #$ff
|
||||||
|
sta Pak.SrcCnt+1
|
||||||
|
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.In.GetRH lda #$ff
|
||||||
|
cmp Pak.SrcCnt+1 return 255 if not $ffxx
|
||||||
|
bne .1
|
||||||
|
|
||||||
|
lda Pak.SrcCnt
|
||||||
|
eor #$ff return !xx if $ffxx
|
||||||
|
|
||||||
|
.1 rts
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.In.MoveFWA clc
|
||||||
|
adc ZPSrcPtr
|
||||||
|
sta ZPSrcPtr
|
||||||
|
bcc .8
|
||||||
|
inc ZPSrcPtr+1
|
||||||
|
|
||||||
|
.8 rts
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.In.Get8Bits ldy #8
|
||||||
|
.HS 2C bit abs
|
||||||
|
Pak.In.Get4Bits ldy #4
|
||||||
|
lda #0 make sure to reset A before reading less than 8 bits only
|
||||||
|
.1 jsr Pak.In.GetBit and to exit with CC if even if 8 bits read
|
||||||
|
rol
|
||||||
|
dey
|
||||||
|
bne .1
|
||||||
|
rts always CC
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.In.GetBit ldx Pak.In.Mask
|
||||||
|
bne .1
|
||||||
|
jsr Pak.In.NxtByte
|
||||||
|
|
||||||
|
ldx #8
|
||||||
|
|
||||||
|
.1 dex
|
||||||
|
stx Pak.In.GetBit+1
|
||||||
|
|
||||||
|
pha Don't trash A
|
||||||
|
lda (UnZPSrcPtr)
|
||||||
|
and Pak.In.BitMask,x
|
||||||
|
cmp #1 if 0:CC, i>0 CS
|
||||||
|
|
||||||
|
pla
|
||||||
|
rts Bit is in C
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.In.GetByte lda (UnZPSrcPtr)
|
||||||
|
Pak.In.NxtByte inc UnZPSrcPtr
|
||||||
|
bne .8
|
||||||
|
inc UnZPSrcPtr+1
|
||||||
|
.8 rts
|
||||||
|
*--------------------------------------
|
||||||
|
MAN
|
||||||
|
SAVE /A2OSX.SRC/LIB/LIBPAK.S.IN
|
||||||
|
ASM
|
166
LIB/LIBPAK.S.LZ.txt
Normal file
166
LIB/LIBPAK.S.LZ.txt
Normal file
|
@ -0,0 +1,166 @@
|
||||||
|
NEW
|
||||||
|
PREFIX /A2OSX.BUILD
|
||||||
|
AUTO 4,1
|
||||||
|
.LIST OFF
|
||||||
|
*--------------------------------------
|
||||||
|
* Sliding Window = 4096
|
||||||
|
*--------------------------------------
|
||||||
|
WSIZE .EQ 4096 power of 2
|
||||||
|
*--------------------------------------
|
||||||
|
* Output BITSTREAM :
|
||||||
|
* 0 : Lit (8)
|
||||||
|
* 1 : Copy, L (4), P.HI (4), P.LO (8)
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.LZ jsr Pak.In.Init Init SrcPtr,SrcCnt
|
||||||
|
jsr Pak.Out.Init
|
||||||
|
|
||||||
|
* future optimization, make P grows from 2 to 12 while increasing W size
|
||||||
|
|
||||||
|
* lda #2 Ptr width starts at 2 bits
|
||||||
|
* sta Pak.LZ.PWidth
|
||||||
|
|
||||||
|
* lda #%00000011 Ptr Mask Starts at %000000000011
|
||||||
|
* sta Pak.LZ.PMaskLO
|
||||||
|
* stz Pak.LZ.PMaskHI
|
||||||
|
|
||||||
|
lda #$ff
|
||||||
|
sta Pak.LZ.WCnt
|
||||||
|
sta Pak.LZ.WCnt+1 WCnt=!0
|
||||||
|
|
||||||
|
.1 jsr Pak.In.GetRH Z if EOF
|
||||||
|
beq .80
|
||||||
|
|
||||||
|
cmp #3
|
||||||
|
bcc .8 no more than 2 bytes left....store
|
||||||
|
|
||||||
|
cmp #19 more than 18 bytes left, limit to 18
|
||||||
|
bcc .2
|
||||||
|
lda #18
|
||||||
|
|
||||||
|
.2 tax X = Read ahead max size
|
||||||
|
|
||||||
|
lda ZPSrcPtr make ZPSrcWPtr=ZPSrcPtr
|
||||||
|
sta ZPSrcWPtr
|
||||||
|
|
||||||
|
lda ZPSrcPtr
|
||||||
|
sta ZPSrcWPtr
|
||||||
|
|
||||||
|
lda Pak.LZ.WCnt
|
||||||
|
sta ZPCnt
|
||||||
|
lda Pak.LZ.WCnt+1
|
||||||
|
sta ZPCnt+1
|
||||||
|
|
||||||
|
stz Pak.LZ.BestLen
|
||||||
|
|
||||||
|
.3 inc ZPCnt
|
||||||
|
bne .4
|
||||||
|
inc ZPCnt+1
|
||||||
|
beq .7 reached begining of window....store
|
||||||
|
|
||||||
|
lda ZPSrcWPtr make ZPSrcWPtr-=1
|
||||||
|
sec
|
||||||
|
sbc #1
|
||||||
|
sta ZPSrcWPtr
|
||||||
|
bcs .4
|
||||||
|
dec ZPSrcWPtr+1
|
||||||
|
|
||||||
|
.4 ldy #0
|
||||||
|
phx save Read ahead max size
|
||||||
|
|
||||||
|
.5 lda (ZPSrcPtr),y Try to find a match
|
||||||
|
cmp (ZPSrcWPtr),y
|
||||||
|
bne .6
|
||||||
|
|
||||||
|
iny
|
||||||
|
dex don't exceed 18 or Src Buffer
|
||||||
|
bne .5
|
||||||
|
|
||||||
|
.6 plx get back Read ahead max size
|
||||||
|
|
||||||
|
cpy #3 matched a least 3 chars ?
|
||||||
|
bcc .3 no....try one char back in Wnd
|
||||||
|
|
||||||
|
cpy Pak.LZ.BestLen better than last match ?
|
||||||
|
bcc .3 no....try one char back in Wnd
|
||||||
|
|
||||||
|
sty Pak.LZ.BestLen
|
||||||
|
lda ZPSrcWPtr
|
||||||
|
sta Pak.LZ.BestPtr
|
||||||
|
lda ZPSrcWPtr+1
|
||||||
|
sta Pak.LZ.BestPtr+1
|
||||||
|
bra .3
|
||||||
|
|
||||||
|
.7 lda Pak.LZ.BestLen do we match something ?
|
||||||
|
beq .8
|
||||||
|
|
||||||
|
lda Pak.LZ.BestPtr
|
||||||
|
sec
|
||||||
|
sbc ZPSrcPtr
|
||||||
|
sta Pak.LZ.BestPtr
|
||||||
|
|
||||||
|
lda Pak.LZ.BestPtr+1
|
||||||
|
sbc ZPSrcPtr+1
|
||||||
|
sta Pak.LZ.BestPtr+1
|
||||||
|
|
||||||
|
tya get len
|
||||||
|
dec Adjust range 0-15
|
||||||
|
dec
|
||||||
|
dec
|
||||||
|
ora Pak.LZ.BestPtr+1 merge with P.HI
|
||||||
|
|
||||||
|
sec
|
||||||
|
jsr Pak.Out.PutCA Put 9 bits 1+LLLL+PPPP
|
||||||
|
bcs .99
|
||||||
|
|
||||||
|
lda Pak.LZ.BestPtr Put 8 bits pppppppp
|
||||||
|
|
||||||
|
jsr Pak.Out.PutA
|
||||||
|
bcs .99
|
||||||
|
|
||||||
|
tya
|
||||||
|
bra .81
|
||||||
|
|
||||||
|
.8 lda (ZPSrcPtr)
|
||||||
|
clc
|
||||||
|
jsr Pak.Out.PutCA Put 9 bits 0+xxxxxxxx
|
||||||
|
bcs .99
|
||||||
|
lda #1
|
||||||
|
|
||||||
|
.81 jsr Pak.In.MoveFWA
|
||||||
|
tya
|
||||||
|
jsr LZ.MoveWndY
|
||||||
|
bra .3
|
||||||
|
bra .71
|
||||||
|
|
||||||
|
.80 clc
|
||||||
|
.99 rts
|
||||||
|
*--------------------------------------
|
||||||
|
Unpak.LZ
|
||||||
|
|
||||||
|
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
|
LZ.MoveWndY tya
|
||||||
|
sec
|
||||||
|
sbc Pak.LZ.WCnt
|
||||||
|
tax
|
||||||
|
lda #0
|
||||||
|
sbc Pak.LZ.WCnt+1
|
||||||
|
|
||||||
|
cpx #WSIZE^$FF
|
||||||
|
sbc /WSIZE^$FF
|
||||||
|
|
||||||
|
bcs .1
|
||||||
|
|
||||||
|
ldx #WSIZE^$FF
|
||||||
|
lda /WSIZE^$FF
|
||||||
|
|
||||||
|
.1 stx Pak.LZ.WCnt
|
||||||
|
sta Pak.LZ.WCnt+1
|
||||||
|
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
|
MAN
|
||||||
|
SAVE /A2OSX.SRC/LIB/LIBPAK.S.LZ
|
||||||
|
ASM
|
91
LIB/LIBPAK.S.OUT.txt
Normal file
91
LIB/LIBPAK.S.OUT.txt
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
NEW
|
||||||
|
PREFIX /A2OSX.BUILD
|
||||||
|
AUTO 4,1
|
||||||
|
.LIST OFF
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.Out.Init lda #$80
|
||||||
|
sta Pak.Out.Mask
|
||||||
|
stz Pak.Out.Byte
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.Out.Close bit Pak.Out.Mask
|
||||||
|
bmi .8
|
||||||
|
lda Pak.Out.Byte
|
||||||
|
jmp Pak.Out.PutByte
|
||||||
|
.8 clc
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.Out.PutCA jsr Pak.Out.PutBitC
|
||||||
|
bcs Pak.Out.Put.rts
|
||||||
|
|
||||||
|
Pak.Out.PutA ldy #8
|
||||||
|
|
||||||
|
.1 asl
|
||||||
|
jsr Pak.Out.PutBitC
|
||||||
|
bcs Pak.Out.Put.rts
|
||||||
|
dey
|
||||||
|
bne .1
|
||||||
|
|
||||||
|
Pak.Out.Put.rts rts
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.Out.PutBitC pha
|
||||||
|
|
||||||
|
bcc .1
|
||||||
|
lda Pak.Mask
|
||||||
|
tsb Pak.Byte
|
||||||
|
clc
|
||||||
|
|
||||||
|
.1 lsr Pak.Mask
|
||||||
|
bne .8
|
||||||
|
|
||||||
|
jsr Pak.Out.PutByte
|
||||||
|
bcs .9
|
||||||
|
|
||||||
|
jsr Pak.Out.Init
|
||||||
|
|
||||||
|
.8 pla
|
||||||
|
* clc
|
||||||
|
rts
|
||||||
|
|
||||||
|
.9 pla
|
||||||
|
* sec
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
|
Pak.Out.PutByte inc Pak.DstCnt
|
||||||
|
bne .1
|
||||||
|
inc Pak.DstCnt+1
|
||||||
|
beq .9
|
||||||
|
|
||||||
|
.1 ldx Pak.Pass
|
||||||
|
bne .6
|
||||||
|
|
||||||
|
phx
|
||||||
|
tax
|
||||||
|
|
||||||
|
inc Pak.CntL,x
|
||||||
|
bne .2
|
||||||
|
|
||||||
|
inc Pak.CntH,x
|
||||||
|
|
||||||
|
.2 plx
|
||||||
|
bra .7
|
||||||
|
|
||||||
|
.6 sta (ZPDstPtr)
|
||||||
|
|
||||||
|
inc ZPDstPtr
|
||||||
|
bne .2
|
||||||
|
inc ZPDstPtr+1
|
||||||
|
|
||||||
|
.7 inc Pak.Stat+S.PAKSTAT.PASS1,x
|
||||||
|
bne .8
|
||||||
|
inc Pak.Stat+S.PAKSTAT.PASS1+1,x
|
||||||
|
|
||||||
|
.8 clc
|
||||||
|
rts
|
||||||
|
|
||||||
|
.9 sec
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
|
MAN
|
||||||
|
SAVE /A2OSX.SRC/LIB/LIBPAK.S.OUT
|
||||||
|
ASM
|
145
LIB/LIBPAK.S.txt
145
LIB/LIBPAK.S.txt
|
@ -5,41 +5,14 @@ AUTO 4,1
|
||||||
.OP 65C02
|
.OP 65C02
|
||||||
.OR $2000
|
.OR $2000
|
||||||
.TF /A2OSX.BUILD/LIB/LIBPAK.O
|
.TF /A2OSX.BUILD/LIB/LIBPAK.O
|
||||||
*--------------------------------------
|
|
||||||
* BITSTREAM :
|
|
||||||
*--------------------------------------
|
|
||||||
* 0 : SHORT3 (1)+3=4 bits
|
|
||||||
* 3 bits : index in Short3 Table
|
|
||||||
*--------------------------------------
|
|
||||||
* 10 : SHORT4 (2)+4=6 bits
|
|
||||||
* 4 bits : index in Short4 Table
|
|
||||||
*--------------------------------------
|
|
||||||
* 110 : REPn (3)+5=8 bits
|
|
||||||
* 5 bits count (1+n)
|
|
||||||
*--------------------------------------
|
|
||||||
* 1110 = BACKLINK : (4)+12+8=24 bits
|
|
||||||
* 12 bits : Offset (HI-4,LO-8)
|
|
||||||
* 8 bits : 4 + n (8 bits count) (259 max)
|
|
||||||
*--------------------------------------
|
|
||||||
* 1111 : STOREn (4) + 4 cnt + 8n....
|
|
||||||
*--------------------------------------
|
|
||||||
PAK.B.SHORT3 .EQ %00000000 0xxx0000
|
|
||||||
PAK.B.SHORT4 .EQ %10000000 10xxxx00
|
|
||||||
PAK.B.REPn .EQ %11000000 110xxxxx
|
|
||||||
PAK.B.BACKLINK .EQ %11100000 1110hhhhllllllllxxxxxxxx
|
|
||||||
PAK.B.STOREn .EQ %11110000 1111xxxx ...
|
|
||||||
*--------------------------------------
|
|
||||||
WSIZE .EQ 4096
|
|
||||||
REPMAX .EQ 32
|
|
||||||
STOREMAX .EQ 16
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
.INB /A2OSX.BUILD/INC/MACROS.I
|
.INB /A2OSX.BUILD/INC/MACROS.I
|
||||||
.INB /A2OSX.BUILD/INC/A2OSX.I
|
.INB /A2OSX.BUILD/INC/A2OSX.I
|
||||||
.INB /A2OSX.BUILD/INC/LIBPAK.I
|
.INB /A2OSX.BUILD/INC/LIBPAK.I
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
ZPSrcWPtr .EQ ZPLIB
|
ZPSrcPtr .EQ ZPLIB
|
||||||
ZPSrcPtr .EQ ZPLIB+2
|
ZPSrcWPtr .EQ ZPLIB+2
|
||||||
|
ZPCnt .EQ ZPLIB+4
|
||||||
ZPHdrPtr .EQ ZPLIB+14
|
ZPHdrPtr .EQ ZPLIB+14
|
||||||
ZPDstPtr .EQ ZPLIB+16
|
ZPDstPtr .EQ ZPLIB+16
|
||||||
ZPStatPtr .EQ ZPLIB+18
|
ZPStatPtr .EQ ZPLIB+18
|
||||||
|
@ -499,68 +472,24 @@ Pak.Flush ldx Pak.StoreCnt
|
||||||
ldx #0
|
ldx #0
|
||||||
|
|
||||||
.1 lda Pak.StoreBuf,x
|
.1 lda Pak.StoreBuf,x
|
||||||
ldy #4
|
sta Pak.LastByte update last byte for REP
|
||||||
|
ldy #8
|
||||||
jsr Pak.PutYBits
|
jsr Pak.PutYBits
|
||||||
bcs .9
|
bcs .9
|
||||||
inx
|
|
||||||
|
inc Pak.Stat+S.PAKSTAT.STORE
|
||||||
|
bne .2
|
||||||
|
inc Pak.Stat+S.PAKSTAT.STORE+1
|
||||||
|
|
||||||
|
.2 inx
|
||||||
dec Pak.StoreCnt
|
dec Pak.StoreCnt
|
||||||
bne .1
|
bne .1
|
||||||
|
|
||||||
ldx #S.PAKSTAT.STORE
|
stz Pak.RepCnt Don't forget to set last byte valid
|
||||||
jsr Pak.UpdateStats
|
|
||||||
|
|
||||||
.8 clc
|
.8 clc
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
* Pak.PutBit (bit in C)
|
|
||||||
*--------------------------------------
|
|
||||||
Pak.PutBit pha
|
|
||||||
|
|
||||||
bcc .1
|
|
||||||
lda Pak.Mask
|
|
||||||
tsb Pak.Byte
|
|
||||||
clc
|
|
||||||
|
|
||||||
.1 lsr Pak.Mask
|
|
||||||
bne .8
|
|
||||||
|
|
||||||
jsr Pak.PutByte
|
|
||||||
bcs .9
|
|
||||||
|
|
||||||
stz Pak.Byte
|
|
||||||
lda #$80
|
|
||||||
|
|
||||||
sta Pak.Mask
|
|
||||||
|
|
||||||
.8 pla
|
|
||||||
* clc
|
|
||||||
rts
|
|
||||||
|
|
||||||
.9 pla
|
|
||||||
* sec
|
|
||||||
rts
|
|
||||||
*--------------------------------------
|
|
||||||
Pak.PutByte inc Pak.DstCnt
|
|
||||||
bne .1
|
|
||||||
inc Pak.DstCnt+1
|
|
||||||
beq .9
|
|
||||||
|
|
||||||
.1 sta (ZPDstPtr)
|
|
||||||
|
|
||||||
inc ZPDstPtr
|
|
||||||
bne .2
|
|
||||||
inc ZPDstPtr+1
|
|
||||||
|
|
||||||
.2 inc Pak.Stat+S.PAKSTAT.PASS2
|
|
||||||
bne .8
|
|
||||||
inc Pak.Stat+S.PAKSTAT.PASS2+1
|
|
||||||
|
|
||||||
.8 clc
|
|
||||||
rts
|
|
||||||
|
|
||||||
.9 sec
|
|
||||||
rts
|
|
||||||
*--------------------------------------
|
|
||||||
Pak.UpdateStats inc Pak.Stat,x
|
Pak.UpdateStats inc Pak.Stat,x
|
||||||
bne .8
|
bne .8
|
||||||
inc Pak.Stat+1,x
|
inc Pak.Stat+1,x
|
||||||
|
@ -684,45 +613,6 @@ UnPak >PULLA Get Dst PTR LO
|
||||||
bne .9
|
bne .9
|
||||||
jmp .1
|
jmp .1
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
UnPak.Get8Bits ldy #8
|
|
||||||
.HS 2C bit abs
|
|
||||||
UnPak.Get4Bits ldy #4
|
|
||||||
lda #0 make sure to reset A before reading less than 8 bits only
|
|
||||||
.1 jsr UnPak.GetBit and to exit with CC if even if 8 bits read
|
|
||||||
rol
|
|
||||||
dey
|
|
||||||
bne .1
|
|
||||||
rts always CC
|
|
||||||
*--------------------------------------
|
|
||||||
UnPak.GetBit ldx #$ff Self Modified code
|
|
||||||
bne .1
|
|
||||||
jsr UnPak.NxtByte
|
|
||||||
|
|
||||||
ldx #8
|
|
||||||
|
|
||||||
.1 dex
|
|
||||||
stx UnPak.GetBit+1
|
|
||||||
|
|
||||||
pha Don't trash A
|
|
||||||
lda (UnZPSrcPtr)
|
|
||||||
and UnPak.BitMask,x
|
|
||||||
cmp #1 if 0:CC, i>0 CS
|
|
||||||
|
|
||||||
pla
|
|
||||||
rts Bit is in C
|
|
||||||
*--------------------------------------
|
|
||||||
UnPak.GetByte lda (UnZPSrcPtr)
|
|
||||||
UnPak.NxtByte inc UnZPSrcPtr
|
|
||||||
bne .8
|
|
||||||
inc UnZPSrcPtr+1
|
|
||||||
.8 rts
|
|
||||||
*--------------------------------------
|
|
||||||
UnPak.PutByte inc UnZPDstPtr
|
|
||||||
bne .8
|
|
||||||
inc UnZPDstPtr+1
|
|
||||||
.8 sta (UnZPDstPtr)
|
|
||||||
rts
|
|
||||||
*--------------------------------------
|
|
||||||
CS.END
|
CS.END
|
||||||
Pak.SrcPtr .BS 2
|
Pak.SrcPtr .BS 2
|
||||||
Pak.SrcCnt .BS 2
|
Pak.SrcCnt .BS 2
|
||||||
|
@ -734,8 +624,6 @@ Pak.LastByte .BS 1
|
||||||
Pak.StoreCnt .BS 1
|
Pak.StoreCnt .BS 1
|
||||||
Pak.StoreBuf .BS STOREMAX
|
Pak.StoreBuf .BS STOREMAX
|
||||||
|
|
||||||
Pak.Mask .BS 1
|
|
||||||
Pak.Byte .BS 1
|
|
||||||
|
|
||||||
Pak.Cnt .BS 2
|
Pak.Cnt .BS 2
|
||||||
|
|
||||||
|
@ -747,6 +635,13 @@ Pak.BestBL .BS 2
|
||||||
Pak.WPtr .BS 2
|
Pak.WPtr .BS 2
|
||||||
Pak.WLimit .BS 2
|
Pak.WLimit .BS 2
|
||||||
Pak.WStrLen .BS 1
|
Pak.WStrLen .BS 1
|
||||||
|
|
||||||
|
Pak.In.Byte .BS 1
|
||||||
|
Pak.In.Mask .BS 1
|
||||||
|
|
||||||
|
Pak.Out.Byte .BS 1
|
||||||
|
Pak.Out.Mask .BS 1
|
||||||
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
Pak.CntL .BS 256
|
Pak.CntL .BS 256
|
||||||
Pak.CntH .BS 256
|
Pak.CntH .BS 256
|
||||||
|
|
Loading…
Reference in New Issue
Block a user