.model small
.data
encodetable db '0',')'
db '1','!'
db '2','@'
db '3','#'
db '4','$'
db '5','%'
db '6','^'
db '7','&'
db '8','*'
db '9','('
PARAM LABEL BYTE
MaxLen db 20
ActLen db ?
Input db 20 dup(?)
CR EQU 13
LF EQU 10
msg db 'Enter the string','$'
display1 db 'The encoded string is : ' ,'$'
Line db CR,LF,'$'
.code
Main PROC NEAR
mov ax,@data
mov ds,ax
LEA di,Input
CALL GetString
CALL GetEncodedString
mov ax,4C00h
int 21h
Main EndP
GetString PROC NEAR
mov ax,00
mov ah,09h
LEA dx,msg
int 21h
mov ax,00
mov ah,0Ah
LEA dx,PARAM
int 21h
mov bh,00
mov bl,ActLen
mov Input[BX],'$'
ret
GetString EndP
GetEncodedString PROC NEAR
mov ch,00
mov cl,ActLen
mov BX,00
L1:
mov al,Input[BX]
LEA SI,encodetable
next:
cmp al,BYTE PTR [SI]
je exch1
cmp al,'0'
jl IncBx
cmp al,'9'
jg IncBx
add SI,2
mov ah,BYTE PTR [SI]
cmp ah,'9'
jle next
jmp ext
IncBx:
INC BX
Loop L1
jmp ext
exch1:
Inc SI
mov al,BYTE PTR [SI]
mov Input[BX],al
INC BX
Loop L1
ext:
mov bh,00
mov bl,ActLen
mov Input[BX],'$'
mov ax,00
mov ah,09h
LEA DX,Line
int 21h
mov ax,00
mov ah,09h
LEA dx, Line
int 21h
mov ax,00
mov ah, 09H
LEA dx,display1
int 21h
mov ax,00
mov ah,09h
LEA dx,Input
int 21h
ret
GetEncodedString EndP
end