EuroAssembler Index Manual Download Source Macros


Sitemap Links Forum Tests Projects

twinf32.htm

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

Format
PE 32-bit
Platform
MS-Windows
Build
euroasm twinf32.htm
Run
twinf32
See also
twinf64.htm.
       EUROASM UNICODE=Off ; For WIDE version set UNICODE=On. No else correction is necessary.
%StdConsole %SETB Yes ; Default mode for macro StdOutput.
twinf32 PROGRAM Format=PE,Width=32,IconFile=,Entry=Main:
        INCLUDE winapi.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 FILE
MovedFile     DS FILE
DeletedFile   DS FILE
WrittenFile   DS FILE
MappedFile    DS FILE
StreamFile    DS FILE
EachFile      DS FILE
DataBlock     D 16 * BYTE

[.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\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 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$
      FileStore  DeletedFile,AtOnceText,SIZE# AtOnceText
      OnError FileStore
      OnError FileAssign
      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

      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+1
      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
.40:  FileRead MovedFile,DataBlock, SIZE# DataBlock
      OnError FileRead
      JZ .50:
      FileWrite WrittenFile,DataBlock,EAX
      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
      MOV EDX,Passed$
      JE .60:
      MOV EDX,Failed$
.60:  StdOutput EDX

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

      StdOutput ="Testing FileStreamOpen, ~Create, ~Append, ~Read, ~Write ... "
      FileStreamOpen MappedFile
      OnError FileStreamOpen
      MOV EBX,EAX
      FileAssign StreamFile,TempPath$,StreamName$
      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 + 1
      FileStreamAppend StreamFile
      OnError FileStreamAppend
      CMP EAX,EBX
      JNE .90:
      MOV EAX,'DDDD'
      FileStreamWriteDword StreamFile
      OnError FileStreamWriteDword
      MOV ECX,[StreamFile.Size]
      ADD EBX,SIZE# EAX
      MOV EDX,Passed$
      CMP ECX,EBX
      JE .95:
.90:  MOV EDX,Failed$
.95:  StdOutput EDX
      FileClose StreamFile

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

▲Back to the top▲