简体   繁体   English

at&t汇编中'push'和'pushq'之间的区别是什么

[英]What's the difference between 'push' and 'pushq' in at&t assembly

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. 我的问题是关于push和pushq之间的区别。

I'm aware that push writes a value to the stack and my assumption is that pushq does the something similar. 我知道push会将一个值写入堆栈,我的假设是pushq做了类似的事情。 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. q在那里的事实让我觉得应该有一个微妙的区别,但我似乎无法理解差异。

I stated to ponder this question while debugging the file /lib/udev/iphone-set-info using gdb with the command 'layout asm'. 我说在使用命令'layout asm'使用gdb调试文件/ lib / udev / iphone-set-info时考虑这个问题。

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. 我知道$ 0x0对于NULL是十六进制的,而%r9是通用寄存器之一。 Does this just mean that Null us written to the stack with register %r9 written above it? 这只是意味着Null我们写入堆栈,其上面写有寄存器%r9吗?

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. 我不确定你使用的是哪种汇编语言,但对于使用AT&T语法的GAS(GNU汇编程序)来说也是如此:GAS汇编指令通常以字母“b”,“s”,“w”,“ l“,”q“或”t“确定操作的操作数大小。

  • b = byte (8 bit) b =字节(8位)
  • s = short (16 bit integer) or single (32-bit floating point) s =短(16位整数)或单(32位浮点)
  • w = word (16 bit) w =字(16位)
  • l = long (32 bit integer or 64-bit floating point) l = long(32位整数或64位浮点)
  • q = quad (64 bit) q =四(64位)
  • t = ten bytes (80-bit floating point) t =十个字节(80位浮点)

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). 如果未指定后缀,并且指令没有存储器操作数,则GAS根据目标寄存器操作数(最终操作数)的大小推断操作数大小。

pushq $0x0 just pushes 8 zero bytes to stack. pushq $0x0只是将8个零字节推送到堆栈。 Then push %r9 defines that %r9 is 64 bit register and pushes it's value to stack. 然后push %r9定义%r9是64位寄存器并将其值推送到堆栈。

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. 关于堆栈增长的有趣事实,因此空字节将具有比%r9的值更高的地址,因此这可能是误解,因为%r9实际值低于空字节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM