Question: Can you answer this in a asm code please? So far with the file IO we have created the following functionality: openInputFile - Opens file

Can you answer this in a asm code please?
So far with the file IO we have created the following functionality:
openInputFile - Opens file for reading
openOutputFile - Opens file for writing
fWriteString - Writes a null terminated string to the file. This uses a strLength procedure
fReadFile - Reads a number of characters from the file
Please follow the video from the lecture material and create the file IO module shown:
Video - File IO
In the latest lab you created
fReadChar - Reads a single character from the file
fWriteChar - Writes a single character to the file
Add this functionality to the FileIO module you created from the video.
Once you have this working create the following two procedures
fReadString - This procedure will read characters from the file until a space is encountered.
fReadLine - The procedures will read characters from the file until the carriage return line feed pair is encountered (0dh,0ah)
Both of these procedures should take as an argument the offset of a string to fill in the edx, The eax should return the number of character read.
You are also required to comment every line of code you write. Failure to do so will drop you grade 20%
When you have finished the assignmentformat your source with tohtmland submit the html in the appropriate place.
NOT Allowed
The use of legacy directives like DB and DW is not allowed in this class. A deduction of 40% will be given if you use them.
The use of indirect addressing around variables is NOT allowed in the class unless you are using indirect addressing. An example of this would be [val1]. Doing this will result in a 25% reduction in your grade.
This is what I got so far.
INCLUDE asmlib.inc ; Including necessary library for basic I/O operations
openInputFile PROTO
fWriteFile PROTO
closeFile PROTO
fReadFile PROTO
fReadChar PROTO
openOutputFile PROTO
fWriteString PROTO
fReadString PROTO
fReadLine PROTO
fWriteChar PROTO
.data ; Data segment (not used in this example)
fname BYTE "testA.txt",0
outBytes BYTE "This is a test of the file io ",0
buffer BYTE 100 DUP(0)
fHandle DWORD ?
bytesRead DWORD 0
.code ; Code segment starts here
main PROC
; Assuming file names and string buffers are defined somewhere
; Open files
call openInputFile
call openOutputFile
; Write a single character to the file
call fWriteChar
; Read a single character from the file
call fReadChar
; Write a null-terminated string to the file
mov edx, OFFSET outBytes
call fWriteString
call closeFile
mov edx, OFFSET fname
call openInputFile
call closeFile
; Read a number of characters from the file
call fReadFile
; Read characters from the file until a space is encountered
; Assuming buffer offset is in edx
mov edx, OFFSET buffer ; Assuming buffer is defined somewhere
call fReadString
; Read characters from the file until a carriage return line feed pair is encountered
; Assuming buffer offset is in edx
mov edx, OFFSET buffer ; Assuming buffer is defined somewhere
call fReadLine
; Close files
call closeFile
; Exit program
; Assuming proper exit mechanism here
exit ; End program
main ENDP
END main ; End of program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!