我的彙編器(16 位)有問題 當我輸入“abc”時,它也會返回 abc。問題是,我如何才能訪問 'a'(第一個元素)?我可以使用堆棧(到字符)嗎?
org 100h
Start:
mov ah,0ah
mov dx,input
int 21h
mov ah,9
mov dx,label
int 21h
mov ah,9
mov dx,input+2
int 21h
End:
mov ax,4c00h
int 21h
label db 10,13,"Your characters: $"
input db 6
db 0
times 8 db "$"
是的當然。
您的字符串只是一個字節序列。
更簡單的方法是實際命名Int 21h/AH=0ah
服務使用的結構的所有部分:
label db 10,13,"Your characters: $"
input db 6
str_len db 0
string: times 8 db "$"
然後:
mov al, BYTE [str_len]
可用於加載字符串的長度al
(任何 8 位寄存器都可以)。
mov al, BYTE [string + X]
將加載(X + 1)th
字符串的字符al
(X
在組裝時已知 - 即靜態)。
mov bx, X
+mov al, BYTE [string + bx]
將加載(X + 1)th
字符串的字符al
(X
在運行時已知 - 即動態)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句