at& t汇编中的'push'和'pushq'有什么区别 [英] What's the difference between 'push' and 'pushq' in at&t assembly

查看:1281
本文介绍了at& t汇编中的'push'和'pushq'有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始寻求对计算机的工作原理有更深入的了解.我的问题是关于push和pushq之间的区别.

我知道push将一个值写入堆栈,我的假设是pushq会执行类似的操作.存在q的事实使我认为应该存在细微的差异,但我似乎无法理解该差异.

我说过在使用gdb通过命令"layout asm"调试文件/lib/udev/iphone-set-info时要思考这个问题.

有问题的代码是:

pushq  $0x0
push   %r9

我知道$ 0x0是NULL的十六进制,而%r9是通用寄存器之一.这是否仅仅意味着将我们写为Null的堆栈上面写有寄存器%r9?

解决方案

我不确定您使用的是哪种汇编语言,但对于使用AT& T语法的GAS(GNU汇编器)也是如此:GAS汇编指令通常以字母"b","s","w","l","q"或"t"作为后缀,以确定要操作的操作数大小.

  • b =字节(8位)
  • s =短(16位整数)或单个(32位浮点)
  • w =字(16位)
  • l = long(32位整数或64位浮点数)
  • q =四(64位)
  • t =十个字节(80位浮点数)

如果未指定后缀,并且该指令没有内存操作数,则GAS会从目标寄存器操作数(最终操作数)的大小中推断出操作数的大小.

pushq $0x0只是将8个零字节压入堆栈.然后push %r9定义%r9是64位寄存器,并将其值压入堆栈.

关于堆栈变小的有趣事实,因此空字节的地址比%r9的值高,因此这里可能会造成误解,因为%r9的值实际上低于空字节.

I've recently started my quest of obtaining a greater understanding as to how my computer works. My question is in regards to the differences between push and pushq.

I'm aware that push writes a value to the stack and my assumption is that pushq does the something similar. The fact the q is there makes me think that there should be a subtle difference but I can't seem to make sense of the difference.

I stated to ponder this question while debugging the file /lib/udev/iphone-set-info using gdb with the command 'layout asm'.

the code in question is :

pushq  $0x0
push   %r9

I understand that $0x0 is hexadecimal for NULL and that %r9 is one of the general registers. Does this just mean that Null us written to the stack with register %r9 written above it?

解决方案

I'm not sure what assembly language you're using, but that's true for GAS(GNU Assembler) that uses AT&T syntax too: GAS assembly instructions are generally suffixed with the letters "b", "s", "w", "l", "q" or "t" to determine what size operand is being manipulated.

  • b = byte (8 bit)
  • s = short (16 bit integer) or single (32-bit floating point)
  • w = word (16 bit)
  • l = long (32 bit integer or 64-bit floating point)
  • q = quad (64 bit)
  • t = ten bytes (80-bit floating point)

If the suffix is not specified, and there are no memory operands for the instruction, GAS infers the operand size from the size of the destination register operand (the final operand).

pushq $0x0 just pushes 8 zero bytes to stack. Then push %r9 defines that %r9 is 64 bit register and pushes it's value to stack.

The interesting fact about the stack that it grows down, so null bytes will have higher addresses than the value of %r9, so here may be misunderstanding, because actually value of %r9 is below the null bytes.

这篇关于at& t汇编中的'push'和'pushq'有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆