• Please review our updated Terms and Rules here

lowest code load address when loading from DOS

steaminghacker

Experienced Member
Joined
Dec 16, 2013
Messages
109
Location
london, UK
Hi,

i have eliminated all ROM and DOS calls from my program. The plan is to use the whole machine. However, im loading from DOS so that DOS needs to be alive whilst it actually loads. I located the program base at 0x5000 and this worked, but not sure if this is ok for all cases. can i go lower? 0x4000 would be good :)

thanks for any ideas.
 
On a Model 4 with LS-DOS/TRS-DOS you can nominally load as low as 0x3000 and even 0x2600 if you're not using system libraries.

Many more DOSes to choose from on the Model I and Model III, but since they have all that ROM the lowest address for them is I think around 0x5200 or 0x5300.
 
can i go lower? 0x4000 would be good

How does 0x3C00 sound?

Do you really have to load from DOS? If you instead put your program on a self-booting floppy diskette, you could fill every single bit of RAM -- including video RAM -- with arbitrary contents from the disk. You wouldn't be able to choose your transfer address, though: it would have to be 0x4200 on a Model I or 0x4049 on a Model III.

To do this on a Model I, put the 196 pages (49 kiB) of desired memory contents on track 0 sector 1 through track 19 sector 6.

In track 0 sector 0 put a simple boot block (which the ROM will load into 4200-42FF) that loads all the other sectors into memory (starting with loading track 0 sector 1 into 3C00-3CFF), but skips over track 0 sector 7 (which would otherwise load into 4200-42FF).

Then seek back to track 0, load A with 7, and jump to 06B7 (in the midst of the ROM's bootstrap code). The ROM will load sector 7 into 4200-42FF and jump to 4200. Voila!

On a Model III, the ROM loads sector 1 (rather than 0) into page 43h (rather than 42h), and the disks have 18 sectors per track (rather than 10). So, put the 196 pages on track 0 sector 2 through track 10 sector 17. In track 0 sector 1 put a simple boot block that loads all the other sectors into memory, but skips over track 0 sector 9 (the data for 4300-43FF).

Then seek back to track 0, issue an FDC command to read sector 9, set the stack pointer to somewhere in ROM (say 1000) and jump to 34EE. The ROM will load sector 9 into 4300-43FF, then an NMI will come in that will push an address on the stack (which, because of where we set the stack pointer, will just make two harmless writes to ROM rather than overwriting any RAM) and then the ROM will jump to 4049.


(No, I haven't tried this myself. I'm just an ideas man. Let me know if it actually works.)
 
Last edited:
Hi, and thanks for your suggestions.

@hp2000, i think I'm missing something...

At the moment, I'm building my code image to start in a predefined location, the other segments all follow on.

eg

Code:
|   CODE                  | DATA    | BSS    |              |T
|-------------------------|---------|--------| ...... stack |O
|                         |         |        |              |P

on the M1 i base at 0x5200, but on the M3 i can go to 0x5000 and the on the M4, i can go down to 0x4400.

I'm assuming that DOS lives somewhere between 0x4200 and 0x5200 and, depending on DOS (and luck), i avoid loading over DOS. DOS is doing the loading here.

I'm assuming that, even on a M4, there's ROM below 0x3800. Is there a trick to page RAM there *before* loading with DOS, or is this something you can only do with an independent loader.

Quick aside on the stack location:

I'd quite like to put the stack at the top. However, if i use HIGH$ (0x4049), i get some weird things. On the M3, it pretty much gives me the top, but the M4/LDOS631 gives me somewhere around 0x4e60. How much stack is here? am i good to 0x4200. I can ignore this HIGH$ thing, but DOS gets upset later.

@Petrofsky.

Yes, I don't really need DOS! I like your idea of loading directly. How do i perform a sector load myself. What if i have no ROM? I would like to try your idea, though.

Other Stuff:

I've realised that i will need to make some disk IO in my program (eg saved game). Presumably that means i need to leave DOS intact after all.
 
Back
Top