Xoa ky tu trang thua, xuat so ky tu cua chuoi
.model small
.stack 100h
.data
s db 80,0,80 dup ("$")
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
lea dx,s
mov ah,0ah
int 21h
;xuong dong
mov ah,02
mov al,0dh
int 21h
mov dl,0ah
int 21h
;xoa ky tu trang
lea di,s+1
mov cx,[di]
inc di
xor ch,ch
mov bx,cx
dau:
lea di,s+2
mov dl,[di]
cmp dl," "
jne stop1
jmp botrang
botrang:
inc di
mov dh,[di]
dec di
mov [di],dh
inc di
loop botrang
dec bx
mov cx,bx
jmp dau
stop1:
cuoi:
mov dl,[di]
cmp dl,20h
jne stop
mov [di],"$"
dec di
jmp cuoi
stop:
mov bx,1
giua:
dec bx
lea di,s+2
les si,s+3
add di,bx
add si,bx
mov dh,[di]
mov bx,di
cmp dh,"$"
je kt
cmp dh," "
jne giua
mov dl,[si]
cmp dl," "
jne giua
giua1:
mov dh,[si]
mov [di],dh
inc di
inc si
cmp dh,"$"
je giua
dec bx
jmp giua1
kt:
;in chuoi
lea dx,s+2
mov ah,9
int 21h
;xuong dong
mov ah,2
mov dl,0dh
int 21h
mov dl,0ah
int 21h
mov bx,0
lea di,s+1
;dem so tu cua chuoi
demtu:
inc di
mov dh,[di]
cmp dh,"$"
je kt1
cmp dh," "
je dem
jmp demtu
dem:
inc bx
kt1:
inc bx
; in so tu cua chuoi
call xuat
;tra con tro ve cho dos
mov ah,4ch
int 21h
main endp
xuat proc
xor bh,bh
mov cx,0
mov ax,bx
lap:
mov dx,0
mov bx,0ah
div bx
inc cx
push dx
cmp dx,0
jne lap
print:
pop dx
mov ah,2
add dl,30h
int 21h
loop print
ret
xuat endp
end
Bạn đang đọc truyện trên: Truyen4U.Com