Assemblers
March 28, 2008
Looks like I did complete those god-awful-time-consuming programs. Here they are, for future reference or whatever…
Mind you, they’re not perfect, nowhere close to it, in fact. The instruction set isn’t complete (bleh) and I’ve used short cuts where it just didn’t make sense to waste time on some feature. There are a few obvious mistakes in the output too, but the damned thing works. So there!
All three programs are written in C Language and are based on the algorithms for the same, provided in “System Software: An Introduction to Systems Programming“, by Leland L. Beck. They’re only sparsely documented, so you’ll probably have trouble reading. Do I look like I care? Oh, and it’s been written for Turbo C++ 3.0
You may also need these files, especially the assemble.txt, which is the source file both the assemblers use (and are equipped to handle).
assemble.txt – Source SIC program
objcode.txt – Output of Two-Pass Assembler
objcod1p.txt – Output of One-Pass Assembler
machcode.txt – Output of Absolute Loader
And no, I don’t mind if you use it partly or in its entirety for whatever purpose you can think of. ^_^
Have fun, people!
Illogicality
March 6, 2008
Question: Design a two pass assembler for an SIC machine in C language.
Time: 3 hrs.
I spent around 5 hours today working on the above mentioned program. A program that I had been working on, at college, for the past few weeks, totalling perhaps 7 hrs out of 9 in three lab periods. That’s 12 hours.
And I haven’t finished.
Now, I really don’t think I’m stupid or anything (or even lacking in the field of coding)… but this reminds me heavily of something Sriram chetan told me about my mini-project a few weeks ago when I told him what it was:
“Hmm… Graphical Representation of Non-Recursive Sorting Methods… hmm… kozhappamilla…
Pakshe… ithu moonu manikkoorinte karyam-e ollu.”
What is interesting is that nobody ever really questions the logic behind our examinations.
Exam (Definition): Tests designed to measure progress against the objectives of a lesson, course or field of study.
It’s a difficult concept, at best, so I’m gonna leave it at that definition. Let’s talk about our 3hr assembler for starts.
The algorithm for the 2 pass assembler is two pages long. One page each for each of the passes. It describes in a very general manner how the first pass scans the whole assembler code, finds of the locations of symbols and stores it. The seconds pass is similarly described as how the results of the first pass are used to put together the final object code.
The whole thing really isn’t that hard to understand. A layman can understand the nitty-gritties of the whole damned thing in maybe 1 or 2 hours of reading. I began much the same way because I didn’t really pay all that much attention to the algorithm last semester. It was way too big for me to have finished studying the the last few hours before the exam, you see.
Constructing the actual program is, as always, an entirely different matter. The assembler is expected to read the contents of a file, and do a hellu-va lot of things (to say the least) before anything resembling an object code comes out of it. After my 12 hrs on this thing, I’ve completed the first pass, and maybe one-third of the 2nd pass.
As far as I know, no one in my class has completed this program yet. And I know that 90% of the girls and at least 70% of the boys (well rounded figures, don’t pay too much attention) are incapable of completing a program of this scale. And this isn’t even that big. I’ve gotten to around 300 lines and think there’s another 100 to go. Not much, no.
But 3 hrs?? I mean, seriously?! I think I’ll barely be able to finish typing 400 lines of code in that time period, let alone make a program that size from scratch.
I also remember that my bro had suggested something like an assembler (macro processor, maybe) as an ‘easy’ candidate for a mini-project. True, it would have been an easy option.
For a mini-project! Not an effin 3 hr exam!
Gotta ask the teach about this one… just to see how she’ll squirm out of it. ^_^
P.S. I’ve updated the blogroll to include Sriram chetan’s new blog.
Edit: I’ve completed those programs and talked about them here.