building code - nealcrook/multicomp6809 GitHub Wiki

Resources

Flow

Different tools want code in different forms. These include:

  • S19 file (S19 refers to file in "srecord" format) absolute (addresses in the file correspond to the absolute address in the target address space). The emulator can read files in this format.
  • HEX file (HEX refers to a file in Intel Hex format) is a absolute (addresses in the file correspond to the absolute address in the target address space). The emulator can read files in this format.
  • HEX file relative (addresses in the file correspond to offsets from eg the base address of the ROM, but any branches and other references in the file use the absolute address so that the image will execute correctly). The ROM images loaded into memory models for the Altera tools must be in this format.
  • Binary file (no addressing information). The images used for the FLEX port, and any boot images loaded onto the SD card must be in this format.

A typical incantation for the assembler looks like this:

$ as9 myfile.asm -l s19 now

This generates a listing file myfile.lst and an image file myfile.s19, in srecord format.

I use a linux tool srec_cat to convert from srecord to hex:

$ srec_cat myfile.s19 -Output myfile.hex -Intel -Data-Only -address-length=2

There are numerous other tools around that can do this manipulation, else write your own in PERL (the formats are simple, line-based and described in detail on Wikipedia and elsewhere).

I use a PERL script to convert HEX files in absolute format to relative format (this requires changing the address field and recalculating the per-line checksum):

$ hex_addr_remap e000 myfile.hex > myfile.hex_remap

I use a PERL script to convert HEX files to binary:

$ hex2bin myfile.hex > myfile.bin

The disassembler has a number of lovely features including:

  • It can disassemble files in FLEX binary format (aw well as Intel HEX, Motorola, binary)
  • It "knows" the FLEX labels and can annotate them in to source without further assistable
  • It can take an "infofile" and use this to annotate labels, defines etc. into the source that it generates