Compare commits

...

1 Commits

Author SHA1 Message Date
SpookyDervish
0e37cccd7a fixing a couple bugs 2025-09-14 05:37:47 +10:00
4 changed files with 32 additions and 30 deletions

View File

@@ -189,7 +189,7 @@ class X86_64Generator(Generator):
elif type(new_value) == str: # we're changing a variable to the value of a register
#lines.append(f"mov QWORD [rsp + {var_pos}], {new_value}\n\t")
lines.append(f"mov {var_pos}, {new_value}\n\t")
scope.table[var_name]["type"] = IntNode
#scope.table[var_name]["type"] = IntNode
else:
@@ -227,7 +227,8 @@ class X86_64Generator(Generator):
elif type(new_value) == str: # we're changing a variable to the value of a register
lines.append(f"mov QWORD [rsp + {var_pos}], {new_value}\n\t")
scope.table[var_name]["type"] = IntNode
#scope.table[var_name]["type"] = IntNode
if scope.table[var_name]["type"] != old_var_type:
warning(self.code, f"Changing the type of \"{var_name}\" at runtime is considered bad practice.")
@@ -697,6 +698,7 @@ class X86_64Generator(Generator):
with open(self.output_path + ".asm", "w") as f:
f.write("; ~~~ Auto generated by the GroundPY compiler for Linux x86_64 targets. ~~~\n\n")
if len(self.constants) > 0:
f.write("section .data\n")
for name, const in self.constants.items():
value = const["value"]
@@ -718,6 +720,7 @@ class X86_64Generator(Generator):
f.write(f"dq {float(value)}")
f.write("\n")
if len(self.buffers) > 0:
f.write("section .bss\n")
for buf, size in self.buffers.items():
f.write(f"{buf} resb {size}\n")

BIN
out

Binary file not shown.

5
out.asm Normal file
View File

@@ -0,0 +1,5 @@
; ~~~ Auto generated by the GroundPY compiler for Linux x86_64 targets. ~~~
section .text
global _start
_start:

View File

@@ -1,6 +0,0 @@
@loop
stdout "/\r"
stdout "-\r"
stdout "\\r"
stdout "|\r"
jump %loop