英特尔的x86到ARM汇编转换

英特尔的x86到ARM汇编转换

本文介绍了英特尔的x86到ARM汇编转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在学习 ARM 汇编语言;

I am currently learning ARM assembly language;

要做到这一点,我想将一些 86 code(AT& T公司语法)来ARM汇编(Intel语法) code。

To do so, I am trying to convert some x86 code (AT&T Syntax) to ARM assembly (Intel Syntax) code.

__asm__("movl $0x0804c000, %eax;");

__asm__("mov R0,#0x0804c000");

从这个,我知道在86的块1堆结构从0x0804c000开始。不过,我当我尝试做相同的手臂
 我收到以下错误:

From this document, I learn that in x86 the Chunk 1 of the heap structure starts from 0x0804c000. But I when I try do the same in arm, I get the following error:

/tmp/ccfNZp9F.s:174: Error: invalid constant (804c000) after fixup

我假设的问题是,ARM只能加载,我知道如何内存间接寻址的作品。

From my previous question, I know how memory indirect addressing works.

写下面做同样的工作的片段?

Are the snippets written below doing the same job?

movl (%eax), %ebx

LDR R0,[R1]

我使用的ARMv7处理器第4版(v7l)

推荐答案

问题1的答案

ARM的MOV指令仅具有可用于立即值12位,这些位被以这种方式使用:对值8位,和4位来指定转数到右边(转数乘以2,增加的范围内)。

The MOV instruction on ARM only has 12 bits available for an immediate value, and those bits are used this way: 8 bits for value, and 4 bits to specify the number of rotations to the right (the number of rotations is multiplied by 2, to increase the range).

这意味着,仅仅值的有限数量的可以与该指令一起使用。它们是:

This means that only a limited number of values can be used with that instruction. They are:


  • 0-255

  • 256,260,264,...,1020

  • 1024,1040,1056,...,4080


等。你得到的错误,因为你常不能用8位+旋转来创建。您可以在值加载到寄存器下面的指令:

And so on. You are getting that error because your constant can't be created using the 8 bits + rotations. You can load that value onto the register following instruction:

LDR r0, =0x0804c000

请注意,这是一个伪指令,但。汇编程序将基本把那个地方不断在code和加载它与一些偏移量与PC(程序计数器)的内存位置。

Notice that this is a pseudo-instruction though. The assembler will basically put that constant somewhere in your code and load it as a memory location with some offset to the PC (program counter).

回答问题2

是那些指令是等价的。

这篇关于英特尔的x86到ARM汇编转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 00:29