Login
Back to forumSee the full topicGo to last reply

Posted By

JamesD
on 2017-12-13
01:45:52
 Re: Does the Plus/4 support some form of VARPTR() command?

Actually, I had something else in mind.

I'd have stub routines call a piece of code that patches the ROM like that.
The stubs would do something like this:
LDA #address ; load A with address normally used by LDA (address),Y
JMP PATCHER ; call the patcher


And the patcher would do something like this, but itprobably needs work as I've been using a lot of Motorola assembly lately. If the code is only called from a handful of places, it's overkill. But if it's called all over the place, it would be the fastest way to patch everything.

STA #temp ; save page zero address to use
LDY #0 ; zero y
PLA ; get LSB of return address
SBC #3 ; subtract 3 (point to address of JSR)
STA RETURNADDRESS ; store it in our own page 0 pointer
PLA ; get MSB of return address
BCC NEXT ; deal with carry from MSB
DEC
NEXT:
PHA ; restore it onto the stack
STA RETURNADDRESS+1 ; save it in our pointer
LDA #OPCODE4LDA(),Y ; load the opcode we want to patch with
STA (RETURNADDRESS),Y ; patch BASIC
INY ; next address
LDA TEMP ; get the address that was passed to us
STA (RETURNADDRESS),Y ; patch BASIC
INY ; next address
LDA #OPCODE4NOP ; NOP to finish the patch
STA (RETURNADDRESS),Y ; patch it
LDA RETURNADDRESS ; get LSB of JSR
PHA ; push it to the stack
RTS ; call the patched code



Back to top


Copyright © Plus/4 World Team, 2001-2024