epaell wrote: ↑Sat Mar 23, 2024 11:03 pm
I noticed that if index register X is set to 0 and A=<vector> when calling the VCTRSW service, it returns the current address of the vector being requested. So for _ACIA it returns $E008 and for _CIDTA it returns $FADC. That's why I was getting hopeful that I could just query those addresses and make use of them as they stand in ASSIST09 just to avoid duplicating code. Unfortunately, the first line of the routine I wanted used direct page addressing and the DP seemed to be set to something different to what ASSIST09 was using.
Yes, X is intended to hold the replacement handler address, or zero if just wanting to query the existing address.
On return X always holds the previous value of the vector (which would still be the current value, if X was 0 on entry).
I'm not clear on what the intended purpose of being able to query the existing address is, given it is intended as a vector swap service, and there doesn't appear to be any efficencies / logic to "checking first".
It's probably that query ability alone, that creates confusion! Perhaps they thought it was just a logical thing to do if a zero address is passed?
EDIT: In retrospect, I wrote the above sentences thinking only of routine addresses (for ASSIST09 extended indirect calls), overlooking the fact that the vector table also includes resource addresses (which are of course valid to query). Perhaps this would have been better implemented as two seperate tables. One just for routine addresses (with no query function), and one just for resource addresses (with a query function). No doubt this has been debated many times before (over the last 40+ years since the code was written. LOL).
I can certainly see the temptation of wanting to call the existing routine, instead of duplicating code.
epaell wrote: ↑Sat Mar 23, 2024 11:03 pm
It's not a major issue and is simple enough to inherit the non-blocking code from ASSIST09 with a bit of cut and paste - I guess I just have a bit of an uneasy feeling about repeating code that I know is already there ... but I also have an uneasy feeling about hacking the DP value to make that code work.
I suppose you could use code 0 (A=0), to retrieve the vector table address (.AVTBL), knowing that ASSIST09 defaults to having the vector table in the work page. Therefore, the high byte of the return value, is the value you want for the DP register setup.
However, this probaby goes against all the rules, as you are then assuming that the .AVTBL address hasn't been changed by another process.
Although if it's all your code, and you've commented it properly, I guess you would be making a reasonably safe assumption.
EDIT: Actually, as the routine is using DP to access a vector table entry, it's the current vector table address that's actually relevant (so ignore what I said in the two sentences above).
Plus, there's the issue of whether you should be saving and restoring the existing DP value. By which time you probably should just steal / duplicate the ASSIST09 CIDTA code.
epaell wrote: ↑Sat Mar 23, 2024 11:03 pm
BTW, it was funny watching your second recent ROM-expansion video because I went through the exact same steps in trying to get asm6809 to compile ASSIST09 a week or two ago (because I wanted to get the assembly listing). I assumed that you were using asm6809 for it previously so was surprised that I had to make changes to the code ... but your recent video explained the history of that and looks like we went through the exact same steps in changing the code.
LOL. That's really funny. When I was doing it, I remember thinking that this has probably been done many times before.
I guess by making a video of my process and the fact that I was able to compare the assembled code to an original "known good" ROM dump from the 80s, I felt it would at least be potentially useful to someone else, so I made the result available via github.
Hopefully this helps save at least one other duplication of effort in the future.