flat assembler
Message board for the users of flat assembler.

Index > Main > Problem with large immediate constants in x64 mode

Author
Thread Post new topic Reply to topic
murder



Joined: 03 Nov 2011
Posts: 14
murder 03 Nov 2011, 17:01
When I try to compile code like this
Code:
mov qword[RegKey+14+rax],'\CLSID'     

I`ve got "value out of range" (in 64-bit mode)

but this
Code:
mov    rdx,'\CLSID' 
mov    qword[RegKey+14+rax],rdx    

still work

sorry for my english Embarassed
Post 03 Nov 2011, 17:01
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20448
Location: In your JS exploiting you and your system
revolution 03 Nov 2011, 18:20
You can't define a large constant like '\CLSID' with mov m64,imm.

See the Intel manual for operand bounds. The largest is this:
Intel manual wrote:
MOV r/m64,imm32
BTW: Are you aware that '\CLSID' is not a pointer to a memory location, but is in actually an immediate constant?
Post 03 Nov 2011, 18:20
View user's profile Send private message Visit poster's website Reply with quote
murder



Joined: 03 Nov 2011
Posts: 14
murder 04 Nov 2011, 13:56
Quote:
Intel manual wrote:
MOV r/m64,imm32


ok, thanks.

I didnt know about this restriction. Sorry.
Post 04 Nov 2011, 13:56
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 07 Nov 2011, 18:35
CPUs limit instruction lengths to 15 bytes.
If 64-bit architecture would allow full 64-bit immediates then
MOV m64,imm64 could be inflated to 20 bytes by only using
Code:
mov qword[rax+rax*8+123456789ABCDEF0h],123456789ABCDEF0h    

I did a simple calculation from the following line that takes 12 bytes
Code:
mov qword[rax+rax*8+12345678h],12345678h    


Thx revolution!


Last edited by Madis731 on 07 Nov 2011, 19:23; edited 1 time in total
Post 07 Nov 2011, 18:35
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20448
Location: In your JS exploiting you and your system
revolution 07 Nov 2011, 19:09
Madis731 wrote:
CPUs limit instruction lengths to 16 bytes.
Erm ... 15 bytes, right?
Post 07 Nov 2011, 19:09
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: 20448
Location: In your JS exploiting you and your system
revolution 07 Nov 2011, 19:13
Madis731 wrote:
If 64-bit architecture would allow full 64-bit immediates then
MOV m64,imm64 could be inflated to 20 bytes by only using
Code:
mov dqword[rax+rax*8+123456789ABCDEF0h],123456789ABCDEF0h    

I did a simple calculation from the following line that takes 12 bytes
Code:
mov qword[rax+rax*8+12345678h],12345678h    
Do you mean:
Code:
mov qword[rax+rax*8+123456789ABCDEF0h],123456789ABCDEF0h    
dqword would be 128 bits!
Post 07 Nov 2011, 19:13
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 07 Nov 2011, 19:25
Sorry, wasn't thinking straight. I was not referencing any documents like I should've done Smile and like I usually do. Fixed!
Post 07 Nov 2011, 19:25
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.