-
1Hardware Setup
Connect 8 LED's through 10k resistors to Arduino pins 2 through 9. I use green LED's for the first 4, and red LED's for pins 6-9.
Connect a momentary push button to the ground rail and pin 10 for the "Enter" button, another to pin 11 for the "Down" button and one to pin 12 for the "Up" button.
If you need to remap anything, it can be changed by modifying the defines in the Arduino sketch.
You'll also need a USB cable to connect the Arduino to your computer to flash the sketch, as well as for interacting with Eep over the serial interface.
-
2Software Setup
The eep_oop_ork.ino sketch can be loaded using the standard Arduino IDE. Once flashed, Eep will communicate on the Arduino's USB-Serial at 115200bps.
-
3Understanding Eep's hardware buttons and blinky lights
For this step, I'll refer to the LEDs as 0 through 7. LED 0 being the one that's connected by default to pin 2 of the Arduino and 7 being connected to pin 9. If you get lost, check the mappings in the Arduino sketch.
Buttons work as follows:
Enter - Flip a bit, and toggle it's respective LED.
Up - Change selected LED. The newly selected led will flash.
Down - Change selected LED in opposite direction. The newly selected led will flash.
The first set of LED's are flags to perform actions and change Eep's behavior. The most important is the SHIFT LED in position 3. This changes the behavior of the LED's in positions 0, 1, and 2,
0: Next. Selecting this advances Eep to the next memory address.
0+Shift: Hi-byte: This selects the upper 8 bits of either address or data
1: Hi-Nybble: This selects the upper 4 bits of the selected byte.
1+Shift: Single Step: Execute the data pointed to at the current address and increment.
2 Address / Data: When this led is on, the address is displayed, when it's off data is.
2+Shift: Run / Stop: When lit, program runs as fast as possible until a halt instruction or crash.
3 Shift: When this LED is lit, the LEDs above change their meaning.
The second set of LEDs are either data or address.
The lo/hi byte and lo/hi nybble flags above let you use led's 4, 5, 6, and 7 to manipulate both the 16 bit address space and 16 bit data words. LED 4 is the most significant and LED 7 is the least significant.
-
4Understanding the Eep Oop Ork Opcodes
Bytecode / Instruction Reference
0 - NOP - No action taken
1 - LDA - Load a value to 'a' register. Address to follow the opcode
2 - STA - Store a value from 'a' to a memory location. Address follows opcode
3 - MOV - Copy value of 'a' register to 'b'. 'a' is unchanged.
4 - ADD - Add 'a' and 'b'. Result of addition is left in 'a'
5 - JMP - Move program execution to the address after this instruction
6 - SUB - Subtract 'b' from 'a'. Result is left in 'a'
7 - JZ - Move program execution to following address only if register 'a' is 0.
8 - SWR - Write the byte in the accumulator to the serial port as output
9 - SRD - Read a byte from serial and store to accumulator (Blocks execution)
10 - LDI - Load next byte into the accumulator - remember this is A in hex for interpreter mode entry
253 - LON - Turn Arduino Light On (FD in hex)
254 - LOF - Turn Arduino Light Off (FE in hex)
255 - HLT - Set run/stop bit to stop and halt program execution (FF in hex)
-
5Using the Eep serial interpreter
Eep's serial interface can be used for input and output to programs, and there is also an interface to read and write to the eep.
When Eep is reset, something similar will be printed to the Arduino's serial interface at 115200bps:
EEP OOP ORK
Base Address: 20B
brk for intrp
--If you type "brk" and press enter you'll get into the interpreter mode, and be given the current address in RAM that Eep is referencing in hexadecimal as well as what's stored at that address.
a: 20B
v:0
eep:
Commands can be entered by typing one of the following letters and pressing enter
w: Write into this address. After pressing enter, you'll just get a blank line for you to type in the hex value of what you would like stored. Pressing enter again stores it and displays it.
r: Reads the current address.
n: Next address. This advances the current address by 2 bytes.
p: Previous address. This decrements the address pointer by 2 bytes.
a: Go to address: After pressing enter, you'll just get a blank line for you to type in the hex value of where you would like to go.
g: Go! Set's the run flag just like using the RUN/STOP LED. Brk can sometimes get you back to the interpreter as long as Eep isn't stuck in a blocking instruction or has accidentally corrupted it's own runtime state. :D
e: Exit interpreter mode
-
6Understanding Eep's Memory Layout.
When Eep is reset, the Safe Base Addr is displayed on the serial interface as well as the LED blinkenlights interface. This address and the next 1024 bytes of memory should be safe for user programs and is set to 0 by default.
Memory below the safe base address is used internally for the Arduino and Eep's runtime state. If memory below the safe base address is modified unwisely, unexpected results may occur.
Depending on the model of chip in your Arduino, there may be memory available beyond the 1k of initialized memory but writing past it is considered undefined behavior.
Eep will let you set the address and value of memory locations just like a void pointer in C. The behavior of what happens when data is written to the address you reference is really up to the board that you're using. The Arduino memory guide has a lot of good information about this.
-
7Tips, Tricks and Gotchas
To load programs to Eep quickly I used minicom's ctrl-a, y command to paste a file that contains the keystrokes to program the Eep. I know it's very kludgy, but hey, it's hackaday and Eep is just for fun.
By default address and values are 16 bits, or 2 bytes long. There's nothing preventing you from setting the address pointer to an odd numbered address. This can both be a blessing and a curse.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.