Moving x86 assembly to 64-bit (x86-64)
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.
- Full 64-bit registers are prefixed with r. So for 64-bit operations, you use
raxrather thaneax,rdirather thanediand so forth. - 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, meaningr8b, r8w and r8din the case ofr8. - 32-bit operations on a register automatically zero out the upper 32-bits of that register. For instance, if you load 0 into
eax, raxis guaranteed to be 0. - 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 r15belong 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, inrdi, rsi, rdx, rcx, r8 and r9respectively. 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 r15belong to the calling function. All others belong to the called function. Return values are via rax. Input parameters are passed first inrcx, rdx, r8 and r9(left to right). Remaining arguments are passed via the stack, right to left. pushad and popadare 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.cqois the newcdq. For sign-extending fromeax to edx(32 bit),cdqwas used. For sign-extendingraxtordx, 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)的更多相关文章
- 64位主机64位oracle下装32位客户端ODAC(NFPACS版)
64位主机64位oracle下装32位客户端ODAC(NFPACS版) by dd 1.下载Oracle Data Access Components(ODAC) Xcopy的两个版本: x86:(我 ...
- autoCAD 2008 Win7 64位, win8 64位 安装 燕秀工具箱 yanxiu.cui 文件下载
Win7 64位, win8 64位 安装 燕秀工具箱 , 提示没有权限. 网站上下载燕秀工具箱, 安装后. 提示权限不够. 解决办法如下; 1. CAD, 权限修改. 2. 下载 yanxiu.cu ...
- 利用Powerdesigner16.5(64位)连接64位oracle 配置系统odbc驱动
利用Powerdesigner16.5(64位)连接64位oracle逆向工程数据库 记录一次Powerdesigner通过odbc连接64位oracle数据库.林林总总国内看到都是些乱七八糟没几个靠 ...
- 浅淡Windows7 32位与64位/x86与x64的区别
看到有很多会员问到底是选Windows7 x86,还是选x64.这里简单的谈一下这这两种系统的区别. 简单的说x86代表32位操作系统 x64代表64位操作系统. 简单的判断电脑是否支持64位操作系 ...
- win2008 64位 + oracle11G 64位 IIS7.5 配置WEBSERVICE
第一个错误: 安装过程依旧是那样简单,但在配好IIS站点,准备连接数据库的时候出错了,以下是错误提示:System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更 ...
- Oracle Linux(64位)安装64位Oracle10g遇到ins_ctx.mk问题
在Oracle Linux Server Release 5.7上安装64位Oracle 10g 时,遇到如下问题: Error in invoking target 'install' of mak ...
- ubuntu16 64位 编译64位程序和32位程序
安装了ubuntu16 64位的系统,想在该环境下用gcc编译64位和32位的程序 默认已经安装了64位环境的gcc 1. 首先确认安装的环境是不是64位的 cocoa@cocoaUKlyn:~/De ...
- 32位x86处理器编程导入——《x86汇编语言:从实模式到保护模式》读书笔记08
在说正题之前,我们先看2个概念. 1.指令集架构(ISA) ISA 的全称是 instruction set architecture,中文就是指令集架构,是指对程序员实际"可见" ...
- c# excel 读写 64位操作系统 64位excel
用c#读写excel时,会出现 “本机未注册Microsoft.ACE.OLEDB.12.0 驱动(什么的,忘了)” 读写 64位的excel 时,要在项目属性里改一下目标平台,默认的为*86, 改为 ...
随机推荐
- 基于Django的Rest Framework框架的响应器
本文目录 一 作用 二 内置渲染器 三 局部使用 四 全局使用 五 自定义显示模版 回到目录 一 作用 根据 用户请求URL 或 用户可接受的类型,筛选出合适的 渲染组件.用户请求URL: ht ...
- 监控ckeditor内容变化,删除编辑器内图片,ueditor同样适用
let body = document.querySelector("iframe").contentDocument.body; let observer = new Mutat ...
- word文档操作-doc转docx、合并多个docx
前言: 临时来了一条新的需求:多个doc文档进行合并. 在网上苦苦搜罗了很久才找到可用的文件(原文出处到不到了 所以暂时不能加链接地址了),现在记录下留给有需要的人. 一:doc转docx 所需jar ...
- Java连载39-构造方法详解
一. 1.多行注释:CTRL + shift + / 2.当一个类中没有定义任何构造方法的话,系统默认给该类提供一个无参数的构造方法,这个构造方法被称为缺省构造器. public class D39 ...
- Python 爬虫介绍,什么是爬虫,如何学习爬虫?
作为程序员,相信大家对“爬虫”这个词并不陌生,身边常常会有人提这个词,在不了解它的人眼中,会觉得这个技术很高端很神秘.不用着急,我们的爬虫系列就是带你去揭开它的神秘面纱,探寻它真实的面目. 爬虫是 ...
- vue项目里面使用脚手架实现跨域
今天在做vue项目的时候,项目在本地,接口数据在阿里云,这就造成了跨域,在网上找了好久,网上大部分的方法都是找到config文件夹下面的index进行修改的,可是我找到的Index却和他们描述的不一样 ...
- 14-认识DjangoRESTframework
了解DjangoRESTframework 现在流行的前后端分离Web应用模式,然而在开发Web应用中,有两种应用模式:1.前后端不分离 2.前后端分离. 1.前后端不分离 在前后端不分离中,前端看见 ...
- fastjson对于yyyy-MM-dd HH:mm格式的反序列化问题
原创GrayHJX 发布于2017-03-14 22:56:33 阅读数 6851 收藏 展开 问题:最近在工作中遇到这么一个问题:有个实体类,它有个date类型的属性,当在这个属性加上fastjs ...
- python连接Oracle工具类
上代码: # -*- coding:utf-8 -*- import cx_Oracle import pandas as pd class ORACLE(object): def __init__( ...
- java基础(9):类、封装
1. 面向对象 1.1 理解什么是面向过程.面向对象 面向过程与面向对象都是我们编程中,编写程序的一种思维方式. 面向过程的程序设计方式,是遇到一件事时,思考“我该怎么做”,然后一步步实现的过程. 例 ...