printf() optimization: Use syscall and mov r14 to rax rather than calling print and strlen -- r14 used to contain wrong length: mistakenly increased r14 (and performed checks) for printfNBuff
This commit is contained in:
16
console.asm
16
console.asm
@ -155,14 +155,8 @@ printf:
|
||||
|
||||
.charToStr:
|
||||
mov [printfNBuff], dil
|
||||
inc r14
|
||||
cmp r14, bufferLength-1
|
||||
je .finish
|
||||
mov dil, 0
|
||||
mov [printfNBuff+1], dil
|
||||
inc r14
|
||||
cmp r14, bufferLength-1
|
||||
je .finish
|
||||
lea rsi, [rel printfNBuff]
|
||||
jmp .insertLoop
|
||||
|
||||
@ -210,10 +204,12 @@ printf:
|
||||
|
||||
.finish:
|
||||
mov byte [r11], 0x0
|
||||
lea rdi, [rel printfBuff]
|
||||
call print
|
||||
lea rdi, [rel printfBuff]
|
||||
call strlen
|
||||
mov rax, NR_write
|
||||
mov rdi, 1
|
||||
lea rsi, [rel printfBuff]
|
||||
mov rdx, r14
|
||||
syscall
|
||||
mov rax, r14
|
||||
cmp r14, bufferLength-1
|
||||
jl .final
|
||||
|
||||
|
Reference in New Issue
Block a user