flat assembler
Message board for the users of flat assembler.

Index > Windows > Something strange...

Author
Thread Post new topic Reply to topic
Necromancer13



Joined: 18 Oct 2007
Posts: 32
Location: Ukraine
Necromancer13 22 Oct 2007, 05:16
FASM converts
Code:
cmp word[var],'MZ'
    

to
Code:
cmp word ptr [var],5A4D
    


but not to
Code:
cmp word ptr [var],4D5A
    


But 'MZ' is 4D5A, not 5A4D!
is it a bug?

_________________
FASM Rulezzzzzz!
Post 22 Oct 2007, 05:16
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 22 Oct 2007, 05:22
http://flatassembler.net/docs.php?article=faq (and perhaps somewhere in the documentation but by a quick search I wasn't able to find it)

Quote:
Why the instruction mov eax,'ABCD' is assembled into mov eax,44434241h? Shouldn't it be reversed?

Altough the most of other assemblers interpret quoted values treating the first character as the most significant, I've decided to use this different approach, just because it's more handy in the most situations. That's because for x86 architecture the least significant byte is the first byte in memory, so if you want to check whether there is 'ABCD' string at ebx address, you can just write cmp dword [ebx],'ABCD'.
Post 22 Oct 2007, 05:22
View user's profile Send private message Reply with quote
Necromancer13



Joined: 18 Oct 2007
Posts: 32
Location: Ukraine
Necromancer13 22 Oct 2007, 05:29
ok.. thanks:)
Post 22 Oct 2007, 05:29
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.