News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

compile error while using cmp

Started by lingjie, May 06, 2007, 01:25:21 AM

Previous topic - Next topic

lingjie

I have a compile error when I compare two BYTE

.386
.model flat,stdcall       ; FLAT memory model & STDCALL calling
option casemap:none       ; set code to case sensitive

include \masm32\include\masm32rt.inc
helper PROTO :BYTE,:BYTE


.stack  4096                  ; reserve 4096-byte stack
.data

.code
start:

invoke helper,'a','z'

exit
PUBLIC start

helper proc startChar:BYTE, endChar:BYTE

inc endChar

cmp startChar,endChar ; compile error here, can only do cmp startChar, 'z', how can I compare startChar and endChar?
ret


helper endp

end start

PBrennick

lingjie,

You cannot compare memory to memory. Move one into a register and do the compare.

cmp startChar,endChar

changes to:

mov eax,startChar
cmp eax,endChar

Paul
The GeneSys Project is available from:
The Repository or My crappy website

raymond

If you continue to declare them as BYTES, you should do the following to avoid another error message or an error in the result:

mov al,startChar
cmp al,endChar

Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

korte




mov ax word ptr startChar
cmp ah,al