flat assembler
Message board for the users of flat assembler.

flat assembler > Windows > mov vs cmove (with the identical arguments) - OK vs Error

Author
Thread Post new topic Reply to topic
fatygant



Joined: 12 Sep 2011
Posts: 30
Location: Poznan, Poland
Hello!

I have another problem which makes me scratch top of my head... I would appreciate your explanation.

I have two instructions in my 64-bit Windows code (of course they do not come one after another):
Code:
mov   rax,modbus_ascii_txt
cmove rax,modbus_ascii_txt    
The first one is assembled with no problems - but the second one generates the error: invalid argument. modbus_ascii_txt is just a memory address of the string defined as 'Modbus ASCII',0.

How is this possible if they work with the same type of operands according to x86_64 documentation?

Many thanks for your help!
Post 07 Feb 2018, 20:40
View user's profile Send private message Reply with quote
alexfru



Joined: 23 Mar 2014
Posts: 66
cmovcc's source operand is either a register or a memory operand. It does not take an immediate.
Post 07 Feb 2018, 23:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16057
Location: 112 Ocean Avenue, Amityville
It is a serious oversight on Intel's part. CMOVcc doesn't support immediate operands, as alexfru states.

One possible way around it is this:
Code:
mov rdx,modbus_ascii_txt ; use a temporary register
cmove rax,rdx    
Post 08 Feb 2018, 03:15
View user's profile Send private message Visit poster's website Reply with quote
fatygant



Joined: 12 Sep 2011
Posts: 30
Location: Poznan, Poland
Thank you alexfru and revolution!
Post 08 Feb 2018, 08:35
View user's profile Send private message 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-2018, Tomasz Grysztar.

Powered by rwasa.