2015-03-14 21:47:37 +00:00
|
|
|
|
PR#3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
PREFIX /A2OSX.SRC
|
2015-03-14 21:47:37 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
|
|
|
|
.TF BIN/TEST
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
|
|
|
|
.INB INC/LIBSTR.I
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Main entry point
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Code signature and INIT table
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* CLD $D8
|
|
|
|
|
* JMP (*,x) $7C
|
|
|
|
|
* #JMPTABLE
|
|
|
|
|
* /JMPTABLE
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
.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
|
|
|
|
|
.DA CS.END-CS.START Code Length To Relocate
|
|
|
|
|
.DA 0 Data Segment to Allocate
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.INIT >LIBLOADP L.LIBSTR
|
|
|
|
|
sta hLIBSTR
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hPREFIX
|
|
|
|
|
lda (pPsContext),y
|
|
|
|
|
>SYSCALL SYS.GetMemPtrA
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHW L.MSG0
|
|
|
|
|
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hCS
|
|
|
|
|
lda (pPsContext),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 (pPsContext),y
|
|
|
|
|
>SYSCALL SYS.GetMemPtrA
|
|
|
|
|
>PUSHYA
|
|
|
|
|
ldy #S.PS.hCMD
|
|
|
|
|
lda (pPsContext),y
|
|
|
|
|
>SYSCALL SYS.GetMemPtrA
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHW L.MSG2
|
|
|
|
|
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hENV
|
|
|
|
|
lda (pPsContext),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
|
|
|
|
|
>PUSHA
|
|
|
|
|
ldy #S.PS.hOUTDEV
|
|
|
|
|
lda (pPsContext),y
|
|
|
|
|
>SYSCALL SYS.DevOutA
|
|
|
|
|
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
|