While 64-bit x86 processors have now been on the market for more than 5 years, software support is only slowly catching on. 64-bit x86, or x86-64 as its inventors at AMD called it, not only offers programmers the ability to manipulate and address data in larger chunks, but added some other niceties like an additional 8 general purpose registers.

Transitioning assembly code from x86 to x86-64 is pretty straightforward, but there are some changes worth noting.

  1. Full 64-bit registers are prefixed with r. So for 64-bit operations, you use rax rather than eax, rdi rather than edi and so forth.
  2. The 8 new integer registers are labeled r8, r9, ... r15. To use only a part of the register, a suffix is added. 8-bits = b, 16-bits = w, 32-bits = d, meaning r8b, r8w and r8d in the case of r8.
  3. 32-bit operations on a register automatically zero out the upper 32-bits of that register. For instance, if you load 0 into eax, rax is guaranteed to be 0.
  4. The C ABI and calling conventions are substantially different. On standard x86 (32-bit), arguments are passed on the stack. On x86-64, many of the arguments are passed via registers.

    For Linux, the calling conventions are as follow:

    Registers rbp, rbx and r12 through r15 belong to the calling function. If the called function intends to modify them, it should save them at the beginning and restore them before returning. The caller must assume that all other registers can be changed by the called function.

    As in x86, integral return values are passed in rax. Parameters are trickier. The first 6 integral parameters are passed left-to-right, in rdi, rsi, rdx, rcx, r8 and r9 respectively. Remaining integral parameters are passed on the stack, but from right-to-left.

    p. 21 of the x86-64 ABI has a good explanation.

    In Windows x64, the system is similar. Registers rbp rbx, rdi, rsi and r12 through r15 belong to the calling function. All others belong to the called function. Return values are via rax. Input parameters are passed first in rcx, rdx, r8 and r9 (left to right). Remaining arguments are passed via the stack, right to left.

  5. pushad and popad are gone. There are no 64-bit equivalent instructions. Presumably this is because with a greater number of registers, there should be no need to save and restore all registers when entering and exiting a function.
  6. cqo is the new cdq. For sign-extending from eax to edx (32 bit), cdq was used. For sign-extending rax to rdx, cqo (convert-quad-to-oct) is used. It’s a handy little instruction, and not one that I managed to find easily.

Moving x86 assembly to 64-bit (x86-64)的更多相关文章

  1. 64位主机64位oracle下装32位客户端ODAC(NFPACS版)

    64位主机64位oracle下装32位客户端ODAC(NFPACS版) by dd 1.下载Oracle Data Access Components(ODAC) Xcopy的两个版本: x86:(我 ...

  2. autoCAD 2008 Win7 64位, win8 64位 安装 燕秀工具箱 yanxiu.cui 文件下载

    Win7 64位, win8 64位 安装 燕秀工具箱 , 提示没有权限. 网站上下载燕秀工具箱, 安装后. 提示权限不够. 解决办法如下; 1. CAD, 权限修改. 2. 下载 yanxiu.cu ...

  3. 利用Powerdesigner16.5(64位)连接64位oracle 配置系统odbc驱动

    利用Powerdesigner16.5(64位)连接64位oracle逆向工程数据库 记录一次Powerdesigner通过odbc连接64位oracle数据库.林林总总国内看到都是些乱七八糟没几个靠 ...

  4. 浅淡Windows7 32位与64位/x86与x64的区别

    看到有很多会员问到底是选Windows7 x86,还是选x64.这里简单的谈一下这这两种系统的区别. 简单的说x86代表32位操作系统  x64代表64位操作系统. 简单的判断电脑是否支持64位操作系 ...

  5. win2008 64位 + oracle11G 64位 IIS7.5 配置WEBSERVICE

    第一个错误: 安装过程依旧是那样简单,但在配好IIS站点,准备连接数据库的时候出错了,以下是错误提示:System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更 ...

  6. Oracle Linux(64位)安装64位Oracle10g遇到ins_ctx.mk问题

    在Oracle Linux Server Release 5.7上安装64位Oracle 10g 时,遇到如下问题: Error in invoking target 'install' of mak ...

  7. ubuntu16 64位 编译64位程序和32位程序

    安装了ubuntu16 64位的系统,想在该环境下用gcc编译64位和32位的程序 默认已经安装了64位环境的gcc 1. 首先确认安装的环境是不是64位的 cocoa@cocoaUKlyn:~/De ...

  8. 32位x86处理器编程导入——《x86汇编语言:从实模式到保护模式》读书笔记08

    在说正题之前,我们先看2个概念. 1.指令集架构(ISA) ISA 的全称是 instruction set architecture,中文就是指令集架构,是指对程序员实际"可见" ...

  9. c# excel 读写 64位操作系统 64位excel

    用c#读写excel时,会出现 “本机未注册Microsoft.ACE.OLEDB.12.0 驱动(什么的,忘了)” 读写 64位的excel 时,要在项目属性里改一下目标平台,默认的为*86, 改为 ...

随机推荐

  1. SSM框架(Spring + Spring MVC + Mybatis)搭建

    Spring是一个轻量级的框架,用到了注解和自动装配,就是IOC和AOP: SpringMVC是Spring实现的一个Web层,相当于Struts的框架: Mybatis是 一个持久层的框架,在使用上 ...

  2. 【洛谷5465】[PKUSC2018] 星际穿越(倍增)

    点此看题面 大致题意: 给定\(l_{2\sim n}\),其中\(l_i\)表示\([l_i,i-1]\)的所有点与\(i\)之间存在一条长度为\(1\)的双向路径.每次询问给出\(l,r,x\), ...

  3. Java连载48-final关键字

    一.final关键字 1.注意点: (1)final是一个关键字,表示最终的,不可变的. (2)final修饰的类无法被继承 (3)final修饰的方法无法被覆盖 (4)final修饰的变量一旦被赋值 ...

  4. HTML连载42-清空默认边距、文字行高

    一.            webstorm取色技巧:webstorm内置了颜色取色器,我们对某种颜色未知的时候,可以利用下图中的取色器,进行颜色识别. 二.系统会默认给body添加外边距,因此我们对 ...

  5. 可迭代对象(__iter__()和__next__())

    如果一个类想被用于for ... in循环,类似list或tuple那样,就必须实现一个__iter__()和__next__()方法,该方法返回一个迭代对象 然后,Python的for循环就会不断调 ...

  6. 一个Web前端工程师或程序员的发展方向,未来困境及穷途末路

    如果你刚好是一个Web前端工程师,或者你将要从事web前端工作.你应该和我有同样的感慨,web前端技术到了自己的天花板,前端工作我能做多少年?3年或5年?自己的职业规划应该怎么样?收入为什么没有增长? ...

  7. jQuery 源码分析(十五) 数据操作模块 val详解

    jQuery的属性操作模块总共有4个部分,本篇说一下最后一个部分:val值的操作,也是属性操作里最简单的吧,只有一个API,如下: val(vlaue)        ;获取匹配元素集合中第一个元素的 ...

  8. Kettle-动态数据链接,使JOB得以复用

    动态数据连接,使JOB得以复用 背景 移动执法系统在目前的主要的部署策略为1+N的方式,即总队部署一套,地市各部署一套,且基本都在环保专网.各地市的业务数据需要推送到总队系统,以便总队系统做整体的监督 ...

  9. WPF 使用EventTrigger时设置SouceName技巧

    使用情节触发器时,如果有触发源/触发源控件时可以将情节触发器放置最顶级的面板控件的触发器中. 通过blend这个神器真的是可以学到不少东西. 代码: //情节动画放置于顶级控制面板 <Widno ...

  10. Jenkins 有关 Maven 的内容

    Jenkins Maven 插件安装 在安装完 Jenkins 后,我们想添加新的项目 为 Maven 项目时,发现找不到这个选项. 原因是我们没有安装插件 Maven Integration. 在 ...