-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot_sect.asm
39 lines (38 loc) · 1.18 KB
/
boot_sect.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
%include "print_string.asm"
%include "disk_load.asm"
%include "print_hex.asm"
; Read some sectors from the boot disk using our disk_read function
[ org 0 x7c00 ]
mov [ BOOT_DRIVE ] , dl ; BIOS stores our boot drive in DL , so it ’s
; best to remember this for later.
mov bp , 0x8000
mov sp , bp
; Here we set our stack safely out of the
; way , at 0x8000
mov bx , 0x9000
; Load 5 sectors to 0 x0000 ( ES ):0 x9000 ( BX )
mov dh , 5
; from the boot disk.
mov dl , [ BOOT_DRIVE ]
call disk_load
mov dx , [0x9000 ]
call print_hex
; Print out the first loaded word , which
; we expect to be 0 xdada , stored
; at address 0 x9000
mov dx , [0x9000 + 512] ; Also , print the first word from the
call print_hex
; 2 nd loaded sector : should be 0 xface
jmp $
; Include our new disk_load function
; Global variables
BOOT_DRIVE : db 0
; Bootsector padding
times 510 -( $ - $$ ) db 0
dw 0xaa55
; We know that BIOS will load only the first 512 - byte sector from the disk ,
; so if we purposely add a few more sectors to our code by repeating some
; familiar numbers , we can prove to ourselfs that we actually loaded those
; additional two sectors from the disk we booted from.
times 256 dw 0xdada
times 256 dw 0xface