A2osX/BIN/TEST.S.txt
2015-11-22 23:30:06 +01:00

191 lines
3.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/BIN/TEST
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/LIBSTR.I
*--------------------------------------
* 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 Code Length To Relocate
.DA 0
.DA 0
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.EVENT
.DA CS.QUIT
L.LIBSTR .DA LIBSTR
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG2 .DA MSG2
L.MSG3 .DA MSG3
L.SSCANF.IP .DA SSCANF.IP
L.PRINTF.IP .DA PRINTF.IP
L.DST.IP .DA DST.IP
L.TEST1 .DA TEST1
L.TEST2 .DA TEST2
L.TEST3 .DA TEST3
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBSTR
>SYSCALL SYS.LoadLibYA
sta hLIBSTR
ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>PUSHW L.MSG0
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.PS.hCS
lda (pPs),y
>SYSCALL SYS.GetMemByIDA
>STYA ZPQuickPtr1
ldy #S.MEM.BIN
lda (ZPQuickPtr1),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>PUSHW L.MSG1
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.PS.hARGS
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
ldy #S.PS.hCMD
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>PUSHW L.MSG2
>LIBCALL hLIBSTR,LIBSTR.PRINTF
ldy #S.PS.hENV
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPBIN
.1 lda (ZPBIN)
beq .2
>PUSHW ZPBIN
>PUSHW L.MSG3
>LIBCALL hLIBSTR,LIBSTR.PRINTF
lda (ZPBIN)
sec
adc ZPBIN
sta ZPBIN
bcc .1
inc ZPBIN+1
bra .1
.2 >PUSHW L.DST.IP
>PUSHW L.SSCANF.IP
>PUSHW L.TEST1
>LIBCALL hLIBSTR,LIBSTR.SSCANF
>PUSHB DST.IP+3
>PUSHB DST.IP+2
>PUSHB DST.IP+1
>PUSHB DST.IP
>PUSHW L.PRINTF.IP
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>PUSHW L.DST.IP
>PUSHW L.SSCANF.IP
>PUSHW L.TEST2
>LIBCALL hLIBSTR,LIBSTR.SSCANF
>PUSHB DST.IP+3
>PUSHB DST.IP+2
>PUSHB DST.IP+1
>PUSHB DST.IP
>PUSHW L.PRINTF.IP
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>PUSHW L.DST.IP
>PUSHW L.SSCANF.IP
>PUSHW L.TEST3
>LIBCALL hLIBSTR,LIBSTR.SSCANF
>PUSHB DST.IP+3
>PUSHB DST.IP+2
>PUSHB DST.IP+1
>PUSHB DST.IP
>PUSHW L.PRINTF.IP
>LIBCALL hLIBSTR,LIBSTR.PRINTF
lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
*--------------------------------------
CS.RUN
CS.EVENT clc
rts
*--------------------------------------
CS.QUIT lda hLIBSTR
>SYSCALL SYS.FreeMemA
clc
rts
*--------------------------------------
PRBYTE pha
lsr
lsr
lsr
lsr
ora #$B0
cmp #$BA
bcc .1
adc #6
.1 jsr COUT
pla
PRHEX and #$0F
ora #$B0
cmp #$BA
bcc COUT
adc #6
bra COUT
*--------------------------------------
CROUT lda #13
*--------------------------------------
COUT phx
phy
ldx #DEVMGR.COUT
jsr pDevJmp
ply
plx
rts
*--------------------------------------
CS.END
hLIBSTR .BS 1
LIBSTR >PSTRING "libstr.o"
MSG0 >CSTRING "PREFIX=%S\n"
MSG1 >CSTRING "BIN={%S}\n"
MSG2 >CSTRING "CMD={%S},ARGS={%S}\nENV:\n"
MSG3 >CSTRING " %S\n"
TEST1 >PSTRING "198.168.1.1"
TEST2 >PSTRING "198.168.1.23"
TEST3 >PSTRING "198.168.1.4"
SSCANF.IP >PSTRING "%d.%d.%d.%d"
PRINTF.IP >CSTRING "IP=%d.%d.%d.%d\n"
DST.IP .BS 4
*--------------------------------------
MAN
SAVE BIN/TEST.S
ASM