assembly - Assembler nasm displaying all divisors of provided number -
i have write programm displays divisors of provided number. number read keyboard , stored in bufor program doesn't work , stuck in black point it... after running segmentation fault (core dumped) maybye more expirienced might it. suggestions welcome! in advance.
_start: ; ;*******reading keyboard mov rax, 0 ; kyboard descriptior mov rdx, 10 ; bytes read mov rdi,0 ; keyboard reading mov rsi, bufor ; syscall; function call ;********loop for************************* mov rax, [bufor] ; mov rcx, 1 mov rcx, 2 ; ecx i=10 for_loop: cmp rcx, [bufor] jae loop_end ; go into, when >= edi xor rdx,rdx ; avoid div errors mov rax, [bufor] ; div rcx ; push rbp ; push function pointer stack mov rbp, rsp; store stack pointer push rcx ; push counter pointer stack cmp rdx, 0 je display inc rcx ; i++ jmp for_loop loop_end: jmp exit display: mov rax, 1 ; fun number mov rdi, 1 mov rsi, rcx ; mov rdx, 5 ; syscall jmp done done: pop rcx ; getcounter pop rbp ;get function pointer ret ; return ;*********exit program******* exit: mov rax, 60 syscall section .data ; section .bss bufor resb 5 ; bufor 5 bytes
Comments
Post a Comment