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

# twinf64.htm

This program is designated for interactive and testing of macros defined in library winf64.htm.

Format
  PE 32bit
Platform
  MS Windows
Build
  euroasm twinf64.htm
Run
  twinf64
See also
  twinf64.htm.

           EUROASM CPU=X64,SIMD=SSE, UNICODE=Off ; For WIDE version set UNICODE=On. No else correction is necessary.
    %StdConsole %SETB Yes ; Default mode for macro StdOutput.
    twinf64 PROGRAM Format=PE,Width=64,IconFile=,Entry=Main:
            INCLUDE winabi.htm, wins.htm, winf%^WIDTH.htm, cpuext%^WIDTH.htm,
    [.data]
    Passed$       D "passed.",13,10,0
    Failed$       D "failed.",13,10,0
    DecEAX        DB "dddddddddd"
    HexEAX        DB "xxxxxxxx"
                  DB 0
    TempPath$     D "%^PROGRAM\TempPath\",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
    StreamName$   D "Stream.txt",0
    AtOnceText        DB "This file was written by FileStore.",13,10,"It will be read by FileLoad and compared.",13,10
    EncloseText       DB "Line appended with FileEnclose.",13,10
    Enclose$Text      DB "Line appended with FileEnclose$.",13,10,0
    EncloseLnText     DB "Line appended with FileEncloseLn."
    AppendedText      DB "Line appended with FileAppend, FileWrite.",13,10
    StreamWrite$Text  DB "Line appended with FileStreamWrite$.",13,10,0
    StreamWriteLnText DB "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\winf%^WIDTH.htm"".",Eol=Yes

          StdOutput ="Testing FileAssign, FileMkDir ... "
          FileAssign TestFile,TempPath$,AtOnceName$
          OnError FileAssign
          FileMkDir  TestFile
          OnError FileMkDir
          StdOutput Passed$

          StdOutput ="Testing FileNameParse: Path="""
          MOV 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:
          MOV RDI,AtOnceText
          MOV RCX,RAX
          REPNE CMPSB
          MOV RDX,Passed$
          JE .15:
    .10:  MOV RDX,Failed$
    .15:  StdOutput RDX

          StdOutput ="Testing FileMove, FileDelete, FileExists? ... "
          FileAssign MovedFile,TempPath$,MovedName$
          OnError FileAssign
          FileMove TestFile, MovedFile
          OnError FileMove
          FileExists? MovedFile
          MOV RDX,Failed$
          JC .20:
          FileDelete DeletedFile
          OnError FileDelete
          FileExists? DeletedFile
          JNC .20:
          MOV 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+1
          MOV RDX,Passed$
          JE .30:
          MOV 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
          OnError FileRead
          JZ .50:
          FileWrite WrittenFile,DataBlock,RAX
          OnError FileWrite
          JMP .40:
    .50:  FileClose MovedFile, WrittenFile
          FileAppend WrittenFile
          OnError FileAppend
          MOV RCX,RAX
          FileWrite WrittenFile,AppendedText, SIZE# AppendedText
          OnError FileWrite
          ADD RCX,RAX
          FileClose WrittenFile
          FileOpen  WrittenFile
          OnError FileOpen
          CMP RAX,RCX
          MOV RDX,Passed$
          JE .60:
          MOV RDX,Failed$
    .60:  StdOutput RDX

          StdOutput ="Testing FileMapOpen, FileMapCreate ... "
          FileMapOpen WrittenFile
          OnError FileMapOpen
          MOV RCX,RAX
          FileAssign MappedFile,TempPath$,MappedName$
          OnError FileAssign
          FileMapCreate MappedFile,RCX
          OnError FileMapCreate
          REP MOVSB
          FileClose WrittenFile, MappedFile
          StdOutput Passed$

          StdOutput ="Testing FileStreamOpen, ~Create, ~Append, ~Read, ~Write ... "
          FileStreamOpen MappedFile
          OnError FileStreamOpen
          MOV RBX,RAX
          FileAssign StreamFile,TempPath$,StreamName$
          OnError FileAssign
          FileStreamCreate StreamFile
          OnError FileStreamCreate
    .70:  FileStreamReadLn MappedFile
          OnError FileStreamReadLn
          JZ .80:
          MOV RCX,RAX
          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 RBX,SIZE# StreamWrite$Text + SIZE# StreamWriteLnText + 1
          FileStreamAppend StreamFile
          OnError FileStreamAppend
          CMP RAX,RBX
          JNE .90:
          MOV EAX,'DDDD'
          FileStreamWriteDword StreamFile
          OnError FileStreamWriteDword
          MOV RCX,[StreamFile.Size]
          ADD RBX,SIZE# EAX
          MOV RDX,Passed$
          CMP RCX,RBX
          JE .95:
    .90:  MOV RDX,Failed$
    .95:  StdOutput RDX
          FileClose StreamFile

          StdOutput ="Testing FileEach. Dir ",TempPath$, Eol=Yes
          FileAssign EachFile,TempPath$,="*.*"
          OnError FileAssign
          FileEach EachFile,DirProc
    DirProc PROC1
             MOV EAX,[RDI+WIN32_FIND_DATAW.FileSizeLow]
             StoD DecEAX
             SUB EAX,EAX
             STOSB
             StdOutput DecEAX,Unicode=Off
             StdOutput =" bytes ", RSI, Eol=Yes
             RET
            ENDP1 DirProc
          StdOutput ="Test %^PROGRAM terminated."
          TerminateProgram
        ENDPROGRAM twinf64

▲Back to the top▲