What I'm trying to do in Brass is have a large variable that's created using .var and try to relocate a routine that needs to be in RAM into it. I'm trying to take the idea of allocating memory to variables and apply it to entire RAM routines. The code I have in attempts to do this is as follows:
Code:
Note: The code above was designed to test the idea.
Note: Brass didn't like that I used _PutS alone. Doing "noname._PutS" fixed that. The "jr $" is there so I can figure out what's going on.
When I do "call offPageCall", PC correctly jumps to one of the possible locations I have defined, which happens to be $9A01 in this instance. This tells me that OPC_END and OPC_START are correct, and are copying the information to RAM correctly. But here's the problem. "STR" resolves to a value as though .relocate was a .org 0
Here's output from Wabbitemu's debugger:
Code:
After that stretch of code is the string "HELLO WORLD"
I can't figure out how to work around this problem without having to define a definite address for the routine to reside. Any thoughts?
Code:
.var 66,offPageCall
.module ROMCALL
InitDevMem:
ld hl,OPC_START
ld de,offPageCall
ld bc,OPC_END-OPC_START
ldir
;other routines
ret
OPC_START:
.relocate offPageCall
jr $
ld hl,0
ld (currow),hl
ld hl,STR
bcall(noname._PutS)
ret
STR:
.db "HELLO WORLD",0
.endrelocate
OPC_END:
.endmodule
Note: The code above was designed to test the idea.
Note: Brass didn't like that I used _PutS alone. Doing "noname._PutS" fixed that. The "jr $" is there so I can figure out what's going on.
When I do "call offPageCall", PC correctly jumps to one of the possible locations I have defined, which happens to be $9A01 in this instance. This tells me that OPC_END and OPC_START are correct, and are copying the information to RAM correctly. But here's the problem. "STR" resolves to a value as though .relocate was a .org 0
Here's output from Wabbitemu's debugger:
Code:
9A01:18fe: jr $9A01 ;2 bytes 12 clocks
9A03:210000: ld hl,$00 ;3 bytes 10 clocks
9A06:224b84: ld ($844B),hl ;3 bytes 16 clocks
9A09:210f00: ld hl,$0F ;3 bytes 10 clocks
9A0C:ef0a45: bcall(_PutS) ;3 bytes
9A0F:c9: ret ;1 bytes 10 clocks
After that stretch of code is the string "HELLO WORLD"
I can't figure out how to work around this problem without having to define a definite address for the routine to reside. Any thoughts?