将两位数存储为变量

Storing double digits as variable

所以我有这个餐厅订单系统的代码

mov ah,09h          ;      
lea dx,getValueMsg  ; Display get value massege
int 21h             ;

mov ah,01h          ;      
int 21h             ; User input the value
sub al,30h          ;        
mov countChicken,al ;

cmp countChicken,1        ;
jb  errorGetChickenValue  ;
                          ; Checking chicken chop value
cmp countChicken,8        ;
ja  errorGetChickenValue  ;

我了解到我可以使用var db 0来存储鸡值,但如果我没记错的话它只能存储一个数字。
我需要存储一个两位数的值,例如 19。我该怎么做?

I learned that I can use var db 0 to store a value for chicken value, but it can only store a single digit if I remembered correctly

定义为 byte (db) 的变量可以保存从 0 到 255 的无符号数。这绝对不仅仅是一个从 0 到 255 的数字9.

I need to store a double-digit value, for example, 19. How can I do that?

如果您需要两位数的值,则必须使用 DOS.InputCharacter 函数 01h 两次,并将这些数字组合成 0 到 99 范围内的单个数字。得到的第一个数字输入的是最重要的数字,您必须将其乘以 10。然后将输入的第二个数字添加到此:

使用mul,11条指令和23个字节

mov ah, 01h
int 21h        ; -> AL
sub al, 30h
mov bl, 10
mul bl         ; AX = AL * BL
mov bl, al
mov ah, 01h
int 21h        ; -> AL
sub al, 30h
add al, bl
mov countChicken, al

使用AAD,8条指令和18个字节

mov ah, 01h
int 21h        ; -> AL
mov bl, al
               ; AH = 01h
int 21h        ; -> AL
mov ah, bl
sub ax, 3030h
aad            ; AX = AH * 10 + AL
mov countChicken, al