02-24-2010, 11:49 PM
Boriel, did you notice this one?
Even with the latest stack fixed version, I'm not understanding well how to do standard function calls with parameters. Where do I find my parameters? On the stack, sure...
When I do
I can get the computer to stop, and have a look at the stack.
It seems to consist of:
nn
nn ; something
nn
nn ; return address
a
44h
b
44h
What is that other 16 bit value on the stack? How should I be handling parameters? StdCall isn't documented in the wiki (and I documented fastcall, through reverse engineering!)
It also means that if I pop my 8 bit value off the stack with POP BC - the 8 bit parameter ends up in B! ?
I'm worried because following the template in the asm library:
For this routine at least, left me in the rom, at the halt fall point, with interrupts disabled! A crash.
In order to get it to work, and put one parameter in A, and the other in DE, it looks like I have to do
Four pops and a push, and some register futzing; which doesn't seem to be ideally fast!
Even with the latest stack fixed version, I'm not understanding well how to do standard function calls with parameters. Where do I find my parameters? On the stack, sure...
When I do
Code:
function thing (a as uByte, b as uByte)
asm
DI
HALT
end asm
end function
It seems to consist of:
nn
nn ; something
nn
nn ; return address
a
44h
b
44h
What is that other 16 bit value on the stack? How should I be handling parameters? StdCall isn't documented in the wiki (and I documented fastcall, through reverse engineering!)
It also means that if I pop my 8 bit value off the stack with POP BC - the 8 bit parameter ends up in B! ?
I'm worried because following the template in the asm library:
Code:
Function test(a as uByte, b as uByte) as uInteger
asm
POP HL ; return address
ex (sp),hl ; get operand
For this routine at least, left me in the rom, at the halt fall point, with interrupts disabled! A crash.
In order to get it to work, and put one parameter in A, and the other in DE, it looks like I have to do
Code:
POP BC ; something
POP HL ; return address
POP BC ; A
LD A,B
POP BC ; b
LD D,0
LD E,B
PUSH HL ; put return address back