[Tfug] OS written in Assembly
John Gruenenfelder
johng at as.arizona.edu
Wed Aug 19 22:31:13 MST 2009
On Wed, Aug 19, 2009 at 09:02:40PM -0700, Bexley Hall wrote:
>--- On Wed, 8/19/09, bpoag at comcast.net <bpoag at comcast.net> wrote:
>
>> A nice thought, but..
>>
>> Compilers surpassed humans in terms of code efficiency a
>> couple decades ago. I love assembly, but, there's a
>> point where it doesn't make sense.
>
>While I agree "in the large" -- maintaining a "significant"
>piece of assembly language code is a *horrendous* undertaking
>(been there, done that, have the T-shirt and the SCARS to
>prove it!) -- there still are niches where compilers just
>can't compete. E.g., write a boot loader in a few *dozen*
>bytes, convert LORAN coordinates to lat-lon with a few
>*hundred* bytes of RAM at your disposal, etc. :-/
>
>OTOH, I kick and scream when I am forced (by circumstances)
>to write something in ASM nowadays. Its just too damn tedious.
>
>OTOOH, I think those of us that grew up with ASM have a much
>easier time dealing with concepts like pointers and *exploiting*
>those concepts (e.g., pointers to functions that return pointers
>to functions, etc.)
I agree with you here. Another place where assembly is very useful, if not
required, is with custom hardware. A fair bit of the code I wrote for a
camera control board (custom built for a satellite they never flew) was
assembly or a C/assembly mix. This included the boot loader, of course, but
also code picking and poking at CPU and FPGA I/O lines to make the camera do
things.
The boot loader could *only* have been written in assembly because there are
so many parts which to go in this or that location, such as where the CPU
starts executing, or the default interrupt vector list, etc.
And, like others have said, in the vast majority of cases, there is almost no
reason to ever use assembly (especially if you want your code to be at all
portable). But, I think it's still important to learn it, or at least have a
decent understanding of it. You come to know how the CPU works so much better
than you would without some knowledge of assembly. And if you don't know
*any* assembly, you're pretty screwed if you ever have to dive deep with your
debugger to track down a nasty bug.
As far as this assembler OS is concerned, it's pretty neat, and I'm sure the
guy who wrote it had a lot of fun. Neat, but not practical. Of course, I
think it does demonstrate that while compilers are generally much better than
humans at this sort of thing, I doubt there is any compiler that can beat a
human at space conservation of this magnitude.
--
--John Gruenenfelder Systems Manager, MKS Imaging Technology, LLC.
Try Weasel Reader for PalmOS -- http://weaselreader.org
"This is the most fun I've had without being drenched in the blood
of my enemies!"
--Sam of Sam & Max
More information about the tfug
mailing list