0x0584/corewar

use signed values instead of unsigned

Closed this issue · 1 comments

use signed values instead of unsigned

the program counter t_pc, can be shifted by an integer offset, and the result is always mod MEM_SIZE

  • the arithmetic modulo operator % is not mathematical mod; by which the circular memory is achieved
    • as -64 mod 255 is -64
    • while -64 % 255 == 192
  • if the operation is long_op the offset is truncated by mod IDX_MOD before setting the PC
  • if PC is negative same as indexing the memory of opposite size