utoa/printf: Support octal (%o)
This commit is contained in:
@@ -123,7 +123,7 @@ itoa:
|
||||
;----- utoa(int, base, padLen, bool padZeroes, bool upperCase) -----;
|
||||
; Converts an unsigned integer to a string
|
||||
; Return value: Pointer to converted string or 0(EOS) if entered base is invalid
|
||||
; Supported bases: 2 (binary), 10 (decimal), 16 (hexadecimal)
|
||||
; Supported bases: 2 (binary), 8, (octal), 10 (decimal), 16 (hexadecimal)
|
||||
; Used registers:
|
||||
; rax* num to divide (DIV) >> Copy bytes when reversing string >> (ret) Pointer to converted string
|
||||
; rbx Stores (upperCase)
|
||||
@@ -143,6 +143,8 @@ utoa:
|
||||
; Before doing anything, check if base is valid
|
||||
cmp rsi, 2
|
||||
je .ok
|
||||
cmp rsi, 8
|
||||
je .ok
|
||||
cmp rsi, 10
|
||||
je .ok
|
||||
cmp rsi, 16
|
||||
@@ -161,7 +163,7 @@ utoa:
|
||||
mov r13, rsi
|
||||
mov r14, rdx
|
||||
mov r15, rcx
|
||||
; First, assure 0 <= padLen <= 64 ;(64, even though max signed int64 = 19 characters; enables to pad with base 2)
|
||||
; First, assure 0 <= padLen <= 64
|
||||
mov rdi, rdx
|
||||
xor rsi, rsi
|
||||
mov rdx, 64
|
||||
|
Reference in New Issue
Block a user