Now I'm Just Tired.
*yawn* wow i'm tired. Although I bet it's not a patch on friends whose family just grew by two today! Congrats to Jon and Kate on the twin girls.
Just sat around hacking all day - that wouldn't help. And eating too much pizza - trying to use up the sauce i defrosted! And I had a long day yesterday, ending with a 1st birthday party for another(!) set of twins in my circle of mates.
As it happened, whilst I was was writing the last post my brand spanking new A/C died! Feck! I thought the 'new pad' smell smelt a bit more 'blue smoke' than it had the day before, but didn't take much notice till a few hours later when nothing was working (I was in another room without vents). Ahh well, just as long as it's fixed promptly, at least it's cool for the next few days.
Well I thought i'd take a break from the interrupt stuff and had the notion of playing with FORTH for a change of pace. I never was much of a FORTH hacker but was always intrigued by it from when I was a kid with a Commodore 64 and somehow ended up with a copy. Even the local country-town library had 'Starting Forth', which is a rather novel programming book (and even if you don't like it, you'd never forget it). I think I even wrote a 'parallel cable' loader for the version I had! For my uni computer hardware class I wrote a type of FORTH as a shell on our hand wire-wrapped 68000 based computer so I could interactively write a program to blink the LED rather than having to re-write the EPROM every time I had a bug (yeah an EPROM! The ones you have to erase with strong UV light!). Although FORTH has been used repeatedly as a bootstrap/bios system for many years had no bearing on wanting to try it, it just seemed like a 'fun' thing to look at again.
Thought it'd be a good opportunity to learn a bit more about ARM assembly too. I found a simple forth implementation written in x86 ('jones forth') and so set about porting that (seemed easiest - it's been so long I couldn't remember much, and I know my implementation did a few things wrong). I was making really good progress until I hit some of the larger functions, but that was because I was trying to write reasonably decent code and learn some of the ins and outs of assembly language.
ARM assembly is more powerful than I thought it would be - in every case the code is cleaner and simpler than the x86 equivalent (excepting /mod - no divide instruction) - although x86 is particularly arcane (to be atypically polite of me - in reality, I think it's shithouse), so that is probably to be expected (and given that every instruction is always 32 bits long, it gives a lot of bits to play with). At first having a condition code check on almost every instruction, condition code updates optional, and a 'shift' operation seemed quite obtuse. But it has a sort of synergistic effect, practically giving you all sorts of extra base instructions let alone super-instructions that do two or three things in one. It's probably more compiler friendly than hacker friendly, but the assembler has some support to aid humans, like automatically choosing the best way to load a 32-bit constant (immediate constants are only shifted versions of 8 bits, so often you need a register/pc-relative load).
So far I have managed to get pretty much all of it typed in and assembling at this point, but then I was too tired to try booting it up and fixing all the bugs. It's only 1000 lines of assembly - most of which is 2-3 line functions, comments and meta-data, so it shouldn't too bad.