I need to build a calculator program in x64 assembly, where the user inputs two numbers and then the program asks for an operator (+,-,*,/) from the user. I am trying to compare the input with stored variables so I can compare the input with those variables and perform the user specified operation.
When running the program in gdb, I see that if I print/c for operator and variable: addition (when I set operator to +
), they both store the same value but in cmp
it does not jump to the appropriate block of code
My code is sort of like this
segment .data
mult db "*"
divide db "/"
addition db "+"
subtract db "-"
operator db ""
segment .data
global _start
_start:
;;get user input, set operator from rsi using syscall
mov r13,[operator]
mov r12,[addition]
cmp r12,r13 ;; my problem is somewhere here
je addFunction ;;Jump to addition operation
mov r12,[subtract]
cmp r12,r13
je subFunction