Reputation: 11
I am trying to compare an input data with a integer value
here the basic code I am using
section .bss
input resb 2
section .text
global _start
_start:
mov eax, 3
mov ebx, 1
mov ecx, input
mov edx, 5
int 0x80
mov eax, [input]
cmp eax, 20 // This is what I cannot get to work, it never compares it to 20 even if i enter 20 as input
je next
All I really want to know is how to do the If statement in Assembly to compare input with an integer.
I would really apprecaite any help with this, thank you.
Upvotes: 1
Views: 3847
Reputation: 1
Try using this code...
section .bss
input resb 2
section .text
global _start
_start:
mov eax, 3
mov ebx, 1
mov ecx, input
mov edx, 5
int 0x80
mov eax, dword[input];dword is require for double word size
cmp eax, 20
je next
Upvotes: 0
Reputation:
You are comparing eax
(the first byte of input) with the integer
20`. This is the DC4 control character, which is almost certainly not your input.
If you want to compare to the number 20, then you will need to convert input to a number first (and accept more than one character of input).
Upvotes: 2