I'm currently trying to avoid the pointer arithmetic workings in C to write an emulator.
Usually, if you add 1
to a pointer in C, you add the size of the pointed to object instead. However, I am trying to work with bits and bytes, so this is undesired.
I was wondering if I was using too many parentheses in this example:
*(int16_t *)(((intptr_t)bc)+sp)
And if not, then is it equivalent to this? :
*(int16_t *)((intptr_t)bc+sp)
sp
is a page-aligned stack address for my emulator (obtained via. mmap
without MAP_FIXED
set). It is an intptr_t
type.
bc
is the name of an int16_t *
type. It's a pointer to a combination of two int8_t
's.