Skip to content

Commit

Permalink
selftest: allocate twice the memory and place pointer in the middle
Browse files Browse the repository at this point in the history
This allows to access memory at negative offsets.
  • Loading branch information
mkannwischer committed Dec 16, 2024
1 parent 4ec2210 commit a173192
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions slothy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,8 +1362,10 @@ def run_code(code, txt=None):
for r in regs:
initial_register_contents[r] = int.from_bytes(os.urandom(16))
for (reg, sz) in address_registers.items():
initial_register_contents[reg] = cur_ram
cur_ram += sz
# allocate 2*sz and place pointer in the middle
# this makes sure that memory can be accessed at negative offsets
initial_register_contents[reg] = cur_ram + sz
cur_ram += 2*sz

final_regs_old, final_mem_old = run_code(codeA, txt="old")
final_regs_new, final_mem_new = run_code(codeB, txt="new")
Expand Down

0 comments on commit a173192

Please sign in to comment.