汇编语言程序设计专题实验报告
第 1 页 共 69 页
汇编语言专题实验
磁盘保护程序设计报告
王 为
06055014
计算机 61
汇编语言程序设计专题实验报告
第 2 页 共 69 页
一.对课程设计的认识....................................................................................................................5
二.实验题目选择的原因................................................................................................................5
三.程序方案设计............................................................................................................................5
功能实现....................................................................................................................................5
总体设计....................................................................................................................................6
模块结构............................................................................................................................6
核心设计............................................................................................................................6
数据处理设计....................................................................................................................6
正确性设计........................................................................................................................7
安全性设计........................................................................................................................7
交互设计............................................................................................................................7
存储分配....................................................................................................................................7
结构体................................................................................................................................7
引导信息............................................................................................................................7
常量与中间变量................................................................................................................7
磁盘读写参数....................................................................................................................7
显示信息............................................................................................................................7
磁盘读写缓冲区................................................................................................................7
详细设计....................................................................................................................................8
Main ...................................................................................................................................8
RDREC ..............................................................................................................................9
BACKUP .........................................................................................................................10
RECOVER.......................................................................................................................12
GETSC.............................................................................................................................14
GETINFO ........................................................................................................................14
SHOWINFO ....................................................................................................................15
GETBAKSIZE.................................................................................................................16
GETBAKLPA..................................................................................................................17
READDISK .....................................................................................................................18
WRITEDISK....................................................................................................................19
B2A ..................................................................................................................................20
CLS ..................................................................................................................................21
MSGSF ............................................................................................................................22
MSG.................................................................................................................................23
YN....................................................................................................................................24
CONTINUE .....................................................................................................................25
RDKB ..............................................................................................................................26
四.调试与测试..............................................................................................................................27
五.软件操作说明..........................................................................................................................29
主程序操作说明..............................................................................................................29
汇编语言程序设计专题实验报告
第 3 页 共 69 页
磁盘信息显示子程序操作说明......................................................................................31
磁盘备份子程序操作说明..............................................................................................31
磁盘恢复子程序操作说明..............................................................................................31
六.实验总结..................................................................................................................................32
问题、疑惑、困难..................................................................................................................32
感悟与思索..............................................................................................................................33
抽象思维与具体实现......................................................................................................33
摊子越铺越大的难题......................................................................................................34
“顶天立地”的新体会..................................................................................................35
基础不牢,地动山摇......................................................................................................35
做事情要一步一个脚印,不能好高骛远......................................................................36
七.参考书目..................................................................................................................................37
八.程序清单..................................................................................................................................37
;宏定义 ....................................................................................................................................37
CLS MACRO ;清屏幕 .............................................................................................37
YN MACRO ;提示输入 Y/N,并判断 ......................................................................38
RDYN MACRO ;判断键盘输入是否为 Y/N..........................................................38
RDKB MACRO ;读一个键盘输入字符..................................................................38
CONTINUE MACRO ;显示按任意键继续信息 .....................................................39
MSGSF MACRO MSGS,MSGF;显示操作成功/失败信息.....................................39
MSG MACRO MSG ;显示信息 ............................................................................39
GETSC MACRO SC,S,C ;由 SC 计算 S,C......................................................40
MVAR MACRO VARD,VARS,SIZE ;多字长数据赋值.......................................40
B2A_8 MACRO BIN,ASC ;二进制向 ASCII 码的转换 .....................................41
B2A_16 MACRO BIN,ASC ;二进制向 ASCII 码的转换 ....................................42
B2A_32 MACRO BIN,ASC ;二进制向 ASCII 码的转换 ....................................43
B2A_64 MACRO BIN,ASC ;二进制向 ASCII 码的转换 ....................................44
READDISK MACRO BufferAddress,LPA,BlockCount ..........................................45
;读磁盘扇区 ....................................................................................................................45
WRITEDISK MACRO BufferAddress,LPA,BlockCount ........................................46
;写磁盘扇区 ....................................................................................................................46
DADD MACRO NUM1,NUM2,NUM3,COUNT ;多字数据除法........................46
DSUB MACRO NUM1,NUM2,NUM3,COUNT ;多字数据除法.........................47
DMUL MACRO MCD1, MCD2, MCD3, COUNT .........................................48
;多字数据乘法 ................................................................................................................48
DDIV MACRO MCD1,MCD2,MCD3,COUNT ;多字数据除法..........................50
CINIT MACRO ;程序段初始化 ...........................................................................52
结构体定义..............................................................................................................................53
DAP_STRUC STRUC ;磁盘读写数据包................................................................53
DPP_STRUC STRUC ;磁盘参数数据包 ................................................................53
;数据段 ....................................................................................................................................53
;除法临时存储单元 ........................................................................................................53
;常量 ................................................................................................................................54
;磁盘参数 ........................................................................................................................54
汇编语言程序设计专题实验报告
第 4 页 共 69 页
;结构体变量 ....................................................................................................................55
;MBR 数据区...................................................................................................................55
;DBR 数据区 ...................................................................................................................55
;ASC_MBR 数据.............................................................................................................56
;ASC_DBR 数据 .............................................................................................................56
; ASC_其他磁盘参数......................................................................................................57
;显示信息区 ....................................................................................................................57
;界面区 ....................................................................................................................57
;开始界面,欢迎信息 ....................................................................................57
;功能菜单界面 ................................................................................................57
;退出界面 ........................................................................................................58
;消息区 ....................................................................................................................58
;磁盘信息读写信息 ........................................................................................58
;磁盘 CHS 信息...............................................................................................58
;主分区信息 ....................................................................................................58
;磁盘备份恢复信息 ........................................................................................59
;磁盘读些缓冲区 ............................................................................................59
代码段......................................................................................................................................59
MAIN PROC FAR;主程序........................................................................................60
RDREC PROC NEAR;读取磁盘引导信息..............................................................61
BACKUP PROC NEAR;备份磁盘信息...................................................................62
RECOVER PROC NEAR;恢复磁盘信息 ................................................................63
GETINFO PROC NEAR;计算并转换磁盘信息......................................................64
SHOWINFO PROC NEAR;显示磁盘信息..............................................................65
GetBAKSize PROC NEAR;计算备份所需扇区数目..............................................66
GetBAKLPA PROC NEAR;计算备份磁盘地址 .....................................................67
Div8 PROC NEAR ;二进制向 ASCII 码的转换...................................................67
Div16 PROC NEAR ;二进制向 ASCII 码的转换.................................................68
DIV_32 PROC NEAR;二进制向 ASCII 码的转换..................................................68
DIV_64 PROC NEAR;二进制向 ASCII 码的转换..................................................68
汇编语言程序设计专题实验报告
第 5 页 共 69 页
一.对课程设计的认识
汇编是一门极其重要的课程。从硬件角度看,学不好汇编就等于不懂计算机。一方面汇
编语言本身非常重要,另一方面在汇编课程中对计算机硬件的原理学习非常重要。程序怎样
存储,怎样运行,内存如何分配,高级语言怎样执行,I/O 设备怎样管理和控制等等。
汇编实验就是把课程内学到的计算机原理以及汇编语言知识应用实践当中,真切、实际地去
感受计算机硬件的操作原理,工作方式以及控制手段,亲身体会汇编编程的思想方法,加深
对计算机整体的认识,为以后积累宝贵的实践经验。
到汇编语言是仅仅比机器语言高一层的语言,能够学好汇编语言才能够对计算机底层的
具体实现有深刻的理解,才能真正明白到底计算机里面是个什么样的。学不好汇编那就是计
算机还没有入门。具体来说专题实验有以下几个作用:
的复习、巩固汇编知识
培养动手能力
培养自学能力
培养独立思考能力和创新能力
熟悉计算机的底层操作、硬件操作
二.实验题目选择的原因
汇编语言一是用在执行效率要求很高的地方,二是用在和底层硬件直接打交道的地方,
这两个地方高级语言都无法实现。能用高级语言实现的地方,用汇编就失去了意义,所以我
就选择了最硬的题目,这样能最好的体现汇编的价值,同时也给自己一个学习硬件知识,亲
身体会磁盘控制的良好机会。
三.程序方案设计
功能实现
读取磁盘的 MBR、DPT、DBR、CHS 信息,获取磁盘信息并显示;将磁盘引导,操作
系统引导信息备份至最后 2 柱面;将磁盘引导,操作系统引导信息备份进行恢复
评论0