在汇编中[]的作用不是单纯的c语言中指针类似,可以分为两种情况,对于变量来说[var]和var作用是一样的
但是对于寄存器来说就有区别了,[eax]是eax的地址(这里是c语言中的指针) 而不加中括号的eax就是c语言中的变量值了,理解有谬误之处望指正
.386
.model flat, stdcall
option casemap :none
include windows.inc
include user32.inc
include kernel32.inc
include masm32.inc
includelib user32.lib
includelib kernel32.lib
includelib masm32.lib
.data
buffer byte "%d",0
num dword 12
.data?
lpszSize db 50 dup(?)
.CODE
START:
lea ebx,[num]
mov eax,[ebx]
mov eax,num
mov eax,[num]
invoke wsprintf,offset lpszSize,offset buffer,eax
invoke MessageBox,NULL, offset lpszSize, offset lpszSize,MB_OK
invoke ExitProcess,0
end START