This program will test macroinstructions defined in library linf64.htm.
EUROASM CPU=X64 tlinf64 PROGRAM Format=ELFX, Width=64, Entry=Main: INCLUDE linabi.htm, linf64.htm, cpuext64.htm [.data] Mask$ D "*.txt",0 Passed$ D "passed.",10,0 Failed$ D "failed.",10,0 HexEAX D "xxxxxxxx" D B 0 TempPath$ D "%^PROGRAM.dir/temp/",0 AtOnceName$ D "AtOnce.txt",0 MovedName$ D "Moved.txt",0 DeletedName$ D "Deleted.txt",0 WrittenName$ D "Written.txt",0 MappedName$ D "Mapped.txt",0 StreamedName$ D "Streamed.txt",0 AtOnceText D "This file was written by FileStore.",10,"It will be read by FileLoad and compared.",13,10 EncloseText D "Line appended with FileEnclose.",10 Enclose$Text D "Line appended with FileEnclose$.",10,0 EncloseLnText D "Line appended with FileEncloseLn." AppendedText D "Line appended with FileAppend, FileWrite.",10 StreamWrite$Text D "Line appended with FileStreamWrite$.",10,0 StreamWriteLnText D "Line appended with FileStreamWriteLn." [.bss] TestFile DS FILE64 MovedFile DS FILE64 DeletedFile DS FILE64 WrittenFile DS FILE64 MappedFile DS FILE64 StreamFile DS FILE64 EachFile DS FILE64 DataBlock D 16 * BYTE [.text] OnError %MACRO FileMacroName JNC .Skip%.: MOV RSI,="%FileMacroName" CALL OnError@RT .Skip%.: OnError@RT: PROC1 StoH HexEAX StdOutput ="error.",Eol=Yes StdOutput RSI, =" returned CF=1, EAX=0x", HexEAX, Eol=Yes TerminateProgram 8 ENDP1 OnError@RT %ENDMACRO OnError Main: StdOutput ="This program %^PROGRAM will test macros from EuroAssembler library ""maclib/linf%^WIDTH.htm"".",Eol=Yes StdOutput ="Testing FileAssign, FileMkDir ... " FileAssign TestFile,TempPath$,AtOnceName$ OnError FileAssign StdOutput TestFile.Name,Eol=Yes FileMkDir TestFile OnError FileMkDir StdOutput Passed$ StdOutput ="Testing FileNameParse: Path=""" LEA RSI,[TestFile.Name] FileNameParse RSI PUSH RAX SUB RAX,RSI StdOutput RSI,Size=RAX StdOutput =""", Name=""" POP RAX PUSH RCX SUB RCX,RAX StdOutput RAX,Size=RCX StdOutput =""", Ext=""" POP RCX SUB RDX,RCX StdOutput RCX,Size=RDX StdOutput =""".",Eol=Yes StdOutput ="Testing FileStore, FileLoad, FileDelete ... " FileAssign TestFile,TempPath$,AtOnceName$ OnError FileAssign FileStore TestFile,AtOnceText,SIZE# AtOnceText OnError FileStore FileAssign DeletedFile,TempPath$,DeletedName$ OnError FileAssign FileStore DeletedFile,AtOnceText,SIZE# AtOnceText OnError FileStore FileLoad TestFile OnError FileLoad CMP RAX,SIZE# AtOnceText JNE .10: LEA RDI,[AtOnceText] MOV RCX,RAX REPNE CMPSB LEA RDX,[Passed$] JE .15: .10: LEA RDX,[Failed$] .15: StdOutput RDX FileClose TestFile StdOutput ="Testing FileMove, FileDelete, FileExists? ... " FileAssign MovedFile,TempPath$,MovedName$ OnError FileAssign FileMove TestFile, MovedFile OnError FileMove FileExists? MovedFile LEA RDX,[Failed$] JC .20: FileDelete DeletedFile OnError FileDelete FileExists? DeletedFile JNC .20: LEA RDX,[Passed$] .20: StdOutput RDX StdOutput ="Testing FileEnclose, FileEnclose$, FileEncloseLn ... " FileEnclose MovedFile,EncloseText, SIZE# EncloseText OnError FileEnclose FileEnclose$ MovedFile,Enclose$Text OnError FileEnclose$ FileEncloseLn MovedFile,EncloseLnText, SIZE# EncloseLnText OnError FileEncloseLn FileLoad MovedFile CMP RAX,SIZE#AtOnceText+SIZE#EncloseText+SIZE#Enclose$Text+SIZE#EncloseLnText LEA RDX,[Passed$] JE .30: LEA RDX,[Failed$] .30: StdOutput RDX StdOutput ="Testing FileOpen, FileCreate, FileRead, FileWrite, FileClose ... " FileOpen MovedFile OnError FileOpen FileAssign WrittenFile,TempPath$,WrittenName$ OnError FileAssign FileCreate WrittenFile OnError FileCreate .40: FileRead MovedFile,DataBlock, SIZE# DataBlock JZ .50: OnError FileRead FileWrite WrittenFile,DataBlock,RAX OnError FileWrite JMP .40: .50: FileClose MovedFile, WrittenFile FileAppend WrittenFile OnError FileAppend MOV ECX,EAX FileWrite WrittenFile,AppendedText, SIZE# AppendedText OnError FileWrite ADD ECX,EAX FileClose WrittenFile FileOpen WrittenFile OnError FileOpen CMP EAX,ECX LEA RDX,[Passed$] JE .60: LEA RDX,[Failed$] .60: StdOutput RDX FileClose WrittenFile StdOutput ="Testing FileMapOpen, FileMapCreate ... " FileMapOpen WrittenFile ; Mapped contents is expected at RSI,RAX. OnError FileMapOpen MOV ECX,EAX FileAssign MappedFile,TempPath$,MappedName$ OnError FileAssign FileMapCreate MappedFile,RCX ; Returns empty contents at RDI,RAX. OnError FileMapCreate REP MOVSB FileClose WrittenFile, MappedFile ; MappedFile should be identical with WrittenFile now. StdOutput Passed$ StdOutput ="Testing FileStreamOpen, ~Create, ~Append, ~Read, ~Write ... " FileStreamOpen MappedFile OnError FileStreamOpen MOV EBX,EAX ; File size. FileAssign StreamFile,TempPath$,StreamedName$ OnError FileAssign FileStreamCreate StreamFile OnError FileStreamCreate .70: FileStreamReadLn MappedFile OnError FileStreamReadLn JZ .80: MOV ECX,EAX FileStreamWrite StreamFile,RSI,RCX OnError FileStreamWrite JMP .70: .80: FileStreamWrite$ StreamFile,StreamWrite$Text OnError FileStreamWrite$ FileStreamWriteLn StreamFile,StreamWriteLnText, SIZE# StreamWriteLnText OnError FileStreamWriteLn FileClose MappedFile, StreamFile ADD EBX,SIZE# StreamWrite$Text + SIZE# StreamWriteLnText FileStreamAppend StreamFile OnError FileStreamAppend CMP EAX,EBX JNE .90: MOV EAX,'DDDD' FileStreamWriteDword StreamFile OnError FileStreamWriteDword MOV AX,'WW' FileStreamWriteWord StreamFile OnError FileStreamWriteWord MOV AL,'B' FileStreamWriteByte StreamFile OnError FileStreamWriteByte ADD EBX,SIZE# EAX + SIZE# AX + SIZE# AL LEA RDX,[Passed$] CMP EBX,[StreamFile.Size] JE .95: .90: LEA RDX,[Failed$] .95: StdOutput RDX FileClose StreamFile StdOutput ="Testing FileEach: ls ",TempPath$,Mask$,Eol=Yes FileAssign EachFile,TempPath$,Mask$ OnError FileAssign FileEach EachFile,DirProc: DirProc:PROC1 StdOutput RSI, Eol=Yes RET ENDP1 DirProc: StdOutput ="Test %^PROGRAM terminated.",Eol=Yes TerminateProgram ENDPROGRAM tlinf64