os-tutorial icon indicating copy to clipboard operation
os-tutorial copied to clipboard

Bootsector disk tutorial doesn't work on real hardware

Open AtieP opened this issue 4 years ago • 2 comments

The disk load code is incorrect because of various factors:

  1. If CS (Code segment) isn't 0, it will not work good. A good practice is to do this:
[bits 16]
[org 0x7c00]

jmp 0x00:main

main:
; code
  1. It is good to set some segments to 0 to avoid bugs. For example:
xor ax, ax    ; ax = 0
mov ds, ax  ; ds = ax (0)
mov es, ax
mov ss, ax
  1. To avoid other bugs, set bp and sp to 0x7c00 and bx to 0x7e00 before calling the subroutine.
  2. And finally, after calling the subroutine, jump to 0x7e00.

Hope this bug be fixed because when I readed and tested this the first time it didn't work and it was frustrating. I'm not trying to advertise myself or to be clumsy, but here you are my bootloader to all that people who were frustrated: https://github.com/AtieP/AtieDOS-2.10/blob/master/bootloader.asm

AtieP avatar Mar 12 '20 19:03 AtieP