汇编之数组(c语言风格)
本帖最后由 whypro 于 2010-12-13 06:51 编辑创建数组:
ArrayName type value
数组名 类型 初始值
举例:
arrayA dword 1,2,3,4,5
地址
00000000 1
00000004 2
.................. 3
.................. 4
废话就不多说了上代码:
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
.data
arraySum dword 1,2,3
szCaption db '消息框!',0
szText db 100 dup(0)
szCharsFormat db 'ArraySum Sum:%d',0
.code
start:
mov esi,offset arraySum
mov ecx,lengthof arraySum ;取数组长度
mov eax,0
L1:
add eax, ;求和
add esi,type arraySum ;指向下一个元素
loop L1 ;跳转到L1,直到ecx=0时,才停止跳转
invoke wsprintf,addr szText, addr szCharsFormat, eax
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK
invoke ExitProcess,NULL
end start
页:
[1]