This commit is contained in:
xomf 2024-05-26 19:34:17 -04:00
parent 8906315af7
commit 999883d2b6

View File

@ -1,6 +1,7 @@
use std::{fs::File, io::{BufWriter, Write}};
use std::{any::Any, fs::File, io::{BufWriter, Write}};
use anyhow::Result;
use bfox_parser::types::token::Token;
use bfox_parser::types::token::TokenType;
use crate::AsmGen;
@ -8,11 +9,30 @@ use crate::AsmGen;
pub fn compile_x86_64_nasm(_asm_gen: &mut AsmGen, tokens: Vec<Token>, bw: &mut BufWriter<File>) -> Result<()>{
writeln!(bw, "BITS 64")?;
writeln!(bw, "section .bss")?;
writeln!(bw, " memory resb 30000")?;
writeln!(bw, " memory_ptr resb 1")?;
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 {
log::debug!("{t:?}");
match t.typ {
TokenType::Add => {
writeln!(bw, " inc byte [rdi]")?;
}
ut => todo!("{ut:?}")
}
}
// Exit