To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 7456
7455  |  7457
Subject: 
RCX Firmware and SP
Newsgroups: 
lugnet.robotics, lugnet.robotics.rcx.legos, lugnet.robotics.rcx.pbforth
Date: 
Sun, 17 Oct 1999 20:40:32 GMT
Viewed: 
1818 times
  
Hi All,

After a very frustrating weekend of fiddling with pbFORTH, I caved
and asked Kekoa to help with a problem I was having with
read_sensor() and pbFORTH. The problem we (mostly he) unearthed
has to do with the SP and RCX firmware routines, so I thought
it would be appropriate to post here...

It turns out the RCX firmware isn't really clever about allocating
variables on the stack. The worst culprit in read_sensor() - it
pushes all 7 registers and then allcates 10 words of local variables.

Guess what, the RCX firmware allocates locals with something like

    14ce:       8f f0             add.b #0xf0,r7l

Which "adds" -10h to the stack....and totally blows the rollover
on the high byte of R7, the stack pointer.

My symptom was bizarre failure modes that depended on where the stack
pointer was - and it wasn't until Kekoa pointed out that the
RCX likes to have a contiguous 256 byte stack for its routines
that the problem was solved. I was able to figure out that the closer
I got to an hh00 boundary (256 bytes) the more likely things were
to fail.

So, to sum up...

1. If you are using RCX firmware routines, make sure that you have
LOTS of stack left before you wrap down to the next 256 byte
boundary - make sure the SP is aligned too.

This is most important in RTXs where each task has its own stack...

Thanks again, Kekoa.

Cheers,

Ralph Hempel - P.Eng

--------------------------------------------------------
Check out pbFORTH for LEGO Mindstorms at:
<http://www.hempeldesigngroup.com/lego/pbFORTH>
--------------------------------------------------------
Reply to:      rhempel at bmts dot com
--------------------------------------------------------



Message has 1 Reply:
  Re: RCX Firmware and SP
 
(...) [...] Hi Ralph, Could you please explain more about consequences for pbFORTH user? As far as I can see, pbFORTH uses fixed 256-byte stack - does it mean that pbFORTH suffers from this problem too? Thanks Sergey Udovenko (25 years ago, 19-Oct-99, to lugnet.robotics.rcx.pbforth)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
8 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR