我从Irvine32库的SmallWin.inc中收到20个错误。所有错误均为“非良性结构重定义”,但带有“错误的初始化程序” +“标签太少” +“初始化程序太少” +“标签太少”。所有错误均源于大约200-300条线。我的程序是使用INVOKE和PROTO在masm中递归的多模块GCD
prog4.asm
include Irvine32.inc
include gcd.asm
.data
ask byte "enter y integers: "
answer byte "the gcd of the y numbers: "
x sdword ?
y sdword ?
.code
main PROC
call Clrscr
mov edx, OFFSET ask ; get variables
call WriteString
call ReadDec
mov x, eax
call ReadDec
mov y, eax
; have variables
invoke GCD, x, y ; returns to eax
mov edx, OFFSET answer
call WriteString
call WriteInt
main ENDP
END
gcd.asm
include Irvine32.inc
GCD PROTO,x:dword,y:dword
.code
;-----------------------------
GCD PROC, x:dword, y:dword
; calculate the gcd of two unsigned ints in recursion
; receives x,y
; returns eax = gcd
;-----------------------------
mov eax,x
mov ebx,y
mov edx,0 ; clear high dividend
div ebx ; divide x by y
cmp edx,0 ; remainder = 0?
je L2 ; yes:quit
INVOKE GCD,ebx,edx ; recursive call
L2:
mov eax,ebx ; eax = gcd
ret
GCD ENDP
END
已编译并运行的最终代码prog4.asm
include Irvine32.inc
gcd PROTO,x:dword,y:dword
.data
ask1 byte "enter the first integer: ", 0
ask2 byte "enter the second integer: ", 0
answer byte "gcd: ", 0
x dword ?
y dword ?
.code
main PROC
call Clrscr
mov edx, OFFSET ask1
call getX ; get variables
mov edx, OFFSET ask2
call getY
; have variables
invoke gcd, x, y ; returns to eax
mov edx, OFFSET answer
call PrintResult
exit
main ENDP
GetX PROC
call WriteString ; print message
call ReadDec ; get x
mov x,eax
ret
GetX ENDP
GetY PROC
call WriteString ; print
call ReadDec ; get y
mov y,eax
ret
GetY ENDP
PrintResult PROC
call WriteString
call WriteDec
ret
PrintResult endp
END main
gcd.asm
include Irvine32.inc
.code
gcd PROC, x:dword, y:dword
; calculate the gcd of the two unsigned ints in recursion
; receives x,y
; returns gcd in eax
mov eax,x
mov ebx,y
mov edx,0 ; clear edx aka high dividend
;
cmp ebx,0 ; stop condition
je L1
div ebx ; a / b // remainder in edx
invoke gcd,ebx,edx ; recursive call gcd(b, a mod b)
L1:
ret
gcd endp
END