bootloader分析(BOIS)

来源:互联网 发布:淘宝网数据字典 编辑:程序博客网 时间:2024/05/22 19:54

BOIS存储在系统的0x7c00位置,利用bochs的调试功能对其进行分析,设置0x7c00的断点,下面是运行的汇编命令

        cli                # Disable interrupts 关闭中断,设置IF寄存器为0
        cld                # String operations increment设置串处理的方向,置0,SI DI自增,串处理从低地址到高地址方向处理


        # Set up the important data segment registers (DS, ES, SS).对各个寄存器清零
        xorw    %ax,%ax            # Segment number zero
        movw    %ax,%ds            # -> Data Segment
        movw    %ax,%es            # -> Extra Segment
        movw    %ax,%ss            # -> Stack Segment

 

        # Set up the stack pointer, growing downward from 0x7c00. 
        movw    $start,%sp             # Stack Pointer  $start地址为0x7c00

#打开A20 Gate Option 详细 为了读取1M以上的地址空间
#    * 读60h端口,读output buffer
#    * 写60h端口,写input buffer
#    * 读64h端口,读Status Register

seta20.1:    inb    $0x64,%al        # Get status  读状态寄存器  in al,0x64
        testb    $0x2,%al        # Busy?  test al,0x02
        jnz    seta20.1        # Yes 占用则跳转
        movb    $0xd1,%al        # Command: Write
        outb    %al,$0x64        #  output port
seta20.2:    inb    $0x64,%al        # Get status
        testb    $0x2,%al        # Busy?
        jnz    seta20.2        # Yes
        movb    $0xdf,%al        # Enable
        outb    %al,$0x60        #  A20

原创粉丝点击