.model small .stack 100 .data mess1 db "(E) Encrypt text file.",10,13,'$' mess2 db "(D) Decrypt text file.",10,13,'$' mess3 db "(Q) quit.",10,13,'$' msg_one DB "Please enter your choice:",10,13,'$' msg_inputfilename db ,10,13,"Please enter the name of the file to read data from :",10,13,'$' msg_outputfilename db ,"Please enter the name of the file to write dana on :",10,13,'$' fileNameBuff db 100, db 0, db 100 dup (?) fileName db 100 dup (?) ;this since i want to copy the original statement to it. TEXT DB 250 DUP(?) FHAND DW ? .code mov ax, @data mov ds, ax start: ;set cursor mov dh, 0 mov dl, 0 call set_cursor call clear_screen ;display mess1 (encrypt text file) mov ah, 09h lea dx, mess1 int 21h ;display mess2 (decrypt text file) lea dx, mess2 call print_message ;display mess3 (Quit) lea dx, mess3 call print_message ;display msg_one lea dx, msg_one call print_message mov ah, 01h int 21h ;the choice is stored in al register cmp al, 'E' je E jmp after_E E: call E_procedure jmp start after_E: cmp al, 'D' je D jmp after_D D: call D_procedure jmp start after_D: cmp al, 'Q' je end_program ;note if user enter another char, just I will repeat the messages jmp start end_program: mov ah, 4ch int 21h ;Main procedures ;========================================================================================================== ;(1)E_procedure ;-------------------------------------------------------------------------------------------------------- E_procedure proc ;display msg_inputfilenaame lea dx,msg_inputfilename call print_message ;read the fileName from user lea dx, fileNameBuff mov ah, 0Ah int 21h mov cl, [fileNameBuff + 1] ;load actual length of the statement to cx register xor ch, ch lea di, fileNameBuff inc di inc di mov bx, cx mov [di+bx], 0 call read_file ;Yanal you should put your code here to encrypt the file ;note, now deal with fileName variable ret endp ;(2)D_procedure ;-------------------------------------------------------------------------------------------------------- D_procedure proc ;display msg_inputfilenaame lea dx,msg_inputfilename call print_message ;read the fileName from user lea dx, fileNameBuff mov ah, 0Ah int 21h mov cl, [fileNameBuff + 1] ;load actual length of the statement to cx register xor ch, ch lea di, fileNameBuff inc di inc di mov bx, cx mov [di+bx], 0 call read_file ;Yanal you should put your code here to decrypt the file ;note, now deal with fileName variable ret endp ;HELPING PROCEDURES ;==================================================================================================================================== ; (1) Clear_screen ;------------------------------------------------------------------------------------------ ; the following procedure clear screen and paint it proc clear_screen push ax push bx push cx push dx MOV AX, 0600H MOV BH, 71h ; white BG (7), Blue text (1) MOV CX, 0000h ; upper left row:column MOV DX, 184Fh ; lower right row:column INT 10H ; call pop dx pop cx pop bx pop ax ret endp ; (2) print_message ;------------------------------------------------------------------------------------------- proc print_message push ax mov ah, 09h int 21h pop ax ret endp ;(4) set_cursor ;----------------------------------------------------------------------------------------- ;parameter(DH, DL) DH: row, DL: column proc set_cursor push ax push bx mov bh, 00h mov ah, 02h int 10h pop bx pop ax ret endp ;(5)read_file ;------------------------------------------------------------------------------------------------ ;this procedure read from file until end read_file proc push ax push dx push si push cx MOV AH,3DH ; READ A FILE MOV AL,02 LEA DX,fileNameBuff ; THE ADDRESS OF FILE NAME SHOULD BE IN DX inc dx inc dx INT 21H MOV FHAND,AX ;FILE HANDLE IS RETURNED IN AX MOV SI,0 L: MOV AH,3FH ; THE FILE HANDLE MOV CX,1 ; NUMBER OF BYTES TO BE READ LEA DX,TEXT+SI ; THE ADDRESS OF DATA TO BE READ mov bx,FHAND INT 21H CMP AX,0 JE EXIT INC SI JMP L EXIT: MOV BYTE PTR TEXT+SI,"$" MOV AH,3EH INT 21H pop cx pop si pop dx pop ax ret endp