我从Irvine32库中的SmallWin.inc得到了20个错误。所有的错误都是“非良性结构重新定义”,而是“不正确的初始化器”+“太少的标签”+“太少的初始化器”+“太少的标签”。所有的错误都来自大约200-300行。我的程序是masm中使用INVOKE和PROTO的递归多模块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
ENDgcd.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发布于 2019-12-13 10:41:49
编译并运行的最终代码
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 maingcd.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
ENDhttps://stackoverflow.com/questions/59313757
复制相似问题