美文网首页
[OS64位][002]源码阅读:程序3-1 boot.asm

[OS64位][002]源码阅读:程序3-1 boot.asm

作者: AkuRinbu | 来源:发表于2019-04-05 12:52 被阅读0次

学习笔记

使用教材(配书源码以及使用方法)
《一个64位操作系统的设计与实现》
http://www.ituring.com.cn/book/2450
https://www.jianshu.com/p/28f9713a9171


汇编源码 boot.asm

http://www.ituring.com.cn/book/2450
随书下载-源代码-第二部分-第三章- 程序3-1 boot.asm

源码阅读

代码功能

  • 一个主引导扇区程序,调用BIOS中断例程,在屏幕上显示字符串Start Boot

代码结构

初始化寄存器
清屏
设置光标
显示字符串
软盘驱动器复位
设置主引导扇区最后两个字节为0x55aa

BIOS int 10中断例程, AH 主功能编号

  • AH=06h 上卷指定范围的窗口(清空屏幕)
  • AH=02h 设置屏幕光标位置
  • AH=13h 在屏幕上显示字符串:ES:BP 要显示的字符串的内存地址
  • AH=00h 软盘驱动器的复位,将软盘驱动器的磁头移动至默认位置 :DL表示驱动器号 DL=00h 代表软盘A: DL=80h 代表第一个硬盘

Boot运行效果图 出现字符start Boot表示运行成功

注意高、低位地址的区别

  • 写法一 (本文使用的代码)
jmp $

StartBootMessage:   db  "Start Boot"

;=======    fill zero until whole sector

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

jmp $
times 510-($-$$) db 0
db 0x55,0xaa

完整源码

;/***************************************************
;       版权声明
;
;   本操作系统名为:MINE
;   该操作系统未经授权不得以盈利或非盈利为目的进行开发,
;   只允许个人学习以及公开交流使用
;
;   代码最终所有权及解释权归田宇所有;
;
;   本模块作者:  田宇
;   EMail:      345538255@qq.com
;
;
;***************************************************/

    org 0x7c00  

BaseOfStack equ 0x7c00

Label_Start:

    mov ax, cs
    mov ds, ax
    mov es, ax
    mov ss, ax
    mov sp, BaseOfStack

;=======    clear screen

    mov ax, 0600h
    mov bx, 0700h
    mov cx, 0
    mov dx, 0184fh
    int 10h

;=======    set focus

    mov ax, 0200h
    mov bx, 0000h
    mov dx, 0000h
    int 10h

;=======    display on screen : Start Booting......

    mov ax, 1301h
    mov bx, 000fh
    mov dx, 0000h
    mov cx, 10
    push    ax
    mov ax, ds
    mov es, ax
    pop ax
    mov bp, StartBootMessage
    int 10h

;=======    reset floppy

    xor ah, ah
    xor dl, dl
    int 13h

    jmp $

StartBootMessage:   db  "Start Boot"

;=======    fill zero until whole sector

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



参考资料

  • [001]Boot:使用bochs制作虚拟软盘镜像boot.img、启动并运行boot程序

https://www.jianshu.com/p/1c0bcee05714

  • 直接往显存 0xb800:0000 写数据

[003][x86汇编语言]开发环境配置:检测点4.2 从虚拟硬盘主引导扇区启动 虚拟机 VirtualBox
https://www.jianshu.com/p/9cb95d936451

[Linux]dd 读写软盘:在软盘主引导扇区写入显示hello world的二进制代码数据
https://www.jianshu.com/p/207aaf0f986b

  • 什么是主引导扇区?

[084][汇编语言]编程:实现从软盘启动进入自己写的超迷你“操作系统”: 显示 hello world!
https://www.jianshu.com/p/2c8ace0ee240

  • 汇编中的10H中断int 10h详细说明

https://blog.csdn.net/hua19880705/article/details/8125706

  • int 10h Video Interrupt

http://80864beginner.com/8086-Interrupt-List/int-10h-Video-Interrupt.html

  • The x86 PC

http://www.ee.hacettepe.edu.tr/~alkar/ELE336/ele336_2014_week5.pdf

相关文章

网友评论

      本文标题:[OS64位][002]源码阅读:程序3-1 boot.asm

      本文链接:https://www.haomeiwen.com/subject/udbhiqtx.html