fix
This commit is contained in:
parent
999883d2b6
commit
43b2030e2d
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
target/
|
target/
|
||||||
*.s
|
*.s
|
||||||
|
*.o
|
|
@ -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, "BITS 64")?;
|
||||||
|
|
||||||
writeln!(bw, "section .bss")?;
|
writeln!(bw, "section .bss")?;
|
||||||
writeln!(bw, " memory resb 30000")?;
|
writeln!(bw, " memory: resb 30000")?;
|
||||||
writeln!(bw, " memory_ptr resb 1")?;
|
writeln!(bw, " mem_ptr: resq 1")?;
|
||||||
|
|
||||||
writeln!(bw, "section .data")?;
|
// writeln!(bw, "section .data")?;
|
||||||
writeln!(bw, " input db 0")?;
|
// writeln!(bw, " input db 0")?;
|
||||||
|
|
||||||
writeln!(bw, "section .text")?;
|
writeln!(bw, "section .text")?;
|
||||||
writeln!(bw, "_start:")?;
|
writeln!(bw, "_start:")?;
|
||||||
|
|
||||||
writeln!(bw, " mov rdi, memory")?;
|
|
||||||
writeln!(bw, " mov [memory_ptr], rdi")?;
|
|
||||||
|
|
||||||
for t in tokens {
|
for t in tokens {
|
||||||
match t.typ {
|
match t.typ {
|
||||||
|
|
||||||
TokenType::Add => {
|
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:?}")
|
ut => todo!("{ut:?}")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user