This lab is based on the ARM Windows Toolkit
Workbook. It will introduce you to the
ARM Windows Toolkit.
The ARM
Project Manager
The ARM Project Manager (APM) takes
over the operations of armmake
and provides transparent use of armcc, armasm, armlib and armlink. Instead of makefiles, the
APM has the concept of projects, where a project contains a list of the source
files that make up your program, and all of the options that are required to
create an image or library.
The ARM
Debugger for Windows
The ARM Debugger for Windows (ADW)
provides a simple point-and-click interface onto the ARM Debugger ToolBox (also used by armsd). It
provides a visual representation of the program being debugged, and allows a
user to start working on the debugging task immediately without the need to
learn many complex commands.
The
Example
This introductory example first
makes use of the APM to build an
image from some source files. Any compilation errors reported will then be
removed using the built-in editor. Finally ADW
will be used to remove any logic errors that may have crept into the program.
Thus while the example is very simple it highlights some important aspects of
the ARM Windows Toolkit and software development in general.
The example requires two components
to be built: A library (LIB.APJ) and the final image (EXAMPLE1.APJ) which will
make use of the library.

Before you begin, you should create the following folders in your classwork directory:
cs221\work\wwb\intro => syntax when working in MS/dos environment
cs221/work/wwb/intro => syntax when working in linux or unix environment
Note: A folder and a directory perform the same function, they are both a means of organizing files in a
tree-like structure. Each folder or directory
is a location in which to store information.
Given a specific directory, you can store files and other folders or
directories within it. Visual user
interfaces such as that found on a Mac or Windows, refer to these locations as
folders, while other interfaces (such as those which are primarily textual)
refer to these locations as directories.

Creating MYLIB.APJ
1. Start the
ARM Project Manager by double-clicking on the ARM Project Manager icon in the
Program Manager or single-click from the Start menu on Windows.
2. Choose
File->New from the menu. Enter the following ‘C’ function:
/* mylib.c
*/
#include <stdio.h>
#include "mylib.h"
void
print (char* szText)
{
printf("Print
Lib: %s\n", szText);
}
3. Choose File->Save as from the menu.
Move through the directory structure
to: E:CLASSWORK\WORK\WWB\intro
and enter
the filename: MYLIB.C
Choose ‘OK’ to
overwrite (if necessary).
4. Repeat step 2 for the following
file:
/*
mylib.h */
#ifndef _MYLIB_H
#define
_MYLIB_H
void print(char * szText);
#endif
Save this file as mylib.h in E:\CLASSWORK\WORK\WWB\intro.
5. Choose Project->New from the menu.
Enter the name: E:\CLASSWORK\WORK\WWB\intro\MYLIB.APJ
Choose ‘OK’ to
overwrite (if necessary).
6. Press the ‘Add...’ button in the Edit
Project Dialog that should now be displayed.
Double-click on ‘MYLIB.C’
Choose ‘OK’ in the Edit Project
Dialog.
7. Select ‘Yes’ to re-display the project
summary
8. Select Options->Project from the
menu.
9. Use the drop-down list next to ‘Project
Type:’ to select ARM Object Library Format.
10. Choose OK.
11. Press the Rebuild-All button on the
Toolbar (use the ToolTips to find it!).
The project should build with the
following messages:
Building...
ARMCC E:\CLASSWORK\WORK\WWB\intro\LIB.C
Creating Library (E:\CLASSWORK\WORK\WWB\intro\LIB.32L)
...
Build Complete.
Creating EXAMPLE1.APJ
1. Choose Project->New from the menu.
Enter the name: E:\CLASSWORK\WORK\WWB\intro\EXAMPLE1.APJ
Choose ‘OK’ to
overwrite (if necessary).
2. Press
the ‘Add...’ button in the Edit Project Dialog that should now be displayed.
Double-click on ‘EXAMPLE1.C’ or copy
it to this directory.
#include <stdio.h>
#include <string.h>
#include "mylib.h"
void StringFunction(int nNum, char *szString);
int main()
{
char szText[80] = "";
/* HASH_DEFINED has
been defined as a per-file parameter
*/
printf(HASH_DEFINED);
/* Call a function in
a pre-built library */
print("Hello,
World - From the Library!");
/* A simple printf call */
printf("Another
Line.\n");
/* A call to a simple
function */
StringFunction(2, szText);
printf("StringFunction() returned: '%s'\n", szText);
StringFunction(1, szText);
printf("StringFunction() returned: '%s'\n", szText);
}
void StringFunction(int nNum, char *szString)
{
switch (nNum)
{
case
1:
{
strcpy(szString, "ARM Project Manager");
break;
}
case 2:
{
strcpy(szString, "ARM Software Development Toolkit
v2.00");
break;
}
default:
{
strcpy(szString, "Default");
break;
}
}
}
Click ‘Add...’ again.
Now, using the Drop-down list,
select ‘List Files of Type: Libraries’
Double-click on ‘MYLIB.32L’
Choose ‘OK’ in the Edit Project
Dialog.
3. Select ‘Yes’ to re-display the project
summary
4. Choose OK.
5. Try selecting Project->Show
Dependencies from the menu.
6. Press the Rebuild-All button on the
Toolbar (use the ToolTips to find it!).
The project should build with the following
messages:
Building...
ARMCC E:\CLASSWORK\WORK\WWB\INTRO\EXAMPLE1.C
"E:\CLASSWORK\WORK\WWB\INTRO\EXAMPLE1.C", line 10: Error:
undeclared name, inventing 'extern int HASH_DEFINED'
"E:\CLASSWORK\WORK\WWB\INTRO\EXAMPLE1.C", line 10: Error:
<function argument>: implicit cast of non-0 int
to pointer
"E:\CLASSWORK\WORK\WWB\INTRO\EXAMPLE1.C", line 14: Error:
expected ')' or ',' - inserted ')' before ';'
E:\CLASSWORK\WORK\WWB\INTRO\EXAMPLE1.C: 0 warnings, 3 errors, 0 serious
errors
Build Unsuccessful
7. Press F4 to move to the first error in
the list. The ARM Project Manager will load the correct source file, and select
the line that caused the error.
You will find that
there is nothing wrong with the code!
The source contains a reference to
the macro ‘HASH_DEFINED’ which has not been defined within any of the source
files. Normally a command-line parameter would have to be added to ARMCC to
specify:
-DHASH_DEFINED=“Defined\n”
Within the ARM Project Manager,
simply select Project->Edit.
Select example1.c and click ‘Edit Params...’
Type in the following:
-DHASH_DEFINED=“Defined\n”
and press
RETURN.
Click on ‘OK’ in the Edit Project
Dialog, then rebuild the project using Rebuild-All.
The project should build with the
following messages:
Building...
ARMCC E:\CLASSWORK\WORK\WWB\INTRO\EXAMPLE1.C
"E:\CLASSWORK\WORK\WWB\INTRO\EXAMPLE1.C", line 14: Error:
expected ')' or ',' - inserted ')' before ';'
E:\CLASSWORK\WORK\WWB\INTRO\EXAMPLE1.C: 0 warnings, 1 error, 0 serious
errors
Build Unsuccessful
8. Press F4 to move to the first error in
the list. Again, the ARM Project Manager will load the correct source file, and
select the line that caused the error. This time, there is something wrong with
the code! There is a close bracket missing. the line
should read:
print(“Hello, World - From the Library!”);
Correct the error, by adding the
missing bracket, and then press Rebuild All again.
Click on ‘Yes’ to instruct the ARM
Project Manager to save the changed source.
The project should
build with the following messages:
Building...
ARMCC E:\CLASSWORK\WORK\WWB\INTRO\EXAMPLE1.C
Linking (E:\CLASSWORK\WORK\WWB\INTRO\EXAMPLE1) ...
code inline inline 'const'
RW 0-Init debug
size data strings
data data data data
Object totals 256 0
144
0 2156
Library totals 12884 188
684 128 512
1104 2012
Grand totals 13140 188
828 128 512
1104 4168
Build Complete.
Executing Example1
1. Click on the ‘Execute’ toolbar icon.
This will load the ARM Debugger for Windows, and run the image that the ARM
Project Manager has just built.
You will notice that StringFunction()
has returned the same value twice. This is not the required behaviour.
2. Quit the ARM Debugger for Windows by
selecting File->Exit.
Debugging Example1
1. Press the ‘Debug’ icon on the Toolbar
of the ARM Project Manager. This time the ARM Debugger for Windows is invoked, and
the image loaded ready for debugging.
The ARM Debugger for Windows will
have set a breakpoint on ‘main’ so that if you select ‘Go’ from the toolbar
execution will halt on the entry to the main function in EXAMPLE1.C.
Do this now.
2. Find the function called ‘StringFunction()’ either by
Selecting View->Function Names, and double-clicking the ‘StringFunction’
entry Or by scrolling the Execution Window manually.
3. Set a breakpoint on the ‘switch’
statement by positioning the cursor on the line and clicking on the ‘Toggle
breakpoint’ icon on the toolbar (use those ToolTips!).
4. Select Execute->Go from the menu, or
click the ‘Go’ toolbar icon.
The ARM Windows Debugger will stop on
the switch statement, and report to you that it has stopped on a breakpoint by
displaying a message in the Status Bar.
5. Display the local variables by
selecting View->Variables->Local. A new window will open showing the two
local variables: nNum and szString.
StringFunction() handles two
cases, and since we wish to see both, the program must first follow the first
case, and then the second. As you can see the number nNum
is initially 1, so this execution should take the first path.
6. Select ‘Go’ again and look at the
Console Window.
The ARM Debugger for Windows will
have stopped a second time on the same breakpoint as before. Look at the local
variables; again nNum is 1 but we want it to be 2.
To change the contents of a local
variable, simply double-click on the VALUE you wish to change, and enter the
new value into the dialog that is displayed.
Press 'Reload', then press 'Go'
twice to bring you to the beginning of the switch statement. Open the local variable window again. Press 'Go' again. Double-click on the value
of nNum in the variable window and change its value
to 2. Press ‘Step’ and watch how the execution window and variable window
changes with each step. Again, look at the Console Window to view the program
output. This time, correctly, StringFunction() has returned two different values.
7. You can quit the ARM Debugger for
Windows, by selecting File->Exit, and go back to the ARM Project
Manager. In the ARM
Project Manager, click on the EXAMPLE1.APJ window. Click on the ‘Show Project’
toolbar button.
The ARM Project Manager will now ask
if it is OK to clear the project output window. Answer ‘YES’ to the question.
8. You now need to correct line 28 of
EXAMPLE1.C to contain a 2 instead of a 1. Double-click on the line that contains:
EXAMPLE1.C ,
this will open the source file ‘EXAMPLE1.C’.
Now we need to find line 28 in the
source file. Select Edit->Go To...
Type in ‘28’ and click on ‘OK’
The editor cursor will now be
positioned at the following line of code:
StringFunction(1,
szText);
Using the editor, change the line to
read:
StringFunction(2, szText);
9. Once you have done this, click on the
‘Rebuild All’ toolbar button.
(Answer ‘YES’ to save the modified
file)
10. After the project has built successfully,
click the ‘Execute’ toolbar button.
Once the ARM Debugger for Windows
has loaded and run the EXAMPLE1
image,
review the Console Window. It should contain something like the
following:
Defined
Print Lib: Hello, World - From the Library!
Another Line.
StringFunction() returned: 'ARM Project Manager'
StringFunction() returned: 'ARM Software Development Toolkit v2.00'
Quit
the ARM Debugger for Windows by selecting File->Exit.