flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Bug in MZ, cmp dword [MemBuffa+1],01000000h

Author
Thread Post new topic Reply to topic
fasm007



Joined: 28 Apr 2007
Posts: 8
Location: USA:State Of Georgia
fasm007 28 Apr 2007, 18:46
The following example seems incorrect to me?
In a simple MZ test app written in fasmw and run in a Windows XP console,
with the following value declared and stored in memory:

MemBuffa dd 00000000h,00000001h

cmp dword [MemBuffa+1],01000000h ;is equal, jne does not jump.
jne somewhere


cmp dword [MemBuffa+1],00000001h ;is not equal, jne, jumps
jne somewhere

_________________
Seriously
Post 28 Apr 2007, 18:46
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 28 Apr 2007, 19:04
You declared
Code:
MemBuffa dd 00000000h,00000001h    
which can be seen as
Code:
MemBuffa db 00, 00, 00, 00, 01, 00, 00, 00    

Now you are accessing "dword [MemBuffa+1]", so you are accessing four bytes starting from the second byte of MemBuffa (00, 00, 00, 01).

Remember that Intel is little endian so the first cmp is comparing against 00, 00, 00, 01 and the second cmp against 01, 00, 00, 00.

I clarified your problem? Actually I'm not so sure what are you asking.
Post 28 Apr 2007, 19:04
View user's profile Send private message Reply with quote
fasm007



Joined: 28 Apr 2007
Posts: 8
Location: USA:State Of Georgia
fasm007 28 Apr 2007, 19:16
Yes, I see. I make this stupid mistake, sometimes. I was thinking MemBuffa+1 dword, instead of MemBuffa+4 bytes, which would have been correct.
The example made it appear that the endian byte order was being flipped, which confused me, further.
Thanks for the reply.
Post 28 Apr 2007, 19:16
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.