Friday, January 7, 2011

PICs Are Cool

Low level computing can be a lot of fun. One of my favorite personal projects was a forth interpreter in z80 assembly for my TI-83 calculator. It was 2000 lines of assembly, and had an working interpreter, so you could program directly on the calculator, as well as a way of loading text programs into the calculator and interpreting them. I wrote several programs for displaying cellular automata like ant and different rules like 184 and 90. I've wanted to get back to it, either to make it more stable and polish it up, or to write a compiler from forth to z80 assembly, so I would just load the programs and run them without an interpreter (which was more fun then useful).
Instead of going back to that, my friend who is an electrical engineer and does cool micro-controller projects has inspired me to buy a pic2 kit and a little micro-controller to play around with. It comes with a little test board, so I can do cool things like light up LEDs.
I'm not terribly good with physical things, though I would love to learn more, so one of my main interests is in programming the device. I would like to write a forth compiler in haskell that results in assembly that can be assembled and loaded onto the device. These things are so resource constrained (37 instructions total, 4KB flash memory, 256 RAM which is partially reserved for special purpose registers- so not a lot to work with) that I would be providing a layer above assembly rather than a real threaded, interpreted forth system. This could be really cool if I pull it off with any success.

I hope to post more about my experience as I learn about this little device. Maybe my friend will even learn a little forth and use it to do his projects! It is certainly nicer then c or assembly!

2 comments:

  1. somehow i doubt i can learn anything about forth. Its all I can do to write a function in C. That's two mentions in a few days on the Ryan brother blogs. I'll be going national soon.

    ReplyDelete
  2. I'm not sure I can really pull this off given how resource constrained these things are and how much control we want in exactly what they are doing, but this could be much easier then c or assembly. One of the nice things about forth is the ability to define an embedded domain specific language- which means that for something like the LED cube we could write a little config file with each frame in the animations, and then compile it as executable code.
    The project may never get that far though.

    ReplyDelete