class Memory:
def __init__(self, size):
self.memory = bitarray([0]*size, endian='little')
def set_bool(self, addr, val):
self.memory[addr] = val
def get_bool(self, addr):
return self.memory[addr]
def set_i32(self, addr, val):
bitarr = int2ba(val, length=INT_SIZE, endian='little')
self.set_bitarray(addr, bitarr)
def get_i32(self, addr):
bitarr = self.memory[addr:addr + INT_SIZE]
val = ba2int(bitarr)
return val
Comments
Leave a comment