⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 汇编指令与机器码的相互转换.htm

📁 用户相信你一定安装过操作系统
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0041)http://computer.info-man.net/zs_4107.html -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD 
profile=http://gmpg.org/xfn/11><TITLE>汇编指令与机器码的相互转换</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META content=汇编指令与机器码的相互转换 name=description><LINK media=screen 
href="汇编指令与机器码的相互转换.files/style.css" type=text/css rel=stylesheet><LINK 
title="RSS 2.0" href="http://computer.info-man.net/rss2.xml" 
type=application/rss+xml rel=alternate>
<META content="MSHTML 6.00.2900.3199" name=GENERATOR></HEAD>
<BODY>
<DIV class=container>
<DIV class=header>
<DIV class=title>
<H1><A href="http://computer.info-man.net/">计算机知识库</A></H1></DIV>
<DIV class=navigation><A href="http://computer.info-man.net/">首页</A> <A 
title=操作系统 href="http://computer.info-man.net/nav1_1.html">操作系统</A> <A 
title=程序设计 href="http://computer.info-man.net/nav1_2.html">程序设计</A> <A 
title=WEB应用 href="http://computer.info-man.net/nav1_3.html">WEB应用</A> <A 
title=数据库 href="http://computer.info-man.net/nav1_4.html">数据库</A> <A title=网络原理 
href="http://computer.info-man.net/nav1_5.html">网络原理</A> <A title=网络应用 
href="http://computer.info-man.net/nav1_6.html">网络应用</A> <A title=安全技术 
href="http://computer.info-man.net/nav1_7.html">安全技术</A> </DIV></DIV>
<DIV class=main>
<DIV class=content><!-- google_ad_section_start -->
<DIV class=post>
<H1><A title=汇编指令与机器码的相互转换 
href="http://computer.info-man.net/zs_4107.html">汇编指令与机器码的相互转换</A></H1>
<SCRIPT type=text/javascript><!--google_ad_client = "pub-6749825135131597";google_alternate_color = "FFFFFF";google_ad_width = 468;google_ad_height = 15;google_ad_format = "468x15_0ads_al_s";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "446666";google_color_text = "446666";google_color_url = "446666";//--></SCRIPT>

<SCRIPT src="汇编指令与机器码的相互转换.files/show_ads.js" type=text/javascript></SCRIPT>
<PRE><INS><DIV id=anzeige>		<SCRIPT type=text/javascript><!--google_ad_client = "pub-6749825135131597";google_alternate_color = "FFFFCC";google_ad_width = 336;google_ad_height = 280;google_ad_format = "336x280_as";google_ad_type = "text";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "446666";google_color_text = "446666";google_color_url = "446666";//--></SCRIPT>
<SCRIPT src="汇编指令与机器码的相互转换.files/show_ads.js" type=text/javascript></SCRIPT>
<SCRIPT type=text/javascript><!--google_ad_client = "pub-6749825135131597";google_alternate_color = "FFFFCC";google_ad_width = 336;google_ad_height = 280;google_ad_format = "336x280_as";google_ad_type = "text";google_ad_channel = "";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "446666";google_color_text = "446666";google_color_url = "446666";//--></SCRIPT>
<SCRIPT src="汇编指令与机器码的相互转换.files/show_ads.js" type=text/javascript></SCRIPT>
		</DIV></INS>机器语言我们只要重点理解一下几个概念:   1. 机器语言指令有操作码(OP)和地址码两部分组成      |_____________OP_______________|__d__|__w__|  |_____________OP_______________|__s__|__w__| &amp;lt;--此格式用于立即寻址方式    在多数操作码中,常使用某些位来指示某些信息:  如图上结构里的: w=1 时 对字来操作           w=0 时 对字节来操作   d值在双操作数指令中才有效         当 d=1 时 有且只有一个寄存器用于目的操作数           d=0 时 有且只有一个寄存器用于源操作数   s=1 时 立即数为8位,但要求扩展成16位数           s=0 时 当指令作字节操作/有16位立即数  由于汇编的指令格式很多,这里我只作一些基本情况介绍,必要时读者可以下载/查阅80x86汇编小站http://www.x86asm.com提供的OPCODES手册来查阅。   2. 寻址方式的机器语言表示:   |  mod  |    reg    |  r/m  |    |_____|_____|_____|_____|_____|_____|_____|  reg 表示寄存器方式,在不包括立即数的双操作数指令的情况下,规定必须有一个操作数在寄存器中,该寄存器由reg字段指定,并与操作码字节中的w位相组合确定的寄存器  mod字段与r/m(register/memory)字段结合在一起确定另一个操作数的寻址方式现在你们下载了80x86汇编小站(http://www.x86asm.com)提供的OPCODES 手册了吗?下载好了,请解压后打开里面的:opcodes.html 文件,然后熟悉里面的表格: 现在熟悉简单的:______________________________________________________________________________表1 &amp;lt;PS:部分资料&amp;gt;    rrr : W=0 : W=1 : reg32   000 : AL : AX : EAX   001 : CL : CX : ECX   010 : DL : DX : EDX   011 : BL : BX : EBX   100 : AH : SP : ESP   101 : CH : BP : EBP   110 : DH : SI : ESI   111 : BH : DI : EDI______________________________________________________________________________表2 &amp;lt;PS:部分资料&amp;gt;    rrr : Index Register             000 : EAX    001 : ECX    010 : EDX    011 : EBX    100 : No Index    101 : EBP    110 : ESI    111 : EDI______________________________________________________________________________表3 &amp;lt;PS:部分资料&amp;gt;    mmm : Function       11                             w=1             000 : DS:[BX+SI]        001 : DS:[BX+DI]    010 : SS:[BP+SI]    011 : SS:[BP+DI]         BX           100 : DS:[SI]    101 : DS:[DI]    110 : SS:[BP]    111 : DS:[BX]______________________________________________________________________________表4 &amp;lt;PS:部分资料&amp;gt;oo : Function   00 : If mmm = 110, then a displacement follows the operation; otherwise, no displacement is used   01 : An 8-bit signed displacement follows the opcode   10 : A 16-bit signed displacement follows the opcode   11 : mmm specifies a register, instead of an addressing mode______________________________________________________________________________上面的表,你都看明白了吗? 现在我就教你们如何利用这样的表格来把汇编指令翻译机器码  3.指令格式简介  8086所用的16位指令格式:  ________  _____________  ________  ________  |操作码| + |mod-reg-r/m| + |位移量| + |立即数|  1~2字节   0~1字节     0~2字节  0~2字节  OK!以上就是基本知识,下面我们来实践吧:  &amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;问题:   MOV AX,1234H 对应的机器码为:B83412    MOV EBX,0   对应的机器码为:66BB00000000   MOV CL,55H  对应的机器码为: B155   MOV AX,BX   对应的机器码为:8BC3    我在问一下,机器码的数据格式是什么? 好像是 机器指令+操作数(高位存放在地址高位,低位存放在地址低位),但是前面MOV AX,怎么就变成了B8,弄不明白,请指教。  PS: 上面的题目是一个网友问的,现在我来实践一遍给你们看。&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;  指令1 -&amp;gt; MOV AX,1234H 对应的机器码为:B83412   解法: 判断-&amp;gt; 这个是8086汇编16位汇编指令格式,并且是立即寻址方式    查表-&amp;gt; 打开opcodes.html文件,找到标题为&amp;ldquo;Main Instructions&amp;rdquo;,单击&amp;ldquo;M&amp;rdquo;字母,然后对应查看 &amp;ldquo;MOV Reg,Imm&amp;rdquo;格式的&amp;ldquo;OpCode&amp;rdquo;项为:1011wrrr   再判断-&amp;gt; 由于寄存器是AX, 立即数是1234H,明显是&amp;ldquo;对字操作&amp;rdquo;,所以w=1        在查看本文章上面的&amp;ldquo;表1&amp;rdquo;,对应的查到rrr的值为000  组合结果-&amp;gt; w=1        rrr=000        1011wrrr=1011 1000B -&amp;gt;B8H           根据&amp;ldquo; 3.指令格式简介&amp;rdquo; -&amp;gt; B8H + |立即数(低位在前高位在后)|= B83412H   PS: &amp;quot;+&amp;quot; 符号不为&amp;ldquo;加号&amp;rdquo;   好了,已经解完第一题了,机器码为 B83412H    &amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;  指令4 -&amp;gt; MOV AX,BX   对应的机器码为:8BC3  解法: 判断-&amp;gt; 这个是8086汇编16位汇编指令格式,并且是寄存器寻址方式    查表-&amp;gt; 打开opcodes.html文件,找到标题为&amp;ldquo;Main Instructions&amp;rdquo;,单击&amp;ldquo;M  &amp;rdquo;字母,然后对应查看 &amp;ldquo;MOV Reg,Reg&amp;rdquo;格式的&amp;ldquo;OpCode&amp;rdquo;项为:1000101woorrrmmm   再判断-&amp;gt; 由于寄存器是AX, BX 明显是&amp;ldquo;对字操作&amp;rdquo;,所以w=1        在查看本文章上面的&amp;ldquo;表4&amp;rdquo;,对应查到oo=11 因为是寄存器寻址方式        在查看本文章上面的&amp;ldquo;表1&amp;rdquo;,对应查到rrr的值为000 ,因为当两个操  作数都是寄存器,那么一般要以目的操作数为准        在查看本文章上面的&amp;ldquo;表3&amp;rdquo;, 对应查到mmm的值为011 ,因为当两个操作数都是寄存器,那么一般要以源操作数为准  组合结果-&amp;gt; w=1        oo=11       rrr=000       mmm=0111000101woorrrmmm=1000 1011 1100 0011B -&amp;gt;8BC3H  好了,已经解完第二题了,机器码为8BC3H&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;  呵呵,不错吧,很简单吧,有了80X86 OPCODES 查询表一切都是那么简单,如果还有什么问题,大家都来这里提问!  剩下的:   指令2 -&amp;gt; MOV EBX,0   对应的机器码为:66BB00000000   指令3 -&amp;gt; MOV CL,55H  对应的机器码为: B155  大家来练练手,注意指令2 需要用到32位指令格式,请查阅相关的80x86汇编语言书籍的机器语言部分,应该有解释的。  指令2的解法,请大家等待,或者大家研究一下,把解法贴出来,给大家参考哦!   ----待续                              2004  2月14日</PRE>当前位置:<A 
href="http://computer.info-man.net/">首页</A>&gt;&gt;<A 
href="http://computer.info-man.net/nav1_2.html">程序设计</A>&gt;&gt;<A 
href="http://computer.info-man.net/nav2_8.html">汇编语言</A>
<DIV class=descr>&nbsp;</DIV>
<P class=info></P></DIV><!-- google_ad_section_end --></DIV>
<DIV class=sidenav>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -