WHICH ASSEMBLER?

David Spencer explains the role of an assembler, and compares two such products now available for the Archimedes.

An assembler is a piece of software that takes an assembly language program (the source code), and converts it into the corresponding machine code (the object code) which can then be executed directly by the computer. Basic V on the Archimedes already contains a built-in assembler, and this will probably be adequate for the majority of users writing short to medium length machine code programs. Indeed, the entire application package for Computer Concept's ScanLight (see review last month) was written using Basic's assembler.

However, there is one important case when the Basic assembler is not adequate. This is when it is desired to assemble a machine code program in several sections, and then link them together to form a single program. In fact, some of the sections may actually be compiled high level languages (C or Pascal), rather than hand-coded routines. Additionally, but of less important, is the Basic assembler's inability to handle the floating point emulator instructions. Both these shortcomings are rectified by the two assembler packages featured here.

ASSEMBLER FEATURES

Before looking at available assemblers, I will describe briefly some of the features you would expect to find in any Archimedes stand-alone assembler.

CONDITIONAL ASSEMBLY

This feature allows sections of the source code to be included, or omitted, when the program is assembled. For example, you may wish to include some debugging statements in your program, but assemble them only if a flag is set at the start of the source code. Conditional assembly usually takes the form of an IF...THEN...ELSE...ENDIF structure.

REPETITIVE ASSEMBLY

This feature allows a section of the source code to be assembled a finite number of times. This can be very useful in creating data tables where each entry is related.

MACROS

A Macro is a section of source code which only appears in the source listing once, but which is used a number of times when the program is being assembled. For example, you might find that a particular pair of instructions appear together at numerous points throughout the program. Rather than typing these instructions in each time they appear, they can be used as the basis of a macro definition, and given a name which thereafter can be used to refer to those instructions. Each time the name of the macro appears as an instruction in the source code, it will be replaced at assembly by the individual instructions making up the macro.

Macro definitions can also include parameters which are specified each time the macro is used (similar to the arguments of a procedure). In this way macros can be used to create pseudo-instructions which can then be used normally in the program.

LITERAL AREAS

One limitation of the ARM is its inability to include a wide range of immediate operands in instructions. This is because of the limited number of bits free in the instruction field. To get around this, constants can be stored in memory and loaded using program-relative addressing. Some assemblers automatically handle this, allowing the user to pretend that a real immediate constant was used.

DATA AREA LAYOUT

A nice feature of an assembler is the ability to lay out an area of memory to be used as workspace automatically. This is done by defining the start address of the area and then using a special operator to allocate a particular sized chunk from the area.

ACORN OBJECT FORMAT

Acorn object format (AOF) is effectively a way of specifying a machine code program which is not quite executable. This is because a program in AOF format may contain calls to routines which are not defined within the program, and in general the address at which the program will be loaded is undefined. To convert an AOF program into an executable one, the Acorn Linker is used. This basically takes several AOF programs and ties them together, making sure that all the routines called are defined somewhere within one of the programs. It then saves the final executable program. All the Acorn language compilers produce AOF output, and any assembly language program to be linked into a compiled program must therefore also be an AOF file.

THE ACORN ASSEMBLER

This was the first Archimedes assembler available, and is (and will always be) the defacto standard against which others are judged. The Acorn assembler is supplied in two versions, one to produce stand-alone machine code programs, and the other to produce AOF files. Both versions are very similar, and both offer a very large number of functions. It would take too much space to discuss all the individual functions, just suffice to say that all the features mentioned above are provided.

The documentation supplied with the Acorn assembler is extensive. It consists of a 177 page manual in the same format as that supplied with their C compiler. Not only is the assembler itself described, but also the ARM processor, including the instruction set of the Floating Point Emulator and the co-processor instructions. Unfortunately, the disc contains no sample programs.
Product:Archimedes Assembler
Supplier:Acorn Computers Ltd,
 Fulbourn Road, Cherry Hinton,
 Cambridge CB1 4JN.
 Tel. (0223) 245200
Price:£226.37 (inc. VAT)

THE WINGPASS MACRO ASSEMBLER

This is the first alternative to the Acorn system, and has been designed with one particular application in mind - namely combining C programs with assembly language routines. This system is somewhat more limited than the Acorn one, for example it does not provide the automatic data area facility or the handling of literal areas. It does however provide a number of features that are solely related to C. For example, it is possible to include a C header file within the source code, and then refer to type definitions within the assembly language program. This makes the package ideal for writing functions which could not be implemented in C, such as routines which must interact directly with hardware. This assembler can be used independently of C, but in this case a copy of Acorn's linker will be needed. This is supplied with all the languages, the Acorn assembler, and the Software Developer's Toolbox.

The manual supplied with the Wingpass assembler is 72 pages long and contains less material than the Acorn one, partly because of the fewer features offered. However, the disc contains a number of example programs which illustrate all the available features.
Product:Macro Assembler
Supplier:Wingpass Ltd,
 19 Lincoln Avenue, Twickenham,
 Middlesex TW2 6NH.
Price:£49.95 (inc. VAT)

CONCLUSION

When comparing these two assemblers one has to consider not only the products themselves, but also their prices and the functions they aim to perform. There is no doubt that the Acorn system offers the most features, and is the most flexible. However, this is exactly what it is designed to do, and used in conjunction with the Software Developer's Toolbox (see RISC User Volume 2 Issue 3) provides a complete environment for developing assembly language programs. The price of this flexibility is however a massive £226.

On the other hand, the Wingpass assembler, while appearing similar at first sight, sets out to perform a totally different function. It is designed primarily for incorporating assembly language routines into C programs, and hence does for C what Basic's assembler does for Basic. The Wingpass assembler doesn't possess, and doesn't need, a number of the functions of the Acorn system. However, at £50, it is less than a quarter of the price of the Acorn system, and this is a saving which should not be ignored.

To summarise, both systems are well written and perform their tasks perfectly. However, before considering either you should think carefully as to whether Basic's assembler would be a suitable, and possibly better, alternative.