Two new pieces were added to the system :
- A simple software to compile the assembly code into binary
- An arduino based RAM loader
Indeed since the beginning of the project I had to manually write the binary code and upload it using dip switches and this is very error prone and it takes forever.
My assembly compiler is very basic, written in PHP (just because it's the langage I'm more comfortable with). The input is an assembly file such as (custom format):
;
; Brute force find three consecutive integers whose sum is equal to 204
var x1
var x2
var x3
var result
const expected 204
init
LD A, 0
LD [x1], A
compute_x
; compute the 3 values and total
LD A, [x1]
LD B, 1
ADD A
OUT A
LD [x1], A
...
It handles:
- comments (anything that follows the semicolon)
- var definitions (only unsigned bytes)
- constant definition
- labels
And it produces a binary file and a human readable processed file very useful to debug both the software and the hardware:
VAR x1 at address 11111111
VAR x2 at address 11111110
VAR x3 at address 11111101
VAR result at address 11111100
CONST expected = 11001100
Label init
00000000 LD A, 0x0 00100110 00000000
00000010 LD [x1], A 01001000 11111111
Label compute_x
00000100 LD A, [x1] 00100101 11111111
00000110 OUT A 00011000
00000111 LD B, 0x1 00101110 00000001
Each line of compiled code contains
- the start address of the code
- the assembly code
- the binary code once compiled (one or two bytes depending on the operand)
Once the binary file is obtained, it was required to load the code into the memory. For this I used an Arduino nano connected to a 74HC595 in a way very close to Ben Eater's EEPROM programmer.
The Arduino will take over the Address and Data bus of the memory by activating the PROG mode, this basically disconects the memory from the Bus through 75HCT245 chips. Once the memory is isolated, the arduino will go through all the needed address using the 75HC595 (a shift register) and upload the data.
Note :
- a dedicated signal is used to write the value on the bus to memory
- Lines A0 to A2 of the arduino are set to digital
- Yes it would be possible to connect directly all 8 lines of Data and 8 lines of Address to the arduino but I wanted to try out the shift register for the time I will have more lines.
Overall everything works and it a good way to finish 2019. I hope 2020 will bring new features such as:
- PCB backplane with a 5A power supply
- Stack Pointer register with associated Push and Pop
- new ALU with compare, logic operations, etc
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.