Skip to content

Files

Latest commit

7f539bf · May 8, 2016

History

History

test

DiMS Test Programs

This directory contains baseline assembly (.S) files and C files for testing the simulator. To ease development, we provide an illustrative Makefile.

Both assembly files and C files are cross-compiled into MIPS32 ELF binaries, hence the .elf extension on all binaries produced.

Usage

The Makefile can be used as a black-box, but diving in is strongly recommended.

To cross-compile all source files into executables:

make all

To clean things up:

make clean

To merely cross-compile a single file, type the name of the target binary:

make ori.elf
make universe.elf

Beware that a MIPS32 assembler may reorder instructions, and many MIPS32 instructions really are pseudo-instructions translated into somehting else by the assembler.

To disassemble a binary to see the bytecode actually produced, prefix it with show_:

make show_ori.elf
make show_universe.elf

This will also cross-compile the source file before showing disassembly.

To disable reordering, add the assembler directive .set noreorder at the top of your assembly file.

Assembly Files

Every assembly file should have the following layout:

.globl _start
_start:

  # First instruction
  # Remaining assembly code

.include "_shutdown.S"

The GNU linker looks for the label _start to mark the following instruction as the entry point of your binary. The file _shutdown.S defines a shutdown sequence for the simulator. This sequence might change as we develop the simulator.

C Files

There is nothing special about C files, except that:

  1. You don’t have the C standard library at hand.
  2. Libraries are not supported by the Makefile in general.

In other words, a C file corresponds to a binary, and so must contain a main function.

All C files are prepended by _jal-main.S, which wraps a jal main instruction as mentioned for assembly files above. This is sufficient to run C, provided that your simulator supports the instructions that your C file disassembles to.