During the last week, I worked on developing an assembler for ASH1! I have always wondered about the assemblers & compilers design… with AESTE, I had the chance to explore this field.

ASH1 assembler is developed using MATLAB. It takes an assembly language source file (text file) and translates it into ASH1 object file (mif file). This is done by carrying out three passes over the source file as the following:

  • In the first pass, comments and blank lines are omitted.
  • In the second pass, labels, constants and instructions are sorted out.
  • In the third pass, instruction arguments are classified and sorted out.

A typical source file would be composed of the following sections:

  1. defs:    In this part of the file, the programmer declares constants ( purely numeric value) or addresses (specific address within the register file) by using symbols that are alphanumeric representations.  The legal character set for the symbols is the set of letters, both upper and lower case (A-Z, a-z), the set of decimal numbers (0-9), and the underscore (_).  The range for the numbers that can be represented within the defs: are 8-bit unsigned integer numbers which is written in decimal number system.
  2. labels: In this part of the file, the programmer states all the labels. Labels are special cases of symbols that can be used only before assembly language instructions to denote the physical address associated with them. The legal character set for the symbols is the set of letters, both upper and lower case (A-Z, a-z), the set of decimal numbers (0-9), and the underscore (_).
  3. program: In this part of the file, the programmer writes down the various assembly language instructions that make up the code of interest. ASH1 assembly language has 38 instructions. Each has different set of arguments.

So after writing the code for ASH1 in a text file, ASH1 assembler can generate the mif file for that code. I developed a simple GUI that can be fired under MATLAB, where the source file can be loaded and assembled.

To ensure that the assembler could run under OCTAVE as well, I separated the GUI layer to enable users to use the assembler code via Command Line Interface (CLI).

 

 

Categories: Experiential

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.