First post, by alexanrs
Hi everyone!
This weekend I decided to try and make a bootable floppy that loads an option ROM into the RAM. I want to do that so my XT clone won't sit semi-useless on my computing area until I sort out a way to put the XTIDE ROM properly into a mapped EEPROM/EPROM (the empty ROM socket doesn't play nice with my pin-compatible EEPROM, and seems to overlap the BIOS anyway). Then I downloaded PCEm and followed this tutorial to learn programming a floppy boot loader. I used their later example (mainly because handling FAT12 enough to locate a file in the root directory was already implemented) as a starting point and coded my modified version that does the following:
- Saves the original SS/ES
- As the original example, loads the FAT and the root directory to predefined segments
- Looks for IDE_XT.BIN and loads it into a segment calculated as Max. Conventional memory in KB - IMAGE_KB)<<6, where IMAGE_KB is currently set to 12
- Subtracts IMAGE_KB from 0000h:0413h (=40h:0013h, where the BIOS stores how much conventional memory the PC has)
- Makes a far call to the IDE_XT segment:0003h
- Prints a message and waits for a key
- Restores the original SS/ES
- Issues an int 19h (to call the bootloader)
Now, this sounds fine in theory, and it is ALMOST working in PCEm - both set as a Generic XT clone or a DTK XT clone. The option ROM loads and gets executed, and I get to XTIDE's boot screen, but it freezes while detecting IDE drives. I know the ROM itself is good (if I copy it to PCEm's ROMS folder, the system finds the virtual HDD and boots from it just fine). I've attached the screenshot to the post. If I comment out the call to int 19h, the system boots just fine to a DOS floppy and I can see the memory has been successfully "stolen" (software reports the total conventional memory as 628KB). I'm using WinImage to set the bootsector to the one I'm compiling.
I'm somewhat stumped: PCEm doesn't have any debugging capabilities and Bochs -which has a fine debugger - is mostly useless trying to emulate anything pre-Pentium. Does anyone have any ideas of what I'm doing wrong or tips of an emulator that emulates a XT-class PC as well as PCEm, but with better debugging support? I've attached the source code (NASM) of the bootsector below (for a 720KB floppy image).
EDIT: ASM not allowed - renamed to TXT