Writing to Flash in SuperPRO, PROplus

Questions about the BASICtools and MakeItC
AMDlloydsp
Posts: 99
Joined: Mon Apr 15, 2013 3:51 pm
Location: NE Central FL

Re: Writing to Flash in SuperPRO, PROplus

Post by AMDlloydsp »

Needs to be integer, Bruce.

There was no error, only a spurious value returned in a single used as the status variable.

One more for the WRITE docs, eh?

Lloyd



basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Writing to Flash in SuperPRO, PROplus

Post by basicchip »

You really shouldn't be using singles for status bits, those are logically integers, as normally you would be doing AND and OR binary type functions on them and those operations are not defined for singles.

I doubt any language does that. Even if it did type conversions, you would lose precision, as the 32 bits would get truncated to 23 bits and an exponent added, so you could lose the lower 8 bits, if any of the upper bits were set.

AMDlloydsp
Posts: 99
Joined: Mon Apr 15, 2013 3:51 pm
Location: NE Central FL

Re: Writing to Flash in SuperPRO, PROplus

Post by AMDlloydsp »

Heh... Yeah. I wasn't, intentionally <G> The variable was incorrectly dim'd in a series of functionally-grouped variables which ALL should have been integers.

Still, if type conversion isn't being done, then the docs should show the status word as being of type integer.

Lloyd

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Writing to Flash in SuperPRO, PROplus

Post by basicchip »

This version of the compiler would flag what you did as an illegal conversion to single.

It catches the inadvertent case you site. We tend to overlook flagging possible errors, as we spend more time thinking about making proper code work.

If for some reason you wanted to convert to a single, you can always

some_integer = WRITE(&H7000, buffer, 512)
some_single = some_integer
ARMbasic.exe
trial compiler version
(133.78 KiB) Downloaded 1303 times

AMDlloydsp
Posts: 99
Joined: Mon Apr 15, 2013 3:51 pm
Location: NE Central FL

Re: Writing to Flash in SuperPRO, PROplus

Post by AMDlloydsp »

Again, thanks, Bruce.

That'll help me defend against attacks of "stupid". <G>

Oddly, I have little difficulty writing code that will work if written as designed. My problem is those niggling errors like dim'ing a whole series of variables wrong!

Lloyd

Post Reply