From 7c4698850871ac7c142f8957fa5d10ca0b309b31 Mon Sep 17 00:00:00 2001 From: Kwarde Date: Thu, 24 Jul 2025 20:32:49 +0200 Subject: [PATCH] FIX printf: '%0(invalid)' as-is (don't exclude '%') --- src/console.asm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/console.asm b/src/console.asm index bbf7ef9..516591a 100644 --- a/src/console.asm +++ b/src/console.asm @@ -222,6 +222,7 @@ printf: je .wrapup cmp byte [rdi + 1], '%' je .rep_pct + xor r12, r12 ; Include specifier (r13 bit0=1) or not (bit0=0) xor r13, r13 cmp byte [rdi + 1], '#' @@ -230,15 +231,13 @@ printf: bts r13, 0 ; Padding: zeroes (r13i bit1=1) or spaces (bit1=0) .argGetPadZeroes: - mov r12, 1 cmp byte [rdi + 1], '0' - jb .noPadding + jb .checkReplArg ja .padSpaces bts r13, 1 .padSpaces: cmp byte [rdi + 1], '9' - jg .noPadding - xor r12, r12 + jg .checkReplArg xor rcx, rcx inc rdi .findPaddingNumLen: @@ -271,7 +270,10 @@ printf: loop .getPaddingLoop pop rax pop rdi - .noPadding: + test r12, r12 + jnz .checkReplArg + dec rdi + .checkReplArg: cmp byte [rdi + 1], 'c' je .rep_c cmp byte [rdi + 1], 'i'