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
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.TF /A2OSX.BOOT/BIN/MEM
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
|
|
|
|
.INB INC/LIBSTR.I
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
PAGELEN .EQ 22
|
2015-09-13 20:35:07 +00:00
|
|
|
|
FOOTERLEN .EQ 8
|
2015-06-03 18:30:57 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:47:37 +00:00
|
|
|
|
ZPPTR1 .EQ ZPBIN
|
|
|
|
|
ZPPTR2 .EQ ZPBIN+2
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* File Header (16 Bytes)
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA CS.END-CS.START Code Length To Relocate
|
|
|
|
|
.DA DS.END-DS.START Data Segment to Allocate
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:47:37 +00:00
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.LIBSTR .DA LIBSTR
|
|
|
|
|
L.MSG0 .DA MSG0
|
|
|
|
|
L.MSG1 .DA MSG1
|
|
|
|
|
L.MSG2 .DA MSG2
|
|
|
|
|
L.MSG3 .DA MSG3
|
|
|
|
|
L.MSG4 .DA MSG4
|
|
|
|
|
L.MSG5 .DA MSG5
|
|
|
|
|
L.MSG6 .DA MSG6
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
CS.INIT >LDYA L.LIBSTR
|
2015-11-22 22:30:06 +00:00
|
|
|
|
>SYSCALL SYS.LoadLibYA
|
2015-03-14 21:47:37 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
sta hLIBSTR
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda #0
|
|
|
|
|
ldy #DS.END-DS.START-1
|
|
|
|
|
|
|
|
|
|
.1 sta (pData),y
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
ldy #MEM.COUNT Skip SLOT0
|
|
|
|
|
lda (pData),y
|
|
|
|
|
inc
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
lda (pPs)
|
2015-03-14 21:47:37 +00:00
|
|
|
|
ora #S.PS.F.EVENT Now accept events
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (pPs)
|
2015-03-14 21:47:37 +00:00
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
CS.RUN ldy #bCANCEL
|
|
|
|
|
lda (pData),y
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
ldy #bSTOP
|
|
|
|
|
lda (pData),y
|
2015-03-14 21:47:37 +00:00
|
|
|
|
bne .8
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-09-13 20:35:07 +00:00
|
|
|
|
ldy #MEM.COUNT
|
|
|
|
|
lda (pData),y
|
|
|
|
|
cmp MemMgr.LastSlot
|
|
|
|
|
beq .10
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
ldy #LINE.COUNT
|
|
|
|
|
lda (pData),y
|
2015-03-14 21:47:37 +00:00
|
|
|
|
bne .1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
>PUSHW L.MSG0
|
|
|
|
|
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.1 ldy #MEM.COUNT
|
|
|
|
|
lda (pData),y
|
2015-03-14 21:47:37 +00:00
|
|
|
|
>SYSCALL SYS.GetMemByIDA
|
|
|
|
|
>STYA ZPPTR1
|
|
|
|
|
lda (ZPPTR1)
|
|
|
|
|
bpl .2
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
ldy #USED.COUNT
|
|
|
|
|
lda (pData),y
|
|
|
|
|
inc
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
.2 jsr CS.RUN.PRINTMEM
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
ldy #MEM.COUNT
|
|
|
|
|
lda (pData),y
|
|
|
|
|
inc
|
|
|
|
|
sta (pData),y
|
2015-09-13 20:35:07 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.8 clc
|
2015-03-14 21:47:37 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2015-09-13 20:35:07 +00:00
|
|
|
|
.9 sec
|
2015-06-03 18:30:57 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2015-09-13 20:35:07 +00:00
|
|
|
|
.10 ldy #LINE.COUNT
|
|
|
|
|
lda (pData),y
|
|
|
|
|
clc
|
|
|
|
|
adc #FOOTERLEN
|
|
|
|
|
cmp #PAGELEN
|
|
|
|
|
bcc .11
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
lda #$FF
|
|
|
|
|
ldy #bSTOP
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
lda #0
|
2015-09-13 20:35:07 +00:00
|
|
|
|
ldy #LINE.COUNT
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
clc
|
2015-03-14 21:47:37 +00:00
|
|
|
|
rts
|
2015-09-13 20:35:07 +00:00
|
|
|
|
|
|
|
|
|
.11 ldy #MEM.COUNT
|
|
|
|
|
>PUSHB (pData),y
|
|
|
|
|
ldy #USED.COUNT
|
|
|
|
|
>PUSHB (pData),y
|
|
|
|
|
>PUSHW L.MSG2
|
|
|
|
|
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
|
|
|
|
|
|
|
|
|
>PUSHW MemMgr.HiMem
|
|
|
|
|
>PUSHW L.MSG3
|
|
|
|
|
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
|
|
|
|
|
|
|
|
|
>PUSHW MemMgr.Free
|
|
|
|
|
>PUSHW L.MSG4
|
|
|
|
|
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
|
|
|
|
|
|
|
|
|
>PUSHW MemMgr.LoMem
|
|
|
|
|
>PUSHW L.MSG5
|
|
|
|
|
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
|
|
|
|
|
|
|
|
|
lda MemMgr.Free
|
|
|
|
|
sec
|
|
|
|
|
sbc MemMgr.LoMem
|
|
|
|
|
tay
|
|
|
|
|
lda MemMgr.Free+1
|
|
|
|
|
sbc MemMgr.LoMem+1
|
|
|
|
|
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHW L.MSG6
|
|
|
|
|
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.PRINTMEM ldy #S.MEM.LEN
|
|
|
|
|
lda (ZPPTR1),y
|
|
|
|
|
pha
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPTR1),y
|
|
|
|
|
ply
|
|
|
|
|
>PUSHYA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
ldy #S.MEM.PTR
|
|
|
|
|
lda (ZPPTR1),y
|
|
|
|
|
pha
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPTR1),y
|
|
|
|
|
ply
|
|
|
|
|
>PUSHYA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
ldy #S.MEM.REFCNT
|
|
|
|
|
lda (ZPPTR1),y
|
|
|
|
|
>PUSHA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
ldy #S.MEM.OWNERPID
|
|
|
|
|
lda (ZPPTR1),y
|
|
|
|
|
>PUSHA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
lda (ZPPTR1)
|
|
|
|
|
>PUSHA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
ldy #MEM.COUNT
|
|
|
|
|
lda (pData),y
|
2015-03-14 21:47:37 +00:00
|
|
|
|
>PUSHA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
>PUSHW L.MSG1
|
|
|
|
|
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
ldy #S.MEM.BIN
|
|
|
|
|
lda (ZPPTR1),y
|
|
|
|
|
bne .3
|
|
|
|
|
|
|
|
|
|
ldy #S.MEM.PTR
|
|
|
|
|
lda (ZPPTR1),y
|
|
|
|
|
sta ZPPTR2
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPTR1),y
|
|
|
|
|
sta ZPPTR2+1
|
|
|
|
|
lda #"{"
|
2015-12-10 18:53:30 +00:00
|
|
|
|
>SYSCALL SYS.COutA
|
2015-03-14 21:47:37 +00:00
|
|
|
|
lda (ZPPTR2)
|
2015-12-10 18:53:30 +00:00
|
|
|
|
>SYSCALL SYS.HexOutA
|
2015-03-14 21:47:37 +00:00
|
|
|
|
lda #"|"
|
2015-12-10 18:53:30 +00:00
|
|
|
|
>SYSCALL SYS.COutA
|
2015-03-14 21:47:37 +00:00
|
|
|
|
ldy #1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
.1 lda (ZPPTR2),y
|
2015-12-10 18:53:30 +00:00
|
|
|
|
cmp #$20
|
2015-03-14 21:47:37 +00:00
|
|
|
|
bcs .2
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
ora #$20
|
2015-12-10 18:53:30 +00:00
|
|
|
|
.2 >SYSCALL SYS.COutA
|
2015-03-14 21:47:37 +00:00
|
|
|
|
iny
|
|
|
|
|
cpy #40
|
|
|
|
|
bne .1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
lda #"}"
|
2015-12-10 18:53:30 +00:00
|
|
|
|
>SYSCALL SYS.COutA
|
2015-03-14 21:47:37 +00:00
|
|
|
|
bra .4
|
|
|
|
|
|
|
|
|
|
.3 >SYSCALL SYS.GetMemPtrA
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>LIBCALL hLIBSTR,LIBSTR.PRINTP
|
|
|
|
|
|
2015-12-10 18:53:30 +00:00
|
|
|
|
.4 lda #13
|
|
|
|
|
>SYSCALL SYS.COutA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
ldy #LINE.COUNT
|
|
|
|
|
lda (pData),y
|
|
|
|
|
inc
|
|
|
|
|
sta (pData),y
|
|
|
|
|
cmp #PAGELEN
|
2015-03-14 21:47:37 +00:00
|
|
|
|
bne .5
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
lda #$FF
|
2015-06-03 18:30:57 +00:00
|
|
|
|
ldy #bSTOP
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
ldy #LINE.COUNT
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
.5 rts
|
|
|
|
|
*--------------------------------------
|
2015-09-13 20:35:07 +00:00
|
|
|
|
CS.DOEVENT ldy #S.EVT.hDEV is Event from active IN device?
|
|
|
|
|
lda (pEvent),y
|
|
|
|
|
ldy #S.PS.hINDEV
|
|
|
|
|
cmp (pPs),y
|
|
|
|
|
bne .9
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2015-09-13 20:35:07 +00:00
|
|
|
|
lda (pEvent)
|
|
|
|
|
and #S.EVT.F.KEY is it a KEY event?
|
|
|
|
|
beq .9
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2015-09-13 20:35:07 +00:00
|
|
|
|
ldy #S.EVT.DATAHI is it an O or SAPPLE key ?
|
|
|
|
|
lda (pEvent),y
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
ldy #S.EVT.DATALO
|
|
|
|
|
lda (pEvent),y
|
|
|
|
|
cmp #$03 Ctrl-C
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
lda #$FF
|
|
|
|
|
ldy #bCANCEL
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bra .8
|
|
|
|
|
|
|
|
|
|
.1 cmp #$13 Ctrl-S
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
ldy #bSTOP
|
|
|
|
|
lda (pData),y
|
|
|
|
|
eor #$FF
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bra .8
|
|
|
|
|
|
|
|
|
|
.2 ldy #bSTOP
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.QUIT lda hLIBSTR
|
|
|
|
|
>SYSCALL SYS.UnloadLibA
|
|
|
|
|
clc
|
2015-03-14 21:47:37 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
2015-06-03 18:30:57 +00:00
|
|
|
|
LIBSTR >PSTRING "libstr.o"
|
|
|
|
|
MSG0 >CSTRING "hMem Flags PID REF PTR LEN BINPATH/DATA\n"
|
2016-02-21 20:45:32 +00:00
|
|
|
|
MSG1 >CSTRING " %03d %b %03d %03d $%H %05D "
|
2015-06-03 18:30:57 +00:00
|
|
|
|
MSG2 >CSTRING "\nAllocated hMem:%d, Total:%d\n"
|
|
|
|
|
MSG3 >CSTRING "High Memory: $%H\n"
|
|
|
|
|
MSG4 >CSTRING "Free ULimit: $%H\n"
|
|
|
|
|
MSG5 >CSTRING "Low Memory: $%H\n"
|
|
|
|
|
MSG6 >CSTRING "\nFree Memory: %D Bytes.\n"
|
2015-03-14 21:47:37 +00:00
|
|
|
|
hLIBSTR .BS 1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
2015-03-14 21:47:37 +00:00
|
|
|
|
LINE.COUNT .BS 1
|
|
|
|
|
MEM.COUNT .BS 1
|
|
|
|
|
USED.COUNT .BS 1
|
|
|
|
|
bSTOP .BS 1
|
|
|
|
|
bCANCEL .BS 1
|
|
|
|
|
DS.END
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.ED
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE BIN/MEM.S
|
|
|
|
|
ASM
|