| Index | Manual | Download | Source | Macros | Embedded word Case ins.
Sitemap | Links | Forum | Tests | Projects

# tlinf32.htm

This program will test macroinstructions defined in library linf32.htm.

Format
  ELFX 32-bit
Platform
  Linux 32-bit
Build
  euroasm tlinf32.htm
Run
  ./tlinf32
Expected output
  This program tlinf32 will test macros from EuroAssembler library "maclib/linf32.htm". Testing FileAssign, FileMkDir ... tlinf32.dir/temp/AtOnce.txt passed. Testing FileNameParse: Path="tlinf32.dir/temp/", Name="AtOnce", Ext=".txt". Testing FileStore, FileLoad, FileDelete ... passed. Testing FileMove, FileDelete, FileExists? ... passed. Testing FileEnclose, FileEnclose$, FileEncloseLn ... passed. Testing FileOpen, FileCreate, FileRead, FileWrite, FileClose ... passed. Testing FileMapOpen, FileMapCreate ... passed. Testing FileStreamOpen, ~Create, ~Append, ~Read, ~Write ... passed. Test tlinf32 terminated.
See also
  tlinf64.htm.

            EUROASM  debug=on
    tlinf32 PROGRAM Format=ELFX, Width=32, Entry=Main:
            INCLUDE linapi.htm, linf32.htm, cpuext32.htm
    [.data]
    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        DB "This file was written by FileStore.",10,"It will be read by FileLoad and compared.",13,10
    EncloseText       DB "Line appended with FileEnclose.",10
    Enclose$Text      DB "Line appended with FileEnclose$.",10,0
    EncloseLnText     DB "Line appended with FileEncloseLn."
    AppendedText      DB "Line appended with FileAppend, FileWrite.",10
    StreamWrite$Text  DB "Line appended with FileStreamWrite$.",10,0
    StreamWriteLnText DB "Line appended with FileStreamWriteLn."

    [.bss]
    TestFile          DS FILE
    MovedFile         DS FILE
    DeletedFile       DS FILE
    WrittenFile       DS FILE
    MappedFile        DS FILE
    StreamFile        DS FILE

    [.text]
    OnError %MACRO FileMacroName
            JNC .Skip%.:
            MOV ESI,="%FileMacroName"
            CALL OnError@RT
    .Skip%.:
    OnError@RT: PROC1
            StoH HexEAX
            StdOutput ="error.",Eol=Yes
            StdOutput ESI, =" 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$
          StdOutput TestFile.Name,Eol=Yes
          OnError FileAssign
          FileMkDir  TestFile
          OnError FileMkDir
          StdOutput Passed$
          StdOutput ="Testing FileNameParse: Path="""
          MOV ESI,TestFile.Name
          FileNameParse ESI
          PUSH EAX
            SUB EAX,ESI
            StdOutput ESI,Size=EAX
            StdOutput =""", Name="""
          POP EAX
          PUSH ECX
            SUB ECX,EAX
            StdOutput EAX,Size=ECX
            StdOutput =""", Ext="""
          POP ECX
          SUB EDX,ECX
          StdOutput ECX,Size=EDX
          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 EAX,SIZE# AtOnceText
          JNE .10:
          MOV EDI,AtOnceText
          MOV ECX,EAX
          REPNE CMPSB
          MOV EDX,Passed$
          JE .15:
    .10:  MOV EDX,Failed$
    .15:  StdOutput EDX
          FileClose TestFile

          StdOutput ="Testing FileMove, FileDelete, FileExists? ... "
          FileAssign MovedFile,TempPath$,MovedName$
          OnError FileAssign
          FileMove TestFile, MovedFile
          OnError FileMove
          FileExists? MovedFile
          MOV EDX,Failed$
          JC .20:
          FileDelete DeletedFile
          OnError FileDelete
          FileExists? DeletedFile
          JNC .20:
          MOV EDX,Passed$
    .20:  StdOutput EDX

          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 EAX,SIZE#AtOnceText+SIZE#EncloseText+SIZE#Enclose$Text+SIZE#EncloseLnText
          MOV EDX,Passed$
          JE .30:
          MOV EDX,Failed$
    .30:  StdOutput EDX

          StdOutput ="Testing FileOpen, FileCreate, FileRead, FileWrite, FileClose ... "
          FileOpen MovedFile
          OnError FileOpen
          FileAssign WrittenFile,TempPath$,WrittenName$
          OnError FileAssign
          FileCreate WrittenFile
          OnError FileCreate
          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
          MOV EDX,Passed$
          JE .60:
          MOV EDX,Failed$
    .60:  StdOutput EDX
          FileClose WrittenFile

          StdOutput ="Testing FileMapOpen, FileMapCreate ... "
          FileMapOpen WrittenFile        ; Mapped contents is expected at ESI,EAX.
          OnError FileMapOpen
          MOV ECX,EAX
          FileAssign MappedFile,TempPath$,MappedName$
          OnError FileAssign
          FileMapCreate MappedFile,ECX   ; Returns empty contents at EDI,EAX.
          OnError FileMapCreate
          REP MOVSB
          FileClose WrittenFile , MappedFile ; MappedFile should be identical with WrittenFile.
          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,ESI,ECX
          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
          MOV EDX,Passed$
          CMP EBX,[StreamFile.Size]
          JE .95:
    .90:  MOV EDX,Failed$
    .95:  StdOutput EDX
          FileClose StreamFile
          StdOutput ="Test %^PROGRAM terminated.",Eol=Yes
          TerminateProgram
        ENDPROGRAM tlinf32

▲Back to the top▲