x86汇编传递引用 [英] x86 Assembly Passing Parameters by Reference

查看:189
本文介绍了x86汇编传递引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的code汇编语言。我可以通过使用按[EDI]栈参数值传递,但我似乎无法使用按引用传递推OFFSET [EDI]。什么是正确的语法引用在这种情况下通过的东西吗?

  sortlist中PROC
;参数存储器地址:
;数字@ [EBP + 8]
;清单@ [EBP + 12];用于访问栈参数
推EBP
MOV EBP,ESP;设置了数组
MOV EDI,[EBP + 12];在列表中数组的地址看跌期权
MOV ECX,[EBP + 8];设置为阵列的循环计数器;测试swapNumber功能
按[EDI]阵列1推将EBP + 12
加入EDI,4
按[EDI];数组2推将EBP + 8
调用swapNumber流行EBP
RET 8
sortlist中ENDP


解决方案

  MOV EDI,8; EDI = 8
推动电子数据交换;我们推到堆栈中的值8
按[EDI]我们推到堆栈中的内存地址的值:8
;在你的情况我是pretty确保您的意思是推,而不是推EDI [EDI]

Below is my code for assembly language. I can pass by a stack parameter value using "push [edi]" but I cannot seem to pass by reference using "push OFFSET [edi]". What's the correct syntax to pass something by reference in this case?

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

解决方案

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]

这篇关于x86汇编传递引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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