ArticleslgStudy

computer science

KERNAL

KERNAL is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand KERNAL rather than just read about it. In short: KERNAL is Commodore's name for the ROM-resident operating system core in its 8-bit home computers: from the original PET of 1977, followed by the extended but related versions used in its successors: the VIC-20; Commodore 64; Plus/4; Commodore 16; and Commodore 128. Description The Commodore 8-bit machines' KERNAL consists of the low-level, close-to-the-hardware OS routines roughly equivalent to the BIOS in IBM PC c…

Key takeaways

  • KERNAL belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect KERNAL to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of KERNAL from memory before moving on to harder problems.

Reference excerpt

KERNAL is Commodore's name for the ROM-resident operating system core in its 8-bit home computers: from the original PET of 1977, followed by the extended but related versions used in its successors: the VIC-20; Commodore 64; Plus/4; Commodore 16; and Commodore 128.

Description The Commodore 8-bit machines' KERNAL consists of the low-level, close-to-the-hardware OS routines roughly equivalent to the BIOS in IBM PC compatibles (in contrast to the BASIC interpreter routines, also located in ROM) as well as higher-level, device-independent I/O functionality. It is user-callable via a jump table in RAM whose central (oldest) part, for reasons of backwards compatibility, remains largely identical throughout the whole 8-bit series. The KERNAL ROM occupies the last 8 KB of the 8-bit CPU's 64 KB address space ($E000–$FFFF). The jump table can be modified to point to user-written routines, for example, to integrate a fast loader so that its fast replacement routines are used system-wide or to replace the system text output routine with one that works in bitmapped mode rather than character mode. This use of a jump table was novel in small computers at the time. The Adventure International games published for the VIC-20 on the cartridge are an example of software that uses the KERNAL. Because they only use the jump table, the games can be memory dumped to disk, loaded into a Commodore 64, and run without modification. The KERNAL was initially written for the Commodore PET by John Feagans, who introduced the idea of separating the BASIC routines from the operating system. It was further developed by several people, notably Robert Russell, who added many of the features for the VIC-20 and the C64.

Example A simple, yet characteristic, example of using the KERNAL is given by the following 6502 assembly language subroutine (written in ca65 assembler format/syntax), implementing the classic "Hello, world!" program:

Note the use of the PETSCII code for Carriage Return, the x index register, and the accumulator. This code stub employs the CHROUT routine, whose address is found at address $FFD2 (65490), to send a text string to the default output device (e.g., the display screen).

The name The KERNAL was known as kernel 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. According to early Commodore myth, and reported by writer/programmer Jim Butterfield among others, the "word" KERNAL is an acronym (or, more likely, a backronym) standing for Keyboard Entry Read, Network, And Link, which is at least somewhat credible 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.

On device-independent I/O Surprisingly, the KERNAL implemented a device-independent I/O API not entirely dissimilar from that of Unix or Plan-9, which nobody actually exploited, as far as is publicly known. Whereas one could reasonably argue that "everything is a file" in these latter systems, others could easily claim that "everything is a GPIB-device" in the former. Due to limitations with the 6502 architecture at the time, opening an I/O channel requires three system calls. The first typically sets the logical filename through the SETNAM system call. The second call, SETLFS, establishes the GPIB/IEEE-488 "device" address to communicate with. Finally OPEN is called to perform the actual transaction. The application then used CHKIN and CHKOUT system calls to set the application's current input and output channels, respectively. Applications may have any number of concurrently open files (up to some system-dependent limit; e.g., the C64 allows for ten files to be opened at once). Thereafter, CHRIN and CHROUT prove useful for actually conducting input and output, respectively. CLOSE then closes a channel. Observe that no system call exists to "create" an I/O channel, for devices cannot be created or destroyed dynamically under normal circumstances. Likewise, no means exists for seeking, nor for performing "I/O control" functions such as ioctl() in Unix. Indeed, the KERNAL proves much closer to the Plan-9 philosophy here, where an application would open a special "command" channel to the indicated device to conduct such "meta" or "out-of-band" transactions. For example, to delete ("scratch") a file from a disk, the user typically will "open" the resource called S0:THE-FILE-TO-RMV on device 8 or 9, channel 15. Per established convention in the Commodore 8-bit world, channel 15 represents the "command channel" for peripherals, relying on message-passing techniques to communicate both commands and results, including exceptional cases. For example, in Commodore BASIC, they might find software not unlike the following:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with KERNAL

Start with the simplest possible case. Write down what KERNAL claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to KERNAL before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about KERNAL ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of KERNAL

In research
KERNAL appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses KERNAL in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
KERNAL is common in secondary-school and first-year university syllabi. It links to neighbouring topics 1977 software, Commodore 64, Commodore software, so understanding it makes those chapters shorter.
In everyday life
Look for KERNAL outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “KERNAL” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study KERNAL in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what KERNAL means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain KERNAL out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is KERNAL in simple terms?

KERNAL is Commodore's name for the ROM-resident operating system core in its 8-bit home computers: from the original PET of 1977, followed by the extended but related versions used in its successors: the VIC-20; Commodore 64; Plus/4; Commodore 16; and Commodore 128. Description The Commodore 8-bit…

Why does KERNAL matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study KERNAL?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on KERNAL.

Tags

  • 1977 software
  • Commodore 64
  • Commodore software
  • Nonstandard spelling
  • Operating system kernels

Keep exploring