Hacker News new | comments | show | ask | jobs | submit login
Compiling the Original Commodore 64 KERNAL Source (pagetable.com)
108 points by ingve 182 days ago | hide | past | web | favorite | 28 comments



"This will take about 16 minutes, so you probably want to switch your emulator into “Warp Mode”. "

I wonder what an equivalent guide written 30 years in the future about today's software would say. "At this point I realised the file was encrypted with 128 bit - so I routed it through the quantum decryptor circuit to find the key"...


Very minor nit-pick, but assembly language is generally said to be "assembled" into machine code, not "compiled". But since "assembly" and its variant words are relatively little-used in development now, and when they are they often mean something quite different, I can understand the author calling it compilation.


As far as I'm concerned Michael Steil, one of the demi-gods of 6502, can call it whatever he wants to call it.


IIRC, some games for the Commodore 64 just disabled the kernal (which was mapped to address space $E000-$FFFF) to have 8 kilobytes of extra ram.


Same thing with the BASIC ROM. It was rare for either to be needed for C64 games after all. And with some notable exceptions, like Sid Meyer's Pirates! which was partially written in BASIC.


Does that mean the games bootstrapped themselves to be their own OS (or to be otherwise OS-less)?


There was very little OS needed. Most of the keyboard and joystick reads were single memory locations, there was no ROM support for graphics or sound, and most games bootstrapped in a fast loader anyway (later for copy protection as well). If necessary, a program could flip the ROM back into memory space to perform I/O, then flip it back out to use the RAM underneath.


https://www.c64-wiki.com/wiki/memory_map

May be of interest for those that want more details.


Well... yes, but the modern sense of the term "OS" is somewhat different than what would apply to the Commodore 64. We tend to think of the OS as a management layer that tells its "processes" how many resources they can have and such, but on the Commodore 64, it's basically just a stream of assembler instructions. The distinction between "kernel" and "program" is all but nonexistent in modern terms. If you've got no use for the functions the kernel provides, then just unmap it and move merrily along.


Agreed. I'd say the onboard s/w was more like a simple version of what we now term a bios.


A very apt comparison.

And much like with the C64, the BIOS maintains a memory map.

http://wiki.osdev.org/Memory_Map_%28x86%29


The 64K of RAM, amounting to the full address space of the 6510 CPU, were partially shadowed by other things (the Kernal ROM, the character map, the BASIC interpreter ROM, etc). Memory writes always went to RAM. By just setting memory location 1 appropriately (POKE 1 in BASIC) you could decide where the reads came from. Since there was a single thread/process (i.e. yours) you could do this as will.


Which lead to an interesting trick: read the ROM locations, write back the data to the same address. Flip the bit and now you have BASIC or the OS in RAM and everything just keeps on running, then you can modify these to your hearts content


Yes, in the sense that the game software would interface with hardware (more) directly, service interrupts, and manage its own low-level i/o, you might could say that it was its own OS. Some software, like GEOS, would completely replace KERNAL with its own OS, API, etc.

(KERNAL was very simple compared to what we think of as operating systems today -- only 8K, no virtual memory, and no processes.)


Kindof a hoot to see these hard-coded string declarations in code.

  WORDS .BYT ' BASIC BYTES FREE',13,0
  FREMES .BYT 147,13,'    **** COMMODORE 64 BASIC V2 ****'
  .BYT 13,13,' 64K RAM SYSTEM ',0


It seems like every time I read something about the history of Commodore I learn about some oddball prototype that never went to market but existed in a functional form within Commodore. I'm a lifelong Commodore fan (got a 64 when I was about 8, and was a C= user until after the bitter end; I finally gave up on my Amiga a year after the company folded...I currently own a functional C64), and still had no idea about this one.

This time it's the VIC-40. I've never even heard of it, but apparently, it was a 40 column version of the VIC-20 with 16k of RAM. The C64 killed it, even though it was announced as coming soon by Commodore. Given how small Commodore was, relatively speaking (the same handful of engineers seemed to build everything), it's surprising that there were so many dead end projects. At least the VIC-40 was canned before it went to market; that would have been a colossal waste of resources.

In hindsight, it seems like the curse of Commodore was just trying to do too many things with the limited resources they had and heading down too many dead end alleys. Often it took the form of trying to capitalize on the success of their low-end lines toward the end of their useful life, rather than putting all their resources into the next generation. e.g. the C64 turned into the C64GS after better gaming systems already existed and the Amiga was five years old, the Amiga 500 effectively got a re-release as the Amiga 600 at a time when the 500 was ridiculously under-powered. Likewise CDTV crammed an Amiga 500 into a VCR box and removed all of its computer-y bits, making it a shitty computer, a mediocre game machine, and a novel but ultimately pointless pre-cursor to DVRs (it could play shitty video from CDROM, but couldn't record or otherwise do much that any ordinary desktop computer could do better at the time).

OK, rant over. When I was a kid, I used to think that "kernal" was an accidental misspelling that stuck; that seems so unlikely to me, today. It seems like it's more of an intentional in-joke. It's interesting to think that the best-selling computer in history was made by a team small enough, and a company casual enough, to let something like that slip through to production.


SYS 64738

I can still remember that after all these years.


I some ways simpler days, but probably completely incompatible with the present day security landscape (sigh).


So, who's to blame for the blatant spelling error?


Robert Russel:

The KERNAL was known as kernel[6] inside of Commodore since the PET days, but in 1980 Robert Russell misspelled the word as kernal in his notebooks. When Commodore technical writers Neil Harris and Andy Finkel collected Russell's notes and used them as the basis for the VIC-20 programmer's manual, the misspelling followed them along and stuck.[7]

According to early Commodore myth, and reported by writer/programmer Jim Butterfield among others, the "word" KERNAL is an acronym (or maybe more likely, a backronym) standing for Keyboard Entry Read, Network, And Link, which in fact makes good sense considering its role. Berkeley Softworks later used it when naming the core routines of its GUI OS for 8-bit home computers: the GEOS KERNAL.


Having been Bob Russel's room mate for a while in college, I'm going to go strongly with the random spelling error theory :)


I did a search on Bob Russel and found a wiki article entitled "Robert Russell (Programmierer)"

I was hoping this was a joke on his bad spelling, but then I realized the article was in German. Oh well.


Please do spill! :)


Not much to say. Bob and I and a small handfull of others showed up as freshman with "personal computers" that we had soldered together from kits. Which is how you got one in those days. Audio cassette tape mass storage. We of course found each other pretty quickly. (And all of us spell like engineers.) Eventually Bob and I became the first two kids on campus with Apple II's, integer basic and 16k DRAM which we quickly upgraded. When Apple finally started shipping floppy drives Bob had his order in ahead of me, and the store got two. The store kept one as a demo unit so I had to wait like 6 weeks for the second allocation. I was burning with jealousy.

I remember Bob had already accepted a job with Sperry Univac when Commodore insisted that he fly out for an interview. He went on a lark for free travel. According to his stories at the time, he was a bit of a crank during the interview since he had no intention of taking the job. This was before the VIC-20, so Commodore's had those lame chicklette keyboards and other lameness. He kept saying "My Apple can do this, why can't you do this?" Somehow, instead of interpreting his criticism as attitude, they were convinced he was a visionary. Go figure. So they paid what he asked and he played key roles on VIC-20 and C64.

History could be very different if he had ended up at Univac. The C64 looks a lot like ideas that were first floated during BS sessions among our gang.


Well, that was interesting. I really enjoyed playing Pit Stop II on my friend's C64 back in like '85. It was way better than my own ZX81 at graphical games.

I do sort of remember idly wondering which people built this marvel, already back then. Since then I've read a bunch of books etc, but a personal connection is hard to beat! Thanks for the story!


The first file I browsed in the source contained repeated uses of the verb "INITILIZE", so the evidence seems strong.



It's so cool the source is available!




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: