diff --git a/build.rs b/build.rs deleted file mode 100644 index 613fb5c..0000000 --- a/build.rs +++ /dev/null @@ -1,8 +0,0 @@ -use std::fs; -use std::path::PathBuf; - -fn main() { - if PathBuf::from("types.toml").is_file() { - fs::remove_file(PathBuf::from("types.toml")).unwrap(); - } -} \ No newline at end of file diff --git a/build/out.asm b/build/out.asm index c69b3e7..d770531 100644 --- a/build/out.asm +++ b/build/out.asm @@ -5,17 +5,34 @@ section .text main: push rbp mov rbp, rsp - mov qword [rbp-8], 0 - mov qword [rbp-16], 1 - mov rax, qword [rbp-16] - mov qword [rbp-40], rax - mov rax, qword [rbp-8] - mov qword [rbp-48], rax - sub rsp, 48 + mov dword [rbp-8], 0xb7891800 + mov dword [rbp-4], 0xffffffe8 + mov rdi, __4_fstr + mov rsi, [rbp-8] + mov al, 0 + sub rsp, 8 + extern printf + call printf + add rsp, 8 + mov dword [rbp-16], 0x00000002 + mov dword [rbp-12], 0x00000000 + mov rax, 60 + mov rdi, [rbp-16] + syscall + mov dword [rbp-24], 0x00000000 + mov dword [rbp-20], 0x00000000 + mov dword [rbp-32], 0x00000001 + mov dword [rbp-28], 0x00000000 + mov rax, qword [rbp-32] + mov qword [rbp-56], rax + mov rax, qword [rbp-24] + mov qword [rbp-64], rax + sub rsp, 64 call _1 - add rsp, 48 - mov qword [rbp-40], 1 - mov rax, qword [rbp-40] + add rsp, 64 + mov dword [rbp-56], 0x00000001 + mov dword [rbp-52], 0x00000000 + mov rax, qword [rbp-56] leave ret @@ -23,7 +40,7 @@ main: _1: push rbp mov rbp, rsp - mov rax, qword [rbp+16] + mov rax, qword [rbp+24] mov qword [rbp-8], rax mov rdi, __4_fstr mov rsi, [rbp-8] @@ -34,7 +51,8 @@ _1: add rsp, 8 mov rax, qword [rbp+16] mov qword [rbp-17], rax - mov qword [rbp-25], 233 + mov dword [rbp-25], 0x01709e79 + mov dword [rbp-21], 0x00000000 mov rax, qword [rbp-17] cmp rax, qword [rbp-25] jz __5_0 @@ -45,7 +63,8 @@ _1: __5_1: cmp byte [rbp-9], 0 jz _1_2 - mov qword [rbp-33], 10 + mov dword [rbp-33], 0x0000000a + mov dword [rbp-29], 0x00000000 mov rax, 60 mov rdi, [rbp-33] syscall @@ -73,4 +92,4 @@ _1: section .data_readonly - __4_fstr db `Integer: %d\n`,0 \ No newline at end of file + __4_fstr db `Integer: %ld\n`,0 \ No newline at end of file diff --git a/build/out.o b/build/out.o index 8b84e4f..95124a7 100644 Binary files a/build/out.o and b/build/out.o differ diff --git a/build/out.out b/build/out.out index f93f857..3d34949 100755 Binary files a/build/out.out and b/build/out.out differ diff --git a/main.why b/main.why index 79c2045..492e901 100644 --- a/main.why +++ b/main.why @@ -1,7 +1,7 @@ fn fib(a: int, b: int) { - printi(a); + printi(b); - if (a == 233) { + if (a == 24157817) { exit(10); } @@ -12,7 +12,11 @@ fn fib(a: int, b: int) { } fn main() -> int { + printi(-100000000000); + exit(2); + fib(0, 1); + return 1; } diff --git a/src/root/builtin/types/bool/printb.rs b/src/root/builtin/types/bool/printb.rs index c195478..ccbebcc 100644 --- a/src/root/builtin/types/bool/printb.rs +++ b/src/root/builtin/types/bool/printb.rs @@ -39,7 +39,7 @@ impl BuiltinInlineFunction for PrintB { |args: &[LocalAddress], _, gt, sz| -> String { let id = format!("{}_fstr", Self::id().string_id()); - let data = format!("{id} db `Boolean: %d\\n`,0"); + let data = format!("{id} db `Boolean: %ld\\n`,0"); gt.add_readonly_data(&id, &data); diff --git a/src/root/builtin/types/int/mod.rs b/src/root/builtin/types/int/mod.rs index 5b142cb..ab0cef6 100644 --- a/src/root/builtin/types/int/mod.rs +++ b/src/root/builtin/types/int/mod.rs @@ -4,6 +4,7 @@ mod p_sub; mod printi; mod eq; +use std::fmt::format; use b_box::b; use unique_type_id::UniqueTypeId; use crate::root::builtin::t_id; @@ -59,7 +60,9 @@ impl Type for IntType { } } LiteralTokens::Int(value) => { - format!(" mov qword {location}, {value}\n") + let full_hex = format!("{:016x}", value); + format!(" mov dword {location}, 0x{} + mov dword {}, 0x{}\n", &full_hex[8..], *location + LocalAddress(4), &full_hex[..8]) } }) } diff --git a/src/root/builtin/types/int/printi.rs b/src/root/builtin/types/int/printi.rs index 45cb4fc..6c87709 100644 --- a/src/root/builtin/types/int/printi.rs +++ b/src/root/builtin/types/int/printi.rs @@ -38,7 +38,7 @@ impl BuiltinInlineFunction for PrintI { |args: &[LocalAddress], _, gt, sz| -> String { let id = format!("{}_fstr", Self::id().string_id()); - let data = format!("{id} db `Integer: %d\\n`,0"); + let data = format!("{id} db `Integer: %ld\\n`,0"); gt.add_readonly_data(&id, &data);