I have a very strange one today and would like a little clarification before I start hacking z88dk output code.
As some might be aware I am currently prototyping a data-driven menu system for the +3e environment and I would like to optimise some of the simpler C code into ASM, I have achieved this with some functions, others I have had to... well mother would not approve.
So my question is this really -
Code: Select all
void asm_WriteByte( void *scr_ptr, unsigned char *byte)
{
*asmstore = *byte; // going to need to set this in a safe area
#asm
ld a,(50000) ; should be the *byte value
ld hl,4 ; 4 bytes on the stack
add hl,sp ; skip over the return address (Stack Pointer)
ld e,(hl)
inc hl
ld d,(hl) ; *scr_ptr
ex de,hl ; exchange registers
ld (hl),a ; put a byte into the screen file
ret
#endasm
}
The above works but I have had to move the value of the (char) Byte pointer into memory location 50000 - which to be honest could easily over-written later down the line with running data. I am wondering what fundamental knowledge I am missing to make this work properly.
I do so appreciate any insight or alternate method for doing things like this.
Thanks for reading.