UMBC CMSC313

Project 2: Secret Agent Man Due: 28 Oct

Requirements Specification

Create the source file jdoe1p2.asm, assembly it, link it, and run it. When it runs correctly, submit using Blackboard. (Remember that the jdoe1 is suppose to be your id that you use to log onto the GL computers, so that there is a unique file! Do not use jdoe1 unless that is in YOUR ID!!)

Specifications

This time you get to be a Secret Agent Man. You will make use of an old cipher system, the Caesar Cipher. This was two wheels, each with a normal alphabet one it. One wheel contained the letters of the original, called plain text (or p), and the enciphered version, called cipher text (or c). You would rotate the outer (plain text) wheel until the letter A was over the desired inner (cipher) letter.

Then you would encipher the message. If you align the Ap over the Dc, this starting sequence was notated as Ap=Dc. The figure above is Ap=Kc To demonstrate this in another way, Ap=Dc would be:

Plain ABCDEFGHIJKLMNOPQRSTUVWXYZ
CipherDEFGHIJKLMNOPQRSTUVWXYZABC
Enciphering the message "Gary", you get "JDUB". That was fun, just like my Captain Midnight Decoder Ring!

For this project, you are open a file, read in the text (containing only the characters a-z, A-Z, 0-9, the comma, and the period), encipher it and store it in a new file. Just to keep things interesting, you must use system calls to open, read, write, and close files in the current directory. You will read in normal text, but when you write it out, you must print it as five letter groups with a space between groups and ten groups per line for as many lines as necessary:

ABCDE FGHIJ KLMNO PQRST UVWXY ZABCD EFGHI JKLMN OPQRS TUVWX YZABC
DEFGH

Additionally, you must convert lower case to upper case before encipherment. Finally, the digits 0 - 9, and the symbols ",", and "." must be spelled out. "1200." becomes "one two zero zero period" After spelling them out, you must then encipher them

You must prompt the user for the first cipher letter (?c). Make sure the user provides a valid first letter (but it can be either upper case or lower case).

System Calls Of Interest22 Mar

;; The conventions used in Linux 2.2, the parameters are stored in left to right 
;; order in the registers EBX, ECX, EDX, EDI, and ESI respectively.
;; The man pages show:
;;       int creat(const char *pathname, mode_t mode);
;;        mov      eax, dword CREATE    ; System Call -- open
;;        mov      ebx, myFile1         ; Pointer to filename
;;        mov      ecx, O_WRONLY        ; Flag for Write Only
;;        mov      edx, 01FDh           ; Mode -- 755 in octal
;;        int      80h
;;        mov      dword [ fdWrite ], eax; save the file descriptor

;;       int open(const char *pathname, int flags, mode_t mode);
;;        mov      eax, dword OPEN      ; System Call -- open
;;        mov      ebx, myFile          ; Pointer to filename
;;        mov      ecx, O_RDONLY        ; Flag for Read Only
;;        mov      edx, 0               ; Mode -- not used to open existing file
;;        int      80h
;;        mov      dword [ fdRead ], eax ; save the file descriptor

;;       ssize_t read(int fd, void *buf, size_t count);
;;        mov      eax, READ            ; System Call -- read
;;        mov      ebx, dword [ fdRead ]; File descriptor opened for reading
;;        mov      ecx, dword inBuff    ; Pointer to input buffer
;;        mov      edx, dword BUFSIZE   ; Number of bytes to read
;;        int      80h
;;        mov      dword [ bytesRead ], eax ; Actual amount read

;;       ssize_t write(int fd, const void *buf, size_t count);
;;        mov      eax, WRITE            ; System Call -- write
;;        mov      ebx, dword [ fdWrite ]; File descriptor opened for writing
;;        mov      ecx, dword outBuff    ; Pointer to output buffer
;;        mov      edx, dword [ bytesWritten ]      ; Number of bytes to write
;;        mov      80h

;;       int close(int fd);
;;        mov      eax, CLOSE
;;        mov      ebx, dword [ fdRead ]
;;        int      80h
;;      

;; What is this size_t/ssize_t/mode_t stuff?????
;;    /usr/src/linux/include/asm-i386/posix_types.h:typedef unsigned short   __kernel_mode_t;
;;    /usr/src/linux/include/linux/types.h:         typedef __kernel_mode_t  mode_t;

;;    /usr/src/linux/include/asm-i386/posix_types.h:typedef int              __kernel_ssize_t;
;;    /usr/src/linux/include/linux/types.h:         typedef __kernel_ssize_t ssize_t;

;;    /usr/src/linux/include/asm-i386/posix_types.h:typedef unsigned int     __kernel_size_t
;;    /usr/src/linux/include/linux/types.h:         typedef __kernel_size_t  size_t;
;;

;; in /usr/include/bits/fcntl.h:
;;
;;     O_RDONLY  00
;;     O_WRONLY  01
;;     O_RDWR    02

%define  O_RDONLY 00
%define  O_WRONLY 01
%define  O_RDWR   02

Program Header Comment Block

Use the following comment block at the beginning of your source code:
;; Filename:       jdoe1p1.asm
;; Name:           Ima Student
;; email:          jdoe1@umbc.edu  
;; Date:           18 Mar 2005
;; Course:         CMSC313 
;; Description:    (Your psuedocode goes here.  Must be detailed)
;; Notes:          (As needed, such has how to compile)

©2005, Gary L. Burt