Primes (Data Abort) Example Project
Copyright (C) ARM Limited 1999-2003. All rights reserved.

* Introduction

This program is for demonstrating Trace support. The 
program calculates the nth prime number. 
However, as given, it fails with a "Data Abort" error 
at runtime.

* Setting Up

This program should run on any ARM core with an ETM.  
Build the project and load the primes.axf image into the target.

Because of the way this demonstration causes the system
to abort, it may not always abort.  For instance it will
not abort on an ARMulator.

It is worth remembering how much RAM is available to you
when running this program.  The program sets a limit
of the 10000th prime number, but that does not guarantee
that you have enough RAM to calculate that far.


*** Don't read this until after trying the example ***

* Where is the error?

The error is in the way the answer is passed back from 
the calculation function.  The main program expects an 
address, which it places in a pointer, and then uses it
for outputting.  However the calculation function is
passing a number not an address.  This essentially means
the system tries to access memory location -1.

To make the program fit the example, some things have 
had to be fixed slightly.  The vector is initialized 
to one space more than needed, and with all elements 
set to -1. 

The calculation function then conveniently passes the 
one unused element back by 'accident'.  


* How to fix the program?

To get the program to work, you need to stop using 
'answer' in the main program as a pointer.  Instead,
set it as a normal int.

You also need to change the element the calculation 
passes back.

Presently Reads:
---------------
int* answer;
answer = (int*)CalculatePrimes(********);
OutputResults(*answer, prime, Time);

return prime_numbers[goal];

Should Read:
------------
int answer;
answer = CalculatePrimes(********);
OutputResults(answer, prime, Time);

return prime_numbers[goal--];

