Close

V0.1 - step by step bootstrap

A project log for Assembler for SuperconBadge

An Assembler for the Supercon 6 Badge - been done. But *ON* the badge?

michael-mllerMichael Möller 08/05/2023 at 12:070 Comments

The code is written and is in V01.1.TXT. This is in a fictious simple assembler format. Now what?

  1. Hand assembly means I edit the text file and add the hex code for each. Also I add the location it will end up in, makes it easier when checking if entered everything.
  2. (Bitter) Experience means there will be errors, and adding one instructions means everything moves, so to minimize that, I add buffer regions with NOP instructions which can be overwritten without consequence.
  3. Where the code uses labels, like "JR GETLEN" the offset or absoulte value of the address can now be calculated and entered. See comments in the result V01.2.TXT
  4. Enter hexcodes via the buttons.

To run the program some input is needed. Of course I can write a simple text file, but as the intention is that it should be able to self-assemble this code needs to be converted to the primitive format it currently uses.

  1. Remove everything execpt the hex code, one instruction per line.
  2. Note the linecount, double and adjust for any last empty line. Convert to Hex and enter that as a 4 hex digit number, BigEndian, at the front of the file.
  3. Join it all into one line. Result is V01.3.TXT

But I was to lazy to key it all with the buttons, so I try to convert this into a loader binary file, using hex editing. (Notepad++ has an extension, your editor may have something, too) So instead of step 4 do:

  1. In ASCII mode of the editor; Revert back the single line and byte count, so one hex triplet per line
  2. Add a "0" in front, and a dash between the pairs.
  3. Swap the two pairs on each line
  4. Replace newline with a dash. This joins it all into one line again.
  5. In Hex mode of the editor; replace any pair by the value. F.eks. The first "30 39" hex pair (being "09" in ASCII) to a "09" value. Yes, this needs  potentially to be done for all 256 possible values, but only a small subset has been used, so this should still be less work. The dashes limit pairs to actual bytes. [After having done this 3 times, because of fumbling errors, I switched to button keying.]
  6. Remove the dashes. Check you have the number of bytes you noted previously.
  7. Add the prefix "00FF0FFA5C3" (in binary values) an the length from before, but remember to swap the bytes.
  8. Add the checksum. Calculating that by hand is tedious (remember we do not use a source computer if we are purists. In the real world the first hardware loader could probably surpress the checksum check.) But, as I gave up on trying this, it is academic.
  9. Upload.

Bootstrap

After keying the initial "proto-assembler" into the badge, I kan write, handassemble and reformat as described, any code and get it "assembled". Including a slightly better "assembler". That is what I mean by having boostrapped the assembler, or rather, the assembler development. The next few iterations are tedious, but it will gradually require less and less of handassembly and reformatting. 

Interestingly enough, having manually keyed in the first version, I can use the save-to-serial feature to get the same loader file that it should generate - a nice verification

Discussions