Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/03/04 08:26
Read: times


 
#61817 - Fastest 16bit INC/DEC
I'm thinking about fastest way to increment or decrement a 16 bit number - preferably just residing at some general memory location, but if you have some effective way of dealing with this in R0-R7 or some other place, that would be quite acceptable too. (note I need that in two locations, so INC DPTR by itself won't really do.)

It's so bad that INC/DEC doesn't set Carry.
What I came up with:

Inc16:
INC LOW
CLR A
CJNE A,LOW,L1
INC HI
L1: (...)

Dec16:
DEC LOW
MOV A,#0FFh
CJNE A,LOW,L2
DEC HI
L2: (...)

These are 4-5 cycles long, but maybe you can think of something faster?

List of 10 messages in thread
TopicAuthorDate
Fastest 16bit INC/DEC            01/01/70 00:00      
   RE: Fastest 16bit INC/DEC            01/01/70 00:00      
      RE: Fastest 16bit INC/DEC            01/01/70 00:00      
         RE: Fastest 16bit INC/DEC            01/01/70 00:00      
            RE: Fastest 16bit INC/DEC            01/01/70 00:00      
               RE: Fastest 16bit INC/DEC            01/01/70 00:00      
                  RE: Fastest 16bit INC/DEC            01/01/70 00:00      
                     RE: Fastest 16bit INC/DEC            01/01/70 00:00      
                        RE: Fastest 16bit INC/DEC            01/01/70 00:00      
   RE: Fastest 16bit INC/DEC            01/01/70 00:00      

Back to Subject List