mell-o-tron / OS-Reference

80 stars 17 forks source link

6.asm weird code #1

Closed smitsyn closed 2 years ago

smitsyn commented 2 years ago

Why does 6/6.asm contain this piece of code at the beginning?

BOOT_DISK: db 0
mov [BOOT_DISK], dl  

It's a garbage that is being executed at the start. Don't know what it does exactly, but it causes qemu to flicker, which I guess means it reboots constantly.

mell-o-tron commented 2 years ago

That code sets the variable BOOT_DISK to the boot disk number, contained in dl.

The one thing wrong with it is that BOOT_DISK should be defined at the end, and should not be reachable by the program counter.

Thanks for letting me notice, I'm changing that :)

smitsyn commented 2 years ago

Another wrong thing is that it is never used in 6.asm, so it shouldn't be there. As I see it, the biggest selling point of your work is that it is focuses on the issue at hand and isn't cluttered, and knowing boot disk number is not related to transferring to protected mode at all. Just my 2 cents.

Also you may want to move the definition in 5.asm also, but looks like it doesn't cause any problems. I wonder what opcode it relates to and why it doesn't break in 5 and breaks in 6 :).

mell-o-tron commented 2 years ago

The point of my code, if there is one, is building up complexity step by step, already thinking forward to the general case, and as I think it's a good idea to save your booting drive number in general I thought it would be a good idea to include that step, as opposed to just leaving dl "as it is", just because it already contains the right value.

I'll move the definition in 5.asm as well, thanks for letting me notice! :)