home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI05.ARJ / ictari.05 / ASSEMBLY / EXEC_STR.TXT next >
Text File  |  1993-06-21  |  3KB  |  98 lines

  1. * EXECUTABLE FILE STRUCTURE
  2. ***************************
  3.  
  4. OFFSET    SIZE    DESCRIPTION
  5. ------    ----    -----------
  6. $00    WORD    $601A - MAGIC WORD TO MAKE IT EXECUTABLE
  7. $02    LONG    SIZE OF TEXT SEGMENT
  8. $06    LONG    SIZE OF DATA SEGMENT
  9. $0A    LONG    SIZE OF BSS  SEGMENT
  10. $0E    LONG    SIZE OF SYMBOL TABLE
  11. $12    LONG    RESERVED
  12. $16    LONG    PRGFLAGS was reserved before GEMDOS 0.15 
  13. $1A    WORD    ABSFLAG  was reserved before GEMDOS 0.15
  14. $1C        TEXT SEGMENT
  15. $1C+($02)        DATA SEGMENT
  16. $1C+($02)+($06)        OPTIONAL SYMBOL TABLE
  17. $1C+($02)+($06)+($0E)    FIXUP OFFSET
  18.         OPTIONAL FIXUP RECORDS (FIXUP OFFSET >0)
  19.          FIXUP RECORDS ENDS WITH ZERO BYTE
  20.  
  21.     PRGFLAGS
  22.     ========
  23. Bit 0    If set, Zero only the programs BSS
  24.     If Clear, Zero all memory from end of program to stack start
  25. Bit 1    If Set, Load into Alternate (Fast) RAM if possible
  26.     If Clear, Load into normal RAM only.
  27. Bit 2    If Set, Malloc will try to use Alternative (Fast) RAM
  28.     If Clear, Malloc will only use normal RAM
  29.     
  30. DO NOT USE ALTERNATIVE RAM FOR ANYTHING THAT HAS SCREENS IN OR FOR ANYTHING
  31. THAT USES DMA IN THAT MEMORY (e.g. STE Sound)
  32.  
  33. Bits 28-31    Used with Pexec() modes 0,3
  34.     mode 7 has you passing PRGFLAGS to child as 2nd argument
  35.     i.e. does not use its own PRGFLAGS
  36.     see PEXEC.TXT
  37.     
  38. STANDARD SYMBOL TABLE consists of a number of records of the format:
  39. ---------------------
  40. symbol_name    8 BYTES
  41. symbol_type    WORD
  42. symbol_value    LONG
  43.  
  44. SYMBOL TYPEs are defined as follows:
  45. Defined        $8000
  46. Equated        $4000
  47. Global        $2000
  48. Equated Register    $1000
  49. External Reference    $800
  50. Data Based Relocatable    $400
  51. Text Based Relocatable    $200
  52. BSS Based Relocatable    $100
  53.  
  54. NOTE:
  55.     Symbol tables are free format and may differ from above.
  56.     Alcyon use Alcyon Format symbols (as above)
  57.     Mark Williams 2 use an empty segment and put symbols after the fixup info
  58.     Mark Williams 3 put id header and debug info into symbol table as well
  59.  
  60. FIXUP OFFSET IS OFFSET OF FIRST LONGWORD THAT NEEDS ALTERING.
  61. IF ABSFLAG>0 and/OR FIXUP OFFSET=0 THEN NO FIXUP TABLE
  62. It is altered by adding the text segment start address to each longword.
  63. OPTIONAL FIXUP RECORDS consist of bytes:
  64.         0 marks the end of the fixup information
  65.         1 add 254 to offset and get next offset byte
  66.     2-254 add to offset and fix longword at that address
  67.     NB:   odd bytes should not be used as all longwords
  68.           should start on even boundary.
  69.  
  70. HOW TO RELOCATE A FILE LOADED INTO MEMORY!
  71. ==========================================
  72. * need to clear BSS segment and make enough room etc.
  73. relocate    move.l    #file_addr,a2    ;start of file to relocate
  74.     cmp.w    #$601a,(a2)    ;magic number - executable
  75.     bne    rel_fail    ;otherwise not
  76.     lea    $1c(a2),a1    ;start of text segment
  77.     move.l    a1,d1
  78.     move.l    a1,a0
  79.     add.l    2(a2),a1    ;add text size
  80.     add.l    6(a2),a1    ;add data size
  81.     add.l    $a(a2),a1    ;add symbol size
  82.     clr.l    d0    ;zero if o.k.
  83.     tst.l    (a1)    ;fixup offset null?
  84.     beq    rel_end    ;finished fixup!
  85.     add.l    (a1)+,a0    ;first fixup pointer
  86. rel_add    add.l    d1,(a0)    ;fixup long
  87. rel_lp1    move.b    (a1)+,d0
  88.     beq    rel_end    ;zero marks finish
  89.     cmp.b    #1,d0
  90.     bne    add_ptr    
  91.     add.w    #$00fe,a0    ;add 254 to pointer if 1
  92.     bra    rel_lp1
  93. add_ptr    add.w    d0,a0    ;add offset
  94.     bra    rel_add
  95. rel_fail    move.l    #-1,d0    ;fail
  96. rel_end    rts        ;d0=already at zero if o.k.
  97.  
  98.