The vm520 Assembler

The vm520 assembler, as520, is used to translate vm520 assembly language into vm520 machine code. The machine code is placed into a vm520 object file. The details of the vm520 virtual machine, including its registers, instructions, instruction encodings and object-file format are available here.

as520 takes a single command-line argument, the name of the assembly language file to be translated. Normally this file should have a file extension of "asm" and the assembler will produce an object file with an extension of "obj". For example, if the file "file.asm" is passed to as520 then it will produce an output file called "file.obj". (If the input file does not have the "asm" extension, then the output file is formed by simply appending ".obj" to the end of the input file name.)

If there are any errors in the input file, then as520 does not produce an output file.

as520 is case sensitive. All opcodes and registers are assumed to be given in lowercase. Registers r13, r14 and r15 can also be referenced as sp, fp and pc, respectively.

as520 is line-oriented. That is, an instruction cannot be broken across multiple lines,

Comment lines are started by a "#". There can be whitespace in front of the "#". Blank lines and comment lines are ignored by the assembler.

as520 allows the use of labels to provide symbolic references for addresses. A label definition can be provided at the beginning of any non-comment line. A label definition consists of the label name, followed by a colon. A label starts with a letter and is made up of letters and digits. It is an error to define a label twice. It is also an error to reference a label that is not defined or imported at some point in the input file. (Note: that it is legal to reference a label before you define it.)

The assembler will expect to see a label to specify the address for an instruction that contains an address. The assembler tracks the actual addresses for labels and will compute the PC-relative address for an instruction that references the label, as required by the vm520 instruction encoding. as520 does the necessary error checking to be sure the PC-relative address will file in the 16-bit or 20-bit address fields used by the instructions.

Some instructions require integer constants or offsets, which can be signed. as520 supports either decimal or hexadecimal specification of these constants, as defined in the C programming language. as520 does the necessary error checking to be sure that the constant or offset fits in the 16-bit or 20-bit field used for constants and offsets.

as520 validates opcodes, both that they are a vm520 opcode and that they are given correct operands in the correct format.

as520 supports four directives:

as520 does the appropriate error checking for symbols given in "import" or "export" directives:


Last modified on November 11, 2010.

Comments and questions should be directed to hatcher@unh.edu