Hi,
Код:
void cursor(char x, char y){
__asm
ld hl, #2
add hl, sp
ld a, #2
call 5633
ld b, (hl)
inc hl
inc hl
ld c, (hl)
....
You're sure "call 5633" does not modify HL?
sdcc pushes characters as single bytes onto the stack. So it should be "ld b,(hl); inc hl; ld c,(hl)"
Another problem has to do with the IY register.
1. If you have the rom interrupt routine at 0x38 running, your program cannot modify IY.
2. If you use rom subroutines to carry out tasks like printing, IY must be set to the value expected by the rom.
To prevent sdcc from modifying IY you must compile with the "--reserve-regs-iy" flag. However this will not stop sdcc from using IY if the stack frame becomes large.
The best way on the zx to get around this problem is to disable interrupts or replace the rom isr and make sure IY is set to the expected value before you make rom calls that depend on it. If you don't do this you will experience odd crashes.
[свернуть]