From 28fbc837eaff40b0f992233e583f8352f13dddfe Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sat, 13 Jul 2024 23:27:06 -0700 Subject: Dynamic allocation for file data! --- main.asm | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'main.asm') diff --git a/main.asm b/main.asm index fbddef4..9a2f7ee 100644 --- a/main.asm +++ b/main.asm @@ -70,20 +70,42 @@ _main: 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 + + alloc FBUF_ALLOC_SIZE + mov rbx, rax m_call ffopen, rel m_test_file + mov [rel test_file_filedata + buffer], rbx + mov qword [rel test_file_filedata + size], FBUF_ALLOC_SIZE 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 + cmp rax, FBUF_ALLOC_SIZE ja .error.exit fbegin test_file - fread test_file + lea rax, [rel test_file_filedata] + call ffread fclose test_file - m_call print_filedata, rel m_test_file + mov rax, [rel test_file_filedata + buffer] + call print_zstring + free rbx, FBUF_ALLOC_SIZE exit_prog -- cgit v1.2.1