zoukankan      html  css  js  c++  java
  • at&t版启动引导初步

    BOOTSEG        = 0x07c0        /* original address of boot-sector */
    SYSSEG        = 0x1000        /* historical load address >> 4 */
        .code16
    
        .global bootsect_start
    bootsect_start:
    
        # Normalize the start address
        ljmp    $BOOTSEG, $start2
    
    start2:
        movw    %cs, %ax  /* make all the register to zero*/
        movw    %ax, %ds
        movw    %ax, %es
        movw    %ax, %ss
        xorw    %sp, %sp  /* zero the sp*/
        sti
        cld
    
    
    msg_loop:
        movw    $bugger_off_msg, %ax
        movw     %ax, %bp
        movw     $16, %cx
        movw     $0x1301, %ax
        movw    $0x00c, %bx
        int    $0x10
        jmp    msg_loop
    
    bugger_off_msg:
        .ascii "hello os world!!!"
        .org 510
        .word 0xaa55

    Makefile

    cc = gcc
    ld = ld
    as = as
    ld_flag = -Ttext 0x0 -s --oformat binary 
    c_flag = -E -traditional-cpp
    
    all:a.img
    a.img: boot.bin
        dd if=boot.bin of=a.img bs=512 conv=notrunc #用 bin file 生成对应的镜像文件
    boot.bin:boot.o
        $(ld) $(ld_flag) $^ -o $@
    boot.o:boot.s
        $(as) $^ -o $@
    boot.s:boot.S
        $(cc) $(c_flag) $^ -o $@
    clean:
        rm a.img boot.s boot.o boo.bin 

    这样一个简单的在bios POST后,打印hello os world的程序就完成了,相对于intel版的代码,在编译阶段相对来说复杂的多,但是复杂也就意味着更自由,继续学习。

  • 相关阅读:
    Spring Boot初学
    Spring MVC必须知道的执行流程
    日志Log4j使用
    SpringMVC处理中文乱码
    Maven设置阿里云镜像
    Maven项目中配置文件导出问题
    使用Limit实现分页
    web项目中设置首页
    JVM 学习笔记记录
    Python内存管理&垃圾回收机制
  • 原文地址:https://www.cnblogs.com/long0x0/p/3209720.html
Copyright © 2011-2022 走看看