EuroAssembler Index Manual Download Source Macros


Sitemap Links Forum Tests Projects

pfcom.htm
Procedures
PfcomCompile
PfcomLoadPgm

This source PF generates EuroAssembler output object file in program format COM.


pfcom PROGRAM FORMAT=COFF,MODEL=FLAT,WIDTH=32
 INCLUDEHEAD "euroasm.htm" ; Interface (structures, symbols and macros) of other modules.
 pfcom HEAD ; Start module interface.
 ENDHEAD pfcom  ; End of module interface.
↑ PfcomCompile OutputStream, Pgm
PfcomCompile is constructor of output 16bit real-mode executable file image in COM format.
This format by default uses one common segment [COM]. Entry point is fixed at [COM]:100h.
Emitted contents of segment(s) is stored to output stream without any metainformations, starting from the entry point.
Load-time relocations are ignored, the loader fills CS,DS,ES,SS with paragraph addres of [COM],
so DS:0 points to 256 bytes long Program Segment Prefix (PSP).
If more than one segment is used in program, segments are linked to output image file with alignment specified by the strongest of following three options: Segment order has been set up by PgmOrderSegments.
If the last segment(s) are uninitialized (PURPOSE=BSS|STACK), their contents is not emitted to image file at all. However, if some initialized data or code follows, BSS|STACK segment is emitted as zero-initialized data.
Relative relocations between segments are resolved. Absolute relocations are fixed up as if the 1st segment were loaded at virtual address VA=0. The program has to manage such relocations at run time.
Input
OutputStream is pointer to a STREAM for the output image contents.
Pgm is pointer to PGM representing completely assembled program.
Output
OutputStream is filled with output file contents.
Error
Errors are reported with macro Msg.
Invoked from
PfOutput
Invokes
ExpReportError PgmConcatenateImage PgmCreateImplicitGroups PgmEvalEntry PgmLinkImage PgmOrderSegments RelocSort SssGetSegm
Tested by
t7457 t7460 t7463 t7466 t7469
PfcomCompile Procedure OutputStream, Pgm
     MOV EBX,[%Pgm]
     Invoke PgmCreateImplicitGroups::,EBX
     Invoke RelocSort::,EBX
     Invoke PgmOrderSegments::,EBX
     Invoke SssGetSegm::,EBX,sssPurposeCODE
     JC .E7723:
     ; Check program entry.
     Invoke PgmEvalEntry::,EBX
     LEA EDI,[EBX+PGM.EntryExp]
     Invoke ExpReportError::,EDI
     JBE .10:
     ; Entry was explicitly specified. Check if it is 256.
     CMP EAX,[EDI+EXP.Seg]
     JNE .E7723:
     CMPD [EDI+EXP.Low],100h
     JE .10:
.E7723:Msg '7723',EAX ; Program format COM requires fixed entry point at [!1S]:100h.
.10: MOV [EDI+EXP.Seg],EAX
     MOVD [EDI+EXP.Low],100h
     MOVD [EDI+EXP.High],0
     MOVD [EDI+EXP.Status],'A'
     ; Check program ImageBase.
     SUB EAX,EAX
     CMP [EBX+PGM.Pgmopt+PGMOPT.ImageBaseLow],EAX
     Msg cc=NZ,'7724' ; Program format COM requires fixed Imagebase=0.
     MOV [EBX+PGM.Pgmopt+PGMOPT.ImageBaseLow],EAX
     MOV [EBX+PGM.Pgmopt+PGMOPT.ImageBaseHigh],EAX
     Invoke PgmLinkImage::,EBX,0
     Invoke PgmConcatenateImage::,EBX
     BufferRetrieve EAX
     ADD ESI,256
     SUB ECX,256
     JNB .80:
     Msg '9341' ; Internal error: invalid COM file size.
.80: StreamStore [%OutputStream],ESI,ECX
     EndProcedure PfcomCompile
↑ PfcomLoadPgm BasePgm, ObjBegin, ObjEnd, FileNamePtr
Executable format COM is not linkable, it cannot be loaded.
Input
BasePgm is pointer to an existing PGM to which the object file is being linked/imported.
ObjBegin is pointer to the contents of linked/imported object file mapped in memory by the caller.
ObjSize is number of bytes in the object file.
FileNamePtr is pointer to zero-terminated object file name (used in error reports).
Output
-
Error
E8534 Format !1S of file "!2$" is not linkable.
PfcomLoadPgm Procedure BasePgm, ObjBegin, ObjSize, FileNamePtr
    Msg '8534',Dict_FormatCOM::,[%FileNamePtr] ; Format !1S of file "!2$" is not linkable.
   EndProcedure PfcomLoadPgm
  ENDPROGRAM pfcom

▲Back to the top▲