From 467b5b7a0bd03edc3dfa6b62212f9426579210ed Mon Sep 17 00:00:00 2001 From: Kwarde Date: Thu, 10 Jul 2025 00:22:36 +0200 Subject: [PATCH] hex2str: Perform test r9,r9 only once (instead of for each number in loop .convert) --- src/convert.asm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/convert.asm b/src/convert.asm index ea08c7c..306851e 100644 --- a/src/convert.asm +++ b/src/convert.asm @@ -109,6 +109,7 @@ udec2str: ; rcx* Counts length of created string ; r8* Dividor for div ; r9* Store arg rsi (uppercase) +; r11* Amount to add to number (for ASCII conversion, lowercase or uppercase) hex2str: mov r9, rsi mov rsi, cnvtBuff @@ -122,19 +123,20 @@ hex2str: .notZero: mov rax, rdi xor rcx, rcx + + mov r8, 87 + test r9, r9 + cmovz r11, r8 + test r9, r9 + jz .convert + mov r11, 55 .convert: xor rdx, rdx mov r8, 16 div r8 cmp rdx, 10 jb .num - test r9, r9 - jz .lower - ;.upper: - add rdx, 55 - jmp .push - .lower: - add rdx, 87 + add rdx, r11 jmp .push .num: add rdx, '0'