inline assembly.zip

  • s2_859068
    了解作者
  • 139.4KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-24 03:19
    上传日期
包括两个文件,一个GCC Inline Assembly HOWTO,一个IBM的文档Inline assembly for x86 in Linux Putting the pieces together
inline assembly.zip
  • inline assembly
  • GCC-Inline-Assembly-HOWTO.pdf
    43.1KB
  • l-ia-pdf.pdf
    154.1KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/626451364c65f41259cae270/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/626451364c65f41259cae270/bg1.jpg"><div class="t m0 x1 h2 y1 ff1 fs0 fc0 sc0 ls0 ws0">&#169; Copyright IBM Corporation 2001<span class="_ _0"> </span>T<span class="_ _1"></span>rademarks</div><div class="t m0 x1 h2 y2 ff1 fs0 fc1 sc0 ls0 ws0">Inline assembly for x86 in Linux<span class="_ _2"> </span>Page 1 of 9</div><div class="t m0 x1 h3 y3 ff2 fs1 fc2 sc0 ls0 ws0">Inline assembly for x86 in Linux</div><div class="t m0 x1 h4 y4 ff2 fs2 fc2 sc0 ls0 ws0">Putting the pieces together</div><div class="t m0 x1 h5 y5 ff1 fs3 fc0 sc0 ls0 ws0">Bharata Rao<span class="fc1"> (</span>rbharata@in.ibm.com<span class="fc1">)</span></div><div class="t m0 x1 h5 y6 ff1 fs3 fc1 sc0 ls0 ws0">IBM Linux T<span class="_ _3"></span>echnology Center<span class="_ _4"></span>, IBM Software Labs, India</div><div class="t m0 x2 h5 y5 ff1 fs3 fc1 sc0 ls0 ws0">01 March 2001</div><div class="t m0 x3 h5 y7 ff1 fs3 fc1 sc0 ls0 ws0">Bharata B. Rao offers a guide to the overall use and structure of inline assembly for x86 on the</div><div class="t m0 x3 h5 y8 ff1 fs3 fc1 sc0 ls0 ws0">Linux platform. He covers the basics of inline assembly and its various usages, gives some</div><div class="t m0 x3 h5 y9 ff1 fs3 fc1 sc0 ls0 ws0">basic inline assembly coding guidelines, and explains the instances of inline assembly code in</div><div class="t m0 x3 h5 ya ff1 fs3 fc1 sc0 ls0 ws0">the Linux kernel.</div><div class="t m0 x1 h5 yb ff1 fs3 fc1 sc0 ls0 ws0">If you're a Linux kernel developer<span class="_ _4"></span>, you probably find yourself coding highly architecture-dependent</div><div class="t m0 x1 h5 yc ff1 fs3 fc1 sc0 ls0 ws0">functions or optimizing a code path pretty often. And you probably do this by inserting assembly</div><div class="t m0 x1 h5 yd ff1 fs3 fc1 sc0 ls0 ws0">language instructions into the middle of C statements (a method otherwise known as inline</div><div class="t m0 x1 h5 ye ff1 fs3 fc1 sc0 ls0 ws0">assembly). Let's take a look at the specific usage of inline assembly in Linux. (We'll limit our</div><div class="t m0 x1 h5 yf ff1 fs3 fc1 sc0 ls0 ws0">discussion to the IA32 assembly<span class="_ _4"></span>.)</div><div class="t m0 x1 h4 y10 ff2 fs2 fc2 sc0 ls0 ws0">GNU assembler syntax in brief</div><div class="t m0 x1 h5 y11 ff1 fs3 fc1 sc0 ls0 ws0">Let's first look at the basic assembler syntax used in Linux. GCC, the GNU C Compiler for Linux,</div><div class="t m0 x1 h5 y12 ff1 fs3 fc1 sc0 ls0 ws0">uses A<span class="_ _4"></span>T&amp;T assembly syntax. Some of the basic rules of this syntax are listed below<span class="_ _4"></span>. (The list is by</div><div class="t m0 x1 h5 y13 ff1 fs3 fc1 sc0 ls0 ws0">no means complete; I've included only those rules pertinent to inline assembly<span class="_ _4"></span>.)</div><div class="t m0 x1 h6 y14 ff2 fs3 fc2 sc0 ls0 ws0">Register naming</div><div class="t m0 x1 h5 y15 ff1 fs3 fc1 sc0 ls0 ws0">Register names are prefixed by %. That is, if eax has to be used, it should be used as %eax.</div><div class="t m0 x1 h6 y16 ff2 fs3 fc2 sc0 ls0 ws0">Source and destination ordering</div><div class="t m0 x1 h5 y17 ff1 fs3 fc1 sc0 ls0 ws0">In any instruction, source comes first and destination follows. This differs from Intel syntax, where</div><div class="t m0 x1 h5 y18 ff1 fs3 fc1 sc0 ls0 ws0">source comes after destination.</div><div class="t m0 x1 h7 y19 ff3 fs4 fc3 sc0 ls0 ws0"> mov %eax, %ebx, transfers the contents of eax to ebx.</div><div class="t m0 x1 h6 y1a ff2 fs3 fc2 sc0 ls0 ws0">Size of operand</div><div class="t m0 x1 h5 y1b ff1 fs3 fc1 sc0 ls0 ws0">The instructions are suffixed by b, w<span class="_ _4"></span>, or l, depending on whether the operand is a byte, word, or</div><div class="t m0 x1 h5 y1c ff1 fs3 fc1 sc0 ls0 ws0">long. This is not mandatory; GCC tries provide the appropriate suffix by reading the operands. But</div><div class="t m0 x1 h5 y1d ff1 fs3 fc1 sc0 ls0 ws0">specifying the suffixes manually improves the code readability and eliminates the possibility of the</div><div class="t m0 x1 h5 y1e ff1 fs3 fc1 sc0 ls0 ws0">compilers guessing incorrectly<span class="_ _4"></span>.</div><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a></div><div class="pi" data-data='{"ctm":[1.612700,0.000000,0.000000,1.612700,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐
    • 嵌入式linux嵌入式linux嵌入式linux嵌入式linux嵌入式linux
      嵌入式linux嵌入式linux嵌入式linux嵌入式linux嵌入式linux
    • 嵌入式linux起步
      嵌入式linux起步,华清远见的一个资料,大家看看
    • 嵌入式linux 学习
      嵌入式linux 开发学习,linux下的uboot,文件系统,驱动介绍。
    • 嵌入式LINUX教程
      嵌入式LINUX教程,作为初学者教程很受欢迎
    • 嵌入式linux
      本光盘为《嵌入式Linux应用开发详解》一书的配套光盘.本软件系统包括本书部分例子程序的源代码和3个实际的样例程序。 本光盘目录结构及说明如下: /demo **本书各章部分例子程序源代码 /examples **样例程序的...
    • 嵌入式linux
      介绍嵌入式linux系统的应用 基础教程
    • 嵌入式Linux开发
      嵌入式系统概述; Linux系统编程简介; Linux应用程序设计; 嵌入式Linux环境构建; 嵌入式Linux应用开发;
    • 嵌入式LINUX教程
      嵌入式linux教程,很实用的一个pdf格式的电子教程,欢迎下载分享!
    • 嵌入式linux开发
      嵌入式linux开发入门 系统的介绍了linux嵌入式开发,对想了解这方面的朋友应该有益处
    • 嵌入式linux教程
      嵌入式Linux技术是近年来发展最为迅猛、最受人们关注的一门新兴技术。本书分为四篇。在附录中包括了通用公共产权说明(GPL)、GDB调试器串行通信协议和嵌入式Linux的重要网上资源。