注册 登录
编程论坛 操作系统内核开发

请教实模式下段的问题

nwpu063417 发布于 2011-01-26 18:40, 1056 次点击
看操作系统入门书籍都有这样一个bootloader的例子,注意两个程序的起始地址不同。为什么第二个将es的值设置为0x7c00之后就可以运行正确了呢?
谢谢大家~~

;loader1.asm
org 0x7c00            
bits 16            
Start:
        mov        ax, cs
        mov        ds, ax
        mov        es, ax

        call DispStr
        jmp $
DispStr:
    mov        ax, Msg
    mov        bp, ax        ; ES:BP  string address
    mov        cx, 16
    mov        ax, 01301h
    mov        bx, 000ch
    mov        dl, 0
    int        10h
    ret

Msg:
    db "Hello, world!"

times 510 - ($-$$) db 0     
dw 0xAA55

;loader2.asm
org 0                 ; We are loaded at 0, not at 0x7C00!
bits 16            
Start:
        mov        ax, 0x7c0
    ;    mov        cs, ax
    ;    mov        ds, ax
        mov        es, ax

        call DispStr
        jmp $
DispStr:
    mov        ax, Msg
    mov     bp, ax        ; ES:BP  string address
    mov        cx, 36
    mov        ax, 01301h
    mov        bx, 000ch
    mov        dl, 0
    int        10h
    ret

Msg:
    db "Hello, world, in 0!"

times 510 - ($-$$) db 0     
dw 0xAA55
2 回复
#2
nwpu0634172011-01-28 11:00
自己解决
http://blogimg.


版内太冷清了吧。。。。
#3
lh68682011-10-24 22:51
第二个能行吗??有点问题吧。。。
1