home *** CD-ROM | disk | FTP | other *** search
-
- *** WimpDebug Introductory Manual ***
-
-
-
- ________________________________ In general ________________________________
-
- As you have probably sussed out by now, WimpDebug is a tool for
- monitoring what happens inside a Wimp application, i.e. it allows you to
- display various status information (variables, register values etc.) from
- your program in an easy-to-use fashion.
- The purpose of this manual is to introduce you to the various ways in
- which you can use WimpDebug. It will learn you how to utilise the range of
- user interfaces in a step-by-step manner, starting at the top level with
- easy-to-use *commands and working downwards to the depths of assembler
- programming.
- At all levels, the basic principles are very similar. The differences
- stem from the various requirements arising from the want of 'comfort' in the
- various modes of use.
-
- Start with running the WimpDebug application. This will load the module
- and start it up as a task, providing an icon on the icon bar. Click on the
- iconbar icon to produce the Display Window. It has 32 text icons, each of
- which may hold up to 255 characters of information.
- And now for how to get something in those icons.
-
-
-
- _________________________ The CLI/*command interface _______________________
-
- WimpDebug provides a simple way of putting information in the Display
- Window icons with *commands. For example, try entering the command
-
- *WDShow 1 Testing.
-
- This will display the string "Testing." in icon number 1 in the Display
- Window - it's as simple as that! (For the moment, ignore the change of icon
- background colour from white to cream.) All WimpDebug interfaces work in a
- manner like this: you specify an icon number and what to display. In some
- circumstances it is also necessary to specify how to treat the information
- you want displayed, e.g. if you give WimpDebug a pointer you must tell it
- how to treat it (display the pointer value or the data it points at, etc.).
- That's not necessary with the *WDShow command, as the way to display the
- string is implicit in the command.
- A variant of *WDShow is *WDShowEval, which takes an expression instead of
- a string as an argument and displays the result in an icon. You may specify
- a number base if wanted (default is signed decimal).
- The *command interface is most useful if you want to display string
- constants (help text etc.) or system variables. Consider the following
- examples:
-
- *WDShow 4 <File$Path>
- Shows the value of the File$Path system variable in icon 4.
-
- *WDShow 0 "Loop counter:"
- Displays the given string in icon 0. You can use this kind of constant
- strings as a reminder of what the number displayed in icon 1 or 16
- represents.
-
- *WDShowEval 18 40*1024*1024
- Shows the result of evaluating the expression in icon 18 - this will be
- "41 943 040". Note the use of spacing between the thousands, millions and
- billions when showing large numbers.
-
- *WDShowEval 5 <sys$year> 2
- Shows the current year as a binary number.
-
- A variety of other *commands are also available. Type "*Help WD." to get
- a list of these.
-
-
-
- ___________________ The BASIC/high-level SWI interface _____________________
-
- Let's get down to business and use WimpDebug with programs - that's what
- it was designed for. Run the following BASIC program:
-
- 10 FOR n=0 TO 30
- 20 SYS "WD_DecS",n,2^n
- 30 NEXT
-
- This illustrates how to use ordinary SYS calls to get WimpDebug display
- something in its icons from a high-level language.
- WimpDebug implements a range of SWI calls using the normal way of
- implementing these (SWI chunk number + 64 subroutines). The names of these
- calls all start with "WD_", which of cource is shorthand for WimpDebug. What
- follows the underscore is the display type you want to use for the value
- supplied in R1 (in the example above this is "DecS", which is shorthand for
- Signed Decimal"). The WRG contains a complete list of the various display
- types available - it can be found in the section entitled "SWI calls for
- high-level languages".
- While looking in the Reference Guide, have a look at the following
- examples - they illustrate quite well the range of possibilities available
- with this simple debug SWI interface (all examples are in BASIC):
-
- SYS "WD_DecS",4,a%
- Shows the variable a% as a signed decimal number in icon 4
-
- SYS "WD_HexI",7,p%,4
- Shows the word pointed at by (p%+4) in icon 7
-
- SYS "WD_BinBI",1,buf%,6
- Shows the byte at (buf%+6) as a binary number in icon 1.
-
- SYS "WD_StringZ",16,a$
- Shows a$ in icon 16.
-
- SYS "WD_DecUBI",6,a$,5
- Shows the code of the 6th character in a$ as an unsigned decimal number
- in icon 6
-
- SYS "DecU",7,a$
- Shows the address of a$ on the BASIC parameter stack as an unsigned
- decimal number in icon 7.
-
- SYS "WD_HexBI",3,RIGHT$(a$)
- SYS "WD_HexBI",3,a$,LEN(a$)-1
- Both show the code of the last character in a$ as a hexadecimal number in
- icon 3
-
- SYS "OS_ValidateMemory",a%,b% TO ;f%
- SYS "WD_PC+PSR",2,f%<<26
- Shows the status of the processor flags returned by OS_ValidateMemory in
- icon 2. Note that a lot of other (in this case) redundant information is
- also shown.
-
-
-
- _________________________ ARM code SWI interface ___________________________
-
- Using the previously discussed high-level language debug interface with
- ARM code programs works, but it's a tedious business, because you have to
- set up registers with specific values, which might interfere with the
- program you are writing - you will probably end up writing quite a lot of
- code in order to preserve the normal state of affairs, e.g. like this:
-
- SWI Wimp_Poll ; Poll
- STMFD SP!,{R0-R2} ; Show the poll reason code in
- MOV R1,R0 ; icon 4
- MOV R0,#4
- MOV R2,#0 ; (clear the offset)
- SWI WD_DecS
- LDMFD SP!,{R0-R2}
- .
- (continue poll processing)
- .
-
- The above example isn't quite realistic, because it assumes that the
- SWI "WD_xxx" calls don't corrupt registers, which they do.
-
- With the ARM code SWI interface, you don't have to use registers for
- passing on information to WimpDebug. Instead, the information is coded into
- the SWI number itself. In addition, the ARM debug SWIs preserve all
- registers. These details in combination make the ARM debug SWIs completely
- transparent (noninterfering) to the program they are called from.
- The only exception to this is R14_SVC, which is corrupted if the calls
- are made when the processor is running in Supervisor mode. The normal
- precautions (stacking R14) should be taken to make things work.
-
- If you glance in the WRG in the section on the ARM code SWI interface,
- you'll find out that calculating the exact SWI number to use in a given
- situation can be rather troublesome. It is much more handy to use macros to
- do this job for us.
- In the directory 'Macros', inside the !WimpDebug application directory,
- two macro files are provided, ready for use. One is for the Acorn
- Stand-alone assembler, the other for the BBC BASIC Assembler.
- Both of them assemble an ARM debug SWI instruction. The SWI number is
- computed by considering the parameters you pass on to the macro. In addition
- to the obvious possibilities, some more esoteric ones are also possible.
- The two macros will now be discussed separately, as they differ quite a
- lot in use.
-
-
- *** The Aasm/ObjAsm macro ***
-
- The text-file 'Aasm' contains macro definitions ready for inclusion in
- your assembler source files - use the GET directive to perform the
- inclusion.
- When you have got things set up, with the macro definitions included etc,
- using them is a piece of cake. For example, the previous example can now be
- rewritten like this:
-
- SWI Wimp_Poll ; Poll
- Show 0,4,DecS ; Show poll reason code in icon 4
- .
- (continue poll processing)
- .
-
- Rather neat, don't you think? You may insert as many 'Show' instructions in
- your program as you wish - they don't have any influence on the execution of
- your program (except that they take some time, of course).
-
- As with the high-level SWI calls, you should, at this point, refer to the
- WRG. There you'll find a list of the various display methods on offer, as
- well as a description of the syntax of the macro parameters. This
- information can be found in the sections "ARM code SWI interface" and "The
- Aasm and BASIC Assembler macros".
-
- Here are some examples using the Aasm macro:
-
- Show 4,2,HexB
- Displays the least significant byte of R4 (b0-b7) in icon 2 as a
- hexadecimal number.
-
- Show 3,16,StringZ
- Displays the zero-terminated string pointed at by R3 in icon 16.
-
- Show 11,10,DecSI
- Displays the word pointed at by R11 in icon 10 as a signed decimal
- number.
-
- Show 3,5,BinBI
- Displays the byte pointed at by R3 in icon 5 as a binary number.
-
- Show 0,0,Bin,8
- Displays the word pointed at by (R0+8) in icon 0 as a binary number. Note
- that indirection is automatically enabled if you specify an offset.
-
- Show 2,1,DecUB,3
- Displays the byte pointed at by (R2+3) in icon 1 as an unsigned decimal
- number.
-
- Show 9,6,DecSB,-11
- Displays the byte pointed at by (R9-11) in icon 6 as a signed decimal
- number.
-
- Show 1,3
- Displays the value in R1 in icon 3, using the display type already in use
- in that icon.
-
- Show ,4,HexB
- Alters the display type used in icon 4 so that the value shown will have
- its LSB displayed as a hexadecimal number.
-
- Show 14,7,PC
- Displays the return address stored in R14 in icon 7, along with
- information about the PSR status bits.
-
- ShowStr 4,"Test string."
- Displays the given string in icon 4.
-
-
- *** The BASIC Assembler macro ***
-
- The BASIC program 'BASIC' in the 'Macros' directory does for the BASIC
- assembler what 'Aasm' does for the stand-alone assembler. The functions they
- provide are in effect the same, but the implementations are different.
- For example, the 'poll-loop' example given above can be coded with the
- BASIC assembler like this:
-
- 10 LIBRARY "macros.basic"
- 20 DIM code% 100
- 30 FOR p%=0 TO 2 STEP 2:P%=code%
- 40 [OPT p%
- .
- 100 SWI "Wimp_Poll"
- 110 FNshow(0,4,"decs")
- 120 .
- .
- 200 ]:NEXT p%
-
- The example above also illustrates how to include the library into the main
- program, and that the macros expect you to use p% as the assembler pass
- control variable, for use in "OPT p%".
-
- The rest of the examples in this section will be the same as those given
- for the AAsm macro, only re-coded using the BASIC assembler macro. Refer to
- the section above and the WRG when following the examples.
-
- FNshow(4,2,"hexb")
- FNshow(3,16,"stringz")
- FNshow(11,10,"DecSI")
- FNshow(3,5,"binbi")
- FNshowo(0,0,"BIN",8)
- FNshowo(2,1,"DECUB",3)
- FNshowo(9,6,"decsb",-11)
- FNshow(1,3,"")
- FNsetshowtype(4,"hexb")
- FNshow(14,7,"PC")
- FNshowstr(4,"Test string.")
-
-
-
- ______________________ Other things you should know ________________________
-
- The WimpDebug module is in fact a completely stand-alone of software - it
- doesn't really need the support files provided in the application directory.
- If you want to, you may copy the !RunImage file, which holds the module,
- into your library and rename it there to 'WimpDebug', or whatever you
- prefer. You may then load the module as part of your boot sequence by
- RMLoad'ing it. At the same time you may also give parameters - see the WRG
- in the section labelled "Booting".
- ____________________________________________________________________________
-
- © Olav Reinert 1991
-