Home / Expert Answers / Computer Science / using-assembly-language-for-x86-processors-7th-edition-using-what-you-have-learned-from-this-un-pa943

(Solved): Using Assembly Language for x86 Processors 7th Edition Using what you have learned from this un ...



Using Assembly Language for x86 Processors 7th Edition

Using what you have learned from this unit create a procedure called fWriteChar that will write a single character to a file.

INCLUDE asmlib.inc
CreateFileA Proto,
fileName: PTR BYTE,
accessMode: DWORD,
shareMode : DWORD,
securityAttrib : DWORD,
creat

Using what you have learned from this unit create a procedure called fWriteChar that will write a single character to a file. The character to write should be passed to the procedure in the al register. This procedure should return the number of by written in the eax register. This means that it should return 1 if the procedure succeeded. Create another procedure call fReadChar that will read one character from a file. This procedure should return the character read in the al register. INCLUDE asmlib.inc CreateFileA Proto, fileName: PTR BYTE, accessMode: DWORD, shareMode : DWORD, securityAttrib : DWORD, creationDispo : DWOFD, flagsAndAttrib : DWORD, hTemplateFile : DWORD Closehandle PROTO, hobject : DWORD Writefile PROTO, hHandle : DWORD, lpBuffer : PTR BYTE, nNumberofBytesTowrite : DWORD, pNumberofBytesWritten : PTR DWORD, lpoverlapped : PTR DWORD GetLastError PROTO ; get most recent error return value GENERIC_READ \( =8006000 \mathrm{Ch} \) GENERIC_WRITE \( =40 \theta \theta 60 \theta \ominus \mathrm{h} \) GENERIC_EXECUTE \( =20060000 \mathrm{~h} \) GENERIC_ALL \( =100600 \theta \mathrm{h} \) CREATE_NEW \( \quad=1 \) CREATE_ALWAYS \( =2 \) OPEN_EXISTING \( =3 \) OPEN_ALWAYS \( =4 \) TRUNCATE_EXISTING \( =5 \) FILE_ATTRIBUTE_NORMAL \( \quad=80 \mathrm{~h} \) \( \mathrm{NULL}=\theta \) -data fname BYTE "test.txt", \( \theta \) fout BYTE "Now is the time for all good men", ?ah, ?dh, \( \theta \) fHandle DWORD ? byteswritten DWORD \( \theta \) . code main PFOC mov eax, \( \theta \quad \); Clear eax mov edx, OFFSET fname INVOKE CreatefileA, edx, GENERIC_WRITE, NULL, NJLL, ; Create the file for w riting OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL mov fHandle, eax ; ; File handle returned in eax INVOKE WriteFile, fHandle, ADDR fOut, SIZEOF fOut, ADDR bytesWritten, NULL ; wr ite text to file INVOKE closeHandle, fHandle ; Close file exit main ENDP END main


We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe