I am learning assembly and while it is simple, something is not working. I wrote a code which takes a number as input and compares it to two. If they are equal the code should print "Entered number is 2", if it does not equal, simply continue and exit. The code works except the cmp and jmp instructions. The code has enough comments to understand it:
section .data ;Data segment
userMsg db 'Please enter a number: ' ;Ask the user to enter a number
lenUserMsg equ $-userMsg ;The length of the message
dispMsg db 'You have entered: '
lenDispMsg equ $-dispMsg
dispMsg1 db 'You have entered 2 '
lenDispMsg1 equ $-dispMsg1
section .bss ;Uninitialized data
num resb 8
section .text ;Code Segment
global _start
_start: ;User prompt
mov eax, 4
mov ebx, 1
mov ecx, userMsg
mov edx, lenUserMsg
int 80h
;Read and store the user input
mov eax, 3
mov ebx, 2
mov ecx, num
mov edx, 8 ;5 bytes (numeric, 1 for sign) of that information
int 80h
;Output the message 'The entered number is: '
mov eax, 4
mov ebx, 1
mov ecx, dispMsg
mov edx, lenDispMsg
int 80h
;Output the number entered
mov eax, 4
mov ebx, 1
mov ecx, num
mov edx, 5
int 80h
;compate the register ecx, which holds num, with 2.
cmp ecx , 2
JE L1 ;if it equals 2, print it is 2
jmp L2 ;if not exit
L1:
mov eax, 4
mov ebx, 1
mov ecx, dispMsg1
mov edx, lenDispMsg1
int 80h
; Exit code
L2:
mov eax, 1
mov ebx, 0
int 80h