汇编:从键盘输入一字符串,并显示,再反向显示
来源:百度知道 编辑:UC知道 时间:2024/05/27 16:59:15
这个程式不处理回格键。
.model tiny
.code
.startup
push ax
push cx
push si
xor cx,cx
lea si,keyBuffer
@1:
mov ah,1
int 21h
cmp al,13
jz @output
cmp al,8
jz @1
mov byte ptr[si],al
inc si
inc cx
cmp cx,255
jl @1
jmp @output
putchar proc near
push ax
mov ah,2
int 21h
pop ax
ret
putchar endp
@output:
mov dl,13
call putchar
mov dl,10
call putchar
;dec cx
dec si
@2:
mov dl,byte ptr[si]
call putchar
dec si
loop @2
pop si
pop cx
pop ax
mov ah,4ch
int 21h
keyBuffer db 255 dup(0)
end