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 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.
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 Procedure BasePgm, ObjBegin, ObjSize, FileNamePtr Msg '8534',Dict_FormatBOOT::,[%FileNamePtr] ; Format !1S of file "!2$" is not linkable. EndProcedure PfbootLoadPgm
ENDPROGRAM pfboot