【发布时间】:2017-02-25 22:52:43
【问题描述】:
我正在用 8086 汇编语言编写一个程序,该程序要求输入 1-9 之间的单个数字,然后将其存储。如果不在 1-9 之间,则应该循环返回。
什么是测试它并使其循环(并允许您输入另一个数字)直到满足要求的好方法?
到目前为止我的代码:
section .data
prompt1 db "Enter a single digit digit between 1-9 --> $"
section .text
;Display prompt
mov ah,9 ; print prompt
mov dx,prompt1 ; load register with prompt1
int 21h ; display it
; Input character and store.
mov ah,1 ; reach char fcn
int 21h ; read character into al
mov bl,al ; store character into bl
【问题讨论】:
-
是什么部分导致了您的问题?你知道比较、条件分支和ASCII码吗?
-
我知道条件分支,但不熟悉比较。
-
然后阅读关于
cmp的参考页面。 TL;DR:你可以只做类似cmp bl, '1'的事情,然后使用你已经知道的条件分支。