Fix issue in printf() with %d --needed to push+pop several registers before/after itoa() call
This commit is contained in:
14
console.asm
14
console.asm
@ -86,8 +86,7 @@ printf:
|
||||
je .rep_d_r9
|
||||
|
||||
;get from stack
|
||||
; rsp + 5*8 : RIP to printf call (+1), PUSH rbp,r12,r13,rdi (+4)
|
||||
mov rsi, qword [rsp + 5*8 + (r10-5)*8]
|
||||
mov rsi, qword [rbp + 16 + (r10-5)*8]
|
||||
jmp .convertInt
|
||||
|
||||
.rep_d_rsi:
|
||||
@ -107,7 +106,15 @@ printf:
|
||||
|
||||
.convertInt:
|
||||
lea rsi, [rel printfNBuff]
|
||||
push rcx
|
||||
push rdx
|
||||
push r8
|
||||
push r10
|
||||
call itoa
|
||||
pop r10
|
||||
pop r8
|
||||
pop rdx
|
||||
pop rcx
|
||||
mov rsi, rax
|
||||
jmp .sinsertLoop
|
||||
|
||||
@ -125,8 +132,7 @@ printf:
|
||||
je .rep_s_r9
|
||||
|
||||
;get from stack
|
||||
; rsp + 5*8 : RIP to printf call (+1), PUSH rbp,r12,r13,rdi (+4)
|
||||
mov rsi, qword [rsp + 5*8 + (r10-5)*8]
|
||||
mov rsi, qword [rbp + 16 + (r10-5)*8]
|
||||
jmp .sinsertLoop
|
||||
|
||||
.rep_s_rdx:
|
||||
|
5
core.asm
5
core.asm
@ -160,12 +160,17 @@ itoa:
|
||||
inc rcx
|
||||
test rax, rax
|
||||
jnz .convert
|
||||
test rbx, rbx
|
||||
jz .toString
|
||||
push byte '-'
|
||||
inc rcx
|
||||
|
||||
.toString:
|
||||
pop rdx
|
||||
mov byte [rsi], dl
|
||||
inc rsi
|
||||
loop .toString
|
||||
mov byte [rsi], 0
|
||||
|
||||
.quit:
|
||||
pop rsi
|
||||
|
Reference in New Issue
Block a user