BITS 16
jmp short _start ; Jump past disk description section
nop
; Disk description table, to make it a valid usb
OEMLabel db "usb-label" ; Disk label
BytesPerSector dw 512 ; Bytes per sector
SectorsPerCluster db 1 ; Sectors per cluster
ReservedForBoot dw 1 ; Reserved sectors for boot record
NumberOfFats db 2 ; Number of copies of the FAT
RootDirEntries dw 224
LogicalSectors dw 2880 ; Number of logical sectors
MediumByte db 0F0h ; Medium descriptor byte
SectorsPerFat dw 9 ; Sectors per FAT
SectorsPerTrack dw 18 ; Sectors per track (36/cylinder)
Sides dw 2 ; Number of sides/heads
HiddenSectors dd 0 ; Number of hidden sectors
LargeSectors dd 0 ; Number of LBA sectors
DriveNo dw 0 ; Drive No: 0
Signature db 41 ; Drive signature: 41 for floppy
VolumeID dd 87654321h ; Volume ID: any number
VolumeLabel db "usb-lable"; Volume Label: any 11 chars
FileSystem db "FAT12 " ; File system type: don't change!
_start:
mov ax, 07C0h ; move 0x7c00 into ax
mov ds, ax ; set data segment to where we're loaded
mov si, string ; Put string position into SI
call print_string ; Call our string-printing routine
jmp $ ; infinite loop!
string db "hello world! from usb", 0
print_string:
mov ah, 0Eh ; int 10h 'print char' function
.loop:
lodsb ; load string byte to al
cmp al, 0 ; cmp al with 0
je .done ; if char is zero, ret
int 10h ; else, print
jmp .loop
.done:
ret
times 510-($-$$) db 0 ; Pad remainder of boot sector with 0s
dw 0xAA55 ; The standard PC boot signature
我们制作了这个引导程序,可以打印“ hello world”,并且可以工作!现在,我们要在引导加载程序屏幕上显示鼠标光标,并且我们已经在引导加载程序中使用了int 33
(启用鼠标中断功能),但是它没有显示光标! [我们还没有学习过OS课程。]