Skip to content

Fix assembler.py #2555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Assembler/assembler.py
Original file line number Diff line number Diff line change
@@ -996,10 +996,13 @@ def parser():
if token.token in variables:
token.token = variables[token.token]
else:
print("Error: undefine variable! --> " + token.token)
print(f"Error: Undefined variable {token.token}")
return

elif token.t == "string":
pass

token.token = str(token.token)

elif isinstance(token.token, float):
pass
elif token.token.isdigit():
@@ -1161,7 +1164,7 @@ def parser():
zeroFlag = False
elif tmpToken.token == "ebx":
ebx -= token.token

# update zero flag
if ebx == 0:
zeroFlag = True
@@ -1249,6 +1252,9 @@ def parser():
# pop register from stack
match token.token:
case "eax":
if len(stack) == 0:
print("Error: Stack Underflow")
return
eax = stack.pop()
case "ebx":
ebx = stack.pop()
@@ -1454,6 +1460,9 @@ def parser():
eax /= eax

case "ebx":
if ebx == 0:
print("Error: Division by Zero")
return
eax /= ebx

case "ecx":