diff --git a/include/hucc/hucc-baselib.asm b/include/hucc/hucc-baselib.asm index 94b879bc..328ed5e8 100644 --- a/include/hucc/hucc-baselib.asm +++ b/include/hucc/hucc-baselib.asm @@ -127,10 +127,13 @@ _peekw.1 .macro ; *************************************************************************** ; *************************************************************************** ; -; void __fastcall __macro __xsafe poke( unsigned int addr<__ptr>, unsigned char with ); +; void __fastcall __macro __xsafe poke( unsigned int addr<__poke>, unsigned char with ); +; +; N.B. Because the value can be a complex C calculation, it isn't safe +; to use __ptr as the destination, which can be overwritten in C macros. _poke.2 .macro - sta [__ptr] + sta [__poke] .endm @@ -138,13 +141,16 @@ _poke.2 .macro ; *************************************************************************** ; *************************************************************************** ; -; void __fastcall __macro __xsafe pokew( unsigned int addr<__ptr>, unsigned int with ); +; void __fastcall __macro __xsafe pokew( unsigned int addr<__poke>, unsigned int with ); +; +; N.B. Because the value can be a complex C calculation, it isn't safe +; to use __ptr as the destination, which can be overwritten in C macros. _pokew.2 .macro - sta [__ptr] + sta [__poke] tya ldy #1 - sta [__ptr], y + sta [__poke], y .endm diff --git a/include/hucc/hucc-baselib.h b/include/hucc/hucc-baselib.h index 4b976658..258c9c9c 100644 --- a/include/hucc/hucc-baselib.h +++ b/include/hucc/hucc-baselib.h @@ -82,8 +82,8 @@ extern unsigned char __fastcall __xsafe __macro ac_exists( void ); extern unsigned int __fastcall __xsafe __macro peek( unsigned int addr<__ptr> ); extern unsigned int __fastcall __xsafe __macro peekw( unsigned int addr<__ptr> ); -extern void __fastcall __xsafe __macro poke( unsigned int addr<__ptr>, unsigned char with ); -extern void __fastcall __xsafe __macro pokew( unsigned int addr<__ptr>, unsigned int with ); +extern void __fastcall __xsafe __macro poke( unsigned int addr<__poke>, unsigned char with ); +extern void __fastcall __xsafe __macro pokew( unsigned int addr<__poke>, unsigned int with ); extern unsigned int __fastcall __xsafe __farpeekw( void __far *addr<__fbank:__fptr> ); diff --git a/include/hucc/hucc.asm b/include/hucc/hucc.asm index b71e6136..b11e07e3 100644 --- a/include/hucc/hucc.asm +++ b/include/hucc/hucc.asm @@ -125,6 +125,7 @@ __fbank .ds 1 __sp .ds 1 __stack .ds HUCC_STACK_SZ __ptr .ds 2 +__poke .ds 2 ; Data pointer used by SDCC for indirect indexed memory access