6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 14, 2024 2:28 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Jan 08, 2023 3:19 am 
Offline

Joined: Sun Jan 08, 2023 2:40 am
Posts: 1
Hi,

I'm building my first homebrew 6502 computer, and have a question about linkers for the 6502 processor.

As a bit of background, I'm mostly a software guy. I'm also a ham radio operator and have done a lot of radio repair and restoration, but my familiarity is primarily analog circuits, particularly vacuum tube equipment. The 6502 was my first processor when I was a kid, and it remains a sentimental favorite. When I saw Ben Eater's videos, I became inspired to build a 6502 breadboard computer as an educational exercise on digital electronics and basic computer hardware.

As of right now, my computer has a working LCD interface, a working PS2 keyboard interface, and I just finished getting a 6551 hooked up to a TTL USB/serial converter. I'm using VASM to assemble my code, and I'm using a windows based computer for the software development. As of right now, all of my code is contained in a single source file (I call it "BIOS.s"), which gets assembled into a binary and burned to the the 28C256 that I'm using as ROM.

What I would like to do next is to start writing code that can be downloaded directly to RAM via the serial port, and I would like to have this code be able to call subroutines in ROM. I can't seem to figure out how to tell the assembler/linker that I want to make calls to a subroutine that is defined in a different source file.

For example, I have a subroutine in BIOS.s called LCD_print_char that prints a character to the LCD screen. Let's say I want to write a separate "hello world" program that will get loaded into RAM at $1000 and executed. How do I tell the assembler/link that I want to call the LCD_print_char that is already present in ROM? I suppose I could look up the addresses for each subroutine and manually code those into my "hello world" program, but that would be painful and there really should be a way to have the assembler/linker do this for me.

Thanks for helping out a beginner!


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 08, 2023 5:08 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
Welcome.

I hardly know anything about linkers.  I used one 30+ years ago, but with a batch file set up by someone else (who initially had a lot of trouble getting it going), and I modified it from the templates for different projects without really understanding it.

However, even without a linker, I can imagine a few ways to do it.  Does your assembler produce a symbol table at the end of the list (.lst) file that you could copy and paste into the new source code that will be used for RAM-resident program material, even if you then finish up with a search-and-replace-all to change them all into EQUates (constants)?

Again without a linker, you could have your various files, with your main file calling the one for the ROM source code by using an INCL (include) line, and then sending only the portion of the output file that is to be RAM-resident out to your target computer over the serial port.

I understand many of the home computers of yesteryear had jump tables of system entry points.  The positions in the tables were fixed; but these pointed to the system entry points, so if the manufacturer modified the system in later versions to fix bugs or add features, the contents of the table would reflect the new addresses but the user didn't have to concern himself with that because the tables' starting addresses didn't change and the index into the table for getting the address of the desired system entry point didn't change.

From WDC's excellent programming manual which I can never pass up an opportunity to recommend, "Programming the 65816, Including the 6502, 65C02 and 65802," chapter 12, and page 190:

    Apple Computer's ProDOS operating system takes this method a step further:  all operating system routines are called via a JSR to a single ProDOS entry point.  One of the parameters that follow the JSR specifies the routine to be called, the second parameter specifies the address of the routine's parameter block.  This method allows the entry points of the internal ProDOS routines to "float" from one version of ProDOS to the next; user programs don't need to know where any given routine is located.

These last two paragraphs are from the "Synthesizing instructions with RTS, RTI, and JSR" page of my treatise on 6502 stacks (plural, not just the page-1 hardware stack), and there's a little more about it there.

For my workbench computer, although I can assemble code on the PC and send it over the serial line as an Intel Hex file, I have not done it that way in many years.  The workbench computer has Forth in ROM, and I send source-code text over the serial link, which gets compiled, assembled, or executed, as appropriate, on the fly (described in the linked page).  Forth entry points in ROM are found by their headers, and approximately 24 assembly-language ones are in a table of constants I compile at the beginning of a project so the onboard assembler has the needed addresses to look up by name, for example JMP POP2-TRUE , .  The incremental compilation and assembly makes for an interactive development with immediate turn-around time between writing a piece of code and trying it out, without having to re-compile or re-assemble any of the previous underlying code.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 08, 2023 5:12 am 
Offline

Joined: Fri Mar 18, 2022 6:33 pm
Posts: 490
The manual for VASM is here:

http://www.ibaug.de/vasm/doc/vasm.pdf

although it is unfortunately somewhat spare! I think the functionality you're looking for can be found in the
Code:
.global
directive. I do use VASM, but I haven't tried this myself. Let me know if it works! :)

_________________
"The key is not to let the hardware sense any fear." - Radical Brad


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: