Peek and poke (sequel)


#1

Hi Johnson ,

I have another question for you (I’m not an expert in C programming …

This was the code :

object *fn_peek (object *args, object env) {
(void) env;
int addr = integer(first(args));
return number(
(int *)addr);
}

object *fn_poke (object *args, object *env) {
(void) env;
int addr = integer(first(args));
object *val = second(args);
*(int *)addr = integer(val);
return val;

How could it be changed to peek and poke 16 bit data (address remains 32bit ofcourse)
I’ve noticed that on mkrzero many regs are 16 bit.
I could than add for example PEEKH and POKEH (H from halfword)
Thanks again !

Ronny Suy