INCLUDE Irvine32.inc
.data
Prompt1 BYTE "Input Text:", 0
Prompt2 BYTE "Caesar Cipher Output:", 0
UserInput BYTE 80 DUP (?)
.code
main PROC
;print out the prompt
mov edx, OFFSET Prompt1
call WriteString
call crlf
;get a string from the user at most 79 letters
mov ecx, 79
mov edx, OFFSET UserInput
call ReadString
call crlf
;print out the output text first before doing the cipher
mov edx, OFFSET Prompt2
call WriteString
call crlf
;point edx to the first letter
mov edx, OFFSET UserInput
A0:
;get the letter at edx, if it equals 0, it's the last letter so exit (to the A1 label)
mov al, [edx]
cmp al, 0
je A1
;if al is uppercases, make it lowercase
.IF (al >= 'A') && (al <= 'Z')
add al, 'a'-'A'
.ENDIF
;only if al is lowercase do the cipher
.IF (al >= 'a') && ( al <= 'z')
add al, 3
;if it wrapped around, subtract
.IF (al > 'z')
sub al, 'z'-'a'+1
.ENDIF
.ENDIF
;print out the letter
call writeChar
;point to the next letter and go back to the loop
add edx, 1
jmp A0
A1:
;get out
call crlf
exit
main ENDP
END main