flat assembler
Message board for the users of flat assembler.

Index > Main > The most useless instruction

Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
Author
Thread Post new topic Reply to topic
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek
The most rarely used instruction in Windows, I believe is int
Post 31 Mar 2012, 12:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
bzdashek wrote:
The most rarely used instruction in Windows, I believe is int
Which version are you referring to? int 0x2e is a very commonly used instruction in many Windows systems.
Post 31 Mar 2012, 14:26
View user's profile Send private message Visit poster's website Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek
What I meant is that interrupts are not used in Windows env as often as in for example DOS.

Also, could you please provide some code or link for educational purposes ? I just haven't seen using int in any examples I put my hands on.
Post 31 Mar 2012, 14:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
bzdashek wrote:
What I meant is that interrupts are not used in Windows env as often as in for example DOS.
How do you know that? Windows just hides int behind an API. Although some newer versions of Windows now use syscall/sysenter.
Post 31 Mar 2012, 14:58
View user's profile Send private message Visit poster's website Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek
revolution wrote:
Windows just hides int behind an API.

I don't argue with that. I was writing about the user-level applications, there you won't see much int calls, would you?
Post 31 Mar 2012, 15:21
View user's profile Send private message Reply with quote
gunblade



Joined: 19 Feb 2004
Posts: 209
gunblade
bzdashek: int is VERY common in 32-bit linux (and other *nix) assembly, as that is the way you call syscalls. It has now changed in 64-bit to the instruction "syscall", however up until very recently (and still, for people who are doing 32-bit applications in linux in assembly (i know theres not that many of us.. but still Smile)) it was one of the most used instructions (maybe an exageration, but it was at least once in every program, since you need it to call the system's exit() syscall in order to exit properly (similar to windows' ExitProcess).

To be fair - you did say "in windows".. so yeah.. but just wanted to point that out anyway.. Very Happy
Post 02 Apr 2012, 12:57
View user's profile Send private message Reply with quote
El Tangas



Joined: 11 Oct 2003
Posts: 120
Location: Sunset Empire
El Tangas
I think xlat is quite useless.
Post 07 Apr 2012, 18:08
View user's profile Send private message Reply with quote
16bitPM



Joined: 08 Jul 2011
Posts: 28
16bitPM
El Tangas wrote:
I think xlat is quite useless.


If I'm not mistaken it's used in the FLAT assembler Wink
It's not a useless instructiion. It doesn't quite follow the "go RISC" ideology but hell, who cares anyway since they now decided to include all sorts of extremely high-level/task-specific instructions in the processors (AES, for example).

Shorter is still often better by the way. More efficient use of cache and prefetch queue, but also the fact that modern processors can do other stuff while the slow instruction is executing. So overall, using extremely speed-optimized code all the time may actually slow things down.
My rule #1: go for size without going out of the way, then optimize really critical sections for speed.
Post 07 Apr 2012, 19:50
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
I use xlat (which has to be xlatb for FASM Wink ).
It's advantage is to easy convert with conversion table without using too much registers.
In fact it is very powerful.

Code:
lodsb
xlatb
stosb
    


is easy to transfer data form A to B with conversion of a table.

How else would you do this ?

It's equivalent is

mov al,[ebx+al]

but this instruction is not possible.
If edi and esi are in use it is a perfect and powerful instruction.
Only one byte size and really fast execution.
Post 07 Apr 2012, 20:23
View user's profile Send private message Send e-mail Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
Really strange is XBTS which was later removed from Intel because it was mainly useless. Laughing

XBTS op1,op2,op3,op4
(extract bit string)

Now it throws in invalid exception if it is not running on 80386.
Post 07 Apr 2012, 20:27
View user's profile Send private message Send e-mail Reply with quote
16bitPM



Joined: 08 Jul 2011
Posts: 28
16bitPM
shutdownall wrote:
Really strange is XBTS which was later removed from Intel because it was mainly useless. Laughing

XBTS op1,op2,op3,op4
(extract bit string)

Now it throws in invalid exception if it is not running on 80386.


Actually it's only recognized on very early 80386 CPU's (before the ΣΣ mark).
Post 07 Apr 2012, 20:56
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
shutdownall wrote:
I use xlat (which has to be xlatb for FASM Wink ).
It does not really have to be the short form, unless you mean that it has to be XLATB if you don't want to write an operand.

It is used at least 15 times in fasm sources, though never in the XLATB form - this is because in early versions the same source code was assembled either into 16-bit or 32-bit code depending on version, so fully qualified form had to be written to ensure that EBX is always used for addressing. The same thing with instructions like LODS, MOVS, etc.
Post 08 Apr 2012, 07:18
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
shutdownall wrote:

It's equivalent is

mov al,[ebx+al]



it's more like this:
Code:
movzx eax,al
mov al,[ebx+eax]
    


ones you got this pattern, you can use any registers to do the xlat thing.

but xlat is xlat and is cool to use since it's a specialized case of this two instructions snippet, and it kepps the eax upper bytes unchanged.

most useless instruction would be the amd 3Dnow sub-instruction set.
Post 08 Apr 2012, 09:26
View user's profile Send private message Visit poster's website Reply with quote
16bitPM



Joined: 08 Jul 2011
Posts: 28
16bitPM
edfed wrote:
most useless instruction would be the amd 3Dnow sub-instruction set.


Why?? It's used in MPLAYER.
Post 08 Apr 2012, 17:13
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
edfed wrote:
ones you got this pattern, you can use any registers to do the xlat thing.

Okay but this coding uses 8 bytes in output file instead of only one and don't ask about execution time. Even with many pipelines which speed up xlat same way and doesn't fill the L1 cache too much.

Nowheredays people don't think to much about code size or execution time. Rolling Eyes
Post 08 Apr 2012, 17:26
View user's profile Send private message Send e-mail Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
Tomasz Grysztar wrote:
unless you mean that it has to be XLATB if you don't want to write an operand.


Can you give an example with operand ?
As found in a manual, operand can be only a segment register to overwrite default segment register of bx (or ebx).
I tried many examples and didn't get any to be accepted.
And in FASMW.ASM you use same only simple form "xlatb" (6 times).
Post 08 Apr 2012, 17:29
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
shutdownall wrote:
And in FASMW.ASM you use same only simple form "xlatb" (6 times).
I did mean the fasm's core code (for instance PREPROCE.INC). The FASMW.ASM is a Win32 specific interface, so there I did not have to follow the rules I mentioned, since that source is always assembled in 32-bit PE context (so "xlatb" will always be equal to "xlat [ebx]").

Manual gives examples for LODS/MOVSB/etc. instructions, XLAT syntax is defined later in document and is analogous. As the manual states, it takes memory operand, with only BX/EBX and possibly segment prefix allowed (also RBX in long mode, but that is covered by a later section).
Post 08 Apr 2012, 18:43
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
16bitPM wrote:
edfed wrote:
most useless instruction would be the amd 3Dnow sub-instruction set.


Why?? It's used in MPLAYER.


lol, MPLAYER is a useless application since there are many open source and better media players.


for the 8 bytes vs 1 byte, it is sure, really sure that the two instruction pattern is less preferable than the one instruction xlat, and that's why intel implemented xlat and all other complex instructions. string operations for example are good example of complex instructions that can be made with reduced instructions.
Post 08 Apr 2012, 18:47
View user's profile Send private message Visit poster's website Reply with quote
16bitPM



Joined: 08 Jul 2011
Posts: 28
16bitPM
edfed wrote:
lol, MPLAYER is a useless application since there are many open source and better media players.


MPLAYER is considered by many to be THE best media player... Especially with modern skins!


Quote:
for the 8 bytes vs 1 byte, it is sure, really sure that the two instruction pattern is less preferable than the one instruction xlat, and that's why intel implemented xlat and all other complex instructions. string operations for example are good example of complex instructions that can be made with reduced instructions.


Absolutely not. Those instructions were introduced in the 8086/8088. In later manuals (i.e. 80486 and especially Pentium and above), Intel recommended NOT to use those and many other instructions in speed-critical sections. Regardless of Intels recommendations however, it's often observed that tight code is still better.
It's a matter of choice really, or better: cautiously choosing which sections you can optimize further for speed.
Post 09 Apr 2012, 10:48
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
Tomasz Grysztar wrote:
(so "xlatb" will always be equal to "xlat [ebx]").

Okay - I didn't expect to be used as memory referencing.
Thought "xlat bx" or "xlat ebx" to be used. Wink
Post 09 Apr 2012, 18:01
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6, 7  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-2020, Tomasz Grysztar.

Powered by rwasa.