printf() don't restore rcx and r8 for (u)int2str()

This commit is contained in:
2025-07-08 17:40:02 +02:00
parent cd565f3bfa
commit ee14dbb853

View File

@@ -69,7 +69,7 @@ puts:
; <!> For all specifiers (except %%) an argument is expected. Mismatch between arguments given and specifiers provided will lead to issues ; <!> For all specifiers (except %%) an argument is expected. Mismatch between arguments given and specifiers provided will lead to issues
; Used registers: ; Used registers:
; rax* (ret) amount of printed characters ; rax* (ret) amount of printed characters
; rdi* (arg) pointer to format[] to format and print ; rdi* (arg) pointer to format[] to format and print >> pointer to buffer
; rsi* (optional arg) >> Used for inserting strings to buffer ; rsi* (optional arg) >> Used for inserting strings to buffer
; rdx* (optional arg) >> Keeps track of amount of processed format specifiers ; rdx* (optional arg) >> Keeps track of amount of processed format specifiers
; rcx* (optional arg) ; rcx* (optional arg)
@@ -160,11 +160,9 @@ printf:
mov rsi, [rbp + RBP_OFFSET_CALLER + ((rdx-5) * SIZE_QWORD)] mov rsi, [rbp + RBP_OFFSET_CALLER + ((rdx-5) * SIZE_QWORD)]
.checkINTorUINT: .checkINTorUINT:
push rax push rax
push rcx
push rdx push rdx
push rdi push rdi
;push rsi sub rsp, SIZE_QWORD
push r8
cmp byte [rdi + 1], 'd' cmp byte [rdi + 1], 'd'
je .callINT2STR je .callINT2STR
mov rdi, rsi mov rdi, rsi
@@ -175,11 +173,9 @@ printf:
call int2str call int2str
.loadConvertedStr: .loadConvertedStr:
mov rsi, rax mov rsi, rax
pop r8 add rsp, SIZE_QWORD
;pop rsi
pop rdi pop rdi
pop rdx pop rdx
pop rcx
pop rax pop rax
jmp .insertString jmp .insertString