Skip to content

Commit

Permalink
BRZ bigint 허용
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Apr 5, 2024
1 parent adefff2 commit 2dc6764
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aheui/aheui.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ def mainloop(program, debug):
elif op == c.OP_JMP:
jump = True
elif op == c.OP_BRZ:
jump = 0 == selected.pop_longlong()
top = selected.pop()
jump = bigint.is_zero(top)
else:
assert False
if jump:
Expand Down
5 changes: 5 additions & 0 deletions aheui/int/bigint.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ def mod(r1, r2):
@jit.elidable
def ge(r1, r2):
return r1.ge(r2)


@jit.elidable
def is_zero(r):
return r.sign == 0
10 changes: 10 additions & 0 deletions aheui/int/smallint.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
try:
import builtins
except ImportError:
builtins = __builtins__


Int = int


Expand Down Expand Up @@ -43,3 +49,7 @@ def mod(r1, r2):

def ge(r1, r2):
return r1 >= r2


def is_zero(r):
return r == 0

0 comments on commit 2dc6764

Please sign in to comment.