0.准备
- 书中这里将显示代码分到Haribote.nas。org 0xc400载入内存中。
- 对于每一个nasm生成的bin文件而言都是从0x0000000开始的,也就是说我们可以把bin文件载入到u盘的任意扇区,从上一个博客我们将30697的扇区载入到内存地址为0x8200中,所以我们把haribote.bin文件放到u盘的30698扇区,内存地址从0x8400开始,所以首先将haribote.nas改成org 0x8400再加入一句打印信息看下效果,毕竟书中最后的效果是显示全黑
- ipl10.nas里的最后jmp 改为jmp 0x8400
; haribote-os
; TAB=4
ORG 0x8400
MOV SI, msg
call putloop
MOV AL,0x13
MOV AH,0x00
INT 0x10
fin:
HLT
JMP fin
msg:
DB 0x0a
DB "fuck test"
DB 0
putloop:
MOV AL,[SI]
ADD SI,1
CMP AL,0
JE FINISH
MOV AH,0x0e
MOV BX,15
INT 0x10
JMP putloop
FINISH:
ret
ipl10.nas
push ds
mov ax, 0x820
mov ds, ax
mov bx, 0x0
mov dl, [bx]
mov dh, 0xff
call dispreg16
JMP 0x8400
haribote.bin内容:
使用dd命令写入u盘30698扇区:
dd if=startHaribote\haribote.bin of=\\.\Volume{19572513-924e-11e8-afeb-806e6f6e6963} seek=30698
写入扇区后,U盘内容如下:
1.结果
看起来黑黑一片,其实是有亮度的,再选择u盘启动后,会先显示上一张的0x42的内容和haribote.nas的内容,然后再屏幕变黑的。