flat assembler
Message board for the users of flat assembler.

Index > Main > qword size in comparison

Author
Thread Post new topic Reply to topic
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
hey i am testing a buf for a string

Code:
cmp dword[buf], '1234'    


this allows anywhere from 1-4 bytes for dword 1-2 for word and etc

if you specify more than the allowed bytes for specified size, it will give you 'value out of range'

why when i try with qword

Code:
cmp qword[buf], '12345678'    
does it give me 'invalid size of operand' ?

_________________
redghost.ca
Post 19 Jan 2006, 05:58
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7709
Location: Kraków, Poland
Tomasz Grysztar
With "use16"/"use32" it won't work, because there's not such instruction.

And with "use64" it won't work too, because AMD64 allows only signed 32-bit immediates to be used in 64-bit instructions.
Post 19 Jan 2006, 07:52
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
You can do this:
Code:
cmp dword[buf], '1234'
Jcc labelXXXX
cmp dword[buf+4], '5678'
Jcc labelXXXX ; same condition
    

Although it may get frustrating if you want some math done on that. Then you must choose the order in which you compare very carefully. For equality this should do the trick. Or use MMX (64bit) or SSE (128bit) instructions. BUT you must remember that 128bit comparison is NOT possible even in this case (read: possible with tricks involved).
Post 19 Jan 2006, 09:48
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger 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-2020, Tomasz Grysztar.

Powered by rwasa.