flat assembler
Message board for the users of flat assembler.
Index
> Main > which is faster? |
Author |
|
michalll 29 Oct 2008, 10:01
I was just wondering when I want to increase a value by two is it faster to use
Code: add ax,2 Code: inc ax inc ax ? |
|||
29 Oct 2008, 10:01 |
|
Raedwulf 29 Oct 2008, 12:13
It really depends on your processor, but I agree with revolution.
Code: inc ax inc ax means that the second inc depends on the first inc - which would mean that the processor would have to wait for the first one to complete. Of course, if the processor has some logic to detect two consecutive incs - then it would process it faster. _________________ Raedwulf |
|||
29 Oct 2008, 12:13 |
|
neville 30 Oct 2008, 02:12
IMHO any slight difference in speed, faster or slower, would be insignificant in 99.999% of applications because register operations like this are much faster than instructions which require memory R/W cycles and almost infinitely faster than most I/O operations, the latter two of which are actually going to determine the overall speed of your application.
True, the instructions have to be initially fetched from memory, twice in the first case, and once for the second (but also another memory access to get the immediate data '2') but pipelining and prefetching and caching and parallel operations make this argument all a bit meaningless. _________________ FAMOS - the first memory operating system |
|||
30 Oct 2008, 02:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.