I wonder whether there is a bug in the machine implementation (or maybe I am confusing something).
- the instruction pointer points to (absolute) offsets, i.e. for next() and prev() it is increased by sizeof(int32_t). Since it is a pointer of type int32, the pointer is internally increased by sizeof(int32_t) * sizeof(int32_t).
- memory is allocated by memory(new int32_t[memsize]), but memsize itself is initialized as memsize(10001024sizeof(int32_t)),
Therefore I think you are using sizeof(int32_t) more memory than actually required. I think there are two ways to resolve this:
- a) decrease memory size and access memory contents by
memory[ip/4]
- b) decrease memory size and access memory contents by manual computation of the offset of the allocated memory
unsigned int* offset = (unsigned int*) ((unsigned char *) memory + ip);
I wonder whether there is a bug in the machine implementation (or maybe I am confusing something).
Therefore I think you are using sizeof(int32_t) more memory than actually required. I think there are two ways to resolve this:
memory[ip/4]unsigned int* offset = (unsigned int*) ((unsigned char *) memory + ip);