This commit is contained in:
Gvidas Juknevičius 2024-05-27 02:42:04 +03:00
parent 999883d2b6
commit 43b2030e2d
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
2 changed files with 9 additions and 9 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
target/
*.s
*.s
*.o

View File

@ -11,23 +11,22 @@ pub fn compile_x86_64_nasm(_asm_gen: &mut AsmGen, tokens: Vec<Token>, bw: &mut B
writeln!(bw, "BITS 64")?;
writeln!(bw, "section .bss")?;
writeln!(bw, " memory resb 30000")?;
writeln!(bw, " memory_ptr resb 1")?;
writeln!(bw, " memory: resb 30000")?;
writeln!(bw, " mem_ptr: resq 1")?;
writeln!(bw, "section .data")?;
writeln!(bw, " input db 0")?;
// writeln!(bw, "section .data")?;
// writeln!(bw, " input db 0")?;
writeln!(bw, "section .text")?;
writeln!(bw, "_start:")?;
writeln!(bw, " mov rdi, memory")?;
writeln!(bw, " mov [memory_ptr], rdi")?;
for t in tokens {
match t.typ {
TokenType::Add => {
writeln!(bw, " inc byte [rdi]")?;
writeln!(bw, " mov rax, memory")?;
writeln!(bw, " add rax, [mem_ptr]")?;
writeln!(bw, " inc byte [rax]")?;
}
ut => todo!("{ut:?}")