汇编语言未编译

问题描述 投票:0回答:1

我正在尝试完成80x86汇编语言程序,该程序提示并输入框的长度,宽度和高度,并计算并显示其体积(长*宽*高)。

我是初学者,所以不知道我在做什么错

.586
.MODEL FLAT

INCLUDE io.h            ; header file for input/output

.STACK 4096

.DATA
Lenght DWORD   ?
Width DWORD  ?
Hight DWORD ?
prompt1 BYTE    "Enter lenght   ", 0
prompt2 BYTE    "Enter width", 0
prompt3 BYTE    "Enter hight", 0
string  BYTE    40 DUP (?)
resultLbl BYTE  "The volume is", 0
res    BYTE    11 DUP (?), 0

.CODE
_MainProc PROC
        input   prompt1, string, 40      ; read ASCII characters
        atod    string          ; convert to integer
        mov     Length, eax    ; store in memory

        input   prompt2, string, 40      ; repeat for second number
        atod    string
        mov     Width, eax


        input   prompt3, string, 40      ; repeat for third number
        atod    string
        mov     Hight, eax




        mov      eax, Length    ; first number to EAX
        mul      eax, Width    ; add second number
        mul      eax, Hight    ; add second number

        dtoa    res, eax        ; convert to ASCII characters
        output  resultLbl, res          ; output label and sum

        mov     eax, 0  ; exit with return code 0
        ret
_MainProc ENDP
END                             ; end of source code

这些是我得到的错误:

Description Severity    Code    Project File    Line    Suppression State
missing operand after unary operator    Error   A2081       27  
missing operand after unary operator    Error   A2081       31  
missing operand after unary operator    Error   A2081       41  
syntax error : ,    Error   A2008       42  
syntax error : ,    Error   A2008       43  
syntax error : width    Error   A2008   14  
The command "ml.exe /c /nologo /Zi /Fo"Debug\example.obj" /W3 /errorReport:prompt /Fl /Taexample.asm" exited with code 1.   Error   MSB3721 C:\Users\rzaman\Downloads\AARaianaZaman\solutions\solutions\windows32   70
assembly x86 masm
1个回答
0
投票

mul指令仅接受一个参数,第二个参数位于寄存器AL / AX / EAX中,具体取决于您传递的参数的大小。英特尔说明手册中的信息-enter image description here所以下面的代码应该工作-

mov eax, Length ; first number to EAX mul Width ; add second number mul Hight ; add second number

此外,如果乘法结果大于32位,则必须从edx寄存器中获得结果的高位。

© www.soinside.com 2019 - 2024. All rights reserved.