You are on page 1of 3

TITLE MASM Template ; Description: ; ; Revision date: INCLUDE Irvine32.inc INCLUDE macros.inc BUFFER_SIZE=501 .

data buffer BYTE BUFFER_SIZE DUP(?) question BYTE "would you like to enter more data?",0 caption BYTE "TEXT",0 filename BYTE "output.txt",0 fileHandle HANDLE ? stringLength DWORD ? bytesWritten DWORD ? str1 BYTE "cannot create file", 0dh,0ah,0 str2 BYTE "byte written to file [output.txt]: ",0 str3 BYTE "enter student IC:",0 str4 BYTE "enter student name:",0 str5 BYTE "enter date of birth:",0 str6 BYTE 0dh,0ah,0

(main.asm)

.code main PROC finit mov edx,OFFSET filename call CreateOutputFile mov fileHandle,eax cmp eax, INVALID_HANDLE_VALUE jne file_ok; mov edx, OFFSET str1; call WriteString jmp quit file_ok: mov edx,OFFSET str3 call WriteString mov ecx,BUFFER_SIZE mov edx,OFFSET BUFFER call ReadString mov stringlength,eax mov eax,fileHandle mov edx,OFFSET buffer mov ecx,stringLength call WriteToFile mov bytesWritten,eax

mov eax,fileHandle mov edx,OFFSET str6 mov ecx,stringLength call WriteToFile mov bytesWritten,eax mov edx,OFFSET str2 call WriteString mov eax,bytesWritten call WriteDec call Crlf mov edx,OFFSET str4 call WriteString mov ecx,BUFFER_SIZE mov edx,OFFSET BUFFER call ReadString mov stringlength,eax mov eax,fileHandle mov edx,OFFSET buffer mov ecx,stringLength call WriteToFile mov bytesWritten,eax mov eax,fileHandle mov edx,OFFSET str6 mov ecx,stringLength call WriteToFile mov bytesWritten,eax mov edx,OFFSET str2 call WriteString mov eax,bytesWritten call WriteDec call Crlf mov edx,OFFSET str5 call WriteString mov ecx,BUFFER_SIZE mov edx,OFFSET BUFFER call ReadString mov stringlength,eax mov eax,fileHandle mov edx,OFFSET buffer mov ecx,stringLength call WriteToFile mov bytesWritten,eax mov eax,fileHandle mov edx,OFFSET str6 mov ecx,stringLength call WriteToFile mov bytesWritten,eax

mov edx,OFFSET str2 call WriteString mov eax,bytesWritten call WriteDec call Crlf

mov ebx,OFFSET caption mov edx,OFFSET question call MsgBoxAsk cmp eax,7 jne file_ok call CloseFile quit: call ReadFloat call Crlf exit main ENDP END main

You might also like