在asm中创建FillArray宏

时间:2017-05-07 13:26:25

标签: assembly macros x86 masm irvine32

我正在创建一个我想从主要调用的Fillarray宏。编译它时没有任何错误,但是在收到用户的第一个输入后程序停止执行。这是我的代码。请帮忙

INCLUDE c:\Irvine\Irvine32.inc

;// .386
;// .model flat,stdcall
;// .stack 4096
ExitProcess proto,dwExitCode:dword

;-----------------------------------------------------
mFillArrray MACRO a, b, d
;
;-----------------------------------------------------

;   mov ecx, LENGTHOF array         ;place the length in ecx
;   mov esi, OFFSET array           ;place the offset in esi
;   mov ebx, TYPE array             ;place the type in ebx

LOCAL L1

pushad
mov ecx, a
mov esi, b
mov ebx, d

L1: 
    call ReadInt                    ; read integer into EAX
    mov [esi],eax                   ; store in array
    add esi,ebx                     ; next integer
    loop L1
    popad
ENDM

.data                               ;// write your data in this section
array DWORD 10 DUP(?)
a DWORD ?
b DWORD ?
d DWORD ?
str1 BYTE "Please enter into the array:",0dh,0ah,0
endl BYTE 0dh,0ah,0 

.code       ;// write your program here
main proc

    mov edx,offset str1             ;moves into edx registry intro string
    call WriteString                ;writes the message

    mFillArrray a, b, d

    mov edx,offset endl             ;moves into edx registry intro string
    call WriteString                ;writes the message

    invoke ExitProcess,0
main endp

end main

0 个答案:

没有答案