首页 > 解决方案 > x86 汇编语言中的减法语法问题

问题描述

到目前为止,我已经写出了大部分代码,但我遇到的最大困难是用户输入的输出。它似乎从每个字符串中收集所有数据,然后输出它们。我希望他们单独输出它们并显示减去已完成学分和所需学分的最终结果。感谢你们提供的任何帮助,并引导我编写代码。

.586
.MODEL FLAT

INCLUDE io.h            ; header file for input/output

.STACK 4096

.DATA 
studentName         DWORD   ?
degreeName              DWORD   ?
creditsCompleted        DWORD   ?
creditsNeeded           DWORD   ?

prompt1 BYTE    "Enter your Name:", 0
prompt2 BYTE    "Enter your Degree Name:", 0
prompt3 BYTE    "Enter the number of Credits Completed:", 0
prompt4 BYTE    "Enter the number of Credits Required:", 0
string  BYTE    40 DUP (?)

resultLbl BYTE  "The Credits left to complete are:", 0
sum     BYTE    40 DUP (?), 0

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

    input   prompt2, string, 40      ; repeat for second number
    atod    string
    mov     degreeName, ecx

    input   prompt3, string, 40
    atod    string 
    mov     creditsCompleted,edx

    input   prompt4, string, 40
    atod    string 
    mov     creditsNeeded,eax


    mov     eax, creditsNeeded     
    sub     eax, creditsCompleted    
    dtoa    sum, eax        
    output  resultLbl, sum  

_MainProc ENDP
END                             ; end of source code

无法弄清楚我输出的数字实际上是如何减去的。这个数字要么高要么低。

标签: assemblyx86masm

解决方案


推荐阅读