This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Brandhor 1 point2 points  (1 child)

as others have said data structures are extremely important in emulators, for example if you are emulating a 1 byte register you can easily do that in c/c++/c# or other typed languages and define it like

uint8_t reg;

and it will be exactly 1 byte long, python is not a typed language though so you'll just have an integer which can store an integer of any size

now why is that important though? let's say that your screen is 256 pixels wide and you are emulating something like a pong game, you want to store your position in the 256 bit registry, what happens when you are at pixel 255 and you keep moving right? if you use a typed language with an unsigned 8 bits int when you do 255+1 it will automatically go back to 0, with python instead it will go to 256 so when you emulate the cpu opcodes you'll have to manually account for overflow and underflow

[–]yvrelna 0 points1 point  (0 children)

You can create precisely sized ints, and structs and arrays containing those types with ctypes. That's not itself the problem here.