flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution
What do you mean by "better"? What are you trying to achieve?
All of those snippets you posted appear to work fine. If they are not working for you then what is it that you want to do "better"? |
|||
![]() |
|
nmyo
By better, I mean better performance and better efficiency. I think I'm just thinking too hard on doing something simple as the above.
Also, it turns out it was bit rotation that I should avoid and not bit shift, so I think I just ended up wasting time trying to come up with something better. |
|||
![]() |
|
revolution
Why "should you avoid bit rotation"?
If you can't see the difference in your code at runtime that I'd suggest that is makes no difference which one your use. But most probably the one with the fewest instructions will be the "easiest" for the CPU to perform. But this is not always true because there are a myriad of things that are happening inside a CPU that any one instruction usually makes no perceivable difference unless you are doing some very specific task under very specific time/space constraints. |
|||
![]() |
|
gens
Code: mov eax, [location] mov [x], ax shr eax, 16 mov [y], ax PS http://www.agner.org/optimize/ the 4'th one also note most x86 cpus move 32bits to/from ram (afaik) |
|||
![]() |
|
revolution
gens wrote: also note most x86 cpus move 32bits to/from ram (afaik) |
|||
![]() |
|
gens
revolution wrote:
think i read somewhere that it was 2x32 for amd if i remember amd and intel get diff results (maybe i read it on the x264 blog, dk) oh well, can be tested |
|||
![]() |
|
shutdownall
You can also just use labels to save memory.
Code: location: .x dw 8765h .y dw 4321h mov eax,[location] mov bx, [location.x] mov cx, [location.y] or an approach like this: Code: location dd 87654321h label x word at location label y word at location+2 mov eax,[location] mov bx,[x] mov cx,[y] |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.