Megacd bios jumping
Moderator: Mask of Destiny
Megacd bios jumping
Hi its again me
In the process of implementing a "jump" log to GensKmod (not me, Kaneda), I wanted to know if there is a fixed ram area where appear the "current" function number.
I mean, each time the user jump to the bios, does the bios write the function number (d0) somewhere?
I vaguely remember the function number is written somewhere but i cannot recall where I read that.
If someone recall don't hesitate
Pfew... My english is more and more bad... I wonder what's happen.
Sorry.
In the process of implementing a "jump" log to GensKmod (not me, Kaneda), I wanted to know if there is a fixed ram area where appear the "current" function number.
I mean, each time the user jump to the bios, does the bios write the function number (d0) somewhere?
I vaguely remember the function number is written somewhere but i cannot recall where I read that.
If someone recall don't hesitate
Pfew... My english is more and more bad... I wonder what's happen.
Sorry.
all of this because Starcream allows hook on read/write memory but not program section
so I tried to mod i_jsr but Starscream is really hard to understand
I tried to add a call to my function but everything explode since x86 registers are lost with this call...
and I discovered sub68k_context.pc != sub68k_readPC( ), which I don't understand!
Stef, if you have any hint
so I tried to mod i_jsr but Starscream is really hard to understand
I tried to add a call to my function but everything explode since x86 registers are lost with this call...
and I discovered sub68k_context.pc != sub68k_readPC( ), which I don't understand!
Stef, if you have any hint
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
sub68k_context.pc contains "Fetch Region pointer + PC value" then you can directly do :
mov eax, [sub68k_context.pc]
to fetch/read the current intruction. This is done for speed reason of course. If you want the real PC value, use ReadPC or unbase pc : sub68k_context.pc - sub68k_context.basePC
I'm not sur about the sub68k_context.basePC variable name since i'm doing it from head :p
mov eax, [sub68k_context.pc]
to fetch/read the current intruction. This is done for speed reason of course. If you want the real PC value, use ReadPC or unbase pc : sub68k_context.pc - sub68k_context.basePC
I'm not sur about the sub68k_context.basePC variable name since i'm doing it from head :p
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
32X SH2 cores uses the same type of based PC.
Well, i just had a look in starscream source, here's register value at "alive" (in execution) time :
- esi = based pc
- ebp = fetch base
If you want only the pc value you have to do that :
mov eax, esi ; get based pc
sub eax, ebx ; unbase it --> eax = pc value
hope it helps you
Well, i just had a look in starscream source, here's register value at "alive" (in execution) time :
- esi = based pc
- ebp = fetch base
If you want only the pc value you have to do that :
mov eax, esi ; get based pc
sub eax, ebx ; unbase it --> eax = pc value
hope it helps you
so it means my PC value is wrong for a long time (on main 68k part)
thanks for the hint, and now understand better some stuff on Starscream (like the code below)
can you help me on this too
it's the code of the jsr + my call
this code is executed the first time but freeze Gens after that..
I suspect the call to the C function SpyCDBiosCall to mod the x86 register
can you confirm this and if yes, how can i backup reg/call/restore reg?
(movem ? push ?)
thanks for the hint, and now understand better some stuff on Starscream (like the code below)
can you help me on this too
Code: Select all
mov ecx,esi
sub ecx,ebp
mov esi,edx
call _SpyCDBiosCall
this code is executed the first time but freeze Gens after that..
I suspect the call to the C function SpyCDBiosCall to mod the x86 register
can you confirm this and if yes, how can i backup reg/call/restore reg?
(movem ? push ?)
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Seems your _SpyCDBiosCall is using fastcall convention (ecx and edx as parameters).KanedaFr wrote:so it means my PC value is wrong for a long time (on main 68k part)
thanks for the hint, and now understand better some stuff on Starscream (like the code below)
can you help me on this tooit's the code of the jsr + my callCode: Select all
mov ecx,esi sub ecx,ebp mov esi,edx call _SpyCDBiosCall
this code is executed the first time but freeze Gens after that..
I suspect the call to the C function SpyCDBiosCall to mod the x86 register
can you confirm this and if yes, how can i backup reg/call/restore reg?
(movem ? push ?)
I do understand you're putting PC in ecx, but what the "mov esi, edx" is supposed to do ? by doing that, you're just erasing the current pc...
Also when you do a function call, you lost your eax, ecx, edx registers values so push them if needed
the first 3 lines are the original 'jsr xxx' emulation stuff
I just add the call _Spy....
I found this
http://nasm.sourceforge.net/doc/html/na ... tion-8.1.2 but they talk about save.restore inside the callee function...
does it mean VC isn't making a clean function ?
and this http://www.delorie.com/djgpp/doc/ug/asm/calling.html
talk about
I just add the call _Spy....
I found this
http://nasm.sourceforge.net/doc/html/na ... tion-8.1.2 but they talk about save.restore inside the callee function...
does it mean VC isn't making a clean function ?
and this http://www.delorie.com/djgpp/doc/ug/asm/calling.html
talk about
Expect the registers %eax, %ecx, and %edx, as well as the floating-point stack, to have changed. Standard library functions may modify the %gs register, and the _far* functions may modify %fs. Other registers will be preserved.