汇编语言(TASM)的价格计算

时间:2020-06-02 17:39:52

标签: assembly user-input calculation tasm multiplication

我正在用汇编语言创建一个餐厅程序,该程序显示食物清单及其价格。

当用户要下订单时,程序将提示用户输入产品编号并输入要购买的食物数量。然后,程序将计算/乘以价格和数量,然后显示订单的总价。

我的代码似乎是错误的,因为它只显示奇怪的字符作为乘法的输出。当我运行程序时,它还会两次显示line7字符串。

如果您能帮助我并解释我所犯的错误,我非常感谢。预先谢谢你!

    inputqty db 10,13 “Input quantity: $”
    line10 db 10,13, “-----Food Menu-----$”
    line7 db 10,13, “1. Pizza: $2 $”
    orderopt db 10,13, “Input product ID to make order: $”
    pizzaprice db 2
    totalprice db 10,13, "Total price: $"

foodmenu:
    mov ah,9
    lea dx,line10 ;display food menu banner
    int 21h
    
    mov ah,9
    lea dx,line7 ;display pizza menu with price
    int 21h

    mov ah,9
    lea dx,orderopt ;prompt user to input choice
    int 21h

    mov ah,1 ;read a character
    int 21h

    cmp al,31h
    je pizzatotal ;calculate the total price of pizza if user input is 1

pizzatotal:
    mov ah,9
    lea dx,inputqty ;prompt user to input quantity
    int 21h
    
    mov ah,1
    int 21h

    sub al,48
    mov bl,pizzaprice
    add bl,48
    mul bl

    mov ah,9
    lea dx,pizzatotal ;displaying the total price
    add dl,48
    int 21h

    mov ah,2
    mov dl,al ;to display result
    add dl,48
    int 21h

    cmp al,30h
    je foodmenu

0 个答案:

没有答案
相关问题