flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2, 3, 4, 5, 6, 7 Next |
Author |
|
gunblade
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). |
|||
![]() |
|
16bitPM
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! |
|||
![]() |
|
LocoDelAssembly
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 |
|||
![]() |
|
JohnFound
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 |
|||
![]() |
|
revolution
16bitPM: It seems nobody understood that you meant a rotation count of more than one.
Hehe, LocoDelAssembly and JohnFound both made the same mistake. ![]() |
|||
![]() |
|
LocoDelAssembly
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.
|
|||
![]() |
|
16bitPM
Weird, yes
![]() But indeed I meant: counts greater than 1: RCR ax,4 or mov cl,6 / rcl bx,cl , ... |
|||
![]() |
|
16bitPM
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 ![]() |
|||
![]() |
|
PeExecutable
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. |
|||
![]() |
|
PeExecutable
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. |
|||
![]() |
|
Devel99
DAA, AAA and all BCD family
|
|||
![]() |
|
Devel99
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 |
|||
![]() |
|
ACP
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 ![]() |
|||
![]() |
|
l4m2
What about LEA EAX, [0*4+EBX] which can be replaced with LEA EAX, [0*1+EBX] ?
|
|||
![]() |
|
revolution
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. ![]() |
|||
![]() |
|
nkeck72
The most useless instruction ever: NOP.
|
|||
![]() |
|
AsmGuru62
It is used for alignment of code.
![]() |
|||
![]() |
|
shutdownall
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 ? ![]() |
|||
![]() |
|
AsmGuru62
"...from one register to another...".
|
|||
![]() |
|
Goto page Previous 1, 2, 3, 4, 5, 6, 7 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.