Compare commits

...

2 commits

Author SHA1 Message Date
8a823cf511 yes 2021-10-03 08:05:13 -04:00
bf18c8b3b8 removed inc and the old strnum 2021-10-03 08:02:46 -04:00
4 changed files with 1 additions and 197 deletions

View file

@ -1,82 +0,0 @@
%include "../inc/length_func.inc"
atoi_func:
mov r8, rdi
mov r8, text ;loop setup
xor r9, r9
_loopasd23:
mov r9b, [r8]
cmp r9, 0 ;check and see if we have reached the end of the string
jz _exitloopasd12
sub r9, 48
mov [r8], r9b
inc r8
jmp _loopasd23
_exitloopasd12:
call length_func
mov r8, rax
mov r11, rax
add r8, rdi
mov rcx, 1
_loop2asd12:
dec r8
mov al, [r8]
mul rcx
mov [r8], al
mov rax, rcx
mov r10, 10
mul r10
mov rcx, rax
cmp r8, rdi
je _exitloop2asd12
jmp _loop2asd12
_exitloop2asd12:
mov r8, rdi
mov r9, rdi
inc r9
_loop3asd12:
mov r11b, [r9]
mov r10b, [r8]
cmp r11, 0
jz _endasdasd23123
add r11, r10
mov [r9], r11b
mov [r8], r10b
inc r8
inc r9
jmp _loop3asd12
_endasdasd23123:
mov rax, [r8]
ret

View file

@ -1,18 +0,0 @@
length_func:
mov r10, rdi
xor r9, r9
_loop67865432:
mov r9, [rdi]
cmp r9, 0
jz _exitloop4323567
inc rdi
jmp _loop67865432
_exitloop4323567:
sub rdi, r10
mov rax, rdi
ret

@ -1 +1 @@
Subproject commit b5e1d53f010a65710144608018bd0274315988a5 Subproject commit cf0d5fa5cb5d9ed232555d60a71e49203cc3c984

View file

@ -1,96 +0,0 @@
extern puts
%include "../inc/length_func.inc"
section .data
text db "42",0
section .text
global main
main:
sub rsp, 8
mov rdi, text
call length_func
mov r9, rax
mov r11, r9
mov r8, text
xor r10, r10
xor r11, r11
_loop:
mov r10, [r8]
cmp r10, 0
jz _exitloop ;if its zero we have reached the end of the string
mov r10, [r8]
sub r10, 48 ; change "0" into 0
mov [r8], r10
add r8, 1
jmp _loop
xor rcx, rcx
add rcx, 1
_exitloop:
cmp r9, r8
je _addvalues
mov r10, r9
mov rax, r10
mul rcx
mov r10, rax
mov [r9], r10
sub r9, 1
mov rdi, 10
mov rax, rcx
mul rdi
mov rcx, rax
jmp _exitloop
add r9, 1
_addvalues:
cmp r9, r11
je _end
mov r10, [r8]
mov r11, [r9]
add r11, r10
mov [r9], r11
add r8, 1
add r9, 1
jmp _addvalues
;this returns the r8 pointer
;mov rdi, text
;cld
;call puts ;this is the put s way of printing a string
_end:
add rsp, 8
ret
; mov rax, 60 ; exit
; mov edi, 1 ; error 1 dont need the exit anymore beacue libc or somthing
; syscall