|
Post by stiggity on Oct 3, 2020 21:54:25 GMT
I've been working on a module load/linker in asm, and im sort of stumped. I store the filename in (a$), and while watching the program run, i see the LOADING"FILENAME" kernal message appear. Its a few lines of code (which is all intermingled into this new routine I dreamt-up.), first in basic (I know this isn't a BASIC forum.. ;/ ) my first line of the main body of code that remains in memory the entire duration the program runs does "fast:bank15:open5,2,0,chr$(6):a=peek(47)+256*peek(48):a=a-2:poke3670,(a and 255):poke3671,a/256"
i wrote that, and its assigning low/hi bytes for the module loading routine's parameters...
LOB = 3670 HIB = 3671 moddrv = 4009
is there some other BASIC i should use to accomplish this? I load a file from line 0 to 59999 and all of the modules are _numbered_ starting at 60000.
Heres a snippet of what I have already written..
mdload LDA $2F
STA $BB
LDA $30
STA $BC
Oq LDY #$00
jsr fetch1
CMP #65
BNE O2q
INY
jsr fetch1
CMP #128
BEQ O3q
O2q CLC
LDA $BB
ADC #$07
STA $BB
LDA $BC
ADC #$00
STA $BC
JMP Oq
O3q INY
JSR fetch1
sta mdlen ;start1 + 1 ;strlen
INY
JSR fetch1 ;strptr low
sta $bb
sta vrlow
INY
JSR fetch1 ;strptr hi
STA $BC
sta vrhi
LDA #1
LDX MODDRV
LDY #1
Jsr $FFBA ;SETLFS
LDA MDLEN
LDX VRLOW
LDY VRHI
Jsr $FFBD ;SETNAM
LDA #1
ldx #0
jsr $ff68 ;SETBANK
LDA #0
LDX lob
LDY hib
Jmp $FFD5 ;load
[code] fetch1 LDA #$BB ;ZP pointer to use LDX #1 ;bank index 1 JMP $FF74 ;kernal
rt code here[/code]
anyone have an explanation with how im approaching this?
-Thanks
|
|
|
Post by stiggity on Oct 4, 2020 3:48:06 GMT
load1 LDA $2F STA $BB LDA $30 STA $BC Oq LDY #$00 jsr fetch1 CMP #65 BNE O2q INY jsr fetch1 CMP #128 BEQ O3q O2q CLC LDA $BB ADC #$07 STA $BB LDA $BC ADC #$00 STA $BC JMP Oq
O3q INY JSR fetch1 STA mdlen ;start1 + 1 ;strlen INY JSR fetch1 ;strptr lo pha INY JSR fetch1 ;strptr hi STA $BC sta NAMhi pla sta $bb sta NAMlo
lda #$01 ; file# ldx moddrv ; SETLFS ldy #1 ; secondary address (0=relocatable, 1=absolute) jsr $ffbA ; set logical file parameters
lda mdlen ; length of filename ldx NAMlo ldy NAMhi jsr $ffbd ; SETNAME
lda #0 ; data in bank 1 ldx #1 ; filename in bank 0 jsr $ff68 ; SETBANK
lda #0 ; 0=load, <>0=verify LDX lob LDY hib jSR $ffd5 ; LOAD jmp $4F4F
fetch1 LDA #$BB ;ZP pointer to use LDX #1 ;bank index 1 JMP $FF74 ;kernal
lob = $0e56 ;3670 hib = $0e57 ;3671
NAMLO .BYTE 0 NAMHI .BYTE 0 MDLEN .BYTE 0
THIS "_loads_" something, but after a list the retrieved code is missing. Below is a better way to setup hi/low byte fior end of basic prg.
a=peek(4624)+256*peek(3625):a=a-2:poke3670,(a and 255):poke3671,a/256 +
|
|
|
Post by stiggity on Oct 4, 2020 3:49:53 GMT
a=peek(4624)+256*peek(4625):a=a-2:poke3670,(a and 255):poke3671,a/256
|
|
|
Post by bjonte on Oct 4, 2020 4:52:00 GMT
It looks like you are loading the data to the end of basic program - 2, which seems correct but I don’t know what you are doing in the beginning of the program. This 4f4f jump, does that relink the BASIC line pointers?
Have you checked in the monitor after the load that the data is in the right place and that the line pointers are relinked?
|
|
|
Post by stiggity on Oct 4, 2020 13:33:19 GMT
bjonte: Ive compiled 10x and have simply "list60000-" to see if the loaded module was imported. I will bring up the monitor and look deeper. In the beginning of the program, im finding the contents of (a$(filename)) i call this from BASIC.. a$="filename": then call this routine. Im setting the SETNAM correct. I'm not certain if im setting the correct BANK, or SETLFS is right. And yes, $4F4F links the basic lines.
|
|
|
Post by stiggity on Oct 4, 2020 13:54:37 GMT
there's data beginning from the start address of the called load, but i'm not sure if it's garbage or actually the BASIC module I attempted to load....Any sort of help is greatly appreciated.
|
|
|
Post by stiggity on Oct 4, 2020 13:58:46 GMT
I think my error may be im LOADing (a$) with a ,8,1 instead of ,8 where would I edit the routine to just load with ,8 (in ASM) instead of ,8,1
|
|
|
Post by stiggity on Oct 4, 2020 19:23:31 GMT
that wasnt it. loading a basic module from basic with a ,dv,1 gives the same result as ,dv I've been messing with this for an hour now. If i play with the BANK values, it doesnt detect the variables name, just a LOAD"garage".. honestly, i don't know whats wrong? I'd REALLY appreciate some guidance...
|
|
|
Post by bjonte on Oct 4, 2020 20:04:28 GMT
Load the module normally and check the contents in the monitor so you can compare it later when you load the module at the end of the current program. The first two bytes in each line should differ due to relinking but the rest should be identical.
|
|
|
Post by stiggity on Oct 4, 2020 20:18:17 GMT
going out on a whim... wheres the start of basic on the 128? bank15 im using during this load.. srry, im aweful using a monitor.... mebbe like "m 5590 55b0"
|
|