P
P
pepl2132018-10-30 18:38:46
assembler
pepl213, 2018-10-30 18:38:46

Why does it give an error in fasm?

format ELF executable 3
entry start

segment readable executable

start:
  mov	eax,4
  mov	ebx,1
  mov	ecx,menu
  mov	edx,menu_size
  int     80h
select_loop:
  mov eax,4
  mov ebx,1
  mov ecx, select
  mov edx, select_size
  int 80h

  ; read data
  mov eax,3
  mov ebx,1
  mov ecx,buffer
  mov edx,1
  int 80h

  cmp buffer,'0'
  je exit
  cmp buffer, '1'
  je c1
  cmp buffer,'2'
  je c2
  jmp select_loop

c1:
  mov eax,4
  mov ebx,1
  mov ecx, hello
  mov edx, hello_size
  int 80h
c2:
  mov eax,4
  mov ebx,1
  mov ecx, go_away
  mov edx, go_away_size
  int 80h


exit:
  mov eax,1
  xor ebx,ebx
  int 80h
segment readable writeable

menu    db '1 - Print hello',13,10
        db '2 - Print go away',13,10
        db '0 - Exit',13,10
menu_size = $-menu
select  db 13,10,'Select>'
select_size = $-select
hello   db 13,10,'Hello!',13,10,13,10
hello_size = $-hello
go_away db 13,10,'Go away!',13,10,13,10
go_away_size = $-go_away
buffer db ?

The code that reads the value, puts it in buffer, compares the values:
if buffer=='0' then exit
if buffer=='1' then print "Hello"
if buffer=='2' then print "Go away"
But fasm throws an error:
flat assembler  version 1.73.02  (16384 kilobytes memory)
program.asm [26]:
   cmp buffer,0
processed: cmp buffer,0
error: invalid operand.

Why? And how to simplify the code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2018-10-30
@pepl213

Is n't it the case cmp [buffer], '0'?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question