為什么得不到想要的結果
本人學習(匯編語言 程序設計<第二版>)有以下的習題﹕
從鍵盤輸入一個字符串(10個字符內)﹐將其中的小寫字母轉成大寫字母﹐然后輸出到屏幕上。
問題﹕程序編譯執行時﹐結果會這樣﹕
a. 用戶輸入﹕1234
屏幕顯示﹕
b. 用戶輸入﹕12345
屏幕顯示﹕ 5
c. 用戶輸入﹕123456
屏幕顯示﹕ 456
...
d. 用戶輸入﹕123456789
屏幕顯示﹕123456789
.model small
.stack
.data
buf db 0ah, 0h, 0ah dup(20h), '$' ;20h => Space
.code
.startup
mov ah, 0ah
mov dx, offset buf
int 21h
mov cx, 0
mov cl, [buf + 01h]
mov si, 2
next: mov al, [buf + si]
cmp al, 'a'
jc savebuf
cmp al, 'z'
jnc savebuf
sub al, 020h
savebuf: mov [buf + si], al
inc si
loop next
mov [buf], 0dh
mov [buf + 01h], 0ah
mov dx, offset buf
mov ah, 09h
int 21h
.exit 0
end