From 3cf5ac94d47262dd3cc2b6a3e0b12bf3e0321af9 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sat, 13 Jul 2024 21:33:43 -0700 Subject: Run file --- main.asm | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 main.asm diff --git a/main.asm b/main.asm new file mode 100644 index 0000000..823420b --- /dev/null +++ b/main.asm @@ -0,0 +1,93 @@ +%include "sys.inc" +%include "alloc.inc" + ;; TODO: Monad bind functions need to return a monad +%include "monad.inc" +%include "lstring.inc" +%include "zstring.inc" +%include "dtos.inc" +%include "file.inc" + + section .data + make_lstring test_lstring, "LString Test: Ok",10 + m_make test_lstring, test_lstring_len_b, 1 + + make_zstring test_zstring, "ZString Test: Ok",10 + m_make test_zstring, test_zstring, 1 + + make_zstring test_two_zstring, "Clone Test: Ok",10 + + m_make test_empty ; m_(label) is the created monad + + make_zstring test_dots, "DTOS Test: " + + make_zstring test_mdots, "Monad-Bound DTOS Test: " + m_make test_mdots + + make_zstring file_too_long_err_s, "File too long!",10 + +_TEST: dq "kO" + + make_fbuffer "input.txt", test_file, FBUF_DEFAULT_SIZE + m_make test_file, test_file_filedata, 1 + + + global _main + global _start + + section .text +_start: +_main: + m_call print_lstring, rel m_test_lstring + + m_call print_zstring, rel m_test_zstring + + m_Nothing rel m_test_zstring + m_call print_zstring + + m_Just rel m_test_zstring, test_two_zstring, 1 + m_call print_zstring + + m_return rel m_test_empty, test_two_zstring + m_call print_zstring, rel m_test_empty + + lea rax, [rel test_dots] + call print_zstring + dtomz_h "kO" ; Little endian + m_call print_zstring + + lea rax, [rel test_mdots] + call print_zstring + mov rax, [rel _TEST] + m_return rel m_test_mdots + m_bind data_to_zstring_mh + m_call print_zstring + + lea rax, [rel test_mdots] + call print_zstring + mov rax, "kO" + m_return rel m_test_mdots + m_bind data_to_zstring_mh + m_call print_zstring + + m_call ffopen, rel m_test_file + flen test_file + push rax + m_return rel m_test_mdots + m_bind data_to_zstring_md + m_call print_zstring + pop rax + cmp rax, FBUF_DEFAULT_SIZE + ja .error.exit + fbegin test_file + fread test_file + fclose test_file + + m_call print_filedata, rel m_test_file + + exit_prog + +.error.exit: + fclose test_file + lea rax, [rel file_too_long_err_s] + call print_zstring + exit_prog 1 -- cgit v1.2.1