flat assembler
Message board for the users of flat assembler.

Index > Main > XOR (x64) *solved*

Author
Thread Post new topic Reply to topic
msschlt



Joined: 13 Sep 2008
Posts: 6
msschlt 04 Mar 2009, 01:48
Hello Smile

My problem:

Code:
    xor     rax, 11223344h
    ;fine

    xor     rax, 1122334455667788h
    ;Error: value out of range

    mov     rdx, 1122334455667788h
    xor     rax, rdx
    ;fine
    


Why out of range?


Last edited by msschlt on 04 Mar 2009, 02:03; edited 1 time in total
Post 04 Mar 2009, 01:48
View user's profile Send private message Reply with quote
chaoscode



Joined: 21 Nov 2006
Posts: 64
chaoscode 04 Mar 2009, 02:00
in long mode just 32 bit immediates are allowed.
Post 04 Mar 2009, 02:00
View user's profile Send private message ICQ Number Reply with quote
msschlt



Joined: 13 Sep 2008
Posts: 6
msschlt 04 Mar 2009, 02:02
Ah ok. Thanks.
Post 04 Mar 2009, 02:02
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20485
Location: In your JS exploiting you and your system
revolution 05 Mar 2009, 01:21
For a long time now we have been "spoiled" by the x86 architecture. It has traditionally allowed all possible constants to be encoded within the instruction stream. Other ISAs have not always been so forthcoming when it comes to encoding constants and people have been forced to find ingenious ways to code around it. But now, with the 64bit coming into the picture, we have entered an era in the x86 world of suddenly not having our precious constants available to us within the instruction stream where they are most convenient.

Case and point above, msschlt expected that the use of xor reg,constant would naturally allow all constant values, just like it did with the 32bit code. This is not the fault of msschlt, but more the fault of the previous x86 ISAs being so forgiving to the assembly programmer.

So now in the new era we will have to rethink how we deal with large constants. We will have to consider a good plan ahead of time. We will have to think harder before starting to simply code up a routine. If any of you have programmed for another CPU you may have already been aware of this problem and found solutions. Now you can use that knowledge in the x86. But we have one saving grace here in the x86 architecture. The infamous mov has been 'promoted' to allow a full 64bit constant. But still, even with that, the 64bit instruction set makes coding just a little bit more tricky, and a little bit more interesting.
Post 05 Mar 2009, 01:21
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.