flat assembler
Message board for the users of flat assembler.

Index > Main > Question about instructions.

Author
Thread Post new topic Reply to topic
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz
Hello everyone. I'm interesting if there is some instruction that does something if before instruction are compared ? For example:
Code:
cmp eax,9
je somewhere
ret
somewhere:
mov eax,5    

Is there any way to do it without jumping ? like move(if equal) and movne(if not equal) instructions like this ? thank you. and sorry for my English.
Post 21 Jan 2011, 19:03
View user's profile Send private message Reply with quote
Coty



Joined: 17 May 2010
Posts: 546
Location: ␀
Coty
For the ARM processor I believe yes, for x86 no.. at-least I have not seen any yet...
Post 21 Jan 2011, 19:11
View user's profile Send private message Send e-mail Visit poster's website AIM Address Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler
I don't think there's a universal way, but there are conditional extensions for some instructions. AFAIK, ret doesn't have a native conditional form, but you could do as revolution does for ARM(http://board.flatassembler.net/topic.php?t=11985), and write a macro to emulate conditional ret.
Post 21 Jan 2011, 19:12
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz
Well, I dont need only mov, any istructions that are like instructions which are executed after CMP command.. Smile and on x86 processors.
Post 21 Jan 2011, 20:09
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler
I wrote:

you could do as revolution does for ARM(http://board.flatassembler.net/topic.php?t=11985), and write a macro to emulate conditional [your instruction here]


Quote:

on x86 processors

If you would have looked, you would have noticed his emulation is conditional jump based. x86 has conditional jumps. Smile

Why do you want to avoid conditional jumps? For code simplicity, or for efficiency? If it's for simplicity, then revolutions method is the easiest way I know of. If it's for efficiency, then the answer is: no, conditional jumps are required for some logic.
Post 21 Jan 2011, 20:16
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
Yes - the cmov instruction with the condition as a suffix:
Code:
mov ebx,5
cmp eax,9
cmove eax,ebx
ret    
Post 21 Jan 2011, 22:00
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz
Tyler
Sorry I'm just novice about that things. So easiest way is to make macro right ? and of course I need it for simplificy. Smile
cod3b453
Thanks, I'll try that. =)
Post 22 Jan 2011, 01:25
View user's profile Send private message Reply with quote
b1528932



Joined: 21 May 2010
Posts: 287
b1528932
be sure to test for cmovCC using cpuid.
Post 22 Jan 2011, 15:30
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17278
Location: In your JS exploiting you and your system
revolution
Tyler wrote:
... but you could do as revolution does for ARM ...
Slight correction there. I use it for fasmarm. Since ARM already has it as a native form. I use the macro in fasmarm (the x86 asm code) to give compatibility with 386+ CPUs (merely to be compliant with the original principles of fasm as used by Tomasz).
Post 22 Jan 2011, 15:45
View user's profile Send private message Visit poster's website Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz
Okay, thank you guys Smile
Post 27 Jan 2011, 13:49
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
before pentium4, there are no cmov.
Post 27 Jan 2011, 16:00
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17278
Location: In your JS exploiting you and your system
revolution
edfed wrote:
before pentium4, there are no cmov.
cmov was introduced with the P6 architecture (Pentium Pro).
Post 27 Jan 2011, 16:12
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
P pro was made the same year than PII, but they waited P4 to introduce it in popular models.

pentium pro is rare to find, more than P4
Post 27 Jan 2011, 16:45
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-2020, Tomasz Grysztar.

Powered by rwasa.