<自己动手写操作系统>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’的操作数也是一个严格语法的表达式)

转载于:https://www.cnblogs.com/GoGoagg/archive/2011/03/22/1991099.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值