Compare commits
2 commits
1ffb79454b
...
4ae491bdb5
Author | SHA1 | Date | |
---|---|---|---|
4ae491bdb5 | |||
86860c606f |
3 changed files with 114 additions and 0 deletions
|
@ -21,3 +21,4 @@ add_executable(length length.asm)
|
||||||
add_executable(yes yes.asm)
|
add_executable(yes yes.asm)
|
||||||
add_executable(case case.asm)
|
add_executable(case case.asm)
|
||||||
add_executable(diff diff.asm)
|
add_executable(diff diff.asm)
|
||||||
|
|
||||||
|
|
28
monkie/emwhy.asm
Normal file
28
monkie/emwhy.asm
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
extern puts
|
||||||
|
|
||||||
|
|
||||||
|
section .data
|
||||||
|
text db "####################################################################################################",10,"####################################################################################################",10,"####################################################################################################",10,"####################################################################################################",10,"####################################################################################################",10,"####################################################################################################",10,"####################################################################################################",10,"####################################################################################################",10,"####################################################################################################",10,"####################################################################################################",10,"####################################################################################################",10
|
||||||
|
store dq 0
|
||||||
|
section .text
|
||||||
|
global main
|
||||||
|
|
||||||
|
main:
|
||||||
|
sub rsp, 8 ;enter
|
||||||
|
|
||||||
|
_setup:
|
||||||
|
xor r8, r8
|
||||||
|
mov r8, text
|
||||||
|
|
||||||
|
mov qword [store], text
|
||||||
|
|
||||||
|
mov r9, [store]
|
||||||
|
|
||||||
|
|
||||||
|
mov rdi, text
|
||||||
|
cld
|
||||||
|
call puts
|
||||||
|
|
||||||
|
_end:
|
||||||
|
add rsp, 8 ;exit
|
||||||
|
ret
|
85
monkie/strnum.asm
Normal file
85
monkie/strnum.asm
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
extern puts
|
||||||
|
|
||||||
|
%include "../inc/length_func.inc"
|
||||||
|
|
||||||
|
section .data
|
||||||
|
text db "42",0
|
||||||
|
section .text
|
||||||
|
global main
|
||||||
|
|
||||||
|
main:
|
||||||
|
sub rsp, 8
|
||||||
|
|
||||||
|
|
||||||
|
mov r8, text
|
||||||
|
call length_func
|
||||||
|
mov r9, rax
|
||||||
|
mov r11, r9
|
||||||
|
|
||||||
|
mov r8, text
|
||||||
|
_loop:
|
||||||
|
mov r10b, [r8]
|
||||||
|
cmp r10b, 0
|
||||||
|
jz _exitloop ;if its zero we have reached the end of the string
|
||||||
|
|
||||||
|
|
||||||
|
mov r10b, [r8]
|
||||||
|
sub r10b, 48 ; change "0" into 0
|
||||||
|
mov [r8], r10b
|
||||||
|
|
||||||
|
|
||||||
|
add r8, 1
|
||||||
|
jmp _loop
|
||||||
|
|
||||||
|
|
||||||
|
xor rcx, rcx
|
||||||
|
add rcx, 1
|
||||||
|
_exitloop:
|
||||||
|
cmp r9, r8
|
||||||
|
je _addvalues
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mov r10b [r9]
|
||||||
|
mul r10b, rcx
|
||||||
|
mov [r9], r10b
|
||||||
|
|
||||||
|
sub r9, 1
|
||||||
|
mul rcx, 10
|
||||||
|
|
||||||
|
jmp _exitloop
|
||||||
|
|
||||||
|
add r9, 1
|
||||||
|
_addvalues:
|
||||||
|
cmp r9, r11
|
||||||
|
je _end
|
||||||
|
|
||||||
|
|
||||||
|
mov r10b, [r8]
|
||||||
|
mov r11b, [r9]
|
||||||
|
add r11b, r10b
|
||||||
|
mov [r9], r11b
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue