I finally did it...
Posted: Mon Jun 03, 2002 11:00 pm
(This has already been posted to Mega-Tokyo, and I know that these two groups overlap a lot, but I thought I'd mention it here for those who didn't see it there.)
Over this past weekend, I finally decided to bite the bullet and get some coding done; to wit, a boot loader of the sort that seems to be giving so many others so much trouble. It seemed rather hypocritical, after all, to be giving advice on something I had not succeeded in myself.
Well, it took me four days (not counting the previous ten years of casual study on the subject) of cursing, sweat, frustration, more cursing, pawing through reference works, googling through the online material, still more cursing when I found the [i]obvious[/i] bug that had stalled me, awkward learning experiences, moments of enlightenment followed by dazed disillusionment, puzzled looks at some of the odder qualities of the Wintel platform, but I finally got the damn thing to work as I designed it. What bothers me is that there are still some places where I am not entirely sure why what I have down now works when the same thing didn't elsewhere.
BTW, my development environment was NASM-Edit under Win98, while my 'test machine' was Bochs 1.3 on the same platform (I have not tested this on a real machine yet). I used a 1.44M empty file to simulate the disk, and partcopy to load the two files into the disk file's 'sectors'.
I had some very weird experiences trying to get the ES:BX settings right when calling the INT13 AL2 service. For some reason, I couldn't get BX to load anything that wasn't a multiple of 0x100! Even stranger, the problem simply vanished when I rewrote the code. Anyone have any insight into that probem?
Even though I've 'solved' it, it still bugs me, as I don't know what was really happening.
I also found out why it is a bad idea to use the HLT instruction instead of a final infinite loop: in order for it to actually halt the processor, you have to shut off interrupts, which in turn means that you cannot reset the system, but have to cycle power to get it going again.
I've still got to go back and comment it better, and add some small bit of documentation so I don't loss what I've gained at after all this work. But for now, I'm happy I'm done. I'll post the existing code in a followup for anyone who wants it.
Over this past weekend, I finally decided to bite the bullet and get some coding done; to wit, a boot loader of the sort that seems to be giving so many others so much trouble. It seemed rather hypocritical, after all, to be giving advice on something I had not succeeded in myself.
Well, it took me four days (not counting the previous ten years of casual study on the subject) of cursing, sweat, frustration, more cursing, pawing through reference works, googling through the online material, still more cursing when I found the [i]obvious[/i] bug that had stalled me, awkward learning experiences, moments of enlightenment followed by dazed disillusionment, puzzled looks at some of the odder qualities of the Wintel platform, but I finally got the damn thing to work as I designed it. What bothers me is that there are still some places where I am not entirely sure why what I have down now works when the same thing didn't elsewhere.
BTW, my development environment was NASM-Edit under Win98, while my 'test machine' was Bochs 1.3 on the same platform (I have not tested this on a real machine yet). I used a 1.44M empty file to simulate the disk, and partcopy to load the two files into the disk file's 'sectors'.
I had some very weird experiences trying to get the ES:BX settings right when calling the INT13 AL2 service. For some reason, I couldn't get BX to load anything that wasn't a multiple of 0x100! Even stranger, the problem simply vanished when I rewrote the code. Anyone have any insight into that probem?
Even though I've 'solved' it, it still bugs me, as I don't know what was really happening.
I also found out why it is a bad idea to use the HLT instruction instead of a final infinite loop: in order for it to actually halt the processor, you have to shut off interrupts, which in turn means that you cannot reset the system, but have to cycle power to get it going again.
I've still got to go back and comment it better, and add some small bit of documentation so I don't loss what I've gained at after all this work. But for now, I'm happy I'm done. I'll post the existing code in a followup for anyone who wants it.