Skip to content

Compiler Construction

I’m taking an online course on compiler construction from Stanford via Coursera. I took it out of general interest and also thinking it would help me with my work on LCC1802 that is used for olduino.

The course uses the classic dinosaur compiler tools (lex and yacc etc) but goes into great detail on the underpinnings. I’m enjoying it and certainly learning new things but I’m also increasingly grateful for the effort that people have put int compilers old and new. The amount of detail work that goes into parsing and type checking a language like C is astounding. Just issuing useful error messages is a daunting thought.

I’m truly lucky to have stumbled into LCC early in my quest for an 1802 C compiler. I might be able to cobble something together with the tools I’m learning but it would be many times as much work and wouldn’t be nearly as well done.

Also, a tip of the hat to Ted Rossin who developed his own C-subset compiler for the 1802 which does indeed parse and check and issue decent messages.

I note though, that as I get closer to the back end of the compiler: storage allocation, instruction generation etc., I find it much easier. I can answer quiz questions by inspection rather than tearing my hair out.

Where’s Willy?

I’ve been swamped the last couple of weeks with a Coursera course on Compilers and a new grandson. ┬áHoping to get some more work done on Olduino in May.

More Clocking Around

I’ve had another yet another go at the SPI clock. I had been using SBI/CBI to set the clock bits which is much faster than digitalWrite() but was still giving me a frequency around 1 mhz. I decided to dedicate port C to the clock & not-clock lines so I could trigger them with PORTC=xx which should translate to a single instruction. I actually had to add a no-op between the assignments to keep the frequency around 2 MHZ. The 4021 shift register wants a pulse of at least 180 uS and I was below that without the no-op. I may look at a faster shift register for a later version but i think this will make enough of a difference for now. In the picture below you see the new 2mhz clock waveform and the old 1mhz. the code below is the output of objdump showing the c source and generated assembly.

      PORTC=0x02;//clock up, notclock down
     158:	82 e0       	ldi	r24, 0x02	; 2
     15a:	88 b9       	out	0x08, r24	; 8
      PORTC=0x01;//clock down, notclock up
     15c:	91 e0       	ldi	r25, 0x01	; 1
     15e:	98 b9       	out	0x08, r25	; 8
     160:	00 00       	nop
      PORTC=0x02;//clock up, notclock down
     162:	88 b9       	out	0x08, r24	; 8
     164:	00 00       	nop

Server is Down, thanks to participants

Over the two days it was up it served almost 500 pages to 25 or so clients. I’m not exactly sure how many because the IP table wrapped around(by design). It was really slow rendering the contact list and i found out why once it was down. In the background it was doing a lot of debug printing including all the ips each time it ran the table. my itoa() is stupid slow and that alone was adding a couple of seconds.

The final client table is shown below:

Client Table Australia Ireland Czech Sbirdasn Craig Scott The mlventura Dr. AndrewWassonBCC Mike_USA USA BillAgain Bill Bill & & & & Kevin Kevin Dave WeAreANONYMOUS Australia Australia



This is what happens if you don’t scrub text fields, browsers replace special characters with codes.

Server on the Public Internet Again

The olduino server is back online at

The obvious change is that instead of reporting the LED status with text it shows an animated picture of the board with the LED either on or off. All I had to do was change the text I sent out from “The LED is ON” to a HTML img tag and your browser does the hard part of fetching the picture and displaying it.

14-03-28 Registered14-03-28 unregistered

Under the covers the big change is that it pays attention to the IP of an incoming request. If it hasn’t seen a particular IP before it invites you to tell it your name or where you are. It displays a rolling list of the last 32 contacts. I originally thought I would have some kind of multi-player game but I couldn’t think of one.

Multi-User Web Server Again

14-03-27 multi-user

I’m back with the multi-user web server. I made a table of IP addresses and names that’s managed by the server and displayed with a button on the form. My table management is very basic: it starts with a next-slot index pointing to the beginning of the table and puts a new user into that slot, incrementing the variable. If it gets to the end of the table it wraps around re-using the slot. I tried out the logic with only three slots and i was able to drive a wrap-around by using the laptop, a tablet and my phone – the phone could present as two different ips because it has cellular access.

The simplistic table structure means you have to search the whole table to find an entry. I was worried that would be slow but what’s strikingly slow even with just a few entries is displaying the table – each row takes 1/3 second. It turns out the time is being spend in my old friend the itoa() routine which converts integers for printing as ascii strings. I used a simplistic C routine for doing it and never optimized it. I wrote something better in assembly for longs but never did for ints. I’ll have to get on that sometime. In the mean time I’ll just change things not to display IPs as much.


Get every new post delivered to your Inbox.