CSE410 System Executable File Format
Overview
A CSE 410 machine executable is a text (character) file containing hex
values to be loaded into memory. In a real system, the file would
contain binary data, which is more compact and faster to load, but we
accept the small penalties of text in trade for the much greater
convenience of examining and understanding the file contents.
Here is an example executable file:
!0010 # entry point is 0x0010
@0010
288100 # 0010: addi r1 r0 0x100 # build pointer to data
6010 # 0013: printc r0 r1 r0 # print 1st character
289001 # 0015: addi r1 r1 $1 # move pointer to next byte
6010 # 0018: printc r0 r1 r0 # print 2nd character
00 # 001a: stop # that's enough!
@0100
6578 616d 706c 6500 # the C-style string "example" in ASCII
Explanation:
- Comments begin with the character '#' and continue to the end of line
- Any strings consisting of an even number of hex digits are loaded
into consecutive memory locations. Unless a directive is given to
change it, loading starts by default at memory location 0x0010. In
the file above, that means bytes 0x10, 0x11, and 0x12 would hold 0x28,
0x81, and 0x00 respectively.
- The leading character '@' indicates a directive to set the load
address. In the example, the load address is set to 0x0010 near the
beginning of the file and to 0x0100 near the end. The '@' must be
followed by exactly four hex digits. Any number of set load address
directives can be given in the file. They need not specify increasing
addresses. There is currently no detection of a load of data more
than once into a single location.
- The 'entry point' is the address of the first instruction to be
executed when execution starts. The leading character '!' is used to
indicate that the entry point should be set. In the file above, the
first instruction that will be executed is at address 0x0010. Address
0x0010 is also the default entry point - it is used if no other
address is specified using this directive.