:3
This commit is contained in:
parent
8906315af7
commit
999883d2b6
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user