%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