I wrote a simple program in assembly code (open console and loop input until user enters 5
). I want to store each input in variable input
(new input will overwrite old). This is my code:
format PE console
entry start
include 'win32a.inc'
;======================================
section '.data' data readable writeable
;======================================
input db "", 0
;=======================================
section '.code' code readable executable
;=======================================
start:
ccall [getchar] ; Wait for input
cmp eax, "5" ; Compare input with string
je exit ; If it is equal, then exit
jne start ; If not, wait for input again
exit:
stdcall [ExitProcess], 0
;====================================
section '.idata' import data readable
;====================================
library kernel,'kernel32.dll',\
msvcrt,'msvcrt.dll'
import kernel,\
ExitProcess,'ExitProcess'
import msvcrt,\
printf,'printf',\
getchar,'_fgetchar'
I tried to to write
ccall [getchar] ; Wait for inout
cmp eax, "5" ; Compare input with string
mov [input], eax ; This line is added
je exit ; If it is equal, then exit
jne start ; If not, wait for input again
but I got error Operand sizes do not match.
. I have searched for this error, but I didn't find anything useful.