From 8c520577b6a1236df9374b4d4fe5dfdcde8941c6 Mon Sep 17 00:00:00 2001 From: Cassie Jones Date: Fri, 28 Feb 2020 21:20:23 +0100 Subject: [PATCH] Remove assembly experiments They were committed for posterity, but they've served their purpose now. --- docs/example.s | 111 ------------------------------------------------- 1 file changed, 111 deletions(-) delete mode 100644 docs/example.s diff --git a/docs/example.s b/docs/example.s deleted file mode 100644 index 517298b..0000000 --- a/docs/example.s +++ /dev/null @@ -1,111 +0,0 @@ -// clang -masm=intel -nostdlib docs/example.s -lSystem -Wl,-e,_start -g -o target/example - -SYS_OFFSET = 0x2000000 -#define SYS(X) (SYS_OFFSET + X) -SYS_EXIT = SYS(0x01) -SYS_WRITE = SYS(0x04) -SYS_MUNMAP = SYS(0x49) -SYS_MMAP = SYS(0xC5) - -PROT_READ = 0x1 -PROT_WRITE = 0x2 -MAP_ANONYMOUS = 0x1000 -MAP_SHARED = 0x1 -MAP_PRIVATE = 0x2 - -STDOUT = 1 -STDERR = 1 - -// args: RDI RSI RDX RCX R8 R9 - -.text -.global _start -_start: - // 16-byte align the stack - sub rsp, 16 - and spl, 0xf0 - - mov rdi, 413 - call ivy_alloc - mov rdi, rax - call _free - mov rdi, 0 - call _exit - - -ivy_alloc: - call _malloc - ret - -ivy_dealloc: - call _free - ret - - -ivy_check_int: - test rdi, 1 - jz ivy_check_ok - cmp qword ptr [rdi], 1 - jne ivy_check_int_fail - jmp ivy_check_ok -ivy_check_lam: - test rdi, 1 - jnz ivy_check_lam_fail - cmp qword ptr [rdi], 0 - jne ivy_check_lam_fail -ivy_check_ok: - ret -ivy_check_int_fail: - mov rsi, [rip + EXPECT_INT_ERROR] - mov rdx, [rip + EXPECT_INT_ERROR_LEN] - jmp ivy_abort -ivy_check_lam_fail: - mov rsi, [rip + EXPECT_LAM_ERROR] - mov rdx, [rip + EXPECT_LAM_ERROR_LEN] - jmp ivy_abort - - -EXPECT_INT_ERROR: .ascii "Error: typecheck expected an integer type" -EXPECT_INT_ERROR_LEN: .quad . - EXPECT_INT_ERROR -EXPECT_LAM_ERROR: .ascii "Error: typecheck expected a lambda type" -EXPECT_LAM_ERROR_LEN: .quad . - EXPECT_LAM_ERROR - - -ivy_abort: - mov rdi, STDERR - call _write - mov rdi, 1 - call _exit - - -ivy_debug_log: - push rax - mov rsi, rsp - sub rsp, 1 - mov rdx, '\n' - mov [rsp], dl - - mov rdx, 0 -ivy_debug_log_loop: - sub rsp, 1 - mov rbx, rax - and rbx, 0xF - add rbx, '0' - mov [rsp], bl - cmp rbx, '9' - jle ivy_debug_skip - add rbx, 'A' - '0' - 10 - mov [rsp], bl -ivy_debug_skip: - shr rax, 4 - add rdx, 1 - cmp rdx, 16 - jl ivy_debug_log_loop - - mov rdi, STDOUT - mov rsi, rsp - mov rdx, 17 - call _write - add rsp, 17 - pop rax - ret -- 2.43.2