【发布时间】:2015-07-27 21:51:51
【问题描述】:
%include "init.inc"
[org 0x0]
[bits 16]
jmp 0x07C0:start_boot
start_boot:
mov ax, cs
mov ds, ax
mov es, ax
load_setup:
mov ax, SETUP_SEG
mov es, ax
xor bx, bx
mov ah, 2 ; copy data to es:bx from disk.
mov al, 1 ; read a sector.
mov ch, 0 ; cylinder 0
mov cl, 2 ; read data since sector 2.
mov dh, 0 ; Head = 0
mov dl, 0 ; Drive = 0
int 0x13 ; BIOS call.
jc load_setup
lea si, [msg_load_setup]
call print
jmp $
print:
print_beg:
mov ax, 0xB800
mov es, ax
xor di, di
print_msg:
mov al, byte [si]
mov byte [es:di], al
or al, al
jz print_end
inc di
mov byte [es:di], BG_TEXT_COLOR
inc di
inc si
jmp print_msg
print_end:
ret
msg_load_setup db "Loading setup.bin was completed." , 0
times 510-($-$$) db 0
dw 0xAA55
我想将 setup.bin 加载到内存地址零。因此,我将 0 值输入到 es 寄存器(SETUP_SEG = 0)。 bx 也是。但它没有用。然后,我有一个关于这个问题的问题。我的测试如下。
SETUP_SEG 的值
0x0000 : 失败
0x0010 : 成功
0x0020 : 失败
0x0030 : 失败
0x0040 : 失败
0x0050 : 成功
我不明白为什么会发生这种情况。所有测试均在 VMware 上进行。有人有想法吗?
【问题讨论】:
-
VMware 运行什么?这看起来像 16 位实模式代码:(
-
对不起,我编辑了上面所有的引导代码。是的,16 位实模式代码。在 VMware 上运行该代码。
标签: operating-system bootstrapping