I know there're knowledgeable guys here, please help solving an issue... There're call vectors (hooks) in Fxxx area in RAM, and I want to set it to call my own code in some slot. Vector occupies 5 bytes enough to hold rst30 and ret. But it will call ROM, which in its turn will need to call next subs in the chain. But to call next sub, ROM should have saved previous call pointer somewhere.
The question is - where to save it? Is there any valid / approved way for ROMs to do that?
Saving that data "somewhere in RAM" is a bad workaround as it can be overwritten by user/another system call and machine may crash...
use the stack pointer i think this is the approved method.You can use a command to increase the stack and set it larger than what it is.
Oh great idea thank you Leo and Nikodr. How will it look like technically?
Eugeny do you want to create a rom program that would run from cartridge ? Do you need to have active ram in slot 0 ?Do you use a custom interrupt handler in that routine?
I need machine to run some code from ROM through hooking and then go further the subroutine chain. As I understand I only can use c000-ffff RAM segment in order to ensure it works in most configurations.
konamiman uses slot work area , this may help :
look for the section :
----- copy paste from konamiman site : example of rom unapi ethernet ----------
;--- Initialize EXTBIO hook if necessary
ld (hl),#C9 ;code for RET
;--- Save previous EXTBIO hook
;--- Patch EXTBIO hook
ld a,#F7 ;code for "RST #30"
;>>> UNAPI initialization finished, now perform
; other ROM initialization tasks.
I need to hook to the entry point permanently, and not temporarily.
When ROM is started, it should "install" its subroutine into the chain and every time in the future this hook/entry point is called, this subroutine should be activated. Location of this subroutine is fixed - in ROM, while it is not clear for me how to implement calling further down the chain - I need machine to "memorize" old hook pointer in order for ROM to call it.
I can not do it in any register, and obviously can not do it in ROM. Thus I need to do is somehwere in RAM. Thus I am looking if there's any place in RAM which can be reliably used for such purposes. Using stack... a good idea, but it is not clear for me how to "install" data into the stack and not to corrupt "ret" and "pop" sequence.
Is it more clear now?
yes yes , sorry i was editing my previous at the same time , yes my question was that i didnt understand but now it is clearer
so the correct answer is more : slot working area .
SLTWRK (FD09H, 128)
contents: allocates specific work area for each slot
but is there specific layout? Is it protected from modifications from other ROMs/applications?
Don't you have an account yet? Become an MSX-friend and register an account!
MSX NOBUNAGA NO YABO Sengoku Gunyuden MSX2 Japan Ga ...
MSX ROM" Dwarf "GPM-132 CASIO JAPAN SOFT ...
MSX DOOR DOOR mk II Cartridge only Import Japan Vi ...
MSX2 SONY HB-F1 XD Console System HIT BIT Home Comp ...