This commit is contained in:
warlock
2021-05-25 17:48:56 +08:00
commit 8328b0c337
6 changed files with 158 additions and 0 deletions

BIN
01_day/boot.img Executable file

Binary file not shown.

38
01_day/hello.asm Executable file
View File

@@ -0,0 +1,38 @@
;hello for you
org 0x7c00
jmp entry
db 0x00
db "helloOSX"
dw 512
db 1
dw 1
db 2
dw 224
dw 2880
db 0xf0
dw 9
dw 18
dw 2
dd 0
dd 2880
db 0,0,0x29
dd 0xffffffff
db "myosudisk "
db "fat12 "
resb 18
entry:
db 0xb8,0x00,0x00,0x8e,0xd0,0xbc,0x00,0x7c
db 0x8e,0xd8,0x8e,0xc0,0xbe,0x74,0x7c,0x8a
db 0x04,0x83,0xc6,0x01,0x3c,0x00,0x74,0x09
db 0xb4,0x0e,0xbb,0x0f,0x00,0xcd,0x10,0xeb
db 0xee,0xf4,0xeb,0xfd
db 0x0a,0x0a
db "hello,today,you are crazy"
db 0x0a
db 0x00
times 510-($-$$) db 0x00
db 0x55,0xaa

38
01_day/hello.img Executable file
View File

@@ -0,0 +1,38 @@
;hello for you
org 0x7c00
jmp entry
db 0x00
db "helloOSX"
dw 512
db 1
dw 1
db 2
dw 224
dw 2880
db 0xf0
dw 9
dw 18
dw 2
dd 0
dd 2880
db 0,0,0x29
dd 0xffffffff
db "myosudisk "
db "fat12 "
resb 18
entry:
db 0xb8,0x00,0x00,0x8e,0xd0,0xbc,0x00,0x7c
db 0x8e,0xd8,0x8e,0xc0,0xbe,0x74,0x7c,0x8a
db 0x04,0x83,0xc6,0x01,0x3c,0x00,0x74,0x09
db 0xb4,0x0e,0xbb,0x0f,0x00,0xcd,0x10,0xeb
db 0xee,0xf4,0xeb,0xfd
db 0x0a,0x0a
db "hello,today,you are crazy"
db 0x0a
db 0x00
times 510-($-$$) db 0x00
db 0x55,0xaa

BIN
01_day/helloos.img Normal file

Binary file not shown.

50
01_day/helloos.nas Normal file
View File

@@ -0,0 +1,50 @@
; hello-os
; TAB=4
; 标准FAT12格式软盘专用的代码 Stand FAT12 format floppy code
DB 0xeb, 0x4e, 0x90
DB "HELLOIPL" ; 启动扇区名称(8字节)
DW 512 ; 每个扇区(sector)大小(必须512字节)
DB 1 ; 簇(cluster)大小(必须为1个扇区)
DW 1 ; FAT起始位置(一般为第一个扇区)
DB 2 ; FAT个数(必须为2)
DW 224 ; 根目录大小(一般为224项)
DW 2880 ; 该磁盘大小(必须为2880扇区1440*1024/512)
DB 0xf0 ; 磁盘类型(必须为0xf0)
DW 9 ; FAT的长度(必须是9扇区)
DW 18 ; 一个磁道(track)有几个扇区(必须为18)
DW 2 ; 磁头数(必须是2)
DD 0 ; 不使用分区,必须是0
DD 2880 ; 重写一次磁盘大小
DB 0,0,0x29 ; 意义不明(固定)
DD 0xffffffff ; (可能是)卷标号码
DB "HELLO-OS " ; 磁盘的名称(必须为11字节,不足填空格)
DB "FAT12 " ; 磁盘格式名称(必须是8字节,不足填空格)
RESB 18 ; 先空出18字节
; 程序主体
DB 0xb8, 0x00, 0x00, 0x8e, 0xd0, 0xbc, 0x00, 0x7c
DB 0x8e, 0xd8, 0x8e, 0xc0, 0xbe, 0x74, 0x7c, 0x8a
DB 0x04, 0x83, 0xc6, 0x01, 0x3c, 0x00, 0x74, 0x09
DB 0xb4, 0x0e, 0xbb, 0x0f, 0x00, 0xcd, 0x10, 0xeb
DB 0xee, 0xf4, 0xeb, 0xfd
; 信息显示部分
DB 0x0a, 0x0a ; 换行两次
DB "hello, world"
DB 0x0a ; 换行
DB 0
RESB 0x1fe-$ ; 填写0x00直到0x001fe
DB 0x55, 0xaa
; 启动扇区以外部分输出
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
RESB 4600
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
RESB 1469432

32
01_day/makefile Executable file
View File

@@ -0,0 +1,32 @@
src=hello.asm
bootstrap=boot.img
boot:boot.img
boot.img:hello.asm
nasm $(src) -o $(bootstrap)
fat12:
@dd if=/dev/zero of=$(bootstrap) seek=1 count=2879 >> /dev/zero
@ls -al $(bootstrap)
loop:fat12
-sudo umount /mnt
sudo mount -t msdos -o loop,fat=12 $(bootstrap) /mnt
run:boot fat12
qemu-system-i386 -drive file=$(bootstrap),if=floppy
runusb:writeusb
sudo qemu -drive file=/dev/sdb,if=floppy
runas:
qemu -drive file=$(bootstrap),if=floppy
writeusb:
sudo dd if=$(bootstrap) of=/dev/sdb