mirror of
https://github.com/nineties/planckforth
synced 2025-01-13 08:01:10 +01:00
Add aligned to python-impl
This commit is contained in:
parent
1b170522cb
commit
b49d6d85c6
1 changed files with 4 additions and 1 deletions
|
@ -17,6 +17,9 @@ rp = MEMORY_SIZE - STACK_SIZE
|
|||
ip = 0
|
||||
pc = 0
|
||||
|
||||
def aligned(n):
|
||||
return (n + CELL - 1) & ~(CELL - 1)
|
||||
|
||||
def read(addr):
|
||||
return int.from_bytes(
|
||||
memory[addr:addr+CELL], 'little', signed=True)
|
||||
|
@ -184,7 +187,7 @@ while True:
|
|||
elif code == LITSTRING:
|
||||
n = read(pc)
|
||||
push(pc + CELL)
|
||||
pc = (pc + 2*CELL + n - 1) & ~CELL
|
||||
pc = aligned(pc + CELL + n)
|
||||
elif code == ADD:
|
||||
b = pop()
|
||||
push(pop() + b)
|
||||
|
|
Loading…
Reference in a new issue