Question: ;(Output of this code ) INCLUDE Irvine32.inc INCLUDE macros.inc BUFFER_SIZE = 80 .data buffer BYTE BUFFER_SIZE DUP(?) filename BYTE 80 DUP(0) fileHandle HANDLE ? fbfr

;(Output of this code )

INCLUDE Irvine32.inc

INCLUDE macros.inc

BUFFER_SIZE = 80

.data

buffer BYTE BUFFER_SIZE DUP(?)

filename BYTE 80 DUP(0)

fileHandle HANDLE ?

fbfr BYTE 1024 dup(0)

fptr dword fbfr

txt byte ".txt",0

fnddol byte 0

.code

main PROC

mWrite "Enter an input filename: "

mov edx,OFFSET filename

mov ecx,SIZEOF filename

call ReadString

call read

mWrite <"Buffer:",0dh,0ah,0dh,0ah>

mov edx,OFFSET fbfr

call WriteString

call Crlf

call waitmsg

exit

main ENDP

read PROC

pusha

mov eax,fileHandle

push eax

mov edx,OFFSET filename

call OpenInputFile

mov fileHandle,eax

cmp eax,INVALID_HANDLE_VALUE

jne file_ok

mWrite <"Cannot open file,0dh,0ah>

jmp quit

file_ok:

rd:

call get_a_byte

jnc buf_size_ok

err:

mWrite "Error reading file. "

call WriteWindowsMsg

jmp close_file

buf_size_ok:

cmp al,0

je close_file

mov al,buffer

cmp al,'$'

je fndbk

buf_size_ok1:

mov fnddol,0

mov edi,fptr

mov byte ptr[edi],al

inc edi

mov fptr,edi

jmp rd

close_file:

mov eax,fileHandle

call CloseFile

jmp quit

fndbk:

call get_a_byte

jc err

cmp al,0

je close_file

mov al,buffer

cmp al,'$'

je buf_size_ok1

cmp fnddol,1

je fndblk2

mov fnddol,1

mov edi,offset fileName

fndblk2:

cmp al,'*'

je fndblk1

mov byte ptr[edi],al

inc edi

jmp fndbk

fndblk1:

cld

mov ecx,4

mov esi,offset txt

rep movsb

call read

jmp rd

quit:

pop eax

mov fileHandle,eax

popa

ret

read ENDP

get_a_byte proc

mov edx,OFFSET buffer

mov ecx,1

mov eax,fileHandle

call ReadFromFile

ret

get_a_byte endp

END main

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 Databases Questions!