我正在寫一個8086彙編語言的程序,要求1-9之間的單個數字,然後存儲它。如果它不在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碼嗎? – Jester
我瞭解條件分支,但不熟悉比較。 – user3394363
然後閱讀關於'cmp'的參考頁面。 TL; DR:你可以做一些像'cmp bl','1''然後使用你已經知道的條件分支。 – Jester