x86汇编32位程序卡在如何完成main

时间:2014-07-17 20:50:40

标签: assembly x86 masm irvine32

; This program computes 1+x+y+x^2+y^2+x^3+y^3


INCLUDE Irvine32.inc 

.data

    xinput BYTE "Enter the value of x :  ",0
    yinput BYTE "Enter the value of y :  ",0
    total BYTE "The value of f(x,y) is : ",0

.code
main PROC

mov edx, OFFSET xinput




        mov ebp, OFFSET yinput
        call WriteString
        mov ebx, 1
        call ReadHex
        mov edx, eax
        mov esp, eax
        add ebx, eax
        add ebp, eax
        call squarex
        add ebx, eax
        mov eax, edx
        call squarey
        add ebp, eax
        mov eax, esp
        call cubex
        add ebx, eax
        mov eax, edx
        call cubey
        add ebp, eax
        mov eax, esp
        mov edx, OFFSET total
        mov esp, OFFSET total
        call WriteString
        call crlf
        mov eax, ebx
        call WriteHex
        call crlf
        exit

squarex PROC

        push ecx
        push edx
        mov ecx, eax
        mov eax, 0
    loop1:
        add eax, edx
        loop loop1
        pop edx
        pop ecx
        ret

squarex ENDP

squarey PROC

        push ecx
        push esp
        mov ecx, eax
        mov eax, 0
    loop1:
        add eax, esp
        loop loop1
        pop esp
        pop ecx
        ret

squarey ENDP

cubex PROC

        push ecx
        push edx
        mov ecx, eax
        call squarex
        mov edx, eax
        mov eax, 0
    loop1:
        add eax, edx
        loop loop1
        pop edx
        pop ecx
        ret

cubex ENDP

cubey PROC

        push ecx
        push esp
        mov ecx, eax
        call squarey
        mov esp, eax
        mov eax, 0
    loop1:
        add eax, esp
        loop loop1
        pop esp
        pop ecx
        ret

cubex ENDP

我很困惑如何完成我的主PROC以将所有值存储在eax中并编译该程序。有帮助吗?

我认为我真的很接近完成这项工作,我在我的循环(cubex)上遇到了致命的错误,但我真的不明白从哪里开始完成这个程序。

1 个答案:

答案 0 :(得分:0)

如果你在Windows上:

恢复ebx,ebp和esp寄存器并调用ret退出。

如果您使用的是Linux:

使用eax = 1和ebx = 0调用int 80h