Assembly (32位程序集)将指针传递到proc

Assembly (32位程序集)将指针传递到proc,assembly,x86,masm,irvine32,Assembly,X86,Masm,Irvine32,我不知道为什么这个程序不能输出 +一, +2 +3 +四, 输出是 +4214784 +1967600538 +2130567168 +1638356 我猜是地址,但为什么?如何纠正 这是我的密码: include irvine32.inc .data matrix dword 1, 2, 3, 4 .code print proto, m:ptr dword main proc invoke print, addr matrix exit main en

我不知道为什么这个程序不能输出

+一, +2 +3 +四,

输出是

+4214784 +1967600538 +2130567168 +1638356

我猜是地址,但为什么?如何纠正

这是我的密码:

include irvine32.inc

.data
  matrix dword 1, 2, 3, 4

.code
  print proto, m:ptr dword

  main proc
    invoke print, addr matrix

    exit
  main endp

  print proc, m:ptr dword
    mov eax, m[0 * type m]
    call writeint

    mov eax, m[1 * type m]
    call writeint

    mov eax, m[2 * type m]
    call writeint

    mov eax, m[3 * type m]
    call writeint

    ret
  print endp

  end main

感谢您的回答

m
是堆栈上传递的指针。汇编程序将把
m
变成类似
[ebp+8]
的东西。索引将访问堆栈上的项目,从该位置开始,而这不是您想要的。您需要取消对
m
指针的引用,只有将其加载到寄存器中才能执行此操作

mov ecx, m  ; this will be mov ecx, [ebp+8] or similar
mov eax, [ecx + 0*4] ; first item
call WriteInt
mov eax, [ecx + 1*4] ; second item
call WriteInt
...
我不建议初学者在不了解确切生成的代码的情况下使用汇编程序的奇特功能