EuroAssembler Index Manual Download Source Macros


Sitemap Links Forum Tests Projects

pfboot.htm
Procedures
PfbootCompile
PfbootLoadPgm

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


pfboot 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,     \
pgm.htm,     \
pgmopt.htm,  \
reloc.htm,    \
syswin.htm,  \
;;
 pfboot HEAD ; Start module interface.
 ENDHEAD pfboot  ; End of module interface.
↑ PfbootCompile OutputStream, Pgm

PfbootCompile is constructor of output 16bit real-mode boot sector file.
This format by default uses one common segment. Entry point is fixed at linear address 7C00h.
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 last word at offset 510 is automatically initialized to the boot sector signature, i.e. 0x55AA.
If the total size of assembled code + data is less than 510 bytes, they will be stuffed with NULL bytes.
It the total sector size exceeds 512, error is reported.

Input
OutputStream is pointer to a STREAM for the output image contents.
Pgm is pointer to PGM representing a completely assembled program.
Output
OutputStream is filled with output file contents.
Error
Errors are reported with macro Msg.
Invoked from
PfOutput
Invokes
PgmEvalEntry PgmGroupByModel PgmLink PgmOrderSegments PgmRelocResolve PgmStreamImage RelocReportUnresolved SymReportUnresolved
Tested by
t8100 t8150
PfbootCompile 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,'3942',[EBX+PGM.Pgmopt.ImageBaseLow] ; Format BOOT requires "PROGRAM ImageBase=0". The value !1K ignored.
     MOV [EBX+PGM.Pgmopt.ImageBaseLow],EAX
     MOV [EBX+PGM.Pgmopt.ImageBaseHigh],EAX
     Invoke PgmLink::,EBX,0,0x7C00
     ; 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,00,'F','A','N'
.W3941:Msg '3941',EAX                               ; Format BOOT requires fixed entry point at 0:0x7C00. "ENTRY=!1S" ignored.
     JMP .00:
.E7793:Msg '7793'                                   ; Size of the output file exceeded 512 bytes.
     JMP .90:
.F:  MOV EAX,[EDX+EXP.Seg]
     SHL EAX,4
     ADD EAX,[EDX+EXP.Low]
     CMP EAX,0x7C00
     JNE .W3941:
     JMP .00:
.A:  BufferRetrieve [EBX+PGM.SegOrdBuffer]
     LODSD
     CMP EAX,[EDX+EXP.Seg]
     JNE .W3941:
.N:  CMPD [EDX+EXP.Low],0x7C00
     JNE .W3941:
.00: Invoke PgmRelocResolve::,EBX
     Invoke RelocReportUnresolved::,EBX
     Invoke PgmStreamImage::,EBX,[%OutputStream]
     StreamGetSize [%OutputStream]
     MOV ECX,512-2
     SUB ECX,EAX
     JB .E7793:                                     ; Size of the output file exceeded 512 bytes.
     JECXZ .80:
.70: StreamStoreByte [%OutputStream],0              ; Stuff the output file to 510 bytes with NUL.
     LOOP .70:
.80: StreamStoreWord [%OutputStream],0xAA55         ; Boot sector signature at file address 510.
.90:EndProcedure PfbootCompile
↑ PfbootLoadPgm 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.
Invoked from
PfLoad
PfbootLoadPgm Procedure BasePgm, ObjBegin, ObjSize, FileNamePtr
    Msg '8534',Dict_FormatBOOT::,[%FileNamePtr] ; Format !1S of file "!2$" is not linkable.
   EndProcedure PfbootLoadPgm
  ENDPROGRAM pfboot

▲Back to the top▲