Seyed Masoud Hosseini · Overview · Study log · Ideas · Transcript · RSS feed
Embedded Systems, 6502 breadboard computer · Lecture 25 of 29 · 21:52
Lecture 25: A Simple BIOS for My Breadboard Computer
Study guide
What this lecture covers
The lecture prepares the breadboard 6502 computer to eventually run Microsoft BASIC by building a proper toolchain-driven ROM image, rather than a single hand-assembled file. It follows the earlier Wozmon-porting videos and precedes running BASIC itself.
You see how other 6502 computers expose simple "character in / character out" style routines at fixed addresses as a minimal BIOS, then build the equivalent for this computer using the cc65 assembler and linker, controlling exactly where code lands in ROM and where the reset vector points.
Key ideas
- BIOS as fixed-address routines: many 6502 systems (Commodore 64, Apple IIe) expose simple, hardware-specific input/output routines at known ROM addresses so higher-level software like BASIC can call them without knowing the underlying hardware.
- cc65 toolchain:
ca65is the assembler,ld65is the linker; building from source requires switching Wozmon's.orgaddress directives to instead be controlled by the linker. - Relocatable object files: an assembled
.ofile is not directly executable ROM content; it retains label metadata so the linker can decide final addresses. - Linker configuration file: describes the memory map (RAM and ROM regions, their start addresses, sizes, and read/write type) and which code segments load into which memory region.
- Custom segments for placement control: defining named segments (for example, a Wozmon segment and a reset-vector segment) lets you control exactly where each piece of code lands in the final ROM image, independent of assembly order.
- Reset vector placement: the 6502 always reads its start address from
$FFFC/$FFFD, so the reset vector segment must be pinned to the very end of ROM regardless of where the rest of the code lives. - Symbol tables for cross-file addressing: the linker can emit a symbol file listing each label's final address, letting other software (like BASIC) reference BIOS routines like
character in/character outby fixed address without needing their source.
Walkthrough
Motivation: other computers' BIOS conventions (0:00)
The lecture reviews the Microsoft BASIC-for-6502 GitHub repository, showing how the Commodore 64 and Apple IIe ports hard-code addresses for monitor routines like character-in/character-out — a minimal BIOS pattern this computer needs its own version of before BASIC can be ported.
Building the cc65 toolchain and fixing a CPU mismatch (1:00)
The lecture clones and builds cc65 locally, then assembles the existing Wozmon source with ca65, hitting an "illegal addressing mode" error caused by an instruction (incrementing the accumulator) that only exists on the 65C02, fixed by declaring the correct CPU target.
From object file to linked ROM image (3:02)
The lecture explains that the assembled object file is relocatable, not final machine code, and removes the source's .org directives in favor of linker-controlled placement. It builds up a linker configuration file step by step: defining the RAM and ROM memory regions, assigning the default code segment into ROM, and padding the output to the full 32K ROM size.
Controlling where code and the reset vector land (8:05)
Because the reset vector must sit at the very end of ROM, the lecture introduces custom segments (a Wozmon segment and a separate reset-vector segment) and a dedicated memory region for the reset vector, iteratively adjusting the configuration until Wozmon is correctly placed with the reset vector pointing to it. It writes the resulting image to an EEPROM and confirms Wozmon still boots correctly, then relocates Wozmon to its traditional address at $FF00 by adding another dedicated memory block.
Building a minimal BIOS layer and organizing source files (16:17)
The lecture adds simple character-in and character-out subroutines as a separate "BIOS" segment, reorganizes the source so a new bios.s file defines shared registers and includes Wozmon as a subordinate file, and removes duplicate register definitions from Wozmon itself.
Generating a symbol table for other software to use (19:21)
Using assembler debug-info directives and a linker symbol-file option, the lecture generates a table of every label's final ROM address, showing how the character-in and character-out routine addresses can be found and used by other programs (like a future BASIC port) without needing the BIOS source itself.
Before you watch
- The earlier videos on Wozmon and its adaptation to the serial interface.
- Basic familiarity with assemblers, linkers, and object files in any toolchain.
- Comfort with hexadecimal addressing and the 6502 memory map used throughout this series.
Check your understanding
- Why can't the linker place code correctly without a memory configuration file once
.orgdirectives are removed? - Why must the reset vector always end up at the very last two bytes of ROM regardless of where other code is placed?
- How does defining custom segments give more placement control than relying on the assembler's default code segment?
- Why is a symbol table useful for software like BASIC that needs to call BIOS routines without including their source?
From the YouTube description
More 6502: https://eater.net/6502
Support these videos on Patreon: https://www.patreon.com/beneater or https://eater.net/support for other ways to support.
------------------
Social media:
Website: https://www.eater.net
Twitter: https://x.com/beneater
Patreon: https://patreon.com/beneater
Reddit: https://www.reddit.com/r/beneater
Special thanks to these supporters for making this video possible:
Adrien Friggeri, Aleksey Smolenchuk, Anthony Weems, anula, Ben, Ben Cochran, Ben Williams, Benjamin Elder, Benji Bromberg, Bill Cooksey, Binh Tran, Богдан Федоров, Bradley Stach, Brian Haug, Burt Humburg, Carl Fooks, Carsten Schwender, Chai, Chris Anders, Chris Lajoie, criis, Cristi Cobzarenco, Daniel Tang, Daniel Zimmer, Dave Walter, Dave Westwood, David Clark, David Cox, David Dawkins, David House, David Klassen, David Sastre Medina, David Turner, Dean Winger, Deep Kalra, DemoniacDeath, Dennis Henderson, Dilip Gowda, Dirk Sperling, Dmitry Guyvoronsky, Dustin Campbell, Dzevad Trumic, Emilio Mendoza, Eric Dynowski, Erik Broeders, Erik Granlund, Ethan Sifferman, Eugene Bulkin, Evan Serrano, Evan Thayer, Eveli László, Florian Bürgi, fxshlein, George Miroshnykov, ghostdunk, Glen Jarvis, Gregory Burns, GusGold, Hailey, Hovis Biddle, Ingo Eble, Isaac Parker, Jack McKinney, Jacob Ford, James Capuder, Jason DeStefano, Jason Grim, Jason Thorpe, JavaXP, Jaxon Ketterman, jemmons, Jeremy Cole, Jesse Miller, Jim Kelly, Jim Kelly, Jim Knowler, Joe Beda, Joe Pregracke, Joe Rork, Joel, Joey Murphy, John Henning, Jon Dugan, Jonn Miller, Josh Smith, Justin Williams, Kai Wells, Kefen, Ken Paul, Kennard Smith, Kenneth Christensen, Kristian Høy Horsberg, Kyle Kellogg, Lambda GPU Workstations, László Bácsi, Lithou, Marcos Fujisawa, Marcus Classon, Mariano Uvalle, Mark Day, Martin Noble, Mats Fredriksson, Matthew Clifford, melvin2001, Michael Cartwright, MICHAEL SLASS, Michael Tedder, Michael Timbrook, Michael Weitman, Miguel Ríos, Mike Coate, mikebad, Miles Macchiaroli, Muqeet Mujahid, Nate Welch, Nicholas Counts, Nicholas Moresco, Nick Chapman, Olivier HUBER, Örn Arnarson, Owen Arnett, Paul Heller, Paul Pluzhnikov, Phil Dennis, Philip Hofstetter, Ponytail Bob, ProgrammerDor, Ralph Irons, Randal Masutani, Randy True, raoulvp, real_huitz, ReJ aka Renaldas Zioma, Ric King, Richard Wagoner, Rick Hennigan, Rob Bruno, Robert Brown, Robert Diaz, Robey Pointer, Roland Munsil, Sagnik Bhattacharya, Sam Sturgis, Scott Gorlick, Scott Holmes, Sean Patrick O’Brien, Sergey Kruk, snc, SonOfSofaman, sorek.uk, Spencer Ruport, Stefan Nesinger, Stephen Kovalcik, Stephen Riley, Steve Jones, TheWebMachine, Thomas Eriksen, Tim Oriol, Tim Sanders, Tim Walkowski, Tom, Tom Smith, Trevor Johnston, tryonlinux, Tyler Latham, Vincent Bernat, Warren Miller, Wraithan McCarroll
← Lecture 24: Adapting WozMon for the Breadboard 6502 · Lecture 26: Running MSBASIC on My Breadboard 6502 Computer →
