A2osX/TEST.S.txt

454 lines
8.6 KiB
Plaintext
Raw Normal View History

NEW
2018-01-11 16:34:09 +00:00
PREFIX /A2OSX.BUILD
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
2018-07-23 15:28:42 +00:00
.TF ROOT/TEST
*--------------------------------------
2018-07-23 15:28:42 +00:00
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/LIBPAK.I
*--------------------------------------
2018-02-09 16:02:47 +00:00
ZPPakHdrPtr .EQ ZPBIN
ZPPakDataPtr .EQ ZPBIN+2
ZPPakSrcPtr .EQ ZPBIN+4
*--------------------------------------
UNPAK.Mask .EQ ZPBIN+8
UNPAK.LastByte .EQ ZPBIN+9
UNPAK.Cnt .EQ ZPBIN+10
UNPAK.Ofs .EQ ZPBIN+12
UNPAK.BLOfs .EQ ZPBIN+14
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #64 SS
2018-02-09 16:02:47 +00:00
.DA #16 ZP
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
2018-02-05 16:25:25 +00:00
L.LIBPAK .DA LIBPAK
L.FLOAT1 .DA FLOAT1
L.FLOAT2 .DA FLOAT2
L.FLOAT3 .DA FLOAT3
L.FLOAT4 .DA FLOAT4
L.FLOAT5 .DA FLOAT5
L.CONST1 .DA CONST1
L.CONST2 .DA CONST2
L.LONG1 .DA LONG1
2017-10-27 14:56:46 +00:00
L.MSG1 .DA MSG1
L.MSG2 .DA MSG2
L.MSG3 .DA MSG3
L.MSG4 .DA MSG4
L.MSG5 .DA MSG5
2018-02-05 16:25:25 +00:00
L.MSG6 .DA MSG6
2018-02-09 16:02:47 +00:00
L.MSG.UnpakErr .DA MSG.UnpakErr
L.MSG.DEBUG.S3 .DA MSG.DEBUG.S3
.DA 0
*--------------------------------------
2018-02-05 16:25:25 +00:00
CS.INIT >LDYA L.LIBPAK
2018-07-19 15:33:55 +00:00
>SYSCALL LoadLib
2018-02-05 16:25:25 +00:00
bcs .9
sta hLIBPAK
clc
.9 rts
*--------------------------------------
CS.RUN ldy #S.PS.ARGC
lda (pPs),y
bne CS.RUN.Pak
jmp CS.RUN.Math
*--------------------------------------
CS.RUN.Pak >PUSHWI 0 Aux type
>PUSHBI 0
>PUSHBI SYS.FOpen.R
lda #1
2018-07-18 15:30:42 +00:00
>SYSCALL GetArg
>SYSCALL RealPath
2018-02-05 16:25:25 +00:00
>PUSHYA
txa
>STA.G PAK.hFileName
>SYSCALL LoadFile
bcs .9
>STYA.G PAK.FileSize
txa
>STA.G PAK.hFileBuf
>LDYA.G PAK.FileSize
2018-07-20 11:51:08 +00:00
>SYSCALL getmem
2018-02-05 16:25:25 +00:00
bcs .9
2018-02-09 16:02:47 +00:00
>STYA ZPPakSrcPtr
2018-02-05 16:25:25 +00:00
txa
>STA.G PAK.hOutBuf
>LDA.G PAK.hFileBuf
2018-07-18 15:30:42 +00:00
>SYSCALL GetMemPtr
2018-02-05 16:25:25 +00:00
>PUSHYA
>PUSHW.G PAK.FileSize
>LDA.G PAK.hOutBuf
2018-07-18 15:30:42 +00:00
>SYSCALL GetMemPtr
2018-02-09 16:02:47 +00:00
>STYA ZPPakHdrPtr
2018-02-05 16:25:25 +00:00
>PUSHYA
>PUSHEA.G PAK.Stat
>LIBCALL hLIBPAK,LIBPAK.Pak
bcc .1
.9 rts
.1 >PUSHW.G PAK.Stat+S.PAKSTAT.STORE
>PUSHW.G PAK.Stat+S.PAKSTAT.S4
>PUSHW.G PAK.Stat+S.PAKSTAT.S3
>PUSHW.G PAK.Stat+S.PAKSTAT.REP
>PUSHW.G PAK.Stat+S.PAKSTAT.BL
2018-02-08 16:39:56 +00:00
>PUSHW.G PAK.Stat+S.PAKSTAT.PASS2
>PUSHW.G PAK.Stat+S.PAKSTAT.PASS1
2018-02-05 16:25:25 +00:00
>PUSHW.G PAK.FileSize
>LDYA L.MSG6
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2018-02-09 16:02:47 +00:00
*--------------------------------------
CS.RUN.Unpak lda ZPPakHdrPtr
clc
adc #S.PAKSTAT
sta ZPPakDataPtr
lda ZPPakHdrPtr+1
adc /S.PAKSTAT
sta ZPPakDataPtr+1
lda (ZPPakHdrPtr)
eor #$ff
sta UNPAK.Cnt
2018-02-05 16:25:25 +00:00
2018-02-09 16:02:47 +00:00
ldy #1
lda (ZPPakHdrPtr),y
eor #$ff
sta UNPAK.Cnt+1
lda #$80
sta UNPAK.Mask
>LDA.G PAK.hFileBuf
2018-07-18 15:30:42 +00:00
>SYSCALL GetMemPtr
2018-02-09 16:02:47 +00:00
>STYA ZPPakSrcPtr
stz UNPAK.Ofs
stz UNPAK.Ofs+1
.1 inc UNPAK.Cnt
bne .2
inc UNPAK.Cnt+1
bne .2
lda #0
sec
rts
.2 lda #'>'
2018-07-18 15:30:42 +00:00
>SYSCALL PutChar
2018-02-09 16:02:47 +00:00
jsr CS.RUN.UnpakGetBitInC
bcs .3
*--------------------------------------
* SHORT3
ldx #3
jsr CS.RUN.UnpakGetXBitInA
clc
adc #S.PAKHDR.SHORT3
tay
lda (ZPPakHdrPtr),y
sta UNPAK.LastByte
jsr DEBUG.S3
jsr CS.RUN.UnpakCmpA
bcs .9
bra .1
.3 jsr CS.RUN.UnpakGetBitInC
bcs .4
*--------------------------------------
* SHORT4
ldx #4
jsr CS.RUN.UnpakGetXBitInA
clc
adc #S.PAKHDR.SHORT4
tay
lda (ZPPakHdrPtr),y
sta UNPAK.LastByte
jsr CS.RUN.UnpakCmpA
bcs .9
bra .1
.4 jsr CS.RUN.UnpakGetBitInC
bcs .5
*--------------------------------------
* REPn
ldx #4
jsr CS.RUN.UnpakGetXBitInA
tay
tax
lda UNPAK.LastByte
.41 jsr CS.RUN.UnpakCmpA
bcs .9
dey
bne .41
.42 txa
clc
adc UNPAK.Cnt
sta UNPAK.Cnt
bcc .2
inc UNPAK.Cnt+1
bra .2
.5 jsr CS.RUN.UnpakGetBitInC
bcs .6
*--------------------------------------
* BACKLINK
ldx #4
jsr CS.RUN.UnpakGetXBitInA
sta UNPAK.BLOfs+1
jsr CS.RUN.UnpakGetByteInA
sta UNPAK.BLOfs
jsr CS.RUN.UnpakGetByteInA
tax
tay
.51
bra .42
*--------------------------------------
* STOREn
.6 ldx #4
jsr CS.RUN.UnpakGetXBitInA
tay
tax
.61 jsr CS.RUN.UnpakGetByteInA
dey
bne .61
sta UNPAK.LastByte
bra .42
.9 >PUSHW UNPAK.Ofs
>LDYA L.MSG.UnpakErr
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2018-02-09 16:02:47 +00:00
2018-02-05 16:25:25 +00:00
lda #0
sec
2018-02-09 16:02:47 +00:00
rts
*--------------------------------------
CS.RUN.UnpakGetByteInA
ldx #8
*--------------------------------------
CS.RUN.UnpakGetXBitInA
lda #0
.1 jsr CS.RUN.UnpakGetBitInC
rol
dex
bne .1
rts
*--------------------------------------
CS.RUN.UnpakGetBitInC
pha
clc
lda (ZPPakDataPtr)
and UNPAK.Mask
beq .1
sec
.1 php
lsr UNPAK.Mask
bne .8
lda #$80
sta UNPAK.Mask
inc ZPPakDataPtr
bne .8
inc ZPPakDataPtr+1
.8 plp
pla
rts
*--------------------------------------
CS.RUN.UnpakCmpA
cmp (ZPPakSrcPtr)
bne .9
inc ZPPakSrcPtr
bne .1
inc ZPPakSrcPtr+1
.1 inc UNPAK.Ofs
bne .8
inc UNPAK.Ofs+1
.8 clc
rts
.9 sec
rts
*--------------------------------------
DEBUG.S3 pha
phx
phy
>PUSHA
>LDYA L.MSG.DEBUG.S3
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2018-02-09 16:02:47 +00:00
ply
plx
pla
rts
*--------------------------------------
2018-02-05 16:25:25 +00:00
CS.RUN.Math >PUSHEA.G ENDPTR
>PUSHW L.CONST2
>PUSHEA.G MYFLOAT2
>SYSCALL StrToF
>PUSHEA.G ENDPTR
>PUSHW L.CONST1
>PUSHEA.G MYFLOAT1
>SYSCALL StrToF
2017-10-27 14:56:46 +00:00
>PUSHEA.G MYFLOAT2
>PUSHEA.G MYFLOAT1
>PUSHW L.FLOAT5
>PUSHW L.FLOAT4
>PUSHW L.FLOAT3
>PUSHW L.FLOAT2
>PUSHW L.FLOAT1
>LDYA L.MSG1
2018-06-21 15:12:10 +00:00
>SYSCALL printf
*--------------------------------------
2017-10-27 14:56:46 +00:00
>PUSHEA.G MYFLOAT1
>PUSHEA.G MYFLOAT2
>LEA.G MYFLOAT3
>SYSCALL FDiv
2017-10-27 14:56:46 +00:00
>PUSHEA.G MYFLOAT3
>LDYA L.MSG2
2018-06-21 15:12:10 +00:00
>SYSCALL printf
*--------------------------------------
>PUSHEA.G MYFLOAT3
>LEA.G MYFLOAT3
>SYSCALL Cos
>PUSHEA.G MYFLOAT3
>LDYA L.MSG3
2018-06-21 15:12:10 +00:00
>SYSCALL printf
*--------------------------------------
>PUSHW L.FLOAT1
>LEA.G MYLONG
>SYSCALL LRIntF
>PUSHEA.G MYLONG
>LDYA L.MSG4
2018-06-21 15:12:10 +00:00
>SYSCALL printf
*--------------------------------------
>PUSHW L.LONG1
>LEA.G MYFLOAT1
>SYSCALL Float
>PUSHEA.G MYFLOAT1
>LDYA L.MSG5
2018-06-21 15:12:10 +00:00
>SYSCALL printf
lda #0
sec
2017-10-27 14:56:46 +00:00
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
2018-02-05 16:25:25 +00:00
CS.QUIT >LDA.G PAK.hFileName
beq .1
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
2018-02-05 16:25:25 +00:00
.1 >LDA.G PAK.hFileBuf
beq .2
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
2018-02-05 16:25:25 +00:00
.2 >LDA.G PAK.hOutBuf
beq .8
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
2018-02-05 16:25:25 +00:00
.8 lda hLIBPAK
2018-07-20 14:10:10 +00:00
>SYSCALL UnloadLib
2018-02-05 16:25:25 +00:00
clc
rts
*--------------------------------------
CS.END
2018-02-05 16:25:25 +00:00
LIBPAK .AZ "libpak.o"
hLIBPAK .BS 1
MSG1 .AS "PrintF:%e, %e, %e\r\n"
.AS "%e, %e\r\n"
.AZ "StrToF:%e, %e\r\n"
FLOAT1 .HS 9B3EBC1FFD 99,999,999.9
FLOAT2 .HS 9E6E6B27FD 999,999,999
FLOAT3 .HS 9E6E6B2800 1,000,000,000
FLOAT4 .HS 8100000000 1
FLOAT5 .HS 9080000000 -32768
2018-02-01 07:16:35 +00:00
CONST1 .AZ "3.141592653"
CONST2 .AZ "3"
LONG1 .DA >123456789
2018-02-01 07:16:35 +00:00
MSG2 .AZ "PI/3=%e\r\n"
MSG3 .AZ "COS(PI/3)=%e\r\n"
MSG4 .AZ "Long=%L\r\n"
MSG5 .AZ "Float=%e\r\n"
2018-02-05 16:25:25 +00:00
MSG6 .AS "Src Length : %D\r\n"
2018-02-08 16:39:56 +00:00
.AS "Pass #1 : %D\r\n"
.AS "Pass #2 : %D\r\n"
2018-02-05 16:25:25 +00:00
.AS "BL Count : %D\r\n"
.AS "REP Count : %D\r\n"
.AS "S3 Count : %D\r\n"
.AS "S4 Count : %D\r\n"
.AZ "STO Count : %D\r\n"
2018-02-09 16:02:47 +00:00
MSG.UnpakErr .AZ "UnPak Error at Offset : %H\r\n"
MSG.DEBUG.S3 .AZ "S3:%h\r\n"
*--------------------------------------
.DUMMY
.OR 0
DS.START
MYFLOAT1 .BS 5
MYFLOAT2 .BS 5
2017-10-27 14:56:46 +00:00
MYFLOAT3 .BS 5
MYLONG .BS 4
ENDPTR .BS 2
2018-02-05 16:25:25 +00:00
PAK.hFileName .BS 1
PAK.FileSize .BS 2
PAK.hFileBuf .BS 1
PAK.hOutBuf .BS 1
PAK.Stat .BS S.PAKSTAT
DS.END
.ED
*--------------------------------------
MAN
2018-01-11 16:34:09 +00:00
SAVE /A2OSX.BUILD/ROOT/TEST.S
ASM