flat assembler
Message board for the users of flat assembler.

Index > Windows > 64-bit 0xFFFFFFFF "Value out of range"?

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
KingDemon



Joined: 16 Oct 2006
Posts: 21
Location: Somewhere in Romania
KingDemon 23 Sep 2009, 19:09
Tomasz Grysztar wrote:
There is only one "struct" macro. I simply forgot to put the second padding into the definition.


Then this is solved!

Thanks!

_________________
Don't mind me! I'm just a crazy next-door neighbor.
Post 23 Sep 2009, 19:09
View user's profile Send private message Reply with quote
KingDemon



Joined: 16 Oct 2006
Posts: 21
Location: Somewhere in Romania
KingDemon 24 Sep 2009, 16:57
FYI: PAINTSTRUCT needs the same kind of padding
Post 24 Sep 2009, 16:57
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 24 Sep 2009, 18:11
Well the next question is how to obtain
4825FFFFFFFF
opcode from fasm? fasm only produces short form with negative values.

Are there many basic opcodes that are unreachable for fasm like this above?
Post 24 Sep 2009, 18:11
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 24 Sep 2009, 18:25
In 32-bit world you could force such opcodes with "word" or "dword" operators, however for 64-bit world, where the immediate is not a full-size in such case I have no suitable syntax option that would be considered to allow such opcode generation.
So I'm afraid that if you really need this exact opcode (perhaps for the purpose of self-modifying code?), you may have to do it like:
Code:
and rax,-80000000h
store dword -1 at $-4    
Post 24 Sep 2009, 18:25
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 24 Sep 2009, 18:44
Then as i supposed tons of opcode are lost in this formula rex.w + sign-ext. dword. Any other formulas as examples? Will you think of fixing this with some new keywords or just leave as is, Tomasz?
Post 24 Sep 2009, 18:44
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 24 Sep 2009, 19:30
The assembler is an abstraction from machine language, and therefore assembly language sees the instructions from the functional point of view, not the opcode point of view. For example you have two way to encode "and eax,ebx": 21 D8 or 23 C3. Since they are functionally equivalent and also size equivalent in this case, assembler is free to choose any of them (it is sometimes used to recognize a "footprint" of an assembler or compiler, BTW).
For the instructions that are functionally equivalent, but not equivalent in size, fasm simply chooses the shortest one, because in this sense it is an optimizing assembler.

The only case when the instructions that are otherwise completely equivalent, but have different sizes, would not be equivalent enough for you, might be some cases of self-modyfing code, where you need to access the displacement field. This is a very rare application, though, and if you are doing such things, then having to use the tricks like above shouldn't really be a problem.

Therefore I don't think there really anything that would require "fixing" here. One of the purposes of assembly language is to abstract you from the encoding so that you can focus on what the instructions do, not how they are encoded.
Post 24 Sep 2009, 19:30
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 24 Sep 2009, 19:37
Quote:

might be some cases of self-modyfing code,

There is another application, you may need to do that for alignment so instead of padding with instructions that do nothing, you just pad making the instructions above the label bigger.
Post 24 Sep 2009, 19:37
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 24 Sep 2009, 19:42
LocoDelAssembly wrote:
Quote:

might be some cases of self-modyfing code,

There is another application, you may need to do that for alignment so instead of padding with instructions that do nothing, you just pad making the instructions above the label bigger.

But to do that manually you also have to know the addresses and instruction sizes yourself. Thus, as it is with self-modifying code, if you really are that much into digging into machine code, you won't mind to use some specialized directives instead of pure assembly language, which is focused on the meaning of instruction, not encoding.
Post 24 Sep 2009, 19:42
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 24 Sep 2009, 19:49
Tomasz Grysztar wrote:
Code:
and rax,-80000000h
store dword -1 at $-4    
That's what I've been using in 32-bit for self-modifying code, I didn't know there was another way to do it Razz

one could get rid of the "footprint" by randomizing the equivalent instructions, right?

_________________
Previously known as The_Grey_Beast
Post 24 Sep 2009, 19:49
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 24 Sep 2009, 19:52
Borsuc wrote:
one could get rid of the "footprint" by randomizing the equivalent instructions, right?
Well, randomization of those opcodes would itself be a kind of footprint. Wink
Post 24 Sep 2009, 19:52
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 24 Sep 2009, 19:55
This is about HLL concept you're talking about but assembler is a bit higher layer of CPU (machine) language. All the power of assembler is that you can talk that language w/ human mnemonics and letters with all the power and variety that machine lang. has. Then why assembler should leave all the power (and often extra) of machine lang.? The optimal way to avoid those cliche or "footprints" is to use RNG to chose between them when the sizes of resulting equivalent opcodes are the same. But this isn't the case when some machine mnemonics are unreachable in assembly language itself w/o some hacks (hardcoding). The point is that every machine mnemonics should be available thru assembly lang. regardless how difficult/weird/hard/suboptimal machine mnemonics is. That's the case.
And relatively optimization - it's optional and is ON in fasm by default but why sacrifice some words (in CPU language) in size sake? Alphabet optimization? Entropy reduction? RISC?
)) a bit too much from me)
but anyway RNG in equal code generation is good (or evil to debug)?
Post 24 Sep 2009, 19:55
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 24 Sep 2009, 19:58
asmfan wrote:
This is about HLL concept you're talking about but assembler is a bit higher layer of CPU (machine) language. All the power of assembler is that you can talk that language w/ human mnemonics and letters with all the power and variety that machine lang. has. Then why assembler should leave all the power (and often extra) of machine lang.? The optimal way to avoid those cliche or "footprints" is to use RNG to chose between them when the sizes of resulting equivalent opcodes are the same. But this isn't the case when some machine mnemonics are unreachable in assembly language itself w/o some hacks (hardcoding). The point is that every machine mnemonics should be available thru assembly lang. regardless how difficult/weird/hard/suboptimal machine mnemonics is. That's the case.

So how would you like to write the instructions for 21 D8 and 23 C3 opcodes to make the different? And why would you need it?
I don't agree that is a HLL concept. This is exactly the assembly language concept in my opinion - the abstraction from machine codes into area of functionality of instructions.
Post 24 Sep 2009, 19:58
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 24 Sep 2009, 20:03
You may find much older discussion on this topic here:
http://board.flatassembler.net/topic.php?t=3866
Post 24 Sep 2009, 20:03
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 24 Sep 2009, 20:08
In some cases RNG as i said this case of instruction is exactly unreachable in their full equivalent w/ any input params. f(s, s=any) == g(m,m=any) then RNG(f, g)

but those that are not d(g, g=any) <> t(w,w=any) even if in some case must be reached directly thru asm in theory. Besides if one is subset of other even if optimal in size then the superset must be reached by asm too as covering more variety of params (imm32).
Post 24 Sep 2009, 20:08
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 24 Sep 2009, 20:12
Yeah, that one was a year before i came here)) missed it, was a funny one, he-he, "damn capitalists"(c) )))
Post 24 Sep 2009, 20:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20459
Location: In your JS exploiting you and your system
revolution 25 Sep 2009, 01:34
I have not yet seen a good use for polymorphic code. If you are writing polymorphic code then I suggest that your reasons for wanting it are not exactly saintly.

Can you show a dire need for it that is used in a good application that users desire and request?
Post 25 Sep 2009, 01:34
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 25 Sep 2009, 08:05
revolution wrote:
I have not yet seen a good use for polymorphic code. If you are writing polymorphic code then I suggest that your reasons for wanting it are not exactly saintly.

Can you show a dire need for it that is used in a good application that users desire and request?


Users request Java and not variation of encoding of the same instruction that in most case fasm allows in ia-32 (not ia-32e alas).

If you need explanation for what's happening in this thread (if you don't want to read it yourself) then see below:

regs i/o are equal in this way
f() = 21 D8
g() = 23 C3

one is subset of other and superset is unreached in some cases thru assembler.
d() = 48 81 E0 *
t() = 48 83 E0 *

And now ask yourself where is polimorphic somewhere. Also i haven't seen users on this board only hi-quality (hope) low-level programmers.
Maybe this is some kind of paranoia of you made by asm* nicks of others here?

_________________
Any offers?
Post 25 Sep 2009, 08:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20459
Location: In your JS exploiting you and your system
revolution 25 Sep 2009, 08:14
I think I got muddled with the thread that Tomasz Grysztar linked to where it talks about polymorphism.

asmfan: I don't understand your Java reference. I can't get how that relates to assembly. Are you writing a JIT compiler?
Post 25 Sep 2009, 08:14
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 25 Sep 2009, 14:27
revolution wrote:
Can you show a dire need for it that is used in a good application that users desire and request?
Intelligent code that modifies itself, some sort of AI? Laughing

But self-modifying constants is very useful, I used it myself a lot.

_________________
Previously known as The_Grey_Beast
Post 25 Sep 2009, 14:27
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 25 Sep 2009, 18:28
Java and other isn't related but is requested by users more than assembly w/ plenty of ways to encode the same instruction.
+We are talkin about different things. you ask different questions i give different answers. it's the matter of talking on different things (and not reading previous posts/discussion).
Post 25 Sep 2009, 18:28
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  Next

< 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.