FASM:如何使用循环在数组中输入值
FASM: How to input values in array using loop
此代码对我不起作用。我的目标是要求用户输入字符串,转换为大写字母,并将它们一一存储在数组中,然后将字符(全部大写)输出回用户。请帮助我:(
org 100h
mov bl, 0
mov ah, 9
mov dx, input
int 21h
again:
mov ah, 1
int 21h
sub al, 20h
mov [inp+bl], al
inc bl
cmp bl, 2
jle again
loops:
mov bl, 0
mov ah, 2
mov dl, [inp+bl]
int 21h
inc bl
cmp bl, 2
jle loops
mov ax, 4Ch
int 21h
input db 'Input: ',24h
output db 'Output: ',24h
inp db 20 dup(?), 24h
mov [inp+bl], al
这里的主要问题是您使用了根本不存在的寻址模式!
如果将 BL
的每个实例都更改为 BX
.
,则可以快速更正代码
mov bx, 0
mov ah, 9
mov dx, input
int 21h
again:
mov ah, 1
int 21h
sub al, 20h
mov [inp+bx], al
inc bx
cmp bx, 2
jle again
loops:
mov bx, 0
mov ah, 2
mov dl, [inp+bx]
int 21h
inc bx
cmp bx, 2
jle loops
sub al, 20h
也许您有 over-simplified 代码,因为这种大写当然只有在用户只输入小型大写字母 a..z 时才有效。
此代码对我不起作用。我的目标是要求用户输入字符串,转换为大写字母,并将它们一一存储在数组中,然后将字符(全部大写)输出回用户。请帮助我:(
org 100h
mov bl, 0
mov ah, 9
mov dx, input
int 21h
again:
mov ah, 1
int 21h
sub al, 20h
mov [inp+bl], al
inc bl
cmp bl, 2
jle again
loops:
mov bl, 0
mov ah, 2
mov dl, [inp+bl]
int 21h
inc bl
cmp bl, 2
jle loops
mov ax, 4Ch
int 21h
input db 'Input: ',24h
output db 'Output: ',24h
inp db 20 dup(?), 24h
mov [inp+bl], al
这里的主要问题是您使用了根本不存在的寻址模式!
如果将 BL
的每个实例都更改为 BX
.
mov bx, 0
mov ah, 9
mov dx, input
int 21h
again:
mov ah, 1
int 21h
sub al, 20h
mov [inp+bx], al
inc bx
cmp bx, 2
jle again
loops:
mov bx, 0
mov ah, 2
mov dl, [inp+bx]
int 21h
inc bx
cmp bx, 2
jle loops
sub al, 20h
也许您有 over-simplified 代码,因为这种大写当然只有在用户只输入小型大写字母 a..z 时才有效。