【问题标题】:x86 Assembly Passing Parameters by Referencex86 程序集通过引用传递参数
【发布时间】:2015-02-28 19:54:07
【问题描述】:

以下是我的汇编语言代码。我可以使用“push [edi]”传递堆栈参数值,但我似乎无法使用“push OFFSET [edi]”通过引用传递。在这种情况下,通过引用传递某些东西的正确语法是什么?

sortList        PROC
;Parameter memory addresses:
;numbers    @ [ebp+8]
;list       @ [ebp+12]

;Used to access stack parameters
push        ebp
mov         ebp, esp

;Sets up the array
mov         edi, [ebp+12]               ;Puts in the address of the list array
mov         ecx, [ebp+8]                ;Sets up the loop counter for the array

;Testing swapNumber function
push        [edi]                           ;array 1 pushed will be ebp+12
add         edi, 4
push        [edi]                           ;array 2 pushed will be ebp+8
call        swapNumber

pop         ebp
ret         8
sortList        ENDP

【问题讨论】:

  • 推送指针而不是内存操作数。即push edi 而不是push [edi]
  • 哦哇...这是一个简单的修复。非常感谢!

标签: assembly x86 pass-by-reference


【解决方案1】:

索引寄存器edi 保存指向您的数据的指针。 [edi] 取消引用此指针(类似于 C 的 * 运算符)。因此,如果push [edi]edi 指向的数据压入堆栈,要将edi 本身压入堆栈,则需要...push edi =)。

【讨论】:

    【解决方案2】:
    mov edi,8 ; edi = 8
    push edi ; we push to the stack the value '8'
    push [edi]; we push to the stack the value in the address memory:8
    ;in your case i'm pretty sure that you mean push edi instead of push [edi]
    

    【讨论】:

      猜你喜欢
      • 2016-09-27
      • 2013-06-17
      • 2010-10-07
      • 2011-08-21
      • 2017-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多