让我们直接对显示器说点什么吧
在上几节中,我们使用的BIOS的中断向量表来进行字符的输出,现在我们直接使用显存对显示器说点什么吧
编写mbr_3.S
;主引导程序
;--------------------------------------------------------------------
SECTION MBR vstart=0x7c00
mov ax,cs
mov ds,ax
mov es,ax
mov ss,ax
mov fs,ax
mov sp,0x7c00
mov ax,0xb800
mov gs,ax
;--------------------------------------------------------------------
mov ax,0600h
mov bx,0700h
mov cx,0
mov dx,184fh
int 10h
mov byte [gs:0x00],'1'
mov byte [gs:0x01],0xA4
mov byte [gs:0x02],' '
mov byte [gs:0x03],0xA4
mov byte [gs:0x04],'M'
mov byte [gs:0x05],0xA4
mov byte [gs:0x06],'B'
mov byte [gs:0x07],0xA4
mov byte [gs:0x08],'R'
mov byte [gs:0x09],0xA4
jmp $
times 510-($-$$) db 0
db 0x55,0xaa
[root@makeOS software]# nasm -o mbr.bin mbr_3.S
[root@makeOS software]# dd if=./mbr.bin \
> of=bochs/hd60M.img \
> bs=512 count=1 conv=notrunc
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.0317031 s, 16.1 kB/s
[root@makeOS bochs]# bin/bochs -f bochsrc.disk
========================================================================
Bochs x86 Emulator 2.6.2
Built from SVN snapshot on May 26, 2013
Compiled on May 25 2017 at 21:59:04
========================================================================
00000000000i[ ] reading configuration from bochsrc.disk
------------------------------
Bochs Configuration: Main Menu
------------------------------
This is the Bochs Configuration Interface, where you can describe the
machine that you want to simulate. Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found. When you are satisfied with the configuration, go
ahead and start the simulation.
You can also start bochs with the -q option to skip these menus.
1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now
Please choose one: [6]
这里我们启动之后,就能看到在屏幕的左上角有1MBR闪烁的样子