diff --git a/01-simple-boot-sector/README.md b/01-bootsector-barebones/README.md similarity index 100% rename from 01-simple-boot-sector/README.md rename to 01-bootsector-barebones/README.md diff --git a/01-simple-boot-sector/boot_sect_simple.asm b/01-bootsector-barebones/boot_sect_simple.asm similarity index 100% rename from 01-simple-boot-sector/boot_sect_simple.asm rename to 01-bootsector-barebones/boot_sect_simple.asm diff --git a/02-boot-sector-interrupts/README.md b/02-boot-sector-interrupts/README.md deleted file mode 100644 index 5045f6e..0000000 --- a/02-boot-sector-interrupts/README.md +++ /dev/null @@ -1,4 +0,0 @@ -We will improve a bit on our infinite-loop boot sector and print -something on the screen. We will raise an interrupt for this. - - diff --git a/02-boot-sector-interrupts/boot_sect_hello.asm b/02-boot-sector-interrupts/boot_sect_hello.asm deleted file mode 100644 index e69de29..0000000 diff --git a/02-bootsector-print/README.md b/02-bootsector-print/README.md new file mode 100644 index 0000000..766547b --- /dev/null +++ b/02-bootsector-print/README.md @@ -0,0 +1,50 @@ +*Concepts you may want to Google beforehand: interrupts, CPU +registers* + +We will improve a bit on our infinite-loop boot sector and print +something on the screen. We will raise an interrupt for this. + +On this example we are going to write each character of the "Hello" +word into the register `al` (lower part of `ax`), the bytes `0x0e` +into `ah` (the higher part of `ax`) and raise interrupt `0x10` which +tells the machine to print on screen the contents of `ax`. + +`0x0e` on `ah` is necessary to indicate tty mode. + +We will set tty mode only once though in the real world we +cannot be sure that the contents of `ah` are constant. Some other +process may run on the CPU while we are sleeping, not clean +up properly and leave garbage data on `ah`. + +For this example we don't need to take care of that since we are +the only thing running on the CPU. + +Our new boot sector looks like this: +```nasm +mov ah, 0x0e ; tty mode +mov al, 'H' +int 0x10 +mov al, 'e' +int 0x10 +mov al, 'l' +int 0x10 +int 0x10 ; 'l' is still on al, remember? +mov al, 'o' +int 0x10 + +jmp $ ; jump to current address = infinite loop + +; padding and magic number +times 510 - ($-$$) db 0 +dw 0xaa55 +``` + +You can examine the binary data with `xxd file.bin` + +Anyway, you know the drill: + +`nasm -fbin boot_sect_hello.asm -o boot_sect_hello.bin` + +`qemu boot_sect_hello.bin` + +Your boot sector will say 'Hello' and hang on an infinite loop diff --git a/02-bootsector-print/boot_sect_hello.asm b/02-bootsector-print/boot_sect_hello.asm new file mode 100644 index 0000000..0f603e5 --- /dev/null +++ b/02-bootsector-print/boot_sect_hello.asm @@ -0,0 +1,16 @@ +mov ah, 0x0e ; tty mode +mov al, 'H' +int 0x10 +mov al, 'e' +int 0x10 +mov al, 'l' +int 0x10 +int 0x10 ; 'l' is still on al, remember? +mov al, 'o' +int 0x10 + +jmp $ ; jump to current address = infinite loop + +; padding and magic number +times 510 - ($-$$) db 0 +dw 0xaa55 diff --git a/03-bootsector-memory/README.md b/03-bootsector-memory/README.md new file mode 100644 index 0000000..6bed1c7 --- /dev/null +++ b/03-bootsector-memory/README.md @@ -0,0 +1,3 @@ +TBD + +Our new boot sector will refer to memory addresses and labels