counter help
Archiver
Posts: 46,084
Another way to skin the cat:
y var word
x var byte
' 0 to 999,999 as xxy,yyy
loop:
x = y + 1 / 10000 + x // 100
y = y + 1 // 10000
GOTO loop
Haven't tried it, but it ought to be pretty close to right. First
instruction should increment x if y would roll over to next 10,000,
then automatically roll x over to 0 as needed. Second statement
adds 1 to y and rolls y over to 0 if appropriate.
See the WRITE statement in the manual to see how to store in
eeprom--pretty straightforward.
Steve
On 30 Mar 01 at 0:29, aconti@n... wrote:
> can somone help me make a counter for the BS2 that can do 0 to
> 999,999 then restart at 0 to start all over again also how could i
> write the counter to the eeprom?
y var word
x var byte
' 0 to 999,999 as xxy,yyy
loop:
x = y + 1 / 10000 + x // 100
y = y + 1 // 10000
GOTO loop
Haven't tried it, but it ought to be pretty close to right. First
instruction should increment x if y would roll over to next 10,000,
then automatically roll x over to 0 as needed. Second statement
adds 1 to y and rolls y over to 0 if appropriate.
See the WRITE statement in the manual to see how to store in
eeprom--pretty straightforward.
Steve
On 30 Mar 01 at 0:29, aconti@n... wrote:
> can somone help me make a counter for the BS2 that can do 0 to
> 999,999 then restart at 0 to start all over again also how could i
> write the counter to the eeprom?
Comments
999,999 then restart at 0 to start all over again also how could i
write the counter to the eeprom?
thanks
tony
aconti@neo.rr.com writes:
999,999 then restart at 0 to start all over again also how could i
write the counter to the eeprom?
The Stamp can't hold numbers that big in a single variable. ·You could do
something like this though:
thous VAR Word
huns VAR Word
Top:
·DEBUG Home,DEC thous,DEC3 huns
·huns = huns + 1
·IF (huns < 999) THEN Top
·huns = 0
·thous = thous + 1
·IF (thous < 999) THEN Top
·thous = 0
·GOTO Top
[/font]