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 |
|
gunblade 11 Apr 2012, 11:53
edfed wrote: lol, MPLAYER is a useless application since there are many open source and better media players. Em - pretty sure he meant mplayer as in.. http://www.mplayerhq.hu/design7/news.html .. as in, the open source movie player (and encoder (mencoder)), based on ffmpeg (also open source). |
|||
11 Apr 2012, 11:53 |
|
16bitPM 21 Sep 2012, 14:38
OK,
I'm wondering about the following instructions, which exist in one form since the 8088 era, but I don't really see how it can be put to use. I also can't find any code examples: RCL mem/reg,CL (CL >1) (8086+) RCR mem/reg,CL (CL >1) (8086+) RCL mem/reg,imm (imm >1) (80186+) RCR mem/reg,imm (imm >1) (80186+) Of course we all know the multi-action ROR/ROL/SHL/SHR/SAR instructions, but other than for euhm... esthetic (?) reasons why would anyone want a multibit shift through the carry flag (i.e. 9,17 or 33 bit shift)?? I you have a proper use: tell me! |
|||
21 Sep 2012, 14:38 |
|
LocoDelAssembly 21 Sep 2012, 15:40
This is just an example, if something like this is ever used somewhere I don't know:
Code: ; AL will hold status flags of several conditions xor al, al cmp [something], MAX_VAL + 1 rcl al, 1 ; Set to one if MAX_VAL was not exceeded sub [counter], 1 sbb dl, dl rcl al, 1 ; Set to one if counter reached zero and dl, VALUE or [counter], dl mov dl, [bits] shr dl, BIT_TO_COPY + 1 ; BIT_TO_COPY < 7 rcl al, 1 ; Copy bit to AL |
|||
21 Sep 2012, 15:40 |
|
JohnFound 21 Sep 2012, 16:02
Rotate through carry is used when you need to shift whole array. Something like this:
Code: mov ecx, count_of_dword_array mov esi, array bt dword [esi+4*ecx-4], 31 rotate_left: rcl dword [esi], 1 add esi, 4 loop rotate_left mov ecx, count_of_dword_array mov esi, array bt dword [esi], 0 rotate_right: rcr dword [esi+4*ecx], 1 loop rotate_right |
|||
21 Sep 2012, 16:02 |
|
revolution 22 Sep 2012, 00:44
16bitPM: It seems nobody understood that you meant a rotation count of more than one.
Hehe, LocoDelAssembly and JohnFound both made the same mistake. |
|||
22 Sep 2012, 00:44 |
|
LocoDelAssembly 22 Sep 2012, 03:42
mmmh, odd, didn't see those ">1", the post was edited before I published perhaps?? Anyway, my example is still kinda valid, for instance, if the least significant bits must be zero then you use a value greater than one for the last RCL.
|
|||
22 Sep 2012, 03:42 |
|
16bitPM 22 Sep 2012, 09:44
Weird, yes
But indeed I meant: counts greater than 1: RCR ax,4 or mov cl,6 / rcl bx,cl , ... |
|||
22 Sep 2012, 09:44 |
|
16bitPM 14 Jul 2015, 11:19
Well it appears I finally found an example. It comes from the infamous 256-byte demo "Lattice":
Code: TEXTURE mov bx,cx rcl dh,cl ; <--- THIS IS THE ONE mov ah,dh sar ah,3 adc al,ah adc al,[es:bx+128] shr al,1 mov [es:bx],al not bh mov [es:bx],al loop TEXTURE As you can see, the value of cl iterates 256 times through all values of 0x0 to 0xff. Interesting case. Genious piece of code. If anyone understands how it works, let me know |
|||
14 Jul 2015, 11:19 |
|
PeExecutable 14 Jul 2015, 15:28
It's not a question of assembly, it's a question of algorithm and in that case there are never an easy answer, other than to study it throughoutly. The instructions are easy to reverse, they are straight forward.
It wouldn't surprise me if some guy out there optimized the texture loading routine, because the loading phase of textures are never critical, and most assembly coders focus 100% on pieces of code that doesn't need speed. Some asm programmers optimize one corn of sand, others optimize buckets of sand. When you ask a guy why he optimizes that corn of sand, he'll tell you because if you didn't it wouldn't be fast enough. If you try to explain to him that he is the most irrational person on the entire planet, he won't believe you. |
|||
14 Jul 2015, 15:28 |
|
PeExecutable 14 Jul 2015, 15:37
16bitPM wrote: Well it appears I finally found an example. It comes from the infamous 256-byte demo "Lattice": I fixed the code to include a space character between the instruction and the operands to make it more readable. (Of course, most assembly programmers want to have it in the most unreadable form that they can produce, because thats what rationality is to them (When heaven come falling down on your head, and you become rational some day....) I replaced the comment "This is the one" with "here", because we're not stupid. And fuck that arrow. Also, the code is not ingenious if you can't understand it, it just means you're not as brilliant as you thought you were. Other than that, assembly is beautiful, it's a beautiful piece of code huh It's a trick, to dedicate so much time to make 1 inch of code that beautiful requires that you make 100 miles of the rest of your code very ugly, he is tricking you, and don't fall for that. He is thinking about his image, not about his code. |
|||
14 Jul 2015, 15:37 |
|
Devel99 29 Nov 2015, 06:14
DAA, AAA and all BCD family
|
|||
29 Nov 2015, 06:14 |
|
Devel99 29 Nov 2015, 06:21
cod3b453 wrote: , it is the only instruction that can directly read rip (lea rax,[rip]), which is very useful when dealing with position independent code. you can use call instead: Code: call_base_address: call 0 pop eax/rax (E/R)ax = call_base_address |
|||
29 Nov 2015, 06:21 |
|
ACP 29 Nov 2015, 10:33
As for call/pop pair please note that this operation requires stack which may not be available under some circumstances. BIOS/UEFI/firmware code in memory preinitialization phase comes to mind immediately but there are other examples as well.
The BCD family is quite useful for shellcode developers but in reality you can call almost every instruction useless/pointless in CISC world if you take a look at some of ARM cores which are missing divide instruction for example. BCD has its place and there was a reason why Intel decided to implement instrucitons for it so long ago. I suggest reading a nice Wikipedia article about BCD usage: https://en.wikipedia.org/wiki/Binary-coded_decimal |
|||
29 Nov 2015, 10:33 |
|
l4m2 16 Dec 2015, 16:00
What about LEA EAX, [0*4+EBX] which can be replaced with LEA EAX, [0*1+EBX] ?
|
|||
16 Dec 2015, 16:00 |
|
revolution 16 Dec 2015, 23:02
l4m2 wrote: What about LEA EAX, [0*4+EBX] which can be replaced with LEA EAX, [0*1+EBX] ? But I don't see much that is useless about that instruction. There are many cases where moving a value from one register to another is useful. |
|||
16 Dec 2015, 23:02 |
|
nkeck72 21 Dec 2015, 17:56
The most useless instruction ever: NOP.
|
|||
21 Dec 2015, 17:56 |
|
AsmGuru62 21 Dec 2015, 20:24
It is used for alignment of code.
|
|||
21 Dec 2015, 20:24 |
|
shutdownall 02 Jan 2016, 12:08
revolution wrote: But I don't see much that is useless about that instruction. There are many cases where moving a value from one register to another is useful. What about mov eax,eax ? |
|||
02 Jan 2016, 12:08 |
|
AsmGuru62 02 Jan 2016, 16:08
"...from one register to another...".
|
|||
02 Jan 2016, 16:08 |
|
Goto page Previous 1, 2, 3, 4, 5, 6, 7 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.