I am trying to create calculator in x86 assembly language, I am taking input to check which operation user wants, but cmp statement is not working. After taking input program directly jumps on add_nums. The second thing I want to ask is that how useful it will be to learn assembly language in-depth in today's era
STDOUT equ 1;
STDIN equ 0;
SYS_EXIT equ 1;
SYS_WRITE equ 4;
SYS_READ equ 3;
section .bss
choice resd 1;
opOne resb 4;
opTwo resb 4;
result resb 4;
section .data
msgBanner db "Enter 1 for addtion : ", 0xA, 0xD;
lenBanner equ $ - msgBanner;
msgInpOne db "Enter First Operand : ", 0xA, 0xD;
lenOne equ $ - msgInpOne;
msgInpTwo db "Enter Second Operand : ", 0xA, 0xD;
lenTwo equ $- msgInpTwo;
endMsg db "Sum is : ";
lenEndMsg equ $ - endMsg;
test1 dd 1;
test2 dd 2;
section .text
global _start;
_start:
mov eax, SYS_WRITE;
mov ebx, STDOUT;
mov ecx, msgBanner;
mov edx, lenBanner;
int 0x80;
mov eax, SYS_READ;
mov ebx, STDIN;
mov ecx, choice;
mov edx, 4;
int 0x80;
mov ecx, [test1];
cmp ecx, [choice];
je sub_nums;
mov ecx, [test2];
cmp ecx, [choice];
je add_nums;
add_nums:
mov eax, SYS_WRITE;
mov ebx, STDOUT;
mov ecx, msgInpOne;
mov edx, lenOne;
int 0x80;
mov eax, SYS_READ;
mov ebx, STDIN;
mov ecx, opOne;
mov edx, 4;
int 0x80;
mov eax, SYS_WRITE;
mov ebx, STDOUT;
mov ecx, msgInpTwo;
mov edx, lenTwo;
int 0x80;
mov eax, SYS_READ;
mov ebx, STDIN;
mov ecx, opTwo;
mov edx, 4;
int 0x80;
mov eax, [opOne];
mov ebx, [opTwo];
sub eax, '0';
sub ebx, '0';
add eax, ebx;
add eax, '0';
mov [result], eax;
mov eax, SYS_WRITE;
mov ebx, STDOUT;
mov ecx, endMsg;
mov edx, lenEndMsg;
int 0x80;
mov eax, SYS_WRITE;
mov ebx, STDOUT;
mov ecx, result;
mov edx, 4;
int 0x80;
mov eax, SYS_EXIT;
int 0x80;
sub_nums:
mov [result], eax;
mov eax, SYS_WRITE;
mov ebx, STDOUT;
mov ecx, endMsg;
mov edx, lenEndMsg;
int 0x80;
mov eax, SYS_EXIT;
int 0x80;