我希望输出一个字符串,但不使用美元符号。无论我是否正确,我都需要计算我的字符串的字符数,并将该值放入cx寄存器中。
我尝试过这样做,但程序只是将整个缓冲区打印出来,而不是我需要的字符串。
顺便说一下,这是Turbo汇编语言。
.model small
.stack 200h
.data
text1 db 0ah, 0dh, 'Your text : $'
text2 db 0ah, 0dh, 'Text in lowercase: $'
string db 255 dup(?)
.code
begin:
mov ax, @data
mov ds, ax
lea dx, text1
mov ah, 09h
int 21h
lea si, string
mov ah, 01h
read:
int 21h
cmp al, 0dh
je print
cmp al, 'A'
jl not_upper
cmp al, 'Z'
jg not_upper
add al, 20h
mov [si], al
inc si
;****************************
inc cx
;****************************
jmp read
not_upper:
mov [si], al
inc si
jmp read
print:
mov al, 00h
mov [si], al
lea dx, text2
mov ah, 09h
int 21h
;****************************
lea dx, string
mov ah, 40h
mov bx, 1
int 21h
;****************************
mov ah, 4ch
int 21h
.exit
end begin