Hardware Reference
In-Depth Information
system. The as88 assembler and t88 tracer use the UNIX calling conventions even
when they are running on Windows, however.
The system call on line 11 does the actual printing. Line 12 performs a
cleanup on the stack, resetting the stack pointer back to the value it had before the
four 2-byte words were pushed onto the stack. If the write call is successful, the
number of bytes written is returned in AX . Line 13 subtracts the system call result
after line 11 from the original string length in CX to see whether the call was suc-
cessful, that is, to see if all the bytes were written. Thus, the exit status of the pro-
gram will be 0 on success and something else on failure. Lines 14 and 15 prepare
for the exit system call on line 16 by pushing the exit status and function code for
the EXIT call onto the stack.
Note that in the MOV and SUB instructions the first argument is the destination
and the second is the source. This is the convention used by our assembler; other
assemblers may reverse the order.
There is no particular reason to choose one
order over the other.
Now let us try to assemble and run HlloWrld.s . Instructions will be given for
both UNIX and Windows platforms. For Linux, Solaris, MacOS X, and other
UNIX variants, the procedure should be essentially the same as for UNIX .
First,
start up a command prompt (shell) window.
On Windows, the click sequence is
usually
Start > Programs > Accessories > Command prompt
Next, change to the examples directory using the cd (Change directory) command.
The argument to this command depends on where the toolkit has been placed in the
file system. Then verify that the assembler and tracer binaries are in this directory,
using ls on UNIX and dir on Windows systems. They are called as88 and t88 ,
respectively. On Windows systems, they have the extension .exe , but that need not
be typed in the commands. If the assembler and tracer are not there, find them and
copy them there.
Now assemble the test program using
as88 HlloWrld.s
If the assembler is present in the examples directory but this command gives an
error message, try typing
./as88 HlloWrld.s
on UNIX systems or
.\as88 HlloWrld.s
on Windows systems.
If the assembly process completes correctly, the following messages will be
displayed:
Project HlloWrld listfile HlloWrld.$
Search WWH ::




Custom Search