I am writing a Y86-64 (a simplified version of X86-64 from CSAPP by Bryant and O’Hallaron) implementation in Prolog. I would like to represent memory as a list of bytes. I am having trouble with this implementation though as, according to the General purpose arithmetic manual page, all integers in SWI Prolog are 64 bits.
Using 64 bit integers is problematic for multiple reasons. First off I am using 8 times more memory than I need to, and second it is unnatural to pretend that a 64 bit integer is actually a 8 bit integer, and part of my goal for this project is to code something that maps closely to how a computer really works.
One mention of bytes in the manual I found under Primitive character I/O, but this has to with streams which is not what I am looking for. I have tried to find the source of these predicates to see if I could figure out how the bytes were represented but there are no links to any source in the manual.
Another mention of bytes I have found in the manual is Predicate hex_bytes/2 from the crypto library. While this was promising the documentation states Bytes is a list of integers between 0 and 255 that represent the sequence as a list of bytes, which insinuates that this predicate is just pretending that the integers are 8 bits.
I have thought about using chars. However I cannot do arithmetic on chars easily. I could represent my memory as a list of chars, and then when I go to do arithmetic get the integer value with char_code/2. However this is clumsy.
I would appreciate help.