From ccbc8a00aeb72f2b54bafacd6ccaad6f93c6e95e Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sat, 2 Nov 2024 17:18:08 -0700 Subject: Remove `mov rax rax` --- dtos.inc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'dtos.inc') diff --git a/dtos.inc b/dtos.inc index fb4a048..56bd0c6 100644 --- a/dtos.inc +++ b/dtos.inc @@ -3,7 +3,8 @@ %ifndef MONAD_INC %include "monad.inc" %endif - + + ;; TODO: Thread safety, allocate the write buffer instead of a global state incase it is interrupted and rewritten section .data _NUMERALS db "0123456789ABCDEF" _DATA_BYTE_BUFFER times 63 db "0" @@ -12,25 +13,33 @@ m_make DTOS_RESULT, _DATA_BYTE_BUFFER %macro dtomz_h 1 + %if "%1" != "%rax" mov rax, %1 + %endif mov rcx, 16 call data_to_zstring %endm %macro dtomz_d 1 + %if "%1" != "%rax" mov rax, %1 + %endif mov rcx, 10 call data_to_zstring %endm %macro dtomz_o 1 + %if "%1" != "%rax" mov rax, %1 + %endif mov rcx, 8 call data_to_zstring %endm %macro dtomz_b 1 + %if "%1" != "%rax" mov rax, %1 + %endif mov rcx, 2 call data_to_zstring %endm @@ -100,6 +109,9 @@ data_to_zstring: pop rbp ret + ;; Monadic functions (m_bind d2zs_m?) + ;; data_to_zstring_m? + ;; rax -> M (d2zs_? rax) data_to_zstring_mh: mov rcx, 16 call data_to_zstring -- cgit v1.2.1