Problems with Keil debugger vs. Forth
  Home FAQ Contact Sign in
comp.lang.forth only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.forth Profile…
 Up
Problems with Keil debugger vs. Forth         


Author: rickman
Date: Jan 29, 2007 10:19

I am working on an entry for the Luminary Micro Stellaris design
contest. The contest rules require you to use the the Keil tools that
come with the LM eval board. This limits the entries to C programs.
I started with a Forth program and converted it to C. This went
without too much trouble and the conversion was fairly easy. I did
find it a bit harder to debug under C using a standard debugger, but
there were not many issues that could not be resolved without too much
pain. Mainly it was a lot easier in Forth to test each word or
routine separately rather than as part of a whole. The C debug tools
just don't make it easy to test routines separately.

The real trouble began when I started writing new code in C that was
somewhat real time. As I used the debugger it became apparent that
this was not going to be so easy. Since the routines had to be tested
as part of the whole, I had to let the interrupts run, so I was never
too sure of the state of the environment while I was debugging.
Still, I didn't have any major problems until I noticed something
odd.

I was using the "Locals" watch window for most of the variables since
this was automatic. But once in awhile some of the local variables
would seem to take on absurd values. I could not find anything...
Show full article (3.36Kb)
4 Comments
Re: Problems with Keil debugger vs. Forth         


Author: Jim Granville
Date: Jan 29, 2007 11:17

rickman wrote:
>
> I was using the "Locals" watch window for most of the variables since
> this was automatic. But once in awhile some of the local variables
> would seem to take on absurd values. I could not find anything in my
> code that was doing it. I dug into the disassembly listing and found
> that local variables and the parameter passing was being done in
> registers rather than on the stack. So when another routine was
> called, the variables were moved to other registers to free up the
> standard parameter regs.

That sounds inefficent..
Show full article (2.44Kb)
no comments
Re: Problems with Keil debugger vs. Forth         


Author: Paul Gotch
Date: Jan 29, 2007 15:36

rickman gmail.com> wrote:
> code that was doing it. I dug into the disassembly listing and found
> that local variables and the parameter passing was being done in
> registers rather than on the stack.

This is completely normal. The procedure call standard actually specifies
that argument/result/scratch registers.

On something like x86 usually everything goes via the stack however most
major procedure call standards for it also allow passing arguments via
registers. MS call this FASTCALL and it doesn't really have name under GCC
but is just attribute which can be applied to a function via a GCC language
extension.
> So when another routine was
> called, the variables were moved to other registers to free up the
> standard parameter regs. At this point the debugger would lose track
> and report the new value in the old register as the variable that had
> been moved to the new register.
Show full article (2.77Kb)
no comments
Re: Problems with Keil debugger vs. Forth         


Author: John Passaniti
Date: Jan 29, 2007 15:58

(rickman wrote:
> I am working on an entry for the Luminary Micro Stellaris design
> contest. The contest rules require you to use the the Keil tools that
> come with the LM eval board. This limits the entries to C programs.

Of course, you could implement a Forth in C...
> I started with a Forth program and converted it to C. This went
> without too much trouble and the conversion was fairly easy. I did
> find it a bit harder to debug under C using a standard debugger, but
> there were not many issues that could not be resolved without too much
> pain. Mainly it was a lot easier in Forth to test each word or
> routine separately rather than as part of a whole. The C debug tools
> just don't make it easy to test routines separately.

I don't know what debugger you use, but what I typically do in my C
development is to create a Forth-like shell where every C function is
exposed. So if I had a function like this:

int subtract(int x, int y) { return x - y; }

I could interactively test it from my shell like this:

1 2 subtract .
Show full article (5.08Kb)
1 Comment
Re: Problems with Keil debugger vs. Forth         


Author: rickman
Date: Jan 30, 2007 05:57

On Jan 29, 6:58 pm, John Passaniti JapanIsShinto.com> wrote:
>> I dug into the disassembly listing and found
>> that local variables and the parameter passing was being done in
>> registers rather than on the stack.
>
> That's not unusual for small micros. Several of the 8-bit C compilers
> I've used use registers to pass arguments to and from functions.
> Normally, this is a win in terms of performance, since pushing and
> popping arguments off the stack is usually slower. I've also seen C
> compilers that use "compiled stack" techniques, where a call-graph
> determines the lifetime of functions and allows a stack to be replaced
> with absolute RAM locations.

I understand what they are doing and why. But they don't communicate
this info to the debugger for the watch window!
Show full article (5.92Kb)
no comments