Compare commits
No commits in common. "e40f7dbe2b92ec7dbba7fe0c1cb7a2ca14755586" and "048a43083ab59b05f5139f0e21617a08a22550bf" have entirely different histories.
e40f7dbe2b
...
048a43083a
5 changed files with 3 additions and 123 deletions
|
@ -18,6 +18,6 @@ add_compile_options(-g)
|
|||
add_link_options(-fno-pie -m64 -no-pie -pedantic-errors)
|
||||
|
||||
#Make a EXE with cpp and asm files
|
||||
add_library(z tolower.asm strlen.asm strcmp.asm atoi.asm hextoi.asm)
|
||||
add_library(z tolower.asm strlen.asm strcmp.asm atoi.asm)
|
||||
add_executable(example example.asm)
|
||||
target_link_libraries(example z)
|
||||
|
|
7
atoi.asm
7
atoi.asm
|
@ -25,10 +25,6 @@ _loop:
|
|||
xor rax, rax
|
||||
mov al, [r9]
|
||||
|
||||
cmp rax, 48
|
||||
jb _nan
|
||||
cmp rax, 57 ;if its not a number then return 0 then exit
|
||||
ja _nan
|
||||
|
||||
; push rax
|
||||
sub rax, 48
|
||||
|
@ -47,8 +43,7 @@ _loop:
|
|||
|
||||
jmp _loop
|
||||
|
||||
_nan:
|
||||
xor r10, r10
|
||||
|
||||
|
||||
_end:
|
||||
mov rax, r10
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
extern libz_strlen
|
||||
|
||||
global libz_atoi
|
||||
|
||||
section .text
|
||||
|
||||
libz_atoi:
|
||||
|
||||
|
||||
; mov r11, rdi ;saveing it for later
|
||||
|
||||
push rdi
|
||||
call libz_strlen
|
||||
mov r9, rax
|
||||
pop rdi
|
||||
|
||||
xor r10, r10
|
||||
|
||||
mov rcx, 1
|
||||
add r9, rdi
|
||||
dec r9
|
||||
|
||||
_loop:
|
||||
|
||||
xor rax, rax
|
||||
mov al, [r9]
|
||||
|
||||
|
||||
; push rax
|
||||
sub rax, 48
|
||||
mul rcx
|
||||
add r10, rax
|
||||
; pop rax
|
||||
|
||||
cmp r9, rdi
|
||||
je _end
|
||||
dec r9
|
||||
; push rax
|
||||
mov rax, 10
|
||||
mul rcx
|
||||
mov rcx, rax
|
||||
; pop rax
|
||||
|
||||
jmp _loop
|
||||
|
||||
|
||||
|
||||
_end:
|
||||
mov rax, r10
|
||||
ret
|
||||
|
|
@ -7,7 +7,7 @@ extern libz_atoi
|
|||
section .data
|
||||
text2 db "asdasdASDd",0
|
||||
text db "asdasdasd",0
|
||||
text3 dq "5",0
|
||||
text3 dq "65",0
|
||||
textstore dq 0,0
|
||||
stoer db "0",0
|
||||
differ db "they differ",0
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
extern libz_strlen
|
||||
|
||||
global libz_hextoi
|
||||
|
||||
section .text
|
||||
|
||||
libz_hextoi:
|
||||
|
||||
|
||||
; mov r11, rdi ;saveing it for later
|
||||
|
||||
push rdi
|
||||
call libz_strlen
|
||||
mov r9, rax
|
||||
pop rdi
|
||||
|
||||
xor r10, r10
|
||||
|
||||
mov rcx, 1
|
||||
add r9, rdi
|
||||
dec r9
|
||||
|
||||
_loop:
|
||||
|
||||
xor rax, rax
|
||||
mov al, [r9]
|
||||
|
||||
cmp rax, 48
|
||||
jb _nan
|
||||
cmp rax, 70 ;if its not a number then return 0 then exit
|
||||
ja _nan ;this actually as a bug if you put a : it will be allowed
|
||||
|
||||
; push rax
|
||||
|
||||
cmp rax, 58 ;if(char < 58){sub char, 48}else{sub char, 55}
|
||||
jb _charbelow
|
||||
sub rax, 55
|
||||
jmp _hexitif
|
||||
_charbelow:
|
||||
sub rax, 48
|
||||
_hexitif:
|
||||
|
||||
mul rcx
|
||||
add r10, rax
|
||||
; pop rax
|
||||
|
||||
cmp r9, rdi
|
||||
je _end
|
||||
dec r9
|
||||
; push rax
|
||||
mov rax, 16
|
||||
mul rcx
|
||||
mov rcx, rax
|
||||
; pop rax
|
||||
|
||||
jmp _loop
|
||||
|
||||
_nan:
|
||||
xor r10, r10
|
||||
|
||||
_end:
|
||||
mov rax, r10
|
||||
ret
|
||||
|
Loading…
Reference in a new issue