DOS starting memory address

Discussions on programming older machines

Re: DOS starting memory address

Postby Trixter » Tue Feb 14, 2017 10:06 pm

I found "Undocumented DOS" somewhat lacking, but I have other resources to check :-)
You're all insane and trying to steal my magic bag!
Trixter
 
Posts: 523
Joined: Mon Sep 01, 2008 12:00 am
Location: Illinois, USA

Re: DOS starting memory address

Postby alanh » Wed Feb 15, 2017 8:03 pm

I took another look at the code and found it. My minimally annotated (but byte perfect reassembly) of 2.14 (char device only) is here:

https://www.retrotronics.org/svn/jride/trunk/jrconfig/

When the command 0 init call is made, the driver can return a break address - like UNIX, the highest memory address occupied by the driver. It returns a fixup address that causes future DOS allocations (including reloading COMMAND.COM) to load > 128 KB.

-Alan
alanh
 
Posts: 258
Joined: Tue May 10, 2011 6:52 pm
Location: Atlanta, GA

Re: DOS starting memory address

Postby Trixter » Wed Feb 15, 2017 10:01 pm

Woohoo! I love learning new stuff in this area. Glad the final mystery was solved.

That's a great disassembly; it doesn't look IDA-assisted. What did you use? (please don't say ndisasm)
You're all insane and trying to steal my magic bag!
Trixter
 
Posts: 523
Joined: Mon Sep 01, 2008 12:00 am
Location: Illinois, USA

Re: DOS starting memory address

Postby Brutman » Wed Feb 15, 2017 10:42 pm

Not to be an ass, but I didn't think it was much of a mystery as to how it worked. The "two boots" thing has been known for years.

That being said, the disassembly is nice to see.
Brutman
Site Admin
 
Posts: 951
Joined: Sat Jun 21, 2008 5:03 pm

Re: DOS starting memory address

Postby alanh » Wed Feb 15, 2017 10:52 pm

_data_75 is the variable that holds the computed new start address. At some point I'll go back and continue annotating it adding semantics for variable/function names.

About 80% of the content came from an disassembler that was originally built into a x86 emulator I wrote more than 20 years ago. I took the real mode bits of the disassembly routines and built them into a stand alone utility I could use to tear down various BIOS/ROM BIOS routines. Another 10% was from cross merging the output with the output from Sourcer. And 10% from just hand annotating the result (the few annotated names, BDA_ references, etc).

The disassembler is command line driven from a definition file. I had grand ideas of making a Qt GUI to graphically annotate a wysiwyg type tree view. But then I remembered IDA was free for private use for many architectures. I just feel like IDA is sooo feature rich that it makes it cumbersome to use at times. I'm not sure the extra effort I could add would be worth the slightly better/simpler usability over IDA.

-Alan
alanh
 
Posts: 258
Joined: Tue May 10, 2011 6:52 pm
Location: Atlanta, GA

Re: DOS starting memory address

Postby Trixter » Wed Feb 15, 2017 11:36 pm

Brutman wrote:Not to be an ass, but I didn't think it was much of a mystery as to how it worked.


The specific method of allocating all memory to 128K was unknown to me. Now I've learned something about how config.sys drivers work.

alanh wrote:About 80% of the content came from an disassembler that was originally built into a x86 emulator I wrote more than 20 years ago.


You buried the lead!

If you're a masochist, try running 8088 MPH in your emulator.
You're all insane and trying to steal my magic bag!
Trixter
 
Posts: 523
Joined: Mon Sep 01, 2008 12:00 am
Location: Illinois, USA

Re: DOS starting memory address

Postby alanh » Thu Feb 16, 2017 5:59 pm

I really hate rabbit holes, but I just can't help myself :)

I added a lot more annotations to the code in the link above and I *believe* cleaned up all the static references with dynamic labels. A positive point of confirmation is I added an assembly flag at the top to support RAM disk or not (Larry's original NRD vs DSK). This introduced an offset shift at the start of the file and everything
still assembles binary bit-perfect for both versions. I have only one concern with a return value in _cmd0_error_exit being static between both versions. It doesn't make any sense.

This is a DOS 2.x ONLY version (apparently). Most of the tables do not extend to 3.x sizes; though this could be fixed fairly easily. I might try 3.10 at some point, but it's 3x the size and 10x the effort! I sort of dislike the wordy-ness of 3.10.

In any case, I believe 2.14 is suitable for modification and divergence from the original at this point. The URL above is an SVN URL. Other eyes are welcome to checkout, submit patches, or whatever.

Here are some clarifications on it's operation. The ROM BIOS is never executes twice. JRC looks in the BDA and if the base memory is 128K, it sets base memory = total memory, clears the screen, and invokes interrupt 19h. Since you've hooked 19h for the boot menu, only the boot menu gets executed twice. This could be avoided by setting a presence flag in the 19h handler on exit, skipping boot menu if set (warm boot), and and clearing it in the main ROM BIOS startup (cold boot).

Also before calling 19h, it updates the floppy count which is why Mike's issue of the second time through the boot menu with a floppy expansion has different behavior than the first pass.

FYI, the argument comment explanations come from the documentation, not me!

Now someone hand me a shotgun so I can kill this rabbit and go hunting pink unicorns and Cheshire cats!
alanh
 
Posts: 258
Joined: Tue May 10, 2011 6:52 pm
Location: Atlanta, GA

Re: DOS starting memory address

Postby KenG » Fri Feb 17, 2017 6:51 am

Can someone point me to a good, free, disassebler for 8088 code? Debug is just too difficult to use on a large program. Do some disasseblers mark subroutines, label DOS calls as to their function, make strings into variables, etc.?
Enhanced PCjr with a jr-IDE (1GB DOM) and a parallel port side car with a compact flash reader and backpack 1.44mb floppy attached. Tandy video mod.
KenG
 
Posts: 149
Joined: Sat Jul 16, 2016 5:36 pm

Re: DOS starting memory address

Postby alanh » Fri Feb 17, 2017 8:02 am

KenG wrote:Can someone point me to a good, free, disassebler for 8088 code? Debug is just too difficult to use on a large program. Do some disasseblers mark subroutines, label DOS calls as to their function, make strings into variables, etc.?


IDA Pro is about as full featured as you can get:

https://www.hex-rays.com/products/ida/s ... ware.shtml
alanh
 
Posts: 258
Joined: Tue May 10, 2011 6:52 pm
Location: Atlanta, GA

Re: DOS starting memory address

Postby KenG » Fri Feb 17, 2017 5:48 pm

Thanks, I will try it.
Enhanced PCjr with a jr-IDE (1GB DOM) and a parallel port side car with a compact flash reader and backpack 1.44mb floppy attached. Tandy video mod.
KenG
 
Posts: 149
Joined: Sat Jul 16, 2016 5:36 pm

Previous

Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests