strings and byte arrays

Questions about the BASICtools and MakeItC
Post Reply
YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

strings and byte arrays

Post by YahooArchive »

>question from info line

Is there any place in the armite like unused registers or the rtc that
you can store data that will persist across resets?

First RAM is not kept alive by the battery backup (a design oversite
in my opinion), so there is probably limited usefulness to keeping
data through a reset, but we do it as well (its how we STOP a CPU
running BASIC, we use 0x4000011c). In BASIC on STOP we do not
initialize memory, but that is done before a program is started (all
user variables set to 0). In C its up to you, as that code is found
in crt0.S

According to the User manual the Realmonitor space is available to the
user (as we don't engage it) This space is from 0x40000040 - 0x40000120.



YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: strings and byte arrays

Post by YahooArchive »

Strings and arrays of bytes use the same data structure

DIM x(size) as string

Strings are defined as a series of bytes terminated by a 0

But you can also use strings to build byte arrays. But remember when
you build a string the 0 is important.

Say you want a byte array of 0,0,$31,$32,$33

You do this by
x(0)=0
x(1)=0
x(2)=$31...

But if you try to build it like a string

x = chr(0)+chr(0)+"123"

you will end up with just "123", because the chr(0) are empty strings,
so when you concatenate them they are lost.

you could (as is done in FREQOUT.bas

x = "11123"
x(0)=0
x(1)=0

Which replaces the first 2 bytes.

Remember that if you print x, it will terminate at the first 0.

Post Reply