Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Ads

Discussion Groups

Discussion Groups | BasicX | Re: Persistent var will not increment

Discussion forum for the BasicX family of microcontroller chips.

Persistent var will not increment - Tom Becker - Sep 21 16:03:00 2005

Given:
dim iY as integer, iAltitude as new persistentinteger

'this increments iAltitude:

iY = iAltitude + 1
iAltitude = iY

'this does not:
iAltitude = iAltitude + 1 Is this a bug or an esoteric detail of the parsing of the line? Tom




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: Persistent var will not increment - Mike Perks - Sep 21 16:29:00 2005

Tom Becker wrote:

> Given:
> dim iY as integer, iAltitude as new persistentinteger
>
> 'this increments iAltitude:
>
> iY = iAltitude + 1
> iAltitude = iY
>
> 'this does not:
> iAltitude = iAltitude + 1 > Is this a bug or an esoteric detail of the parsing of the line?
>
It's a compiler bug and a nasty one at that. Here is what I found using
bxDism - see below for the link to download and use this amazing tool :)

In the first example, the persistent variable iAltitude is loaded from
persistent memory address 32, incremented and stored. The stack variable
iY is loaded and stored into the persistent memory address 32. Here is
the BasicX code (from bxDism):
73 20 00 pushI test.ialtitude ' (32) [persistent]
0f incI
69 ec 00 popI test.iy ' (236)
61 ec 00 pushI test.iy ' (236)
77 20 00 popI test.ialtitude ' (32) [persistent]

In the second case, the BasicX code that is generated is:
79 20 00 incI 32

This code increments absolute address 32 which is a) incorrect and b)
can lead to some nasty side effects if the wrong address is changed at
the wrong time.

Mike
http://home.austin.rr.com/perks/basicx/bxDism/





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Persistent var will not increment - Tom Becker - Sep 21 16:40:00 2005

> In the second case, the BasicX code that is generated is:
> 79 20 00 incI 32

Nice tool, Mike. Thanks. Tom





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Persistent var will not increment - bartcraytor - Sep 24 11:12:00 2005

There is a BUG in the persistant variables. Seems like I recall the
necessity of having to program a delay after incrementing or one of the
other steps.




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Persistent var will not increment - Don Kinzer - Sep 24 20:06:00 2005

--- In basicx@basi..., "bartcraytor" <bartcraytor@y...> wrote:
> Seems like I recall the necessity of having to program a delay
> after incrementing or one of the other steps.

According to the manual, on the BX-01 you need provide at least 4ms of
delay between writing a persistent variable and a subsequent read of
that same variable. It clearly states, however that this does not
apply to the BX-24 and BX-35.

The problem originally described by Tom was shown by Mike to be a code
generation error in the compiler.

Don




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )