0
我在程序集中有一些代码有点奇怪。我有一个C extern函数,它调用asm .asm文件中的另一个函数。这个C函数从.asm文件中放入我的函数使用的堆栈三个地址。一切都很顺利,直到此出现:在同一内存地址的两个不同的值 - 程序集
; Let's say we take from the stack first parameter from my C function.
; This parameter is a string of bytes that respect this format:
; - first 4 bytes are the sign representation of a big number
; - second 4 bytes are the length representation of a big number
; - following bytes are the actual big number
section .data
operand1 dd 0
section .text
global main
main:
push ebp
mov ebp, esp
mov eax, [ebp + 8] ; Here eax will contain the address where my big number begins.
lea eax, [eax + 8] ; Here eax will contain the address where
; my actual big number begins.
mov [operand1], eax
PRINT_STRING "[eax] is: "
PRINT_HEX 1, [eax] ; a SASM macro which prints a byte as HEX
NEWLINE
PRINT_STRING "[operand1] is: "
PRINT_HEX 1, [operand1]
NEWLINE
leave
ret
当运行这段代码,我得到了终端[EAX]正确的输出,以及[操作数1]它不断印刷数,如果我修改,这将不会改变我的C函数的第一个参数。我在这里做错了什么?
请将问题的答案作为答案发布,并将其标记为正确。然后其他用户可以看到问题已解决。 – alain
*调用* asm * .asm文件中的另一个函数*:什么?您不需要使用inline-asm来调用在'.asm'文件中定义的函数。只需编写一个原型并正常调用。 –