Register assignments, aliasing a string
Greets,
The first half or so of the code for a project I'm working on is done, but there is a piece that is giving me grief.
I need to declare a 50 character or so string. Except ... all of my registers have been assigned to other variables already. I've reach the conclusion that I need to handle register assignment myself, so I'm going to be replacing things like
watts VAR Word
with
watts VAR W3
That I'm cool with.
What I don't know is if I declare a string
outputString VAR Byte(50)
where it is going to be allocated in the registers so I don't use any of that variables registers at the same time I'm using the variable itself.
(edited to add: 50 bytes was a bad example on account of a BS2 doesn't have 50 bytes of register space, but the general question is still the same -- how is register allocation handled by the tokenizer.)
Post Edited (Julie in Texas) : 12/8/2009 11:03:01 PM GMT
The first half or so of the code for a project I'm working on is done, but there is a piece that is giving me grief.
I need to declare a 50 character or so string. Except ... all of my registers have been assigned to other variables already. I've reach the conclusion that I need to handle register assignment myself, so I'm going to be replacing things like
watts VAR Word
with
watts VAR W3
That I'm cool with.
What I don't know is if I declare a string
outputString VAR Byte(50)
where it is going to be allocated in the registers so I don't use any of that variables registers at the same time I'm using the variable itself.
(edited to add: 50 bytes was a bad example on account of a BS2 doesn't have 50 bytes of register space, but the general question is still the same -- how is register allocation handled by the tokenizer.)
Post Edited (Julie in Texas) : 12/8/2009 11:03:01 PM GMT
Comments
PBasic has a declaration for an ALIAS which allows you to specify an alternate name for a memory location or locations. If you're going to break up a word into parts, you'd declare the larger unit as a variable, then use an ALIAS for each of the pieces.
Thanks! Though I came up with a way to do it that doesn't require a string.
All of my microcontroller bad memories are coming back to me. I keep forgetting that when code space is abundant, use code. When data space is abundant, use data. And these things have preciously little data space and a relatively larger amount of code space. My program (3 channel DC current, amp-hour and and kilowatt-hour meter and data logger) is a little over 1K right now, which makes it the smallest program I've written since Jimmy Carter was president.
Seriously consider a Propeller for your next project.· It's cheaper, blazingly faster, almost as easy to use, better in some ways, etc., etc., etc.· On the other hand, the BS1 is still very useful for the right scale project.
There's likely other ways as well.
Perhaps the next go round, although I'm trying to get the firmware written so I can debug the hardware. Once I have the hardware the way I like it, I'll revisit the MCU decision. I thought I was going to have to go with a PIC no matter what, but it's starting to look like the Stamps have the bandwidth to do all the calculations.
Velocostrich,
I'm an old school programmer from way, way back. I just need to dust the cobwebs off my brain and remember all those things I tried so hard to forget. Right now I'm struggling to remember how to do 64 bit integer math in 16 unsigned bits ... (I'm cheating -- I'm doing base-1000 math and having accumulators for milliwatt-hours, watt-hours and kilowatt-hours, for example).
There's some great information to be had over at www.emesys.com/BS2index.htm -- not sure if you've seen that already.
As for 64-bits crammed into 16? Sounds like the start of a programming war-story to me [noparse]:)[/noparse]
On that note, you should read "The Story of Mel" (if you haven't seen that already, either): catb.org/jargon/html/story-of-mel.html