Tuesday 10 February 2009

Reflection: 6502 assembler

I intended this blog to be part technical and part anecdotal, this post I feel probably falls into both categories at once.

Back in the day when I were a lad etc etc and other grammatically incorrect cliches pertaining to a time only about 12 years ago, I was studying an A-Level in electronics under the Welsh Joint Education Committee exam board. The course was split up into 5 modules:

  1. Basic digital electronics
  2. Basic analogue electronics
  3. Slightly harder digital and analogue electronics
  4. 6502 assembler
  5. Communications
  6. A project
Okay so I can't count... anyway you can guess the vague areas studied in each: 1. Logic gates, boolean algebra, karnaugh maps and so on; 2. resistance, capacitance, diodes, transistor switches and amplifier circuits, RC circuits etc; 3. capacitor charge and discharge, diode characteristics, a/d and d/a converters; 4. 6502 assembler 5. yeah y'know radios, tv's, all the stuff I'd covered in my radio amateurs exam at 14 years old (yawn). 6. I made a guitar tuner... phase locked loop... I won't even go into it here.

You may have noticed something here, 4. 6502 Assembler ... umm ... I've no idea whatsoever why this was included in the course - there's a miriad of exciting bits of electronics out there to cover but no, there it was 1 whole terms worth of assembly language - wow!

The way our practicals work was that we sat down infront of a base unit connectd to a central computer and got assimi... no sorry, wrong reality again, ... got tested on a bunch of multiple choice questions. The great bit was that the whole practical could be carried out on the same unit which looked like one of those yamaha O2R digital mixing consoles without any over the twiddly knobs on top - instead we normally had a prototype board on which we could just plug components in to build up whatever circuit we required.

Module 4 supplied a basic motherboard with a 6502 processor, a socket for an eprom (dead flash - we had a battery unit for ours so we could actually retain work on it!) and even an io port. But the best part was a 16 key hex pad and a 6 x 8 segment led display - old skool!

So how did it work? You had to figure out what you wanted to do - I mean exactly what you wanted to do, which register was going to hold which bit of data and so on; then you wrote it down in pnemonics - a shorthand pseudo-language; then the best bit: you translated it directly into hex represented 6502 machine code with the aid of a lookup table and typed it in on the hex key pad.

Now while this was all very well and good, what was the purpose? The purpose was a very good one - to gain an in-depth, ground level understanding of what was going on inside. I'm a huge fan of modern languages like python who's high level functionality provide an amazingly flexible approach to software development but isn't it better to really really understand what's under the bonnet?

Well that's my opinon anyway.

</rant>

No comments:

Post a Comment