Question: I NEED MY CODE THIS ONE REPRESENT THE SAME OUTPUT IN THE IMAGE WHAT THE ERRORS OR WHAT THE WRONG WITH THE ENC AND DEC
I NEED MY CODE THIS ONE REPRESENT THE SAME OUTPUT IN THE IMAGE WHAT THE ERRORS OR WHAT THE WRONG WITH THE ENC AND DEC KEYS USING EMU8086 CODE:
Org 100h
.data
prompt1 db "if you want to encrypt, type E:","if you want to decrypt, type D: $"
illegal db "that is an illegal character,please try again: $"
prompt3 db "enter the encryption key(a single digit from 1 t0 9): $"
prompt4 db "input a message of no more than 20 characters. when done,press
result1 db "encryption message: $"
result2 db "decryption message: $"
buffer1 db 23 dup('$')
.data
mov ax,@data
mov ds,ax
start:
mov dx,offset prompt1
mov ah,9h
int 21h
mov ah,1 ;read e or d amd check if input is vaild
int 21h
cmp al,'E'
je read
cmp al,'D'
je read
MOV DX,OFFSET ILLEGAL ;PROMPT USER FOR SHIFT AMOUNT
mov ah,9
int 21h
jmp start ;prompt again
read: ;read message form keyboard
mov [3100h],al ;save input
mov dx,offset prompt3
mov ah,9
int 21h
mov ah,1 ;read key
int 21h
mov [3101h],al ;save key
cmp [3100h],'D'
je de ;if d, then decryption message
mov dx,offset prompt4 ;read message to be encrypted
mov ah,9
int 21h
mov ah,0ah
mov dx,offset buffer1 ;read into buffer
int 21h
en:
mov si,buffer1 ;encryption
add si,1
mov ch,0
mov cl,[si]
again: ;encrypt every word
inc si
mov al,[si]
add al,[3101h] ;add key
mov [si-2],al
loop again ;repeat ;loop through message
mov [si],'$'
mov [si-1],'$'
mov dx,offset result1
mov ah,9
int 21h
mov dx,offset buffer1
mov ah,9
int 21h
jmp start
de: ;decryption
lea si,buffer1
pop cx
again1:
mov al,[si]
sub al,0 ;subtract key
mov [si],al
inc si
loop again1 ;repeat ; loop and apply thr enc/dec
mov dx,offset result2
mov ah,9
int 21h
mov dx,offset buffer1
mov ah,9
int 21h
ends:
hlt
ret 
if you want to encrypt, type E :", "if you want to decrypt, type D : E enter the encryption key(a single digit fron 1 to 9): 1 input a message of no nore than 20 characters. when done, press enter : abc encryption message: bcd if you want to encrypt, type E:," "if you want to decrypt, type D: E enter the encryption key(a single digit fron 1 to 9): 2 encryption message: cde if you want to encrypt, type E:", "if you want to decrypt, type D
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
