Jump to content
IGNORED

Re-vectoring DOSINI for CIO handler...


Recommended Posts

ok, what in the hell am I doing wrong, in my INIT...

 2300  202023             JSR     IHTBS
  2303  A50C               LDA     DOSINI
  2305  8DDC26             STA     DSAV
  2308  A50D               LDA     DOSINI+1
  230A  8DDD26             STA     DSAV+1
  230D  A919               LDA     #LOW RESET
  230F  850C               STA     DOSINI
  2311  8923               STA     #HIGH RESET
  2313  850D               STA     DOSINI+1
  2315  18                 CLC
  2316  6CDC26             JMP     (DSAV)
                    
  2319              RESET
  2319  202023             JSR     IHTBS
  231C  18                 CLC
  231D  6CDC26             JMP     (DSAV)   
                    
                           ; INSERT INTO HATABS
                    
  2320              IHTBS  PROC

DSAV is zero initialized., IHTBS is my insert into HATABS routine.

 

It's 2am and I am about ready to go bash my brains against the wall :P

 

Link to comment
Share on other sites

When stealing such vectors then chaining to the "old" value, first ensure it has a valid value.

Also, you only need to do it once.

 

If you do so too early in the boot process you might find it hasn't been populated yet.

Also (it's been a while since I've browsed the code) during the boot process the BOOTFLG value at 9 doesn't necessarily hold a valid value (I think they use bitshift on it?)

 

 

Edited by Rybags
Link to comment
Share on other sites

1 hour ago, tschak909 said:

ok, what in the hell am I doing wrong, in my INIT...


 2300  202023             JSR     IHTBS
  2303  A50C               LDA     DOSINI
  2305  8DDC26             STA     DSAV
  2308  A50D               LDA     DOSINI+1
  230A  8DDD26             STA     DSAV+1
  230D  A919               LDA     #LOW RESET
  230F  850C               STA     DOSINI
  2311  8923               STA     #HIGH RESET
  2313  850D               STA     DOSINI+1
  2315  18                 CLC
  2316  6CDC26             JMP     (DSAV)
                    
  2319              RESET
  2319  202023             JSR     IHTBS
  231C  18                 CLC
  231D  6CDC26             JMP     (DSAV)   
                    
                           ; INSERT INTO HATABS
                    
  2320              IHTBS  PROC

DSAV is zero initialized., IHTBS is my insert into HATABS routine.

 

It's 2am and I am about ready to go bash my brains against the wall :P

 

Two problems: As stated, first ensure that DOSINI is valid at all, i.e. bit 0 of the bootflag $9 is set. If not, use $E4C0 as value of DOSINI because all os revisions ensure that this is an RTS.

 

Second, if you adjust LOMEM, make sure that you call the old init code *first* before initializing your vector. Otherwise, your value of LOMEM will be overwritten again by the value of LOMEM of the init function you are calling.

 

  • Like 1
Link to comment
Share on other sites

The boot flag - I'm fairly sure it gets set once the boot process is complete.  As an example, it would likely hold an invalid value if you checked it during boot continuation code (load address + 6)

 

Additional to that - only alter LOMEM if it's a coldstart.  WARMST (8) should = 00.

Link to comment
Share on other sites

2 hours ago, thorfdbg said:

use $E4C0 as value of DOSINI because all os revisions ensure that this is an RTS

Except these which do not. Basically do not assume anything about the OS ROM contents except the FP entry points, jump table entry points $e450-$e48e, vector tables at $e400-$e44f and $e48f-$e4be, charsets and CPU vectors.

  • Like 1
Link to comment
Share on other sites

21 minutes ago, drac030 said:

Except these which do not. Basically do not assume anything about the OS ROM contents except the FP entry points, jump table entry points $e450-$e48e, vector tables at $e400-$e44f and $e48f-$e4be, charsets and CPU vectors.

No, look, this is a documented entry point. It is the last entry in the reserved jump table.

Link to comment
Share on other sites

For my bootable menu loader I needed a guaranteed non volatile RTS to use as an INIT address.

$E44C is the init routine for the C handler.  All it does is set the baud rate values followed by RTS.  So comes in handy.

Edited by Rybags
Link to comment
Share on other sites

@thorfdbg There are two reserved vector tables, one at $e49f-$e4ae, the other at $e4af-$e4be. The last entry of the latter (for the init jump) is located at $e4bb-$e4be. That RTS at $e4c0 is only retained in the XL OS because the 400/800 OS has an RTS there (legitimately ending a routine) and certainly there exist some crap software which rely on that location - but that does not make this a "documented entry point". It is just a location some program illegitimately references assuming stuff it should not about the contents of the ROM.

 

Besides, it is certainly not true that "ALL OS revisions" have the RTS at $e4c0, because even omitting my own OS, I can mention at least two other which do not: Turbo-816 OS and earlier versions of Altirra OS.

Edited by drac030
typo
Link to comment
Share on other sites

In your RESET routine you have a JSR $XXXX instruction at the start. The code that installs your driver patches the $XXXX with whatever is in DOSINI. Now in the code I sent you, I don't actually check DOSINI to see if it's valid because I'm assuming that some DOS is always loaded and therefore DOSINI is valid. In your case that might not be true, so you need to check DOSINI to see if it's valid (non-zero I suppose, or >$0500) and if it isn't just change that instruction to three NOPs ($EA$EA$EA). That way you invoke all prior handlers which may set MEMLO and then you do your stuff and set the new MEMLO.

Link to comment
Share on other sites

Where I am right now, it's patching the old DOSINI for sure, I can see it in amoeba, but things still go sideways.. urgh :(

  2300              START  
                    
  2300  202F23             JSR     IHTBS
  2303  A50C               LDA     DOSINI
  2305  8DEB26             STA     DSAV
  2308  8D1F23             STA     RESET+1
  230B  A50D               LDA     DOSINI+1
  230D  8DEC26             STA     DSAV+1
  2310  8D2023             STA     RESET+2
  2313  A91E               LDA     #LOW RESET
  2315  850C               STA     DOSINI
  2317  8923               STA     #HIGH RESET
  2319  850D               STA     DOSINI+1
  231B  6CEB26             JMP     (DSAV)
                    
  231E              RESET
  231E  20FFFF             JSR     $FFFF   ; PATCH.
  2321  202F23             JSR     IHTBS
  2324  A900               LDA     #LOW PGEND
  2326  8DE702             STA     MEMLO
  2329  A930               LDA     #HIGH PGEND
  232B  8DE802             STA     MEMLO+1
  232E  60                 RTS              

 

n-asm.atr

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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...