Rename int2str/uint2str -> dec2str/udec2str
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
%include "src/constants.asm"
|
%include "src/constants.asm"
|
||||||
|
|
||||||
extern strlen
|
extern strlen
|
||||||
extern int2str
|
extern dec2str
|
||||||
extern uint2str
|
extern udec2str
|
||||||
|
|
||||||
section .rodata
|
section .rodata
|
||||||
mNL db NL
|
mNL db NL
|
||||||
@@ -166,11 +166,11 @@ printf:
|
|||||||
cmp byte [rdi + 1], 'd'
|
cmp byte [rdi + 1], 'd'
|
||||||
je .callINT2STR
|
je .callINT2STR
|
||||||
mov rdi, rsi
|
mov rdi, rsi
|
||||||
call uint2str
|
call udec2str
|
||||||
jmp .loadConvertedStr
|
jmp .loadConvertedStr
|
||||||
.callINT2STR:
|
.callINT2STR:
|
||||||
mov rdi, rsi
|
mov rdi, rsi
|
||||||
call int2str
|
call dec2str
|
||||||
.loadConvertedStr:
|
.loadConvertedStr:
|
||||||
mov rsi, rax
|
mov rsi, rax
|
||||||
add rsp, SIZE_QWORD
|
add rsp, SIZE_QWORD
|
||||||
|
@@ -3,11 +3,11 @@
|
|||||||
section .bss
|
section .bss
|
||||||
cnvtBuff resb 21
|
cnvtBuff resb 21
|
||||||
section .text
|
section .text
|
||||||
global int2str
|
global dec2str
|
||||||
global uint2str
|
global udec2str
|
||||||
|
|
||||||
;----- int2str(num) -----;
|
;----- dec2str(num) -----;
|
||||||
; Converts a signed integer to a string
|
; Converts a signed integer to a string (decimal output)
|
||||||
; Return value: Pointer to string containing the converted number
|
; Return value: Pointer to string containing the converted number
|
||||||
; Used registers:
|
; Used registers:
|
||||||
; rax* num stored for div >> (ret) pointer to cnvtBuff[]
|
; rax* num stored for div >> (ret) pointer to cnvtBuff[]
|
||||||
@@ -16,7 +16,7 @@ section .text
|
|||||||
; rdi* (arg) number to convert to string >> Remembers if num is negative
|
; rdi* (arg) number to convert to string >> Remembers if num is negative
|
||||||
; rsi* Points to cnvtBuff for writing characters
|
; rsi* Points to cnvtBuff for writing characters
|
||||||
; r8* Dividor for div
|
; r8* Dividor for div
|
||||||
int2str:
|
dec2str:
|
||||||
mov rsi, cnvtBuff
|
mov rsi, cnvtBuff
|
||||||
test rdi, rdi
|
test rdi, rdi
|
||||||
jnz .notZero
|
jnz .notZero
|
||||||
@@ -56,8 +56,8 @@ int2str:
|
|||||||
mov rax, cnvtBuff
|
mov rax, cnvtBuff
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;----- uint2str(num) -----;
|
;----- udec2str(num) -----;
|
||||||
; Converts an unsigned integer to a string
|
; Converts an unsigned integer to a string (decimal output)
|
||||||
; Return value: Pointer to string containing the converted number
|
; Return value: Pointer to string containing the converted number
|
||||||
; Used registers:
|
; Used registers:
|
||||||
; rax* num stored for div >> (ret) pointer to cnvtBuff[]
|
; rax* num stored for div >> (ret) pointer to cnvtBuff[]
|
||||||
@@ -66,7 +66,7 @@ int2str:
|
|||||||
; rdi* (arg) number to convert to string
|
; rdi* (arg) number to convert to string
|
||||||
; rsi* Points to cnvtBuff for writing characters
|
; rsi* Points to cnvtBuff for writing characters
|
||||||
; r8* Dividor for div
|
; r8* Dividor for div
|
||||||
uint2str:
|
udec2str:
|
||||||
mov rsi, cnvtBuff
|
mov rsi, cnvtBuff
|
||||||
test rdi, rdi
|
test rdi, rdi
|
||||||
jnz .notZero
|
jnz .notZero
|
||||||
|
@@ -12,13 +12,13 @@ extern strcpy
|
|||||||
extern strcat
|
extern strcat
|
||||||
extern strclr
|
extern strclr
|
||||||
; convert.asm
|
; convert.asm
|
||||||
extern int2str
|
extern dec2str
|
||||||
extern uint2str
|
extern udec2str
|
||||||
|
|
||||||
section .rodata
|
section .rodata
|
||||||
TEST_print equ 1
|
TEST_print equ 1
|
||||||
TEST_puts equ 1
|
TEST_puts equ 1
|
||||||
TEST_int2str equ 1 ;includes uint2str
|
TEST_dec2str equ 1 ;includes udec2str
|
||||||
TEST_printf equ 1
|
TEST_printf equ 1
|
||||||
TEST_strlen equ 1
|
TEST_strlen equ 1
|
||||||
TEST_strcpy equ 1
|
TEST_strcpy equ 1
|
||||||
@@ -111,18 +111,18 @@ _start:
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
;---
|
;---
|
||||||
;--- int2str() / uint2str()
|
;--- dec2str() / udec2str()
|
||||||
;---
|
;---
|
||||||
%if TEST_int2str
|
%if TEST_dec2str
|
||||||
; x/s $rax after calls to confirm proper output
|
; x/s $rax after calls to confirm proper output
|
||||||
mov rdi, -569384
|
mov rdi, -569384
|
||||||
call int2str
|
call dec2str
|
||||||
mov rdi, -569384
|
mov rdi, -569384
|
||||||
call uint2str
|
call udec2str
|
||||||
mov rdi, 0xFFFFFFFFFFFFFFFF
|
mov rdi, 0xFFFFFFFFFFFFFFFF
|
||||||
call int2str
|
call dec2str
|
||||||
mov rdi, 0xFFFFFFFFFFFFFFFF
|
mov rdi, 0xFFFFFFFFFFFFFFFF
|
||||||
call uint2str
|
call udec2str
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
;---
|
;---
|
||||||
|
Reference in New Issue
Block a user