加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 x86汇编语言-从实模式到保护模式

x86汇编语言-从实模式到保护模式.pdf

x86汇编语言-从实模式到保护模式

你们这些年轻人
2012-10-24 0人阅读 举报 0 0 暂无简介

简介:本文档为《x86汇编语言-从实模式到保护模式pdf》,可适用于IT/计算机领域

本书出版时间:年月底月初。任何疑问请到新浪微博均陵鼠侠或者加群。x汇编语言:从实模式到保护模式李忠王晓波余洁著PublishingHouseofElectronicsIndustry北京·BEIJINGx汇编语言:从实模式到保护模式内容简介每一种处理器都有它自己的机器指令集而汇编语言的发明则是为了方便这些机器指令的记忆和书写。尽管汇编语言已经较少用于大型软件程序的开发但从学习者的角度来看要想真正理解计算机的工作原理掌握它内部的运行机制学习汇编语言是必不可少的。这套图书分为两册采用开源的NASM汇编语言编译器和VirtualBox虚拟机软件以个人计算机广泛采用的Intel处理器为基础详细讲解了Intel处理器的指令系统和工作模式以大量的代码演示了//位软件的开发方法。上册集中介绍处理器的位实模式和位保护模式以及基本的指令系统下册侧重于介绍位工作模式、多处理器管理、高速缓存控制、温度和电源管理、高级可编程中断控制器、多媒体支持等。这是一本有趣的书它没有把篇幅花在计算一些枯燥的数学题上。相反它教你如何直接控制硬件在不借助于BIOS、DOS、Windows、Linux或者任何其他软件支持的情况下来显示字符、读取硬盘数据、控制其他硬件等。本书可作为大专院校相关专业学生和计算机编程爱好者的教程。未经许可不得以任何方式复制或抄袭本书之部分或全部内容。版权所有侵权必究。图书在版编目(CIP)数据/主编北京:电子工业出版社ISBNⅠ①汇…Ⅱ①…Ⅲ①Ⅳ①中国版本图书馆CIP数据核字()第号责任编辑:董亚峰印刷:装订:出版发行:电子工业出版社北京市海淀区万寿路信箱邮编开本:×印张:字数:千字印次:年月第次印刷定价:元凡所购买电子工业出版社图书有缺损问题请向购买书店调换。若书店售缺请与本社发行部联系联系及邮购电话:()。质量投诉请发邮件至zltspheicomcn盗版侵权举报请发邮件至dbqqpheicomcn。服务热线:()。第章十六进制计数法前言尽管汇编语言也是一种计算机语言但却是与众不同的与它的同类们格格不入。一方面处理器的工作是执行指令用它所做的一切都是执行指令并获得结果另一方面汇编语言为每一种指令提供了简单好记、易于书写的符号化表示形式。一直以来人们对于汇编语言的认识和评价可以分为两种一种是觉得它非常简单另一种是觉得它学习起来非常困难。你认为我会赞同哪一种?说汇编语言难学这没有道理。学习任何一门计算机语言都需要一些数制和数制转换的知识也需要大体上懂得计算机是怎么运作的。在这个前提下汇编语言是最贴近硬件实体的也是最自然和最朴素的。最朴素的东西反而最难掌握这实在说不过去。因此原因很可能出在我们的教科书上那些一上来就搞一大堆寻址方式的书往往以最快的速度打败了本来激情高昂的初学者。但是说汇编语言好学也同样有些荒谬。据我的观察很多人掌握了若干计算机指令会编写一个从键盘输入数据然后进行加减乘除或者归类排序的程序后就认为自己掌握了汇编语言。还有直到现在我还经常在网上看到学生们使用DOS中断编写程序他们讨论的也大多是实模式而非位或者位保护模式。他们知道如何编译源程序也知道在命令行输入文件名程序就能运行了使用一个中断就能显示字符。至于这期间发生了什么程序是如何加载到内存中的又是怎么重定位的似乎从来不关汇编语言的事。这样做的结果就是让人以为汇编语言不过如此没有大用而且非常枯燥。很难说我已经掌握了汇编语言的要义。但至少我知道尽管汇编语言不适合用来编写大型程序但它对于理解计算机原理很有帮助特别是处理器的工作原理和运行机制。就算是为了这个目的也应该让汇编语言回归它的本位那就是访问和控制硬件(包括处理器)而不仅仅是编写程序输入几个数字找出正数有几个、负数有几个大于的有几个。事实上汇编语言对学习和理解高级语言比如C语言也有极大的帮助。老教授琢磨了好几天终于想到一个好的比喻来帮助学生理解什么是指针实际上这对于懂得汇编语言的学生来说根本就不算个事儿并因此能够使老教授省下时间来喝茶。对于一个国家来说不能没有人来研究基础学科尽管它们不能直接产生效益而对于一个人来说也不能没有常识。尽管常识不能直接挣钱吃饭但它影响谈吐影响你的判断力和决断力决定着你接受新事物和新知识的程度。相应地汇编语言就是计算机语言里的常识和基础。这是继《穿越计算机的迷雾》之后我写的第二本书。这本书与上本书有两点不同第一上一本花了年才完成而这本只用了一年速度之快令我自己咂舌第二上本书属于科普性质漫谈计算机原理这本书就相对专业了。那些还想把我的书当小说看的人这回要失望了。很多人可能会问我为什么要写这样一本书。我只能说我第一次学汇编的经历实在是太深刻了。我第一次学汇编语言是在年手中的教材不能说不好但学习起来实在很吃力。要知道在那个年代没有网络要买到好书还得到大武汉。就这样我抱着两本书反反复复地看直到半年之后才懂得汇编语言是个什么东西。后来虽然有心写一本汇编语言的书一本不一样的汇编语言书但始终没有时间和精力。时间过得真快转眼年过去了。猛回头我发现同学们依然在走我的老路他们所用x汇编语言:从实模式到保护模式的教材都还是我那个年代的至少区别不大都还在讲处理器的实模式。保护模式是从哪个处理器开始引入的?当然是。它是哪个年代的产品?年!可是直到现在市面上也找不到太多能够把保护模式讲得比较清楚的图书。也许我应该做点什么。不事实上我已经做了那就是你手中的这本图书。王晓波和湖北经济学院的余洁共同参与了本书的创作。在计划写这本书的时候我就给自己画了几条线。首先不能走老路一上来就讲指令、寻址方式采用任务驱动方式来写每一章都要做点事情最好是比较有趣足够引起读者的事情。在解决问题的过程中引入一个个的指令并进行讲解。一句话我希望是润物细无声式的。其次汇编语言和硬件并举完全抛弃BIOS中断和DOS中断直接访问硬件发挥汇编语言的长处。这样读者才会深刻体会到汇编的妙处。这套图书主要讲述位实模式、位保护模式和Intel架构。引入虚拟模式是为了兼容传统的程序现在看来已经完全过时不再进行讲述。至于增强的位模式IAe读者可以在读完这本书之后自学也予以省略。书中配套的程序清单和源代码以及可能用到的程序软件感兴趣的读者可到电子工业出版社华信教育资源网下载(待定)。本书原来有章后来考虑到实模式的内容过多而去掉了一章。这一章的标题是《聆听数字的声音》讲述如何通过直接访问和控制SoundBlaster声卡来播放声音对此感兴趣的朋友可以在配书光盘中找到它。特别感谢长春电视台的王志强台长和台长助理周武军上本书《穿越计算机的迷雾》出版后台长王志强亲自过问出版情况并给予我特别的奖励希望大家同样能从这本书中读到他们对我的关怀和鼓励同时也要感谢我的母亲、我爱人和我的女儿她们是我的精神支柱。好友王南洋、桑国伟、刘维钊、蒋胜友、邱海龙、万利等负责了本书的一部分校对工作好友周卫平帮我验证配书代码是否能够在他的机器上正常工作如果想调试本书中的程序可以使用bochs软件它的视频教程是由王南洋制作的在这里向他们表示感谢。在阅读本书的过程中如果有任何问题可以按以下电子邮件地址给我写信:leechungcom或者进入我的博客参与讨论。博客地址是http:blogcomleechung第章十六进制计数法目录第部分预备知识第章十六进制计数法···························································································二进制计数法回顾··················································································关于二进制计数法···········································································二进制到十进制的转换·····································································十进制到二进制的转换·····································································十六进制计数法·····················································································十六进制计数法的原理·····································································十六进制到十进制的转换··································································十进制到十六进制的转换··································································为什么需要十六进制···············································································本章习题····································································································第章处理器、内存和指令····················································································最早的处理器························································································寄存器和算术逻辑部件············································································内存储器····························································································指令和指令集······················································································古老的Intel处理器········································································的通用寄存器·········································································程序的重定位难题·········································································内存分段机制···············································································的内存分段机制······································································本章习题··································································································第章汇编语言和汇编软件···················································································汇编语言简介······················································································NASM编译器·····················································································从网上下载NASM安装程序····························································安装NASM编译器········································································下载配书源码和工具······································································用Nasmide体验代码的书写和编译过程··············································用HexView观察编译后的机器代码····················································本章习题··································································································x汇编语言:从实模式到保护模式第章虚拟机的安装和使用·········································································计算机的启动过程················································································如何将编译好的程序提交给处理器····················································计算机的加电和复位······································································基本输入输出系统·········································································硬盘及其工作原理·········································································一切从主引导扇区开始···································································创建和使用虚拟机················································································别害怕虚拟机是软件···································································下载OracleVMVirtualBox·······························································安装OracleVMVirtualBox·······························································创建一台虚拟PC···········································································虚拟硬盘简介···············································································练习使用FixVhdWr工具向虚拟硬盘写数据·········································第部分位处理器下的实模式第章编写主引导扇区代码···················································································欢迎来到主引导扇区·············································································注释·································································································在屏幕上显示文字················································································显卡和显存··················································································初始化段寄存器············································································显存的访问和ASCII代码································································显示字符·····················································································显示标号的汇编地址·············································································标号···························································································如何显示十进制数字······································································在程序中声明并初始化数据·····························································分解数的各个数位·········································································显示分解出来的各个数位································································使程序进入无限循环状态·······································································完成并编译主引导扇区代码····································································主引导扇区有效标志······································································代码的保存和编译·········································································加载和运行主引导扇区代码····································································把编译后的指令写入主引导扇区·······················································启动虚拟机观察运行结果································································程序的调试··················································································第章十六进制计数法本章习题··································································································第章相同的功能不同的代码·············································································代码清单·······················································································跳过非指令的数据区·············································································在数据声明中使用字面值·······································································段地址的初始化···················································································段之间的批量数据传送··········································································使用循环分解数位················································································计算机中的负数···················································································无符号数和有符号数······································································处理器视角中的数据类型································································数位的显示·························································································其他标志位和条件转移指令····································································奇偶标志位PF··············································································进位标志CF·················································································溢出标志OF·················································································现有指令对标志位的影响································································条件转移指令···············································································NASM编译器的$和$$标记···································································观察运行结果····················································································本章习题··································································································第章比高斯更快的计算·······················································································从加到的故事·············································································代码清单·······················································································显示字符串·························································································计算到的累加和··········································································累加和各个数位的分解与显示·································································堆栈和堆栈段的初始化···································································分解各个数位并压栈······································································出栈并显示各个数位······································································进一步认识堆栈············································································程序的编译和运行················································································处理器的寻址方式·········································································寄存器寻址··················································································立即寻址·····················································································内存寻址·····················································································本章习题·································································································x汇编语言:从实模式到保护模式第章硬盘和显卡的访问与控制···········································································本章代码清单·····················································································本章意图····················································································代码清单················································································用户程序的结构··················································································分段、段的汇编地址和段内汇编地址·················································用户程序头部··············································································加载程序(器)的工作流程···································································初始化和决定加载位置··································································准备加载用户程序········································································外围设备及其接口········································································IO端口和端口访问·······································································通过硬盘控制器端口读扇区数据······················································过程调用····················································································加载用户程序··············································································用户程序重定位···········································································将控制权交给用户程序··································································处理器的无条件转移指令·······················································用户程序的工作流程············································································初始化段寄存器和堆栈切换····························································调用字符串显示例程·····································································过程的嵌套·················································································屏幕光标控制··············································································取当前光标位置···········································································处理回车和换行字符·····································································显示可打印字符···········································································滚动屏幕内容··············································································重置光标····················································································切换到另一个代码段中执行···························································访问另一个数据段·······································································编译和运行程序并观察结果···································································本章习题·································································································第章中断和动态时钟显示·················································································外部硬件中断·····················································································非屏蔽中断·················································································可屏蔽中断·················································································实模式下的中断向量表··································································实时时钟、CMOSRAM和BCD编码················································第章十六进制计数法代码清单················································································初始化、RTC和中断向量表·····················································使处理器进入低功耗状态·······························································实时时钟中断的处理过程·······························································代码清单的编译和运行·····························································内部中断···························································································软中断·····························································································常用的BIOS中断·········································································代码清单················································································从键盘读字符并显示·····································································代码清单的编译和运行·····························································本章习题·································································································第部分位保护模式第章位Intel微处理器编程架构··································································基本的工作模式··········································································线性地址···················································································现代处理器的结构和特点····································································流水线······················································································高速缓存···················································································乱序执行···················································································寄存器重命名·············································································分支目标预测·············································································位模式的指令系统···························

用户评价(3)

  • 10.44.7.248 以前,总是觉得编程很神秘。由于对计算机的不了解,对算法的迷惘,使我看到编程题不知如何入手,如何分析。读了《x86汇编语言:从实模式到保护模式》后使我从害怕编程变为热爱编程,使我从内部真正了解了计算机。

    2013-05-27 00:18:37

  • lactoferrin 作者主动放出大部分章节就已经很仁慈了,要读完整的建议购买正版.

    2013-05-24 00:52:10

  • 10.44.7.248 这位同学,你冒充作者本人上传本书,这没什么,但是冒充作者口吻散布什么“没有任何书和资料比朕的更清晰”这种言论,很不礼貌啊。

    2013-02-04 04:06:04

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/49

x86汇编语言-从实模式到保护模式

仅供在线阅读

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利