EuroAssembler Index Manual Download Source Macros


Sitemap Links Forum Tests Projects

pgmopt.htm
Class
PGMOPT
Enumerations
%PgmoptList
Encoding
PgmoptEnc
Procedures
PgmoptAssemble
PgmoptCheck
PgmoptSetDefaults
PgmoptSetLinkProp

PGMOPT object defines program options which can be set in [PROGRAM] section of euroasm.ini file or in PROGRAM keyword operands.

Instances of this class are members of structures EA, SRC and PGM.

An object which wants to know a particular option should read it from PGM.Pgmopt of the latest PROGRAM on context stack.

Manipulation with PGMOPT object
ActionSourceDestination
EaCreate Factory defaultsEa.Pgmopt
Global euroasm.iniEa.Pgmopt
SrcCreate Ea.PgmoptSrc.Pgmopt
Local euroasm.iniSrc.Pgmopt
PgmCreateProgram Src.PgmoptPgm.Pgmopt
PROGRAM option= PROGRAM option=Pgm.Pgmopt

In order to introduce a new PROGRAM option, it must be inserted into

  1. %PgmoptList enumeration,
  2. PGMOPT structure,
  3. factory-default euroasm.ini file,
  4. PgmoptAssemble configurating handler,
  5. PgmoptSetDefaults dispatching,
  6. VarExpand retrieving handler,
  7. Pseudoinstructions/PROGRAM manual,
  8. Elements/PROGRAM System %variables manual.
       EUROASM NOWARN=2101
pgmopt PROGRAM FORMAT=COFF,MODEL=FLAT,WIDTH=32
INCLUDEHEAD "euroasm.htm" ; Interface (structures, symbols and macros) of other modules.
INCLUDEHEAD  \  ; Include headers of another modules used in this module.
ctx.htm,     \
ea.htm,      \
eaopt.htm,   \
exp.htm,     \
msg.htm,     \
pf.htm,      \
pgm.htm,     \
reloc.htm,   \
sss.htm,     \
stm.htm,     \
sym.htm,     \
syswin.htm,  \
var.htm,     \
;;
 pgmopt HEAD ; Start of module interface.
↑ PGMOPT
This structure keeps assembled options from configuration file euroasm.ini or from pseudoinstruction PseudoPROGRAM.
PGMOPT STRUC                    ; +00h.
.OutFilePtr             D DWORD ; Target output file name. Quotes removed.
.OutFileSize            D DWORD
.IconFilePtr            D DWORD ; Embedded icon file name. Quotes removed.
.IconFileSize           D DWORD
                                ; +10h.
.StubFilePtr            D DWORD ; Embedded MZ stub file name. Quotes removed.
.StubFileSize           D DWORD
.EntryPtr               D DWORD ; Symbol name of the entry point.
.EntrySize              D DWORD ; Size of the entry symbol name.
                                ; +20h.
.Status                 D DWORD ; Boolean options, see below.
.Subsystem              D DWORD
.MaxExpansions          D DWORD ; Maximal allowed number of expansions (%FOR,%WHILE, %REPEAT).
.MaxPasses              D DWORD ; Maximal allowed number of assembly passes.
                                ; +30h.
.ImageBaseLow           D DWORD ; Virtual address where the linked image should be loaded.
.ImageBaseHigh          D DWORD
.FileAlign              D DWORD ; Alignment of COFF sections within the output file.
.SectionAlign           D DWORD ; Alignment of COFF sections when loaded to memory.
                                ; +40h.
.MajorOsVersion         D DWORD
.MinorOsVersion         D DWORD
.MajorSubsystemVersion  D DWORD
.MinorSubsystemVersion  D DWORD
                                ; +50h.
.MajorImageVersion      D DWORD
.MinorImageVersion      D DWORD
.MajorLinkerVersion     D DWORD
.MinorLinkerVersion     D DWORD
                                ; +60h.
.SizeOfHeapCommitLow    D DWORD
.SizeOfHeapCommitHigh   D DWORD
.SizeOfHeapReserveLow   D DWORD
.SizeOfHeapReserveHigh  D DWORD
                                ; +70h.
.SizeOfStackCommitLow   D DWORD
.SizeOfStackCommitHigh  D DWORD
.SizeOfStackReserveLow  D DWORD
.SizeOfStackReserveHigh D DWORD
                                ; +80h.
.Win32VersionValue      D DWORD
.DllCharacteristics     D DWORD
 ENDSTRUC PGMOPT               ; SIZE# PGMOPT = 88h
↑ PgmoptEncoding
specifies boolean options kept in PGMOPT.Status.
LSB of PGMOPT.Status contains one of program format identificators pgmoptBIN, pgmoptELF etc.
See also
%PfList
pgmoptFormatMask    = 0x0000_003F ; FORMAT= property of program (1..63), defined in %PfList.
pgmoptLinkPropMask  = 0x0000_FFC0 ; Properties concerning relation to other programs:
pgmoptDynamic       = 0x0000_0040 ; ELFX or ELFSO format uses dynamic linking with shared objects.
pgmoptELFbased      = 0x0000_0080 ; ELF* format, combine nonglobal symbols too. Congruate VA.
pgmoptLinkable      = 0x0000_0100 ; Object modules can be linked from this format (OMF,COFF,LIBOMF,LIBCOF,ELF,RSRC).
pgmoptExportable    = 0x0000_0200 ; This output format can export its symbols (DLL,ELFSO).
pgmoptImportable    = 0x0000_0400 ; IMPORT declaration can be linked from this format (DLL,OMF,COFF,LIBOMF,LIBCOF,ELFSO).
pgmoptImports       = 0x0000_0800 ; Format supports dynamic linking (all but BIN,COM,MZ).
pgmoptLibrary       = 0x0000_1000 ; This format is a library (LIBCOF,LIBOMF).
pgmoptExecutable    = 0x0000_2000 ; This format can be executed (COM,MZ,PE,ELFX).
pgmoptImage         = 0x0000_4000 ; This format is a linked image (BIN,BOOT,COM,MZ,PE,DLL,ELFX).
pgmoptLibMember     = 0x0000_8000 ; This module (OMF|COFF) was loaded from a library (LIBOMF|LIBCOF), not from .obj file.
pgmoptModelMask     = 0x007F_0000 ; MODEL=  property of program.
pgmoptTINY          = 0x0001_0000
pgmoptSMALL         = 0x0002_0000
pgmoptMEDIUM        = 0x0004_0000
pgmoptCOMPACT       = 0x0008_0000
pgmoptLARGE         = 0x0010_0000
pgmoptHUGE          = 0x0020_0000
pgmoptFLAT          = 0x0040_0000
;                   = 0x0080_0000
pgmoptWidthMask     = 0x0700_0000 ; WIDTH= property of program.
pgmoptWidth16       = 0x0100_0000 ; pgmoptWidthMask values must match sssWidthMask.
pgmoptWidth32       = 0x0200_0000
pgmoptWidth64       = 0x0400_0000
;                   = 0x0800_0000
pgmoptLISTMAP       = 0x1000_0000 ; Program options which control the listing.
pgmoptLISTGLOBALS   = 0x2000_0000
pgmoptLISTLITERALS  = 0x4000_0000
pgmoptRelWithAddend = 0x8000_0000 ; Used in PfelfLoadPgm to distinguish REL and RELA ELF relocations.
↑ %PgmoptList
enumerates names of keywords used in [PROGRAM] section of configuration file euroasm.ini and in pseudoinstruction PROGRAM.
%PgmoptList %SET DLLCHARACTERISTICS, ENTRY, FILEALIGN, FORMAT, ICONFILE, IMAGEBASE,\
   LISTMAP, LISTGLOBALS, LISTLITERALS, MODEL, MAXEXPANSIONS, MAXPASSES,            \
   MAJOROSVERSION, MAJORSUBSYSTEMVERSION, MAJORIMAGEVERSION, MAJORLINKERVERSION,   \
   MINOROSVERSION, MINORSUBSYSTEMVERSION, MINORIMAGEVERSION, MINORLINKERVERSION,   \
   WIN32VERSIONVALUE, OUTFILE, SECTIONALIGN, SIZEOFHEAPCOMMIT, SIZEOFHEAPRESERVE,  \
   SIZEOFSTACKCOMMIT, SIZEOFSTACKRESERVE, STUBFILE, SUBSYSTEM, WIDTH
%PgmoptListLength %SETL %PgmoptList
   ENDHEAD pgmopt ; End of module interface.
↑ PgmoptSetLinkProp PgmoptFormat
PgmoptSetLinkProp specifies linkage properties of all program formats recognized by EuroAssembler. Other bits are ignored.
Input
PgmoptFormat is 32bit value which specifies in its lower 8 bits program format in the encoding defined in PfPgmoptList.
Output
EAX contains program properties specified by pgmoptFormatMask and pgmoptLinkPropMask.
Error
-
Example
Invoke PgmoptSetLinkProp pgmoptCOFF ; returns EAX=pgmoptCOFF+pgmoptLinkable+pgmoptLinks
Invoked by
PfLoad PfOutput PfcoffLoadModule PfelfLoadPgm PfomfLoadModule PgmoptAssemble
PgmoptSetLinkProp Procedure PgmoptFormat
      MOV EAX,[%PgmoptFormat]
      AND EAX,pgmoptFormatMask
      PUSH .Dispatched:
      Dispatch AL,%PfPgmoptList
      RET
.pgmoptDLL:
      OR EAX,pgmoptImage|pgmoptExportable|pgmoptImportable|pgmoptImports
      RET
.pgmoptELFSO:
      OR EAX,pgmoptExportable|pgmoptImportable|pgmoptImports|pgmoptELFbased|pgmoptDynamic
      RET
.pgmoptLIBCOF:
.pgmoptLIBOMF:
      OR EAX,pgmoptLibrary|pgmoptLinkable|pgmoptImportable|pgmoptImports
      RET
.pgmoptOMF:
.pgmoptCOFF:
      OR EAX,pgmoptLinkable|pgmoptImportable|pgmoptImports
      RET
.pgmoptELF:
      OR EAX,pgmoptLinkable|pgmoptELFbased
      RET
.pgmoptELFX:
      OR EAX,pgmoptELFbased
.pgmoptPE:
      OR EAX,pgmoptImage|pgmoptExecutable|pgmoptImports
.pgmoptMZ:
.pgmoptCOM:
      OR EAX,pgmoptImage|pgmoptExecutable
      RET
.pgmoptBOOT:
.pgmoptBIN:
      OR  EAX,pgmoptImage
      RET
.pgmoptRSRC:
      OR EAX,pgmoptLinkable
      RET
.Dispatched: MOV [%ReturnEAX],EAX
   EndProcedure PgmoptSetLinkProp
↑ PgmoptAssemble PgmoptPtr, PgmoptId, TxtPtr, TxtSize
PgmoptAssemble will evaluate one PROGRAM option and store its value to PGMOPT object.
Input
PgmoptPtr Pointer to PGMOPT structure, where the assembled option will be written to.
PgmoptId System %^variable type encoding varTypeSysPgmopt as specified in %Variable types encoding + varTypeSysEnum (ordinal number of the option in %PgmoptList). This identifies which program option is being assembled here.
TxtPtr Pointer to the option value, such as expression or enumerated token CON, Flat etc.
TxtSize Size of the option value. Spaces are stripped off.
Output
The object at PgmoptPtr is modified.
Error
Errors are reported with macro Msg.
See also
EaoptAssemble.
Invokes
DictLookup ExpEval PgmoptSetLinkProp
Invoked by
EaIniAssemble PgmParameters
PgmoptAssemble Procedure PgmoptPtr, PgmoptId, TxtPtr, TxtSize
PgmoptNamePtr  LocalVar                          ; Ptr to Msg !1S with the option name.
PgmoptValuePtr LocalVar                          ; Ptr to Msg !2S with the option value.
PgmoptExp LocalVar Size=SIZE#EXP                 ; Expression object to evaluate.
     ; Initialize error Msg parameters. 
     LEA EAX,[%TxtPtr]
     MOV EDI,[%PgmoptId]
     MOV [%PgmoptValuePtr],EAX
     AND EDI,varTypeSysEnum
     SHR EDI,16                                  ; EDX is now 1..%PgmoptListLength, i.e. ordinal number of enumeration.
     MOV ESI,[%TxtPtr]
     LEA EAX,[EDI+2*EDI] ; 3,6,9,12,,,
     MOV ECX,[%TxtSize]
     StripSpaces ESI,ECX
     StripQuotes ESI,ECX
     StripSpaces ESI,ECX
     LEA EAX,[DictPgmopt::+4*EAX-12]             ; Ptr+Size of Pgmopt name.
     MOV [%PgmoptNamePtr],EAX                    ; Ptr to DD pair with option name (for the case when error occurs).
     MOV EBX,[%PgmoptPtr]
     XOR EDX,EDX
     DEC EDX
     MOV EAX,EDX                                 ; Preinitialize EDX:EAX to -1 (default numeric value when unspecified).
     CALL [.PgmoptHandlerTable-4 + 4*EDI]        ; Call the actual handler subprocedure.
     Msg cc=C,'3716',[%PgmoptNamePtr],[%PgmoptValuePtr] ; Invalid [PROGRAM] option "!1S=!2S". Ignored.
     JMP .99:
[.data]
     ALIGN DWORD
.PgmoptHandlerTable:                             ; Table of pointers to option handlers.
Option %FOR %PgmoptList
         DD .%Option:
       %ENDFOR Option
[.text]
; Program options callable handlers.
; Input:  CF=0
;         EDI=option ordinal number, 1..%PgmoptListLength
;         EDX:EAX=-1
;         EBX=^PGMOPT target structure where the evaluated option value will be stored.
;         ESI,ECX=pointer and size of option value in unassembled format, spaces stripped off.
; Output: CF=0, PGMOUT structure modified, EAX,ECX,EDX,EDI undefined.
; Error:  CF=1, Msg reported, EAX,ECX,EDX,EDI undefined.

; Options FORMAT, MODEL, WIDTH, FILEALIGN, SECTIONALIGN, IMAGEBASE, OUTFILE, STUBFILE, ICONFILE, TIMESTAMP
;   have variable default value (no factory defaults).

.FORMAT:XOR EAX,EAX
      JECXZ .F8:                                 ; If FORMAT= set to empty, it will be set later to the default (BIN).
      Invoke DictLookup::, DictProgramFormats::, ESI,ECX
      LEA EDX,[%TxtPtr]
      Msg cc=C,'6528',[%PgmoptValuePtr],=B"%PfList" ; Illegal program format "!1S". Expected !2$.
 .F8: RstSt [EBX+PGMOPT.Status],pgmoptFormatMask+pgmoptLinkPropMask
      Invoke PgmoptSetLinkProp,EAX
      SetSt [EBX+PGMOPT.Status],EAX
      RET
.MODEL:XOR EAX,EAX
      JECXZ .M8:                                 ; If MODEL= left empty, it will be set later according to FORMAT= option.
      Invoke DictLookup::, DictProgramModels::, ESI,ECX ; Return one of pgmoptModelMask flag.
      Msg cc=C,'3733',[%PgmoptValuePtr],DictProgramModels:: ; Illegal memory model "!1S". Expected !2L.
 .M8: RstSt [EBX+PGMOPT.Status],pgmoptModelMask
      SetSt [EBX+PGMOPT.Status],EAX
      RET
.WIDTH:
      JECXZ .W8:                                 ; If WIDTH= set to empty, use -1. It will be set later according to FORMAT= option.
      CALL .Integer
      JC .W9:
      MOV ECX,pgmoptWidth64
      CMP EAX,64
      JE .W8:
      MOV ECX,pgmoptWidth32
      CMP EAX,32
      JE .W8:
      MOV ECX,pgmoptWidth16
      CMP EAX,16
      JE .W8:
      Msg '3736',EAX                             ; Illegal program width "!1D", must be 16,32,64. Ignored.
      JMP .W9:
.W8:  RstSt [EBX+PGMOPT.Status],pgmoptWidthMask
      SetSt [EBX+PGMOPT.Status],ECX
.W9:  RET

.IMAGEBASE:
      JECXZ .IB8:                                ; If IMAGEBASE= left empty, use -1. It will be set later according to FORMAT= option.
      CALL .Integer:
      JC .IB9:
.IB8: MOV [EBX+PGMOPT.ImageBaseLow],EAX
      MOV [EBX+PGMOPT.ImageBaseHigh],EDX
.IB9: RET

.FILEALIGN:
      JECXZ .FA8:                                ; If FILEALIGN= left empty, it will set later according to FORMAT= option.
      Invoke DictLookup::, DictAlignValue::, ESI,ECX ; Returned EAX=alignment value.
      JNC .FA8:
      CALL .Integer:                             ; Otherwise evaluate ESI,ECX as numeric expression.
      JC .FA9:
      CALL .PowerOf2
      JC .FA9:
.FA8: MOV [EBX+PGMOPT.FileAlign],EAX
.FA9: RET

.SECTIONALIGN:
      JECXZ .SA8:                                ; If SECTIONALIGN= left empty, it will set later according to FORMAT= option.
      Invoke DictLookup::, DictAlignValue::, ESI,ECX
      JNC .SA8:
      CALL .Integer:
      JC .SA9:
      CALL .PowerOf2:
      JC .SA9:
.SA8: MOV [EBX+PGMOPT.SectionAlign],EAX
.SA9: RET

.OUTFILE:
      JECXZ .OF8:
      PoolStore [Ea.Pool::],ESI,ECX,ZeroTerminate=Yes
      MOV [EBX+PGMOPT.OutFilePtr],EAX
.OF8: MOV [EBX+PGMOPT.OutFileSize],ECX
      RET

.STUBFILE:
      PoolStore [Ea.Pool::],ESI,ECX,ZeroTerminate=Yes
      MOV [EBX+PGMOPT.StubFilePtr],EAX
      MOV [EBX+PGMOPT.StubFileSize],ECX
      RET

.ICONFILE:
      JECXZ .IF8:
      PoolStore [Ea.Pool::],ESI,ECX,ZeroTerminate=Yes
      MOV [EBX+PGMOPT.IconFilePtr],EAX
 .IF8:MOV [EBX+PGMOPT.IconFileSize],ECX
      RET

; Options with constant factory default values, unchanged if specified as empty.

.SUBSYSTEM:
      JECXZ .SS9:
      Invoke DictLookup::, DictProgramSubsystems::, ESI,ECX
      JNC .SS8:
      CALL .Integer                              ; If it's not specified as an enumerated value, try numeric value.
      JC .SS9:
      CALL .BoundW
      JC .SS9:
.SS8: MOV [EBX+PGMOPT.Subsystem],EAX
.SS9: RET

.LISTMAP:MOV EDI,pgmoptLISTMAP
      JMP .FlagStatus:
.LISTGLOBALS:MOV EDI,pgmoptLISTGLOBALS
      JMP .FlagStatus:
.LISTLITERALS:MOV EDI,pgmoptLISTLITERALS
      JMP .FlagStatus:

.ENTRY:
      JECXZ .EN8:
      PoolStore [Src.Pool::],ESI,ECX
      JC .EN9:
      MOV [EBX+PGMOPT.EntryPtr],EAX
 .EN8:MOV [EBX+PGMOPT.EntrySize],ECX
 .EN9:RET

.DLLCHARACTERISTICS:
      JECXZ .DLL9:
      CALL .Integer:
      JC .DLL9:
      CALL .BoundW: ; Check if it fits to 16 bits.
      JC .DLL9:
      MOV [EBX+PGMOPT.DllCharacteristics],EAX
.DLL9:RET

.MAXPASSES:
      JECXZ .MP9:
      CALL .Integer:
      JC .MP9:
      CALL .BoundW:
      JC .MP9:
      MOV [EBX+PGMOPT.MaxPasses],EAX
 .MP9:RET

.MAXEXPANSIONS:
      JECXZ .ME9:
      CALL .Integer:
      JC .ME9:
      CALL .BoundD:
      JC .ME9:
      MOV [EBX+PGMOPT.MaxExpansions],EAX
.ME9: RET

.MAJOROSVERSION:
      JECXZ .MjO9:
      CALL .Integer:
      JC .MjO9:
      CALL .BoundW:
      JC .MjO9:
      MOV [EBX+PGMOPT.MajorOsVersion],EAX
.MjO9:RET

.MINOROSVERSION:
      JECXZ .MnO9:
      CALL .Integer:
      JC .MnO9:
      CALL .BoundW:
      JC .MnO9:
      MOV [EBX+PGMOPT.MinorOsVersion],EAX
.MnO9:RET

.MAJORSUBSYSTEMVERSION:
      JECXZ .MjS9:
      CALL .Integer:
      JC .MjS9:
      CALL .BoundW:
      JC .MjS9:
      MOV [EBX+PGMOPT.MajorSubsystemVersion],EAX
.MjS9:RET

.MINORSUBSYSTEMVERSION:
      JECXZ .MnS9:
      CALL .Integer:
      JC .MnS9:
      CALL .BoundW:
      JC .MnS9:
      MOV [EBX+PGMOPT.MinorSubsystemVersion],EAX
.MnS9:RET

.MAJORLINKERVERSION:
      JECXZ .MjLk9:
      CALL .Integer:
      JC .MjLk9:
      CALL .BoundB:
      JC .MjLk9:
      MOV [EBX+PGMOPT.MajorLinkerVersion],EAX
.MjLk9:RET

.MINORLINKERVERSION:
      JECXZ .MnLk9:
      CALL .Integer:
      JC .MnLk9:
      CALL .BoundB:
      JC .MnLk9:
      MOV [EBX+PGMOPT.MinorLinkerVersion],EAX
.MnLk9:RET

.MAJORIMAGEVERSION:
      JECXZ .MjI9:
      CALL .Integer:
      JC .MjI9:
      CALL .BoundW:
      JC .MjI9:
      MOV [EBX+PGMOPT.MajorImageVersion],EAX
.MjI9:RET

.MINORIMAGEVERSION:
      JECXZ .MnI9:
      CALL .Integer:
      JC .MnI9:
      CALL .BoundW:
      JC .MnI9:
      MOV [EBX+PGMOPT.MinorImageVersion],EAX
.MnI9:RET

.WIN32VERSIONVALUE:
      JECXZ .WV9:
      CALL .Integer:
      JC .WV9:
      CALL .BoundD:
      JC .WV9:
      MOV [EBX+PGMOPT.Win32VersionValue],EAX
.WV9: RET

.SIZEOFHEAPCOMMIT:
      JECXZ .SHC9:
      CALL .Integer:
      JC .SHC9:
      MOV [EBX+PGMOPT.SizeOfHeapCommitLow],EAX
      MOV [EBX+PGMOPT.SizeOfHeapCommitHigh],EDX
.SHC9:RET

.SIZEOFHEAPRESERVE:
      JECXZ .SHR9:
      CALL .Integer:
      JC .SHR9:
      MOV [EBX+PGMOPT.SizeOfHeapReserveLow],EAX
      MOV [EBX+PGMOPT.SizeOfHeapReserveHigh],EDX
.SHR9:RET

.SIZEOFSTACKCOMMIT:
      JECXZ .SSC9:
      CALL .Integer:
      JC .SSC9:
      MOV [EBX+PGMOPT.SizeOfStackCommitLow],EAX
      MOV [EBX+PGMOPT.SizeOfStackCommitHigh],EDX
.SSC9:RET

.SIZEOFSTACKRESERVE:
      JECXZ .SSR9:
      CALL .Integer:
      JC .SSR9:
      MOV [EBX+PGMOPT.SizeOfStackReserveLow],EAX
      MOV [EBX+PGMOPT.SizeOfStackReserveHigh],EDX
.SSR9:RET

 ; PROGRAM options evaluation helper subprocedures.

.BoundD: PROC                                    ; Check if EDX=0. Return CF if not.
      CMP EDX,0x0000_0001
      CMC
      Msg cc=C,'3708',[%PgmoptNamePtr],[%PgmoptValuePtr] ; Value of !1S=!2S does not fit into 32 bits. Ignored.
      RET
     ENDP .BoundD:

.BoundW: PROC                                    ; Check if integer EAX will fit into WORD. Return CF if not.
      CMP EAX,0x0001_0000
      CMC
      Msg cc=C,'3707',[%PgmoptNamePtr],[%PgmoptValuePtr] ; Value of !1S=!2S does not fit into 16 bits. Ignored.
      RET
     ENDP .BoundW:

.BoundB: PROC                                    ; Check if integer EAX will fit into BYTE. Return CF if not.
      CMP EAX,0x0000_0100
      CMC
      Msg cc=C,'3706',[%PgmoptNamePtr],[%PgmoptValuePtr] ; Value of !1S=!2S does not fit into  8 bits. Ignored.
      RET
     ENDP .BoundB:

.PowerOf2: PROC                                  ; Check if the value EAX is zero or a power of two. Return CF if not. Destroys ECX,EDX.
      BSF ECX,EAX
      BSR EDX,EAX
      JZ .90:
      CMP ECX,EDX
      JE .90:
.80:  Msg '3738',EAX                             ; Value !1D should be a power of 2. Ignored.
      STC
.90:  RET
    ENDP .PowerOf2:

.Integer: PROC ; Option value in ESI,ECX is evaluated as a scalar integer to EDX:EAX and %PgmoptExp.
 ; Input: ESI,ECX=option value ptr and size.
 ; Output: CF=0, EDX:EAX=32bit signed value, ECX,EDX modified.
 ; Error:  CF=1, Msg reported, EAX,ECX,EDX,EDI modified.
      LEA EDI,[%PgmoptExp]
      Invoke ExpEval::,EDI,ESI,ECX,0
      JC .90:
      MOV ECX,[EDI+EXP.Status]
      CMP CL,'N'
      JE .70:
      Msg '3721',[%PgmoptNamePtr],[%PgmoptValuePtr] ;  Scalar value expected instead of !1$=!2S
      STC
      JMP .90:
 .70: JSt [EBX+PGMOPT.Status],pgmoptWidth64,.80:
      CMP CH,7                                      ; Does the number magnitude exceed 32 bits?
      JB .80:
      Msg '3708',[%PgmoptNamePtr],[%PgmoptValuePtr] ; Value of !1S=!2S does not fit into 32 bits. Ignored.
      STC
      JMP .90:
 .80: MOV EAX,[EDI+EXP.Low]
      MOV EDX,[EDI+EXP.High]
      CLC
 .90: RET
     ENDP .Integer:

.Boolean: PROC ; Option value in ESI,ECX is evaluated as Boolean. Returns EAX=0 or -1.
 ; Input: ESI,ECX=option value ptr and size.
 ; Output: CF=0, EAX=value 0 or -1, ECX,EDX,EDI modified.
 ; Error:  CF=1, EAX,ECX,EDX,EDI modified.
     Invoke DictLookup::, DictBoolean::, ESI,ECX ; YES/NO/TRUE/FALSE/ON/OFF etc.
     JNC .90:                                    ; If enumerated boolean token found, EAX is 0 or -1.
     CALL PgmoptAssemble.Integer:
     JC .90:
     TEST EAX
     JZ .90:
     MOV EAX,-1
.90: RET
    ENDP .Boolean:

.FlagStatus: PROC ; Input: EDI=PGMOPT.Status flag mask, e.g. pgmoptLISTGLOBALS. ESI,ECX=source boolean value.
      PUSH EDI
        CALL PgmoptAssemble.Boolean:             ; Returns EAX=0 or -1.
      POP EDI
      JC .90:
      AND EAX,EDI
      NOT EDI
      AND [EBX+PGMOPT.Status],EDI                ; Reset bit.
      OR  [EBX+PGMOPT.Status],EAX                ; Set if the option in EDI was TRUE.
 .90: RET
     ENDP .FlagStatus:

.99:EndProcedure PgmoptAssemble
↑ PgmoptSetDefaults PgmoptPtr
PgmoptSetDefaults checks nonstatic program options and sets them to default values if they were not specified explicitly in euroasm.ini or as keywords in pseudoinstruction PROGRAM, i.e. if they were left empty or omitted, which is signalized with empty string or with numeric value -1.
Option FORMAT= defaults to BIN.
Other options MODEL=,WIDTH=,IMAGEBASE=,SECTIONALIGN=,FILEALIGN default to values which depend on the program format, see manual.
Input
PgmoptPtr Pointer to PGMOPT object to modify.
Output
Pgmopt is modified.
Error
-
See also
PfList.
Invoked by
PseudoPROGRAM
Invokes
CtxPeek EaBufferRelease EaBufferReserve EaId2Fs
PgmoptSetDefaults Procedure PgmoptPtr
      MOV EDI,[%PgmoptPtr]
      Invoke CtxPeek::,ctxPROGRAM,0
      JC .99:                                    ; Skip if no source is loaded yet (global "euroasm.ini" is processed).
      MOV EBX,EAX                                ; Program context.
      Invoke EaBufferReserve::,PgmoptSetDefaults
      Invoke EaId2Fs::,[EBX+CTX.NamePtr],[EBX+CTX.NameSize],EAX
      BufferRetrieve EAX
      MOV EBX,ESI                                ; EBX,EDX is now filesystem-friendly program name.
      MOV EDX,ECX                                ; It will be used as a default for OUTFILE.
      Invoke EaBufferRelease::,EAX

.FORMAT:PROC
      MOV EAX,pgmoptFormatMask
      AND EAX,[EDI+PGMOPT.Status]
      JNZ .90:                                   ; If FORMAT= was explicitly specified, do not change it.
      RstSt [EDI+PGMOPT.Status],pgmoptFormatMask+pgmoptLinkPropMask
      OR EAX,pgmoptBIN+pgmoptImage               ; Otherwise use BIN as the default format.
      OR [EDI+PGMOPT.Status],EAX
  .90:ENDP .FORMAT:

.OUTFILE:PROC                                    ; AL is one of pgmoptFormatMask.
      SUB ECX,ECX
      CMP [EDI+PGMOPT.OutFileSize],ECX
      JNZ .90:                                   ; If OUTFILE= was explicitly specified, use it as is.
      ; Otherwise the output file name will be "%^Program" concatenated with default format extension.
      MOV CL,4                                   ; Most usual extension size.
      Dispatch AL,%PfPgmoptList
.pgmoptBIN: MOV ESI,".bin"
       JMP .50:
.pgmoptCOM: MOV ESI,".com"
       JMP .50:
.pgmoptBOOT:MOV ESI,".sec"
       JMP .50:
.pgmoptCOFF:
.pgmoptOMF: MOV ESI,".obj"
       JMP .50:
.pgmoptLIBOMF:
.pgmoptLIBCOF: MOV ESI,".lib"
       JMP .50:
.pgmoptDLL: MOV ESI,".dll"
       JMP .50:
.pgmoptRSRC:MOV ESI,".res"
       JMP .50:
.pgmoptELF:MOV ESI,".o"
       MOV CL,2
       JMP .50:
.pgmoptELFSO:MOV ESI,".so"
       MOV CL,3
       JMP .50:
.pgmoptELFX:MOV ESI,".x"
       MOV CL,2
       JMP .50:
.pgmoptMZ:
.pgmoptPE: MOV ESI,".exe"
       ;JMP .50:
.50:  PUSH ECX                                   ; ESI now contains ECX (0..4) characters of file extension.
       LEA ECX,[EDX+ECX+1]                       ; %^Program + extension + zeroterminator.
       PoolNew [Src.Pool::],ECX,Align=BYTE
       DEC ECX
       MOV [EDI+PGMOPT.OutFilePtr],EAX
       MOV [EDI+PGMOPT.OutFileSize],ECX
       CopyTo EAX,EBX,Size=EDX                   ; Permanently save program name.
       ADD EAX,EDX
      POP ECX
      PUSH ESI
        MOV ESI,ESP
        CopyTo EAX,ESI,Size=ECX                  ; Append the extension.
        MOV [EAX+ECX],CH                         ; Zero terminator.
      POP ESI
 .90:ENDP .OUTFILE:

.MODEL:PROC
      MOV EDX,[EDI+PGMOPT.Status]
      MOV EAX,pgmoptModelMask
      AND EAX,EDX
      JNZ .90:                                   ; If MODEL= was explicitly specified, use it as is.
      MOV EAX,pgmoptFormatMask                   ; Otherwise get the default model for this program format.
      AND EAX,EDX
      Dispatch AL,%PfPgmoptList
.pgmoptCOFF:
.pgmoptPE:
.pgmoptDLL:
.pgmoptLIBCOF:
.pgmoptRSRC:
.pgmoptELF:
.pgmoptELFX:
.pgmoptELFSO:
       MOV EAX,pgmoptFLAT
       JMP .50:
.pgmoptBIN:
.pgmoptCOM:
.pgmoptBOOT:
       MOV EAX,pgmoptTINY
       JMP .50:
.pgmoptOMF:
.pgmoptLIBOMF:
.pgmoptMZ:
       MOV EAX,pgmoptSMALL
   .50:OR EDX,EAX
       OR [EDI+PGMOPT.Status],EDX
   .90:ENDP .MODEL:

.WIDTH:PROC
       MOV EAX,pgmoptWidthMask
       AND EAX,EDX
       JNZ .90:                                  ; If WIDTH= was explicitly specified, use it as is.
       MOV EAX,pgmoptFormatMask
       AND EAX,EDX
       Dispatch AL,%PfPgmoptList
.pgmoptBIN:
.pgmoptBOOT:
.pgmoptCOM:
.pgmoptOMF:
.pgmoptMZ:
.pgmoptLIBOMF:
       JSt EDX,pgmoptFLAT,.Width32:              ; MODEL=FLAT defaults to WIDTH=32.
       MOV EAX,pgmoptWidth16                     ; Other realmode models default to WIDTH=16.
       JMP .50:
.pgmoptCOFF:
.pgmoptLIBCOF:
.pgmoptPE:
.pgmoptDLL:
.pgmoptRSRC:
.pgmoptELF:
.pgmoptELFX:
.pgmoptELFSO:
.Width32:
       MOV EAX,pgmoptWidth32
   .50:OR EDX,EAX
       OR [EDI+PGMOPT.Status],EDX
   .90:ENDP .WIDTH:

.SECTIONALIGN:PROC
      CMPD [EDI+PGMOPT.SectionAlign], -1         ; If not explicitly specified, SectionAlign=-1.
      JNE .90:                                   ; Leave the explicitly specified alignment as is.
      MOV EAX,pgmoptFormatMask
      AND EAX,EDX
      Dispatch AL,%PfPgmoptList
.pgmoptBOOT:
.pgmoptOMF:
.pgmoptLIBOMF:
.pgmoptLIBCOF:
.pgmoptCOFF:
      SUB EAX,EAX                                ; SectionAlign=0.
      JMP .50:
.pgmoptBIN:
.pgmoptCOM:
.pgmoptMZ:
      MOV EAX,16                                 ; SectionAlign=10h.
      JMP .50:
.pgmoptELF:
.pgmoptELFX:
.pgmoptELFSO:
;;;      MOV EAX,16                                 ; SectionAlign=16
      MOV EAX,64                                 ; SectionAlign=40h.
    ;;;;  MOV EAX,4K                                ; SectionAlign=1000h.
      JMP .50:
.pgmoptPE:
.pgmoptRSRC:
.pgmoptDLL:
       MOV EAX,4K                                ; SectionAlign=1000h.
 .50:  MOV [EDI+PGMOPT.SectionAlign],EAX
 .90: ENDP .SECTIONALIGN:

.FILEALIGN:PROC
      CMPD [EDI+PGMOPT.FileAlign],-1             ; If not explicitly specified, FileAlign=-1.
      JNE .90:                                   ; Leave the explicitly specified alignment as is.
      MOV EAX,pgmoptFormatMask
      AND EAX,EDX
      Dispatch AL,%PfPgmoptList
.pgmoptBOOT:
.pgmoptOMF:
.pgmoptLIBOMF:
.pgmoptLIBCOF:
.pgmoptRSRC:
.pgmoptCOFF:
       SUB EAX,EAX                               ; FileAlign=0.
       JMP .50:
.pgmoptMZ:
.pgmoptBIN:
.pgmoptCOM:
.pgmoptELF:
.pgmoptELFX:
.pgmoptELFSO:
       MOV EAX,16                                ; FileAlign=10h.
       JMP .50:
.pgmoptPE:
.pgmoptDLL:
       MOV EAX,512                               ; FileAlign=200h.
   .50:MOV [EDI+PGMOPT.FileAlign],EAX
   .90:ENDP .FILEALIGN:

.IMAGEBASE:PROC
      MOV EAX,-1
      CMP [EDI+PGMOPT.ImageBaseLow], EAX         ; If not explicitly specified, ImageBase=-1.
      JNE .90:
      CMP [EDI+PGMOPT.ImageBaseHigh],EAX         ; If not explicitly specified, ImageBase=-1.
      JNE .90:                                   ; Leave the explicitly specified base as is,
      MOV EAX,pgmoptFormatMask                   ;   otherwise use the format-dependent default.
      AND EAX,EDX
      XOR EDX,EDX
      Dispatch AL,%PfPgmoptList
.pgmoptLIBCOF:
.pgmoptLIBOMF:
.pgmoptCOFF:
.pgmoptRSRC:
.pgmoptOMF:
.pgmoptBIN:
.pgmoptBOOT:
.pgmoptCOM:
.pgmoptMZ:
.pgmoptELF:
.pgmoptELFSO:
      XOR EAX,EAX                                ; ImageBase=0.
      JMP .50:
.pgmoptELFX:
.pgmoptPE:
      MOV EAX,4M                                 ; ImageBase=40_0000h.
      JMP .50:
.pgmoptDLL:
      MOV EAX,256M                               ; ImageBase=1000_0000h.
  .50:MOV [EDI+PGMOPT.ImageBaseLow],EAX
      MOV [EDI+PGMOPT.ImageBaseHigh],EDX
.90: ENDP .IMAGEBASE:
.99:EndProcedure PgmoptSetDefaults
↑ PgmoptCheck Pgm
PgmoptCheck warns when program options are not consistent.
It is invoked when the [PROGRAM] division of euroasm.ini and parameters of PROGRAM pseudoinstruction were translated to PGM.Pgmopt object.
Input
Pgm is pointer to the checked PGM.
Output
-
Error
W3739
Invoked by
PseudoPROGRAM
PgmoptCheck Procedure Pgm
      MOV EBX,[%Pgm]
      MOV EAX,[EBX+PGM.Pgmopt.Status]
      AND EAX,pgmoptFormatMask
      Dispatch AL,pgmoptBIN,pgmoptCOM,pgmoptMZ,pgmoptBOOT
      JMP .90:
.pgmoptBIN:
.pgmoptBOOT:
.pgmoptCOM:
.pgmoptMZ:
      ; Realmode formats require %^FileAlign=%^SectionAlign.
      MOV ECX,[EBX+PGM.Pgmopt.FileAlign]
      MOV EDX,[EBX+PGM.Pgmopt.SectionAlign]
      CMP ECX,EDX
      JE .90:
      JA .W3739:
      XCHG ECX,EDX
      MOV [EBX+PGM.Pgmopt.FileAlign],ECX
      MOV [EBX+PGM.Pgmopt.SectionAlign],ECX
.W3739:Msg '3739',ECX ; Realmode program format requires FileAlign=SectionAlign. Both options were set to !1K.
.90:EndProcedure PgmoptCheck
    ENDPROGRAM pgmopt

▲Back to the top▲