CSE 378 Winter 2005
A Simple Assembler Program (in Multiple Guises)
From: 1/10/05

What is written below assumes you have the following in your .bash_profile file (in your home directory):
alias cebcc="java  comp.parser"
alias cebasm="java  asm.parser"
alias ceblink="java  asm.Linker"
alias cebdumpe="java  util.Exe"
alias cebdumpm="java  asm.Module"
alias cebsim="java dbg.UI"

To assemble foo.s, to produce foo.o:

$ cebasm foo.s
To link foo.o and prologue.o, to produce foo.exe:
$ ceblink --output foo prologue.o foo.o 
To run foo using Cebollita's simulator:
$ cebsim foo

Incarnation Comment Required
Prologue
Required
Runtime Library
fact0.s This is what you, the first-time assembly language programmer might want to write -- it has just what you mean, and nothing more. Unfortunately, it won't assemble (because the assembler needs more help from you). None -- can't even assemble, much less link. None
fact1.s This is fact0.s, but with the minimal additional stuff added to satisfy the assembler. None None
fact2.s This is fact1.s, but with code added to do output. Only the OS can actually manipulate attached hardware (like IO devices). This version employs direct invocation of operating services (via the syscall instruction). None None
fact3.s Here we start using a prologue to start separating system dependent ideas (like what needs to happen when a user program is about to be run) from system independent ideas ("execution starts at main"). The __start entry point is in the prologue, as is the code required to halt execution. The entry point of our application is now main. prologue-os.s None
fact4.s Like fact3.s, but the (system dependent way of making) systems calls have been replaced with procedure calls to a "standard C-- runtime library." The benefits of this is that the fact programmer doesn't have to understand how to invoke system services on whatever OS his/her code runs on, and that the fact is now portable (or would be, if it were written in C-- rather than Cebollita assembler (which is very processor specific).) prologue-os.s iolib-os.s
     
makefile make is a program that helps automate building programs. In our case, it can be used to automate the compile/assemble/link process. This makefile can be used to create executables -- e.g., make fact2 will build the fact2 example, including linking it with the proper prologue.

You don't need to understand or use make for this course. But, I'm guessing that at some point you'll decide you wish you were using it.