__smallc __naked function with asm - which regs need to be preserved?
Posted: Sun Apr 18, 2021 8:35 pm
I think I am using the new compiler, my command line is this:
zcc +cpm -I.. -DPORT_CPM -clib=sdcc_iy -create-app ..\main.c -otest.com
I have a function that get's a character from CP/M:
uint8_t C_RAWIO() __smallc __naked
{
__asm
push ix
ld c,6 //bdos function 0x06
ld e,0xff //bdos parameter return character without echoing
call 5 //call bdos
ld l,a //copy result a into l for return
pop ix
ret
__endasm;
}
It works, but when I wrote this I probably just made it work.
I found these:
https://github.com/z88dk/z88dk/wiki/CallingConventions
https://github.com/z88dk/z88dk/wiki/The-Stack-Frame
But are they relevant for the compiler I am using? I don't think it is the old one.
I'm not sure why I am pushing/popping ix here.
Which registers do I need to preserve? Which ones do I not?
Are there any that need to be saved before a CP/M call?
zcc +cpm -I.. -DPORT_CPM -clib=sdcc_iy -create-app ..\main.c -otest.com
I have a function that get's a character from CP/M:
uint8_t C_RAWIO() __smallc __naked
{
__asm
push ix
ld c,6 //bdos function 0x06
ld e,0xff //bdos parameter return character without echoing
call 5 //call bdos
ld l,a //copy result a into l for return
pop ix
ret
__endasm;
}
It works, but when I wrote this I probably just made it work.
I found these:
https://github.com/z88dk/z88dk/wiki/CallingConventions
https://github.com/z88dk/z88dk/wiki/The-Stack-Frame
But are they relevant for the compiler I am using? I don't think it is the old one.
I'm not sure why I am pushing/popping ix here.
Which registers do I need to preserve? Which ones do I not?
Are there any that need to be saved before a CP/M call?