CSE 322 Summer 2018 Lab 10

August 7, 2018

Problem 1 (section 10.7)

Encoding and Decoding string using XLAT instruction

Title secret message
.Model small
.stack 100h
code_key db 65 dup(' '), 'XQPOGHZBCADEIJUVFMNKLRSTWY'
db 37 dup(' ') 
decode_key db 65 dup(' '), 'JHIKLQEFMNTURSDCBVWXOPYAZG' 
db 37 dup(' ')
coded db 80 dup('$') 
; XQPO$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$4
prompt db 'Enter a message to be encoded', 0dh, 0ah, '$'
crlf db 0dh, 0ah, '$' 
main proc
mov ax, @data
mov ds, ax

mov ah, 9
lea dx, prompt
int 21h

mov ah, 1
lea bx, code_key
lea di, coded
int 21h
cmp al, 0dh
je endwhile
mov [di], al
inc di
jmp while_
mov ah, 9
lea dx, crlf
int 21h

lea dx, coded
int 21h

lea dx, crlf
int 21h

mov ah, 2
lea bx, decode_key
lea si, coded
mov al, [si]
cmp al, '$'
je endwhile1 
mov dl, al
int 21h
inc si
jmp while1
mov ax, 4ch
int 21h 
main endp
end main

Problem 2

Change the encode key and decode key in problem 1 to create a decoded message with the letters replaced by 3 letters ahead.
Example A becomes D, B becomes E, etc

To be done by students

Problem 3

Change the code in problem 2 to encode both capital and small letters

To be done by students

Section 11.5
Section 11.6
Chapter 11 problem 8
Chapter 11 problem 9
Chapter 11 problem 10

Leave a Reply