flat assembler
Message board for the users of flat assembler.
Index
> Main > `mov al, 1` vs `or al, 1` which is faster? |
Author |
|
tf2_coolguy0000 06 Nov 2022, 00:31
`mov al, 1` vs `or al, 1` which is faster?
|
|||
06 Nov 2022, 00:31 |
|
AsmGuru62 06 Nov 2022, 13:04
They are same if AL=0.
|
|||
06 Nov 2022, 13:04 |
|
revolution 06 Nov 2022, 13:12
AsmGuru62 wrote: They are same if AL=0. BTW: Having the previous value of AL = 1 also works. |
|||
06 Nov 2022, 13:12 |
|
bitRAKE 06 Nov 2022, 14:14
Code: SALC ; D6 ; if CF=1 and not 64-bit. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
06 Nov 2022, 14:14 |
|
Furs 06 Nov 2022, 19:35
tf2_coolguy0000 wrote: `mov al, 1` vs `or al, 1` which is faster? It might not always be faster, but it is objectively better, as long as it does the same thing (which I'm assuming you know it does in your specific case, since you're asking). It's also the same amount of bytes to encode: 2. |
|||
06 Nov 2022, 19:35 |
|
edfed 06 Nov 2022, 22:39
maybe the "faster" aspect of the question is not only related to the "time needed to execute the instruction", but also, "what amount of circuitry is needed to execute the instruction". means that in an extremely RISC system, the question is relevant cause to mov something, you just point to register, and store immediate value. and for a OR, the CPU should point to register, load the register, OR immediate, store in FLAGS and store in register.
but the time spended to ask this question, you missed a lot of fun in your real life... |
|||
06 Nov 2022, 22:39 |
|
revolution 06 Nov 2022, 23:49
Furs wrote: mov al, 1` because it renames the register and has no input dependency on its previous value. Both instructions use previous bits of RAX. Both instructions rename. No difference there. Only one instruction updates the FLAGS. So MOV might be more efficient with power usage. Measure it in your system to see if there is a difference. If the OP wants a guess, I suspect there will be no measurable difference in execution time in any code or in any CPU. These low level instructions are done in the core of the ALU and are practically identical with regard to how they pass through the execution stages. |
|||
06 Nov 2022, 23:49 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.