[英]CMP and jmp variations in assembly
cmp al,'0'
je true
cmp al,'1'
je true
cmp al,'2'
je true
cmp al,'3'
je true
cmp al,'4'
je true
cmp al,'5'
je true
cmp al,'6'
je true
cmp al,'7'
je true
cmp al,'8'
je true
cmp al,'9'
je true
jne error
我很感興趣如何使用間隔和ASCII碼來減少這個數量的cmp。 謝謝。
ASCII碼是數字。 當你寫'0'時,匯編程序將它轉換為30h = 48d。 正如您在此ASCII表中看到的那樣,字母“0”到“9”由連續數字30h..39h表示。 所以,你可以扭轉你的檢查:如果al
低於“0”或al
大於“9”,然后轉到error
。 您只需要兩個比較:
cmp al,'0'
jb error ; jump if below
cmp al,'9'
ja error ; jump if above
true:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.