首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Irvine32 SmallWin.inc导致错误

Irvine32 SmallWin.inc导致错误
EN

Stack Overflow用户
提问于 2019-12-13 06:46:17
回答 1查看 110关注 0票数 0

我从Irvine32库中的SmallWin.inc得到了20个错误。所有的错误都是“非良性结构重新定义”,而是“不正确的初始化器”+“太少的标签”+“太少的初始化器”+“太少的标签”。所有的错误都来自大约200-300行。我的程序是masm中使用INVOKE和PROTO的递归多模块GCD

prog4.asm

代码语言:javascript
复制
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

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2019-12-13 10:41:49

编译并运行的最终代码

prog4.asm

代码语言:javascript
复制
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

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59313757

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档