feat: print values

feat: take count from user
This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-01-08 15:51:29 +03:00
parent db4e2ff61c
commit a8360d3b04

View file

@ -1,19 +1,75 @@
.global _start .global _start
.intel_syntax noprefix .intel_syntax noprefix
.data
count:
.byte 0x00
number:
.byte 0x00
new_line_collector:
.byte 0x00
.text
_start:
//hello world
lea rsi, [text_hello_world]
mov rdx, 13
call printf
// first 5 series of fibonnacci using stack lea rsi, [text_how_far_do_you_want_to_go]
mov rdx, 28
call printf
_start: lea rsi, [count]
mov ax, 1 mov rdx, 1
mov bx, 0 call scanf
push bx
cmp cx, 00H mov r8, 1
je son mov r9, 0
push bx
loop:
mov bl, 0x30
cmp bl, count
jae exit
dec byte ptr count
add r8, r9
push r9
mov r10, r9
add r10, '0'
mov number, r10
lea rsi, [number]
mov rdx, 1
call printf
xchg r8, r9
jmp loop
//exit
exit:
lea rsi, [text_goodbye]
mov rdx, 9
call printf
mov rax, 60
xor rdi, rdi
syscall
dongu: text_hello_world:
add bx, ax .asciz "Hello World\n"
push ax text_how_far_do_you_want_to_go:
xchg ax, bx .asciz "How Far Do You Want to Go = "
loop dongu: text_goodbye:
//exit .asciz "\nGoodbye\n"
syscall printf:
mov rax, 1
mov rdi, 1
syscall
xor rdi, rdi
ret
scanf:
mov rax, 0
mov rdi, 0
syscall
mov rax, 0
mov rdi, 0
mov rsi, [new_line_collector]
mov rdx, 1
syscall
xor rdi, rdi
ret