Skip to content

Commit

Permalink
generate hello world
Browse files Browse the repository at this point in the history
  • Loading branch information
ibx34 committed Dec 25, 2024
1 parent 1d64aca commit f10e938
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ def __init__(
self, input: list[AstirExpr], symbol_tables: dict[int, SymbolTable]
) -> None:
super().__init__(input)
self.lines: list[str] = [".global _start", ".p2align 3"]
self.lines: list[str] = [
".global _start",
".p2align 3",
'helloworld: .ascii "Hello World!"',
]
self.symbol_tables: dict[int, SymbolTable] = symbol_tables
# All tables related to registers most likely
# have keys that map to a Symbol's id.
Expand Down
3 changes: 3 additions & 0 deletions ast_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ def parse(self, tag=None) -> AstirExpr | None:
if current is None or current.ty == TT.CLOSE_SQUARE:
self.advance()
break
elif current.ty == TT.COMMA:
self.advance()
continue
parsed = self.parse()
if parsed is None:
self.at -= 1
Expand Down
4 changes: 3 additions & 1 deletion boot.dal
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

//take_int_and_add_2\ x int, y int :: int → x + y

_start\ :: int → asm ["bl print_hello_world"]
asm ["print_hello_world: mov X0, #1", "adr X1, helloworld", "mov X2, #13", "mov X16, #4", "svc 0", "ret"]

_start\ :: int → asm ["bl print_hello_world", "mov X0, #0", "mov X16, #1", "svc 0"]

0 comments on commit f10e938

Please sign in to comment.