zoukankan      html  css  js  c++  java
  • <自己动手写操作系统>2011032201

    【分析】

    部分代码:
    org  07c00h            ; Boot状态, Bios将把 Boot Sector加载到 0:7C00处并开始执行

    ;=====================================================================================

    BaseOfStack        equ    07c00h    ; Boot状态下堆栈基地址(栈底, 从这个位置向低地址生长)

    BaseOfLoader        equ    09000h    ; LOADER.BIN 被加载到的位置 ----  段地址
    ;暂时未知为什么Loader.bin加载到09000h段地址中?
    OffsetOfLoader        equ    0100h    ; LOADER.BIN 被加载到的位置 ---- 偏移地址

    RootDirSectors        equ    14    ; 根目录占用空间
    ;14怎么计算出来的?=RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec – 1)) / BPB_BytsPerSec=(224*32 + 512 -1)/512=14.9980=14
    SectorNoOfRootDirectory    equ    19    ; Root Directory 的第一个扇区号
    ;根据Fat12文档可以计算出,因为启动扇区(0),FAT1(1-9),FAT2(10-18),所以19是根目录的第扇区号
    SectorNoOfFAT1        equ    1    ; FAT1 的第一个扇区号    = BPB_RsvdSecCnt
    ;根据Fat12文档,得出BPB_RsvdSecCnt
    DeltaSectorNo        equ    17    ; DeltaSectorNo = BPB_RsvdSecCnt + (BPB_NumFATs * FATSz{BPB_FATSz16}) - 2
    ;根据Fat12文档,得出BPB_RsvdSecCnt=1,BPB_NumFATs=2,FATSz=BPB_FATSz16=9,所以结论是17

                        ; 文件的开始Sector号 = DirEntry中的开始Sector号 + 根目录占用Sector数目 + DeltaSectorNo

    ;=====================================================================================

    这段代码中equ关键字,查阅nasm,有如下声明:
    EQU: Defining Constants (定义常数)

                 EQU defines a symbol to a given constant value: when EQU is used, the source line must contain a label. ('EQU'定义一个符号,代表一个常量值:当使用'EQU'时,源文件行上必须包含一个 label)
                 The action of EQU is to define the given label name to the value of its (only) operand. This definition is absolute, and cannot change later. ('EQU'的行为就是把给出的 label 的名字定义成它的操作数(唯一)的值)
                 So, for example,

                 message                  db           ’hello, world’
                 msglen                   equ          $-message

                 defines msglen to be the constant 12. msglen may not then be redefined later. (把'msglen'定义成了常量 12。'msglen'不能再被重定义)
                 This is not a preprocessor definition either:the value of msglen is evaluated once, using the value of $ (see section 3.5 for an explanation of $) at the point of definition, rather than being evaluated wherever it is referenced and using the value of $ at the point of reference.(这也不是一个预自理定义:  'msglen'的值只被计算一次,计算中使用到了'$'(参阅 3.5)在此时的含义。注意  ‘EQU’的操作数也是一个严格语法的表达式)
  • 相关阅读:
    学习Spring,看这几本书就够了
    这份书单会告诉你,Java网络编程其实很重要
    心雨(三)【英语】
    成功安装SQL Server实例后 无法找到SQL Server Configuration Manager工具的解决方案
    Windows Cluster失败后,AlwaysOn在残存Server节点上快速恢复DB的详细步骤
    SQL Server 数据库本地备份文件通过OSS工具上阿里云(恢复还原数据库)
    透过systemctl管理mysqld服务
    MongoDB 读偏好设置中增加最大有效延迟时间的参数
    MongoDB 副本集丢失数据的测试
    MySQL 时间类型 DATE、DATETIME和TIMESTAMP
  • 原文地址:https://www.cnblogs.com/GoGoagg/p/1991099.html
Copyright © 2011-2022 走看看