flat assembler
Message board for the users of flat assembler.

Index > Main > Cmovnz what a f ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1701
Roman 19 Jan 2024, 12:36
I read nice asm command. I test this and thinking do assert without jnz.
Code:
mov ebx,11
xor eax,eax
test eax,eax            ;zf = 1 
cmovnz eax,ebx    ; eax  = 0
    


I am happy, work.
Now i am write code for assert and ...

Code:
xor eax,eax
test eax,eax            ;zf = 1 
cmovnz eax,[eаx]    ;Get crash ! What a f..k ?
    

And not exist cmovnz [eax],register

https://www.youtube.com/watch?v=emiNHDgFUC4&t=2s


Last edited by Roman on 19 Jan 2024, 13:19; edited 2 times in total
Post 19 Jan 2024, 12:36
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 913
Location: Russia
macomics 19 Jan 2024, 12:47
ne/nz = (zf=0)
Code:
mov ebx,11
xor eax,eax
cmp eax,1            ;zf = 0 
cmovnz eax,ebx    ; eax  = ebx    
Post 19 Jan 2024, 12:47
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20121
Location: In your JS exploiting you and your system
revolution 19 Jan 2024, 13:30
The memory address is always read, no matter what the condition state is in.

You can't use cmovcc to avoid reading a null pointer. The address must always be valid (unless you like crashes Razz).
Post 19 Jan 2024, 13:30
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: 20121
Location: In your JS exploiting you and your system
revolution 19 Jan 2024, 13:33
If we look at the pseudo-code for the operation (from the x86 manual) we see this:
Code:
temp := SRC
IF condition TRUE
    THEN DEST := temp;
ELSE IF (OperandSize = 32 and IA-32e mode active)
    THEN DEST[63:32] := 0;
FI;    
The very first line is to read the SRC operand. So if you have an invalid address then it crashes.
Post 19 Jan 2024, 13:33
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1701
Roman 19 Jan 2024, 13:44
Its bad news.
Intel planned implement in avx10 instruction test memory.
Post 19 Jan 2024, 13:44
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.