From a8360d3b04be710946c78a65212afb0dcc52f6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=9CM=C3=9C=C5=9E?= <96421894+Tahinli@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:51:29 +0300 Subject: [PATCH] feat: print values feat: take count from user --- 008-fibonacci.s | 84 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 14 deletions(-) diff --git a/008-fibonacci.s b/008-fibonacci.s index 7c45e5f..4757fdf 100644 --- a/008-fibonacci.s +++ b/008-fibonacci.s @@ -1,19 +1,75 @@ .global _start .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: - mov ax, 1 - mov bx, 0 - push bx - cmp cx, 00H - je son + lea rsi, [count] + mov rdx, 1 + call scanf + + mov r8, 1 + 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: - add bx, ax - push ax - xchg ax, bx - loop dongu: - //exit - syscall \ No newline at end of file + text_hello_world: + .asciz "Hello World\n" + text_how_far_do_you_want_to_go: + .asciz "How Far Do You Want to Go = " + text_goodbye: + .asciz "\nGoodbye\n" + 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