;
;Get String & Remove Spase
;
.model small
.data
maxlen db 50
actlen db ?
string db 50 dup(?)
d1 db ?
d2 db ?
temp1 db ?
temp2 db ?
.code
start:
mov ax,@data
mov ds,ax
;-------------Get String
mov ah,10
mov dx,offset maxlen
int 21h
;-------------Add '$'
mov bl,actlen
mov bh,0
mov string[bx],36
;-------------- Enter
mov ah,2
mov dl,10
int 21h
;------------------------------- Get char & Chek by space+'$'
mov d1,0
mov d2,1
up0:
mov bl,d1
mov bh,0
cmp string[bx],32
je u1
;else
up1:
mov bl,d1
mov bh,0
cmp string[bx],36
je fin
inc d1
inc d2
jmp up0
;----------------------------------------------------------
;-------------------------- Finish
fin:
;-------------Print
mov ah,9
mov dx,offset string
int 21h
;----------- End
mov ah,0
int 16h
mov ah,4ch
int 21h
;-----------------------
;;-------------- remove space
u1:
mov bl,d2
mov bh,0
cmp string[bx],32
jne up1
;else
mov bl,d2
mov bh,0
mov temp1,bl
mov temp2,bl
inc temp2
do:
mov bl,temp2
mov bh,0
mov si,bx
mov bl,temp1
mov bh,0
mov al,string[si]
mov string[bx],al
inc temp1
inc temp2
cmp string[bx],36
jne do
;else
jmp up0
end start
اینم یه نمونه کد.
امیدوارم به دردت بخوره.