Cebollita

Cebollita Toolset

Last modified: April 14, 2005
Sloop SMOK
  CSE Home  About Us    Search    Contact Info 

Introduction

The Cebollita toolset provides a set of command-line tools for compiling, assembling, linking, inspecting, and simulating programs.

Environment Issues

Please see the Setup Guide for JDK requirements and environment variables, like CLASSPATH.

Compiling

A C-- program can be compiled thusly:
$ java comp.parser [sourcefile]
[sourcefile] is the name of a C-- program. C-- is a C-subset that is defined elsewhere. If successful, the compiler will deposit a file with a .s extension in the same directory as the sourcefile.

The compiler will also produce (in the local directory) an HTML file (called [sourcefile]-AST.html) that corresponds to the parse-tree for the given source file.

$ java comp.parser --version
Will print out the version of the toolset.

Assembling

Given an assembly file, it can be transformed into an object file thusly:
$ java asm.Asm [asmfile]
If successful, a file with a .o extension will be created. The assembler also understands the following flags:
--version
Print the current toolset version and quit.
--verbose
Print lots of messages while assembling.
--bare
Just dump a "bare" executable, rather than an object file. This will just dump a stream of instructions. This facility is deprecated -- it can't be guaranteed to do anything interesting anymore.
-O
Perform (possibly incorrect) peephole optimizations. Very much under development -- use at great risk to your family and home.

Linking

Given a set of object files, the linker will attempt to build an executable.
$ java asm.Linker [object-files]
will resolve inter- and intra-file references and dump an executable called a.exe in the specified executable format. The linker will also dump a file called a.sym, which is a symbol table for the executable. Having this is sometimes helpful for debugging. The linker also understands the following flags:
--version
Print the current toolset version and quit.
--verbose
Print lots of messages while linking.
--entry [name]
Set the entry point to the given symbol name. By default, the symbol __start is used to define the entry point.
--at [address]
Link the program as if the text segment will begin at the given address. By default, this value is zero. This option is useful for linking system-level programs that may expect to live at memory-resident locations other than those starting at address zero.
--output [filename]
Name the output with the given filename, rather than a.exe.
--bare
Just dump a "bare" executable, consisting only of a sequence of instructions. This file will contain no header, and no data segment. This option is useful for building system-level programs that need to be loaded before the OS loader is running.

Inspecting Executables

Executables can be inspected (dumped) as follows:
$ java util.Exe [exefile]
This will dump meta-information about the executable, as well as disassembly of the instructions. A useful variant is to use the --smokmem flag, which will dump an executable in a SMOK compatible memory file format:
 
$ java util.Exe --smokmem [exefile]
This will dump header, data, and text segment information about the current module.

Inspecting Modules

Individual modules can be inspected (dumped) as follows:
$ java asm.Module [object-file]
This will dump header, data, and text segment information about the current module.

Disassembler

Converts an instruction from hex to assembler. Can be run in two modes: sits in a loop expecting one hex instruction per input line until a ctrl-C is typed, or by giving one or more hex instructions as arguments on invocation. Examples:
$ java util.Disasm
> 34084000
ori     $t0, $0, 16384
> 8d090000
lw      $t1, $t0, 0
> [killed with ^C]

$ java util.Disasm 34084000 1c2f0100
ori     $t0, $0, 16384
bgtz    $at, 256
$


Department of Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA  98195-2350
(206) 543-1695 voice, (206) 543-2969 FAX
[comments to zahorjan@cs.washington.edu]