flat assembler
Message board for the users of flat assembler.
Index
> Main > Getting low and high order of dword |
Author |
|
revolution 15 Jun 2014, 04:59
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"? |
|||
15 Jun 2014, 04:59 |
|
nmyo 15 Jun 2014, 05:17
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. |
|||
15 Jun 2014, 05:17 |
|
revolution 15 Jun 2014, 05:23
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. |
|||
15 Jun 2014, 05:23 |
|
gens 15 Jun 2014, 13:53
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) |
|||
15 Jun 2014, 13:53 |
|
revolution 15 Jun 2014, 14:06
gens wrote: also note most x86 cpus move 32bits to/from ram (afaik) |
|||
15 Jun 2014, 14:06 |
|
gens 15 Jun 2014, 14:30
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 |
|||
15 Jun 2014, 14:30 |
|
shutdownall 15 Jun 2014, 21:10
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] |
|||
15 Jun 2014, 21:10 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.