AC21009 Assignment 3 Manchester Baby Assembler
- GCC
- G++
To build the project run the following command
make
To remove the output files that have occurred from previous builds, run the following command
make clean
To use on UNIX use the follow command
./assembler.o [Input-File*] [Output-File*] [Config-File] [Debug]
Any arguments with a *
are required
This is your input text file with your assembly code.
This is the text file you want to output the Machine Code to.
This is the config file you want to use if you want a custom Config See bellow for documentation
Here you can use -d
to enable to full debug dump.
This dumps all debug into from all the Instruction and Variable containers as they run.
See the included configSample.txt
for an example.
numberOfInstructionsConfig: 7
numberOfMemoryLocationsConfig: 32
bitsNotUserAfterLineNo: 8
bitsNotUsedAfterFunctionNumber: 16
bitsUsedForLineNo: 5
bitsUsedForFunctionNo: 3
jumpFunctionNumber: 0
mnemonics: [JMP JRP LDN STO SUB CMP STP]
functionNumbers: [0 1 2 3 4 6 7]
Each of these options should be named as following and then a space left before the the int value you want to use that option.
- numberOfInstructionsConfig: : This is the number of instruction your the computer you're assembling for should have and should match the number of item in the
mnemonics
andfunctionNumbers
- numberOfMemoryLocationsConfig: : This is the number of memory addresses your computer can use.
- bitsNotUserAfterLineNo: : This is the number of bits left blank after the Line Number.
- bitsNotUsedAfterFunctionNumber: : This is the number of bits left blank after the Function Number.
- bitsUsedForLineNo: : This is the number of bits used for the Line Number.
- bitsUsedForFunctionNo: : This is the number of bits used for the Function Number.
- jumpFunctionNumber : The function Number used for jump command
Each of these for their list should have square brackets [
& ]
encapsulating each the list of items, as well no commas or speech marks
should be used to surround each option.
- mnemonics: : Contains the mnemonics used in the assembly file.
- functionNumbers : Corresponding function number for the mnemonic.
For these 2 items you need to have each item in either list match up. So item one in each list are a pair, and item two are a pair etc...
e.g. For the example above JMP
will have the function number 0
.
and then SUB
would match up with the function number 4
.
These are all the possible error codes and their meanings.
This error is when the the value passed through is too big to fit in the available memory size.
When you're look for a memory location that doesn't exist
When you've defined a variable already and you try to define it again
When you use a variable with an instruction that you haven't defined
When there isn't enough memory locations to the number of Variables and Instructions.
Assembly used a Instruction that doesn't exist in the instruction Set
When the assembler looks at an non-existent vector location
You've used a label on a instruction line twice
When the input int/long is too big for the function it's being imputed to
Assembler can't find instructions to process in the assembly file
this error was deprecated in commit d3ecd1616640e4163a91aeaf2d334c55b978d2c6
Can't find the START
or/and END
markers in the assembly file
Assembler failed to input you assembly file into it's data structure
invalid parameter given
There was an error opening your text file.
When one of your instruction in your assembly file is used but not defined
When you custom mnemonics
and functionNumbers
in your config text file
don't have the same number of items in each to match up.
When the line number of a variable is too large for the number of bits defined to hold the bits in machine code.
When the function number of a variable is too large for the number of bits defined to hold the bits in machine code.
When there's a invalid char in the config file, e.g when you have a non decimal number when defining the function numbers
When parts of config don't match, mainly numberOfInstructionsConfig and the number of mnemonics stated