Jump to content
  • entries
    9
  • comments
    8
  • views
    835

6502 computer: programming a (rudimentary) BIOS


bluejay

408 views

I'm terrible at 6502 programming. Thankfully, programming a simple BIOS can be done by only using simple commands like LDA, JSR, TXA, etc. I wrote a simple program that set up all the ICs such as the 65C22 and MC6847 to whatever mode I wanted them to be in apart from the YM3812, since I've yet to figure out how to program it. I also made a "video counter" to keep track of at what memory location the previous character was placed. This acts as the cursor. Also, the I don't think the MC6847's datasheet explains this, but I assume that the MC6847 will read the characters in standard 6 bit ASCII starting from the first byte of the video RAM. Do correct me if I'm wrong. I also had the MC6847 print "TEST" on the screen upon initialization.

 

However, I had previously made a simple PS/2 keyboard interface using a couple of parallel to serial shift registers, and, well, decoding the "scan codes" that keyboards send to the computer are not as straightforward as I'd like. A PS/2 keyboard will send a "scan code" corresponding to whatever key was pressed or released. Some are 8 bit, some are 16 bit, some are ridiculously long. However, all the basic alphabet and number keys are 8 bit, which makes it simple for us. I used this table, which I believe is scan code set #2. Apologies to those that use dark mode.

Interfacing the PC's Keyboard.

 

The first time I programmed this, I had a lump of instructions that basically read the data the keyboard was sending, compared it with every 8 bit scan code (by "every" I mean every scan code that represents an alphabet key that was pressed. Keep in mind this is still a work in progress.) and branched into a subroutine corresponding to the matching scan code which would output a 6 bit ASCII value for that character.  However, when I tried to assemble this code, I got an error telling me a branch was out of range. To solve this issue, I just split the script into chunks of 4 characters each, and added JMP instructions after each segment to jump to the next. Maybe 4 characters per segment was overkill, but the code assembled without error, so I'd call that a win.

 

So, here's the current BIOS. It's still not at a state where it will work when I just program this into a ROM chip but you can still get the gist of how it works. Some folks here on Atariage told me some ways I can avoid all the confusing subroutine calls, so I will definitely look into that when revising the BIOS. Expect the next version of the BIOS to also include code to control the 8250 UART, 8255 peripheral interface, and YM3812 sound chip.

 

Thanks for stopping by!

6502bios.txt

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...