So I have a five year old now, and I'd like to someday teach her something useful that I know. Volunteering in Kindergarten class has got me thinking, maybe I could put together a short presentation on Assembly language and binary logic. I know, Kindergarten is way too early to learn binary math, but probably by the time I finish writing the tutorials, she'l be in High School. :)
To ease some of the frustration of Assembly and Machine language coding, I wrote a C program that parses and compiles a faux Assembly language that is a little easier to read and understand. The program will execute the binary code and emulate monitor ROM as well as Raspberry Pi GPIO registers.
To get started playing around with it, get the code from the github link in the Software Apps section or download the package directly at https://people.ucsc.edu/~reburns/downloads/
At the command line:
## if you do not have ncurses $ sudo apt install libncurses-dev ## then $ wget https://people.ucsc.edu/~reburns/downloads/mikode-1.2.2.tar.gz $ gzip -cd mikode-1.2.2.tar.gz | tar xf - $ cd mikode-1.2.2 $ ./configure $ make all check $ sudo make install
You can play around with the snake game example that is in examples/snake.asm, or set up breadboard with an led and a button and compile and run the example below.
To get something running quickly, wire up a breadboard like the below schematic and then:
$ cd examples $ mikode example1.asm ... pass 1... pass 2... writeing example1 ... success! $ sudo mikode -rg example1 Press F3 to quit F1 to see the registers, F4 stop/start F5 step
The instruction set is based off of the Atmel AVR 8 bit instruction set, which I think is great to learn for embedded projects. You can see all of the instructions here: https://github.com/BobBurns/mikode/wiki
I will hopefully have a full Assembly Language for Kids tutorial up soon.
Please feel free to contact me if you find bugs or have any suggestions. Or see https://github.com/BobBurns/mikode
New version 1.1.1 fixed SubtractImm bug and added new demo code examples/shootit.asm
Also, tested on the PocketChip today. Hoping to map GPIO to that device to play with it
Update 12/14/17: Adding step functionality. Press F5 to step through code
Update 12/19/17 Added PocketChip functionality. Beta release:
Update 12/21/17: Better faster gpio execution
Update 12/24/17: patch 1.2.2. I didn't quite catch all of the define changes for HAVE__BCM_H . Sorry if you could not compile for Pi yesterday.
; blinking an led and reading gpio 26 ; ; special rom address ; screen rom 0xc000 ; ; 0xe100 output register ; 0xe101 direction register ; 0xe102 input register ; ; pin mappings ; b0 - gpio 6 ; b1 - gpio 13 ; b2 - gpio 19 ; b3 - gpio 26 ; b4 - gpio 12 ; b5 - gpio 16 ; b6 - gpio 20 ; b7 - gpio 21 ; ; defs .def temp = r9 LoadImm r10,0x08 StoreDirect 0xe101,r10 ; toggle pin to set input LoadImm r10,0x00 StoreDirect 0xe101,r10 ; set direction input gpio26 LoadImm r10,0x04 StoreDirect 0xe101,r10 ; set direction output gpio19 loop: LoadImm temp,0x04 StoreDirect 0xe100,temp Call delay LoadImm temp,0x00 StoreDirect 0xe100,temp Call delay Jump loop delay: LoadImm r0,0x40 dlp: Call read Decrement r0 BranchNotEqu dlp Return read: LoadDirect temp,0xe102 ;read pin during delay loop AndImm temp,0x08 ; test b3 (gpio 26) BranchEqu putx LoadImm temp,' ' Jump cont putx: LoadImm temp,'X' cont: StoreDirect 0xc540,temp ; should be middle of the screen Return
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!