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. INCLUDEHEAD \ ; Include headers of another modules used in this module. ea.htm, \ eaopt.htm, \ exp.htm, \ msg.htm, \ pf.htm, \ pfpe.htm, \ pgm.htm, \ pgmopt.htm, \ reloc.htm, \ sss.htm, \ stm.htm, \ sym.htm, \ syswin.htm, \ ;;
pfcom HEAD ; Start module interface.
ENDHEAD pfcom ; End of module interface.
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,
it starts at the entry point, which is the first byte in the output file.
Load-time relocations are not possible, the loader fills CS,DS,ES,SS with paragraph addres of [COM],
so DS:0
points to 256 bytes long Program Segment Prefix (PSP).
Segment are typically not used in COM format. If more than one segment is used in the program,
segments are linked to output image file with alignment specified by the strongest of following three options:
PROGRAM FILEALIGN=
(default=0),PROGRAM SECTIONALIGN=
(default=0),SEGMENT ALIGN=
(default=16).Segment order has been set up by PgmOrderSegments.
Relative relocations between segments are resolved. Absolute relocations are fixed up as if the image (starting with
PSP) was loaded at virtual address VA=0. The program has to manage such relocations by itself at run time.
PfcomCompile Procedure OutputStream, Pgm MOV EBX,[%Pgm] Invoke SymReportUnresolved::,EBX Invoke PgmGroupByModel::,EBX Invoke PgmOrderSegments::,EBX SUB EAX,EAX CMP [EBX+PGM.Pgmopt.ImageBaseLow],EAX Msg cc=NZ,'3932',[EBX+PGM.Pgmopt.ImageBaseLow] ; Format COM requires "PROGRAM ImageBase=0". The value !1K ignored. MOV [EBX+PGM.Pgmopt.ImageBaseLow],EAX MOV [EBX+PGM.Pgmopt.ImageBaseHigh],EAX Invoke PgmLink::,EBX,0,100h ; Check program entry. Invoke PgmEvalEntry::,EBX LEA EDX,[EBX+PGM.EntryExp] MOV ECX,[EDX+EXP.Status] LEA EAX,[EBX+PGM.Pgmopt.EntryPtr] ; ENTRY= value in case of W3931. Dispatch CL,'A','N',00 JMP .W3931: ; Format COM requires fixed entry point at [!1S]:100h. "ENTRY=!2S" ignored. .A: BufferRetrieve [EBX+PGM.SegOrdBuffer] LODSD CMP EAX,[EDX+EXP.Seg] JNE .W3931: .N: CMPD [EDX+EXP.Low],100h JE .00: .W3931: Invoke EaBufferReserve::,%^PROC MOV EDX,EAX Invoke SssFindByPurpose::,sssGroup,sssPurposeCODE,sssNotBSS,0,EBX,EDX XOR EAX,EAX BufferRetrieve EDX JZ .70: LODSD .70: Invoke EaBufferRelease::,EDX LEA ECX,[EBX+PGM.Pgmopt.EntryPtr] Msg '3931',EAX,ECX ; 3931 Format COM requires fixed entry point at [!1S]:100h. "ENTRY=!2S" ignored. .00: Invoke PgmRelocResolve::,EBX Invoke RelocReportUnresolved::,EBX Invoke PgmStreamImage::,EBX,[%OutputStream] EndProcedure PfcomCompile
PfcomLoadPgm Procedure BasePgm, ObjBegin, ObjSize, FileNamePtr Msg '8534',Dict_FormatCOM::,[%FileNamePtr] ; Format !1S of file "!2$" is not linkable. EndProcedure PfcomLoadPgm
ENDPROGRAM pfcom