Comp226 - Practical 2

Producing Executables from Assembly Files

Amongst the Prac2 example files there are a number of assembly files, some of which we have not built into executables for you. These include:

File

Purpose

count.s

The assembly code for the counting example.

ians.s

A simple example provided by Ian.

char_io.s

Reads twenty characters from the "Console Input" and writes them to the "Console Output".

simple.s

Just adds %r2 to %r3 and puts the result in %r4.

rnd_test.s and random.s

A pair of files which implement a simple program to generate a sequence of "pseudo-random" numbers. Type in the number of random trials you want to make and an arbitrary "seed" value (both in hex) and watch it go.


Each of these is a text file, which you can view and modify using your favourite text editor.

To produce the corresponding executables we need to perform two steps:

as-isem -o file.o file.s

as-isem -a -o file.o file.s > file.log

ld-isem -o file file1.o file2.o file3.o

For instance, the "count" executable was produced by issuing the commands:

as-isem -o count.o count.s
ld-isem -o count count.o

Try assembling and linking the other examples - then running them in Isem to see how they work.

Of course, for bigger projects we'd use the "make" utility to do all of this automatically - we'll show you how to do this in a later practical.


Dom.