PDA

View Full Version : Fastest way to clear array



Pic2008
- 20th March 2010, 01:51
Due to time limitation, what is the fastest way to clear an array without using "For ...next" loop?

Any idea?

Darrel Taylor
- 20th March 2010, 04:32
what is the fastest way to clear an array without using "For ...next" loop?


CLEAR
But then, that clears everything.

The fastest way really depends on the PIC, and the array size.
Using FSR's will always be fastest.

But this one's really easy with PBP 2.60 (fast too).

ArraySize CON 64
MyArray VAR BYTE[ArraySize]

ARRAYWRITE MyArray,[REP 0\ArraySize]

Pic2008
- 21st March 2010, 00:59
"Clear" means clear all variables in the RAM, or does it clear the register to the default state also eg TRISA, PORTB etc?

Darrel Taylor
- 21st March 2010, 01:10
Only the GP RAM, and all of it.
<br>