I'm programming in assembly, and I'm very new to the language. I'm using yasm in Ubuntu to do my programming. I'm supposed to take input from the user and tell whether their input is even or odd. If the input is odd, I need to see if it's greater than 5 or less than 5. Then, after everything, I need to make sure the user wants to go again. I'm pretty sure I have that down, I'm just having trouble verifying the user input. I'm trying to make sure they input a number from 0 to 9.
Below is everything I've written for my program, and I can't find where I'm going wrong. When I try to run it I get this error: Floating point exception (core dumped)
; Data section, declaring variables
section .data
output dd 'Enter a single digit between 0 and 9' ;1st output
nl db 0x0a
opLen equ $-output ;length of 1st output
Go equ 0x59 ;to check confirmation
go equ 0x79 ;to check confirmation
rem dd 0xffff ;empty remainder for modulo
output1 dd 'You entered an even number' ;output for even
op1Len equ $-output1 ;even output length
output2 dd 'You entered an odd number <= 5' ;output for odd less or equal to 5
op2Len equ $-output2 ;output length for first odd
output3 dd 'you entered an odd number > 5' ;output for odd more than 5
op3Len equ $-output3 ;output length for second odd
output4 dd '...what?...' ;output for if the thing entered is not a number
op4Len equ $-output4 ;else output length
confirm dd 'go again? (y/n): ' ;confirmation message
cLen equ $-confirm ;confirmation message length
divs dd 2
section .bss
input dd 0xffff ;for user input
again dd 0xffff ;for second user input
section .text
global _start
_start:
call printOutput ;prints first output
call getInput ;receives user input
call checkNumZero ;checks if number is greater than zero
call checkEvenOdd ;does the modulo operation on the number
cmp dword [rem], 0 ;compares the remainder and 0
je handleTrueEven ;if remainder is zero, then the first message is outputted
call isOdd ;if the remainder isn't zero, it checks if it is greater or less than 5
call goAgain ;asks the user if they want to go again
printOutput:
mov rax, 1
mov rdi, 1
mov rsi, output
mov rdx, opLen
syscall
ret
getInput:
mov rax, 0
mov rdi, 0
mov rsi, input
mov rdx, 0xffff
syscall
ret
checkNumZero:
cmp dword [input], '0'
jbe checkNumNine
call else
checkNumNine:
cmp dword [input], '9'
ja else
ret
else:
mov rax, 1
mov rdi, 1
mov rsi, output4
mov rdx, op4Len
syscall
ret
checkEvenOdd:
mov rax, 0
mov eax, dword [input]
div dword [divs]
mov dword [rem], edx
ret
handleTrueEven:
mov rax, 1
mov rdi, 1
mov rsi, output1
mov rdx, op1Len
syscall
ret
isOdd:
cmp dword [input], 5
jle lessThan
call moreThan
ret
lessThan:
mov rax, 1
mov rdi, 1
mov rsi, output2
mov rdx, op2Len
syscall
ret
moreThan:
mov rax, 1
mov rdi, 1
mov rsi, output3
mov rdx, op3Len
syscall
ret
goAgain:
mov rax, 1
mov rdi, 1
mov rsi, confirm
mov rdx, cLen
syscall
mov rax, 0
mov rdi, 0
mov rsi, again
mov rdx, 0xffff
syscall
cmp dword [again], 0x79
jne doneIf
cmp dword [again], 0x59
jne doneIf
ret
doneIf:
mov rax, 60
mov rdi, 0
syscall