DSPRelated.com
Forums

ADSP 21160 VDSP++ questions

Started by Tom Hanley January 3, 2001
Hello,
I have just started working with the SHARC DSP recently and have
mainly been using C++ through VDSP++. However, now I am trying to write
some simple mathematic tests in assembly, just to check some of the ALU
ops that I'm not sure how to check through C and to become familiar with
the assembly language used by Analog Devices. Anyway, I have reached an
impass...
I wrote a simple subtraction problem just to get the basics down.
Originally, this was much longer and more involved, however it didn't
work... so I kept trimming it down until I was left with a single ALU
operation, but the problem has not gone away...

#include "def21160.h"

.segment/DM seg_dmda;
.endseg;

.segment/PM seg_pmda;
.endseg;

.segment/PM seg_pmco;
.global _main;
_main:
f2;
f3B;
f4f2;
.endseg;

It compiles just fine, but when I go to run it through the debugger I
get an error that reads "PC Stack Underflow" I'm not entirely sure why
it is doing this, since it makes it to the end of the program just fine,
and the registers seem to have the right values in them. Also, the
program has no loops, so I don't know why it should be doing anything
that would cause it to crash. I've never seen an underflow before, so
I'm at a loss. Any ideas what I might have done wrong? I have tried
using different registers, using #define to create symbols to use, and a
few other things, but they all do the same thing when I try to run it.
Another thing I noticed is that if I change _main to anything else, it
won't compile. I get an error saying that _main is referenced by one of
the headers in the 21xx library (not the one that I am directly calling
in the program, either). The thing that confuses me about this is that
other sample files I have downloaded from various sites online have not
had this same error. Could this be a problem with how I have the linker
configured?
The platform I am using is Windows 95, VDSP++ IDE v 3.0.1.0. (I'm not
sure if that matters or not, but it probably couldn't hurt). Any advice
would be greatly appreciated.

thanks,
Tom



On Wed, 3 Jan 2001 10:15:16 -0500 (EST), Tom Hanley wrote:

> .global _main;
> _main:
> f2;
> f3B;
> f4f2;
> .endseg;

What's it supposed to do next, after the subtract? You're probably
seeing the result of the execution of the garbage in memory following
your program. Take a look at the sample programs you have and see how
they *end* a program. (I'm guessing with an RTS instruction, to return
to a monitor or to some startup code.)

Kenneth Porter
Kensington Laboratories, Inc.
mailto:
http://www.kensingtonlabs.com



One thing I notice is that there is no RTS or IDLE instruction in the _main
function. I haven't used C or C++ on the ADI parts yet, but I think there
should be one of these instructions here. RTS if _main is called by
someone, and IDLE (or some other branch) if _main was JUMPed to.

Good luck,
Pat

> -----Original Message-----
> From: Tom Hanley [mailto:]
> Sent: Wednesday, January 03, 2001 9:15 AM
> To:
> Subject: [adsp] ADSP 21160 VDSP++ questions > Hello,
> I have just started working with the SHARC DSP recently and have
> mainly been using C++ through VDSP++. However, now I am
> trying to write
> some simple mathematic tests in assembly, just to check some
> of the ALU
> ops that I'm not sure how to check through C and to become
> familiar with
> the assembly language used by Analog Devices. Anyway, I have
> reached an
> impass...
> I wrote a simple subtraction problem just to get the basics down.
> Originally, this was much longer and more involved, however it didn't
> work... so I kept trimming it down until I was left with a single ALU
> operation, but the problem has not gone away...
>
> #include "def21160.h"
>
> .segment/DM seg_dmda;
> .endseg;
>
> .segment/PM seg_pmda;
> .endseg;
>
> .segment/PM seg_pmco;
> .global _main;
> _main:
> f2;
> f3B;
> f4f2;
> .endseg;
>
> It compiles just fine, but when I go to run it through
> the debugger I
> get an error that reads "PC Stack Underflow" I'm not
> entirely sure why
> it is doing this, since it makes it to the end of the program
> just fine,
> and the registers seem to have the right values in them. Also, the
> program has no loops, so I don't know why it should be doing anything
> that would cause it to crash. I've never seen an underflow
> before, so


-----------------------------------

This message has been scanned for viruses with Trend Micro's Interscan
VirusWall.