我的意见是 ABCDEFGHIJKLMNOPQRSTUVWXYZ
输出是:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
我怎么能这样做?任何人都可以帮助我。我是汇编语言的新手。
在这里我可以试试这个,
.model small
.stack 100h
.code
.data
msg1 db 'Enter a Uppercase letter: $'
msg2 db 0DH, 0AH, 'Lowercase letter is :'
char db ?, '$'
main proc
mov ax,@data
mov ds,ax
lea dx, msg1
mov ah,9
int 21h
mov cx,26
mov ah,1
int 21h
add al,20h
mov char,al
lea dx, msg2
mov ah,9
int 21h
MOV AH,4CH
int 21h
main endp
end main
但是这个只打印一个单字符。如果我输入:A然后输出:a
答案 0 :(得分:0)
或许试试这个......
您拥有char db ?, '$'
,而不是:
char db 81 dup(?) # make space for up to 80 chars plus a `$` terminator
然后从mov cx, 26
改为:
lea cx, char # cx holds current position in output string
readone:
mov ah, 1 # existing code to get a char
int 21h # existing code to get a char
cmp al, 10 # is the char a newline?
je printstr # if it is, no need to go further
add al, 20h # existing code to convert case (if not newline)
mov [cx],al # move the converted character to the current string position
# literally: move the value in al to the address in cx
inc cx # move to next position in string
jmp readone # read another char
printstr:
mov [cx], 36 # add the trailing $ to the output string
lea dx, msg2 # existing code
mov ah, 9 # existing code
int 21 # existing code
... # the rest of your code
这样的东西应该输入,直到你按下Enter键,然后打印转换后的字符串(我无法检查,因为我没有运行你的系统或汇编程序)。
它没有错误检查(你的输入最好是所有大写字母,否则输出将是不可预测的!)。