PDA

View Full Version : 32 bit counter



Charles Linquis
- 18th December 2007, 23:57
I use the following assembly routine whenever I need a 16 bit counter

infsnz var
incf var + 1

but now I need a 32 bit counter (in assembly).
Apparently, I'm not smart enough to figure it out for myself.

Can someone please show me how to implement my 32 bit counter?

mister_e
- 19th December 2007, 02:52
almost the same, but you'll need Var+2 and var +3

Maybe some stuff could be extracted from
http://www.piclist.com/techref/microchip/math/frtomath32.asm
http://www.piclist.com/techref/microchip/math/32bmath-ph.htm

Charles Linquis
- 19th December 2007, 03:30
It appears that the best routine would be

count32

incfsz var
bra doneproc
incfsz var + 1
bra doneproc
incfsz var + 2
bra doneproc
incf var + 3
bnc doneproc
bsf eflag,0


doneproc



but I can't test it tonight. Can anyone find anything wrong with this?

mister_e
- 19th December 2007, 03:38
This has to work... hey that was easier than you thought right?

EDIT it runs smooth on MPSIM... :eek: well for that i may trust MPSIM ;)

Charles Linquis
- 19th December 2007, 15:10
I tried it this morning. It works. The technique works with any number of bits.