Here is the deal. I am writing a program in assembly that compresses and decompresses text based files. The user should be able to input a text file, and declare the name of what that file should be name when turned into a .drl file (just a random extension for my prog).

Right now I am working on reading the file to be compressed. First off I am reading the file one byte at a time and looking for " "(the space character). I want to search the text files for " word" and replace each instance of that word preceded with a space with a "key." This key will be designed using Huffman's Algorithm.

Anyways I want to read the character and as long as its not null, append it to the end of a string. How do I do that?(might be simple, but I'm not seeing it)

Next, how do I read from the file one byte prior to where I finished. Meaning: if I read a space and stop the read(because its the start of a new word) how do I re-read that space to add it to the word next time around?

Those are all the questions I am at the point of asking right now, but as I have seen plenty of times before, you guys are pretty strict on not giving out help on homework without effort shown. So here is my incomplete code. Feel free to make any and all helpful criticism.

Thank You.

Include Irvine32.inc  ;includes Master Irvine's Library

.data
message1 BYTE "Please type the file name of the file to be compressed",0     ;initiates the variable message1 and assigns it "Please type the file name of the file to be compressed", 0
message2 BYTE "Please type the filename to save the compression to(must end in .drl):",0       ;initiates the variable message2 and assigns it "Please type the filename to save the compression to:", 0
message3 BYTE "Cannot compress an empty file!",0                             ;initiates the variable message3 and assigns it "Cannot compress and empty file", 0
message4 BYTE "Please select one of the options:",0dh, 0Ah,
				"1. Compress a file",0dh,0ah,
				"2. DeCompress a file",0dh,0ah,0               ;initiates the variable message4 and assigns it "PLease select one 1. Compress 2. DeCompress", 0
message5 BYTE "Please type the file name of the file to be DeCompressed(must be a .drl file):",0     ;initiates the variable message1 and assigns it "Please type the file name of the file to be Decompressed", 0
message6 BYTE "Please type the filename to save the DeCompressed File to:",0       ;initiates the variable message2 and assigns it "Please type the filename to save the DeCompression to:", 0
handle1 DWORD ?								    ;Uninitialized variable for handle1
handle2 DWORD ?								    ;Uninitialized variable for handle2
BUFFER_SIZE = 1									;sets buffer size to 1
buffer BYTE BUFFER_SIZE DUP(0)							;Duplicates buffer to buffer size and sets to 0
bytesRead DWORD ?								;Unintialized variable for bytesread
bytesWritten DWORD ?								;Unintialized variable for byteswritten
sourceFile BYTE 20 DUP(0),0							;initiates the variable for the sourceFile
destinationFile BYTE 20 DUP(0),0						;initiates the variable for the destinationFile

.code
main PROC					;beginning of main proc
call ShowPrompt				;calls showprompt proc
call checkForEmptyFile		;calls checkforemptyfile proc
call getFileHandles			;calls getfilehandles proc
call ReadFromFile1			;calls read from file1 proc
call closeFiles				;calls the closeFiles proc
exit						;properly exits
main ENDP					;end of main proc

;--------------------------------------------------------------------------------------------------------------;
showPrompt PROC				;beginning of showPrompt proc
L1:							;loop one
mov edx, OFFSET message4	;moves the offset of message 4 into edx
call WriteString			;displays message4
call crlf					;new line
call ReadChar				;reads user input of a char
cmp al, "1"					;compares input to the char '1'
je Compress					;if equal then jump to Compress
cmp al, "2"					;compares user input to the char '2'
je DeCompress				;if equal then jump to DeCompress
jmp L1						;start loop over again if neither '1' nor '2'

Compress:					;beginning of Compress label
mov edx, OFFSET message1	;moves the offset of message1 into edx
call WriteString			;displays message1
call crlf					;new line
mov edx, OFFSET sourceFile	;moves the offset of sourceFile into edx
mov ecx, SIZEOF sourceFile	;moves the sizeOf sourceFile into ecx
call ReadString				;reads the user input of a string
call crlf					;new line
Compressb:					;destination
mov edx, OFFSET message2	;moves the offset of message2 into edx
call WriteString			;displays message2
call crlf							;new line
mov edx, OFFSET destinationFile		;moves the offset of destinationFile into edx
mov ecx, SIZEOF destinationFile		;moves the sizeOf destinationFile into ecx
call ReadString						;reads the user input of a string
call crlf							;new line

mov edi, OFFSET destinationFile
mov eax, ".drl"
mov ecx, SIZEOF destinationFile
cld
repne scasb
jnz Compressb
dec edi
ret									;return

DeCompress:							;beginning of DeCompress Label
mov edx, OFFSET message5			;moves the offset of message5 into ex
call WriteString					;displays message5
call crlf							;new line
mov edx, OFFSET sourceFile			;moves the offset of sourceFile into edx
mov ecx, SIZEOF sourceFile			;moves the sizeOf sourceFile into ecx
call ReadString						;reads the user input of a string
call crlf							;new line

mov edi, OFFSET sourceFile
mov eax, ".drl"
mov ecx, SIZEOF sourceFile
cld
repne scasb
jnz DeCompress
dec edi

mov edx, OFFSET message6			;moves the offset of message6 into edx
call WriteString					;displays message6
call crlf							;new line
mov edx, OFFSET destinationFile		;moves the offset of destinationFile into edx
mov ecx, SIZEOF destinationFile		;moves the sizeOf destinationFile into ecx
call ReadString						;reads the user input of a string
call crlf							;new line
ret									;return
showPrompt ENDP						;end of ShowPrompt proc

;--------------------------------------------------------------------------------------------------------------;
checkForEmptyFile PROC
mov edx, OFFSET sourceFIle				; moves the offset of sourceFile into edx
call OpenInputFile						; calls openinputfile proc
cmp eax, INVALID_HANDLE_VALUE			;check validity of file handle
je Quit2
mov handle3, eax									;jumps to quit label if invalid
mov edx, OFFSET buffer						;moves the offset of buffer into edx
mov ecx, BUFFER_SIZE
mov eax, handle3						;moves the buffer_Size into ecx
call ReadFromFile						;calls ReadFromFile
mov bytesRead, eax						;move eax into bytesRead
cmp eax, 0							;compare eax to 0
je QUIT								;if eax=0 then jump to quit
mov eax, handle3					
call Closefile						;calls closeFiles proc		
ret									;return

QUIT:								;beginning of QUIT label
mov edx, OFFSET message9			;moves the offset of message9 into edx
call WriteString					;displays message9							
exit								;properly exits

QUIT2:
mov edx, OFFSET message6			;moves the offset of message6 into edx
call WriteString					;calls writestring
exit								;exits
checkForEmptyFile ENDP				;end of checkForEmptyFile proc

;--------------------------------------------------------------------------------------------------------------;
getFileHandles PROC						;beginning of getfilehandles proc
mov edx, OFFSET sourceFIle				; moves the offset of sourceFile into edx
call OpenInputFile						; calls openinputfile proc
cmp eax, INVALID_HANDLE_VALUE			;check validity of file handle
je Quit									;jumps to quit label if invalid
mov handle1, eax						;moves eax into handle1
mov edx, OFFSET destinationFile					;moves the offset of the destination file into edx
call CreateOutputFile						;calls the CreatOutputFile proc
cmp eax, INVALID_HANDLE_VALUE			;check validity of file handle
je Quit									;jumps to quit label if invalid
mov handle2, eax						;moves eax into handle2
ret										;return

QUIT:									;beginning of quit label
mov edx, OFFSET message6				;moves the offset of message6 into edx
call WriteString						;writes edx
call crlf								;new line
call crlf								;new line
call main								;calls main proc
getFileHandles ENDP							;end of getFileHandles Proc

;--------------------------------------------------------------------------------------------------------------;
readFromFile1 PROC							;begining of readFromfile1 proc
Read:									;beginning of read label
mov eax, handle1						;moves handle1 into eax
mov edx, OFFSET buffer					; moves the offset of the buffer into edx
mov ecx, BUFFER_SIZE					;moves the buffer size into ecx
First:
call ReadFromFile
cmp eax, 0
je Quit2
cmp eax, " "
je Next


jmp New
NEXT:
mov bytesread, eax						;moves the data into bytesread
New:
call ReadFromFile						;reads data from file
cmp eax, 0							;compares eax to 0
je Quit2							;if eax = 0 then jump to Quit2
cmp eax, " "
jne NEXT
push eax							;push eax onto stack

pop eax								;pops eax off stack
cmp eax, 5							;compares eax to 5
jb Quit								;jump to quit if carry
call clear							;new line
jmp Read							;jump back to Read

Quit:								;beginning of Quit label
call crlf							;new line
mov edx, OFFSET message8					;moves the offset of message8 into edx
call WriteString						;displays message8
ret								;return


Quit2:								;beginning of Quit2 label
ret								;return
readFromFile1 ENDP						;end of readFromFile1 proc

;--------------------------------------------------------------------------------------------------------------;
closeFiles PROC							;beginning of closeFiles proc
mov eax, handle1						;moves handle1 into eax
call CloseFile							;closes the file
mov eax, handle2						;moves handle2 into eax
call CloseFile							;close the file
ret								;return
closeFiles ENDP							;end of the closeFiles proc

And I, like other recent posts, am using MASM and use the Assembly Language for Intel-Based Computers (5e)- Irvine

UPDATE: Kinda bummed that over 70 people have viewed and no one can help, but I'm hoping that someone will see this soon who can help. I am working on solving the problem of reading the file byte by byte and storing into 1 variable. The best solution so far is to setup a variable such as word dword 45 dup('~'), 0 which i can then add to each byte of the 'word', is this right? then my terminating character is '~' since this is my least likely character(i think) to encounter in my file.

Here is an updated code. It works up to the point of creating the new file, then it basically just freezes.

Is there a way to edit previous posts so that I don't have to keep making this longer and longer?

Include Irvine32.inc  ;includes Master Irvine's Library

.data
message1 BYTE "Please type the file name of the file to be compressed",0     ;initiates the variable message1 and assigns it "Please type the file name of the file to be compressed", 0
message2 BYTE "Please type the filename to save the compression to(must end in .drl):",0       ;initiates the variable message2 and assigns it "Please type the filename to save the compression to:", 0
message3 BYTE "Cannot compress an empty file!",0                             ;initiates the variable message3 and assigns it "Cannot compress and empty file", 0
message4 BYTE "Please select one of the options:",0dh, 0Ah,
				"1. Compress a file",0dh,0ah,
				"2. DeCompress a file",0dh,0ah,0               ;initiates the variable message4 and assigns it "PLease select one 1. Compress 2. DeCompress", 0
message5 BYTE "Please type the file name of the file to be DeCompressed(must be a .drl file):",0     ;initiates the variable message1 and assigns it "Please type the file name of the file to be Decompressed", 0
message6 BYTE "Please type the filename to save the DeCompressed File to:",0       ;initiates the variable message2 and assigns it "Please type the filename to save the DeCompression to:", 0
message7 BYTE "Cannot compress an empty file!",0                             ;initiates the variable message7 and assigns it "Cannot compress and empty file", 0
message8 BYTE "Complete!",0                                                 ;initiates the variable message8 and assigns it "Complete!", 0
handle1 DWORD ?								    ;Uninitialized variable for handle1
handle2 DWORD ?								    ;Uninitialized variable for handle2
handle3 DWORD ?								    ;Uninitialized variable for handle3
BUFFER_SIZE = 1									;sets buffer size to 1
buffer BYTE BUFFER_SIZE DUP(0)							;Duplicates buffer to buffer size and sets to 0
bytesRead DWORD ?								;Unintialized variable for bytesread
bytesWritten DWORD ?								;Unintialized variable for byteswritten
sourceFile BYTE 20 DUP(0),0							;initiates the variable for the sourceFile
destinationFile BYTE 20 DUP(0),0						;initiates the variable for the destinationFile
times dword 46 DUP('~'),0

.code
main PROC					;beginning of main proc
call ShowPrompt				;calls showprompt proc
call checkForEmptyFile		;calls checkforemptyfile proc
call getFileHandles			;calls getfilehandles proc
call ReadFromFile1			;calls read from file1 proc
call closeFiles				;calls the closeFiles proc
exit						;properly exits
main ENDP					;end of main proc

;--------------------------------------------------------------------------------------------------------------;
showPrompt PROC				;beginning of showPrompt proc
L1:							;loop one
mov edx, OFFSET message4	;moves the offset of message 4 into edx
call WriteString			;displays message4
call crlf					;new line
call ReadChar				;reads user input of a char
cmp al, "1"					;compares input to the char '1'
je Compress					;if equal then jump to Compress
cmp al, "2"					;compares user input to the char '2'
je DeCompress				;if equal then jump to DeCompress
jmp L1						;start loop over again if neither '1' nor '2'

Compress:					;beginning of Compress label
mov edx, OFFSET message1	;moves the offset of message1 into edx
call WriteString			;displays message1
call crlf					;new line
mov edx, OFFSET sourceFile	;moves the offset of sourceFile into edx
mov ecx, SIZEOF sourceFile	;moves the sizeOf sourceFile into ecx
call ReadString				;reads the user input of a string
call crlf					;new line
Compressb:					;destination
mov edx, OFFSET message2	;moves the offset of message2 into edx
call WriteString			;displays message2
call crlf							;new line
mov edx, OFFSET destinationFile		;moves the offset of destinationFile into edx
mov ecx, SIZEOF destinationFile		;moves the sizeOf destinationFile into ecx
call ReadString						;reads the user input of a string
call crlf							;new line

mov edi, OFFSET destinationFile
mov eax, ".drl"
mov ecx, SIZEOF destinationFile
cld
repne scasb
jnz Compressb
dec edi
ret									;return

DeCompress:							;beginning of DeCompress Label
mov edx, OFFSET message5			;moves the offset of message5 into ex
call WriteString					;displays message5
call crlf							;new line
mov edx, OFFSET sourceFile			;moves the offset of sourceFile into edx
mov ecx, SIZEOF sourceFile			;moves the sizeOf sourceFile into ecx
call ReadString						;reads the user input of a string
call crlf							;new line

mov edi, OFFSET sourceFile
mov eax, ".drl"
mov ecx, SIZEOF sourceFile
cld
repne scasb
jnz DeCompress
dec edi

mov edx, OFFSET message6			;moves the offset of message6 into edx
call WriteString					;displays message6
call crlf							;new line
mov edx, OFFSET destinationFile		;moves the offset of destinationFile into edx
mov ecx, SIZEOF destinationFile		;moves the sizeOf destinationFile into ecx
call ReadString						;reads the user input of a string
call crlf							;new line
ret									;return
showPrompt ENDP						;end of ShowPrompt proc

;--------------------------------------------------------------------------------------------------------------;
checkForEmptyFile PROC
mov edx, OFFSET sourceFIle				; moves the offset of sourceFile into edx
call OpenInputFile						; calls openinputfile proc
cmp eax, INVALID_HANDLE_VALUE			;check validity of file handle
je Quit2
mov handle3, eax									;jumps to quit label if invalid
mov edx, OFFSET buffer						;moves the offset of buffer into edx
mov ecx, BUFFER_SIZE
mov eax, handle3						;moves the buffer_Size into ecx
call ReadFromFile						;calls ReadFromFile
mov bytesRead, eax						;move eax into bytesRead
cmp eax, 0							;compare eax to 0
je QUIT								;if eax=0 then jump to quit
mov eax, handle3					
call Closefile						;calls closeFiles proc		
ret									;return

QUIT:								;beginning of QUIT label
mov edx, OFFSET message7			;moves the offset of message7 into edx
call WriteString					;displays message7				
exit								;properly exits

QUIT2:
mov edx, OFFSET message6			;moves the offset of message6 into edx
call WriteString					;calls writestring
exit								;exits
checkForEmptyFile ENDP				;end of checkForEmptyFile proc

;--------------------------------------------------------------------------------------------------------------;
getFileHandles PROC						;beginning of getfilehandles proc
mov edx, OFFSET sourceFIle				; moves the offset of sourceFile into edx
call OpenInputFile						; calls openinputfile proc
cmp eax, INVALID_HANDLE_VALUE			;check validity of file handle
je Quit									;jumps to quit label if invalid
mov handle1, eax						;moves eax into handle1
mov edx, OFFSET destinationFile					;moves the offset of the destination file into edx
call CreateOutputFile						;calls the CreatOutputFile proc
cmp eax, INVALID_HANDLE_VALUE			;check validity of file handle
je Quit									;jumps to quit label if invalid
mov handle2, eax						;moves eax into handle2
ret										;return

QUIT:									;beginning of quit label
mov edx, OFFSET message6				;moves the offset of message6 into edx
call WriteString						;writes edx
call crlf								;new line
call crlf								;new line
call main								;calls main proc
getFileHandles ENDP							;end of getFileHandles Proc

;--------------------------------------------------------------------------------------------------------------;
readFromFile1 PROC							;begining of readFromfile1 proc
Read:									;beginning of read label
mov eax, handle1						;moves handle1 into eax
mov edx, OFFSET buffer					; moves the offset of the buffer into edx
mov ecx, BUFFER_SIZE					;moves the buffer size into ecx
First:
call ReadFromFile
cmp eax, 0
je Quit2
cmp eax, " "
je Next


jmp New
NEXT:
mov bytesread, eax						;moves the data into bytesread
New:
call ReadFromFile						;reads data from file
cmp eax, 0							;compares eax to 0
je Quit2							;if eax = 0 then jump to Quit2
cmp eax, " "
jne NEXT
push eax							;push eax onto stack

pop eax								;pops eax off stack
cmp eax, 5							;compares eax to 5
jb Quit								;jump to quit if carry
call clear							;new line
jmp Read							;jump back to Read

Quit:								;beginning of Quit label
call crlf							;new line
mov edx, OFFSET message8					;moves the offset of message8 into edx
call WriteString						;displays message8
ret								;return


Quit2:								;beginning of Quit2 label
ret								;return
readFromFile1 ENDP						;end of readFromFile1 proc

;--------------------------------------------------------------------------------------------------------------;
clear PROC							;beginning of Clear proc	
mov ecx, SIZEOF buffer						;moves the sizeOf buffer into ecx
mov esi,0							;moves 0 into esi
L2:								;loop two	
mov buffer[esi],0						;moves 0 into buffer at esi
inc esi								;increment esi	
loop L2								;loop back
ret								;return	
clear ENDP							;end of clear proc

;--------------------------------------------------------------------------------------------------------------;
closeFiles PROC							;beginning of closeFiles proc
mov eax, handle1						;moves handle1 into eax
call CloseFile							;closes the file
mov eax, handle2						;moves handle2 into eax
call CloseFile							;close the file
ret								;return
closeFiles ENDP							;end of the closeFiles proc


end MAIN

ANOTHER UPDATE: Hoping someone will be able to help soon! Haha.

Right now my major problem is that I read a word, put it into the newword variable and then try to add that to an array of words to store till I write the output file. However, every time I add the word and then display it to check I only get random symbols and junk. Any ideas why? here is my updated code....

;AUTHOR: DANIEL LUCAS

Include Irvine32.inc  ;includes Master Irvine's Library

.data
message1 BYTE "Please type the file name of the file to be compressed",0     ;initiates the variable message1 and assigns it "Please type the file name of the file to be compressed", 0
message2 BYTE "Please type the filename to save the compression to(must end in .drl):",0       ;initiates the variable message2 and assigns it "Please type the filename to save the compression to:", 0
message3 BYTE "Cannot compress an empty file!",0                             ;initiates the variable message3 and assigns it "Cannot compress and empty file", 0
message4 BYTE "Please select one of the options:",0dh, 0Ah,
				"1. Compress a file",0dh,0ah,
				"2. DeCompress a file",0dh,0ah,0               ;initiates the variable message4 and assigns it "PLease select one 1. Compress 2. DeCompress", 0
message5 BYTE "Please type the file name of the file to be DeCompressed(must be a .drl file):",0     ;initiates the variable message1 and assigns it "Please type the file name of the file to be Decompressed", 0
message6 BYTE "Please type the filename to save the DeCompressed File to:",0       ;initiates the variable message2 and assigns it "Please type the filename to save the DeCompression to:", 0
message7 BYTE "Cannot compress an empty file!",0                             ;initiates the variable message7 and assigns it "Cannot compress and empty file", 0
message11 BYTE "Here3", 0dh, 0Ah,0                                                 ;initiates the variable message8 and assigns it "Complete!", 0
message9 BYTE "Here1", 0dh, 0Ah,0   
message10 BYTE "Here2", 0dh, 0Ah,0   
message8 BYTE "Complete!",0   
handle1 DWORD ?								    ;Uninitialized variable for handle1
handle2 DWORD ?								    ;Uninitialized variable for handle2
handle3 DWORD ?								    ;Uninitialized variable for handle3
handle4 DWORD ?								    ;Uninitialized variable for handle4
BUFFER_SIZE = 1									;sets buffer size to 1
buffer BYTE BUFFER_SIZE DUP(0)							;Duplicates buffer to buffer size and sets to 0
bytesRead DWORD ?								;Unintialized variable for bytesread
bytesWritten DWORD ?								;Unintialized variable for byteswritten
sourceFile BYTE 20 DUP(0),0							;initiates the variable for the sourceFile
destinationFile BYTE 20 DUP(0),0						;initiates the variable for the destinationFile
newword byte 46 DUP(?),0
fresh byte 46 DUP(0),0
store dword ?
wordArray DWORD ?
wordNum dword 1

.code
main PROC					;beginning of main proc
call ShowPrompt				;calls showprompt proc
call checkForEmptyFile		;calls checkforemptyfile proc
call getFileHandles			;calls getfilehandles proc
call ReadFromFile1			;calls read from file1 proc
call closeFiles				;calls the closeFiles proc
exit						;properly exits
main ENDP					;end of main proc

;--------------------------------------------------------------------------------------------------------------;
showPrompt PROC				;beginning of showPrompt proc
L1:							;loop one
mov edx, OFFSET message4	;moves the offset of message 4 into edx
call WriteString			;displays message4
call crlf					;new line
call ReadChar				;reads user input of a char
cmp al, "1"					;compares input to the char '1'
je Compress					;if equal then jump to Compress
cmp al, "2"					;compares user input to the char '2'
je DeCompress				;if equal then jump to DeCompress
jmp L1						;start loop over again if neither '1' nor '2'

Compress:					;beginning of Compress label
mov edx, OFFSET message1	;moves the offset of message1 into edx
call WriteString			;displays message1
call crlf					;new line
mov edx, OFFSET sourceFile	;moves the offset of sourceFile into edx
mov ecx, SIZEOF sourceFile	;moves the sizeOf sourceFile into ecx
call ReadString				;reads the user input of a string
call crlf					;new line
Compressb:					;destination
mov edx, OFFSET message2	;moves the offset of message2 into edx
call WriteString			;displays message2
call crlf							;new line
mov edx, OFFSET destinationFile		;moves the offset of destinationFile into edx
mov ecx, SIZEOF destinationFile		;moves the sizeOf destinationFile into ecx
call ReadString						;reads the user input of a string
call crlf							;new line
push eax
mov edi, OFFSET destinationFile
mov eax, ".drl"
mov ecx, SIZEOF destinationFile
cld
repne scasb
jnz Compressb
dec edi
pop eax
ret									;return

DeCompress:							;beginning of DeCompress Label
mov edx, OFFSET message5			;moves the offset of message5 into ex
call WriteString					;displays message5
call crlf							;new line
mov edx, OFFSET sourceFile			;moves the offset of sourceFile into edx
mov ecx, SIZEOF sourceFile			;moves the sizeOf sourceFile into ecx
call ReadString						;reads the user input of a string
call crlf							;new line

mov edi, OFFSET sourceFile
mov eax, ".drl"
mov ecx, SIZEOF sourceFile
cld
repne scasb
jnz DeCompress
dec edi

mov edx, OFFSET message6			;moves the offset of message6 into edx
call WriteString					;displays message6
call crlf							;new line
mov edx, OFFSET destinationFile		;moves the offset of destinationFile into edx
mov ecx, SIZEOF destinationFile		;moves the sizeOf destinationFile into ecx
call ReadString						;reads the user input of a string
call crlf							;new line
ret									;return
showPrompt ENDP						;end of ShowPrompt proc

;--------------------------------------------------------------------------------------------------------------;
checkForEmptyFile PROC
mov edx, OFFSET sourceFIle				; moves the offset of sourceFile into edx
call OpenInputFile						; calls openinputfile proc
cmp eax, INVALID_HANDLE_VALUE			;check validity of file handle
je Quit2
mov handle3, eax									;jumps to quit label if invalid
mov edx, OFFSET buffer						;moves the offset of buffer into edx
mov ecx, BUFFER_SIZE
mov eax, handle3						;moves the buffer_Size into ecx
call ReadFromFile						;calls ReadFromFile
mov bytesRead, eax						;move eax into bytesRead
cmp eax, 0							;compare eax to 0
je QUIT								;if eax=0 then jump to quit
mov eax, handle3					
call Closefile						;calls closeFiles proc		
ret									;return

QUIT:								;beginning of QUIT label
mov edx, OFFSET message7			;moves the offset of message7 into edx
call WriteString					;displays message7				
call crlf							;new line
exit								;properly exits

QUIT2:
mov edx, OFFSET message6			;moves the offset of message6 into edx
call WriteString					;calls writestring
call crlf							;new line
exit								;exits
checkForEmptyFile ENDP				;end of checkForEmptyFile proc

;--------------------------------------------------------------------------------------------------------------;
getFileHandles PROC						;beginning of getfilehandles proc
mov edx, OFFSET sourceFIle				; moves the offset of sourceFile into edx
call OpenInputFile						; calls openinputfile proc
cmp eax, INVALID_HANDLE_VALUE			;check validity of file handle
je Quit									;jumps to quit label if invalid
mov handle1, eax						;moves eax into handle1
mov edx, OFFSET destinationFile					;moves the offset of the destination file into edx
call CreateOutputFile						;calls the CreatOutputFile proc
cmp eax, INVALID_HANDLE_VALUE			;check validity of file handle
je Quit									;jumps to quit label if invalid
mov handle2, eax						;moves eax into handle2
ret										;return

QUIT:									;beginning of quit label
mov edx, OFFSET message6				;moves the offset of message6 into edx
call WriteString						;writes edx
call crlf								;new line
call crlf								;new line
call main								;calls main proc
getFileHandles ENDP							;end of getFileHandles Proc

;--------------------------------------------------------------------------------------------------------------;
readFromFile1 PROC							;begining of readFromfile1 proc
mov store, OFFSET newword
mov edi, OFFSET newword
mov esi, OFFSET wordArray
Read:									;beginning of read label

mov eax, OFFSET newword
mov edx, eax					;moves the offset of message9 into edx
call WriteString						;displays message9

First:
mov eax, handle1						;moves handle1 into eax
mov edx, OFFSET buffer					; moves the offset of the buffer into edx
mov ecx, BUFFER_SIZE					;moves the buffer size into ecx

call ReadFromFile
cmp eax, 0
je Quit2
cmp buffer, " "
je Next
jmp first

NEXT:
mov al, buffer
mov [edi], al						;moves the data into bytesread
inc edi



New:
mov eax, handle1						;moves handle1 into eax
mov edx, OFFSET buffer					; moves the offset of the buffer into edx
mov ecx, BUFFER_SIZE					;moves the buffer size into ecx
call ReadFromFile						;reads data from file
cmp eax, 0							;compares eax to 0
je Quit2							;if eax = 0 then jump to Quit2
add eax, bytesread
mov bytesread, eax
cmp buffer, " "
jne NEXT

mov edi, OFFSET newword
mov eax, " "
mov ecx, SIZEOF newword
cld
repne scasb
jnz noWorth
dec edi
cmp bytesread, 4
jb NoWorth
push eax
mov eax, handle1
mov handle4, eax
;call scanMe
pop eax

Worth:
mov edi, OFFSET newword
mov [esi], edi
add esi, 4

NoWorth:
call clear
mov bytesread, 0

mov edx, OFFSET newword					;moves the offset of message9 into edx
call WriteString	
jmp first


Quit:								;beginning of Quit label
call crlf							;new line
mov edx, OFFSET message8					;moves the offset of message8 into edx
call WriteString						;displays message8
ret								;return


Quit2:								;beginning of Quit2 label
mov edx, OFFSET wordArray					;moves the offset of message9 into edx
call WriteString						;displays message9
ret								;return
readFromFile1 ENDP						;end of readFromFile1 proc

;--------------------------------------------------------------------------------------------------------------;
clear PROC							;beginning of Clear proc	
mov ecx, SIZEOF newword						;moves the sizeOf buffer into ecx
mov esi,0							;moves 0 into esi
L2:								;loop two	
mov newword[esi],0						;moves 0 into buffer at esi
inc esi								;increment esi	
loop L2								;loop back
ret								;return	
clear ENDP							;end of clear proc

;--------------------------------------------------------------------------------------------------------------;
closeFiles PROC							;beginning of closeFiles proc
mov eax, handle1						;moves handle1 into eax
call CloseFile							;closes the file
mov eax, handle2						;moves handle2 into eax
call CloseFile							;close the file
ret								;return
closeFiles ENDP							;end of the closeFiles proc

;--------------------------------------------------------------------------------------------------------------;
scanMe PROC
	mov edi, handle4
	NotDone:
	mov esi, SIZEOF handle4
	xor eax,eax
	mov eax, OFFSET newword
	mov ecx, lengthof handle4
	cld
	repne scasb
	jnz quit
	push eax
	mov eax, wordNum
	inc eax
	mov wordNum, eax
	pop eax
	mov edx, wordNum					;moves the offset of message9 into edx
	call Writedec						;displays message9
	;cmp edi, esi
	;jb NotDone
	quit:
	ret
scanMe ENDP

end MAIN

I have finished the compressor to where it works on most text based files, and it works on EXE files. If you would like the FULL source code, please contact me and I will try to help you out. I would post it on here, but I know for a fact that this is still a homework assignment and since I still attend school I dont want to get in trouble myself for supplying the code to classmates who attend my university. PLUS: I worked really hard on it with the help of a very kind man from the forums, and I don't want to just give that work away to everyone!

Contact: [email]snipped[/email]

..yes, that is my real email...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.