home *** CD-ROM | disk | FTP | other *** search
-
- #type &FFD
- ; -------------------------------------------
- ; The following is the ARM Object Format file
- ; -------------------------------------------
- ;
- .AOF_objfilestart
- ;
- ; File header
- ; -----------
- ;
- DCD &C3CBC6C5 ; chunkfileid
- DCD 5 ; maxchunks
- DCD 5 ; numchunks
- ;
- ; Chunks
- ; ------
- ;
- ; Header chunk
- ;
- DCB "OBJ_HEAD"
- DCD AOF_headerstart-AOF_objfilestart ; header offset
- DCD AOF_headerend-AOF_headerstart ; header size
- ; Area chunk
- ;
- DCB "OBJ_AREA"
- DCD AOF_areastart-AOF_objfilestart ; area offset
- DCD AOF_areaend-AOF_areastart ; area size
- ; Identification chunk
- ;
- DCB "OBJ_IDFN"
- DCD AOF_idstart-AOF_objfilestart ; id offset
- DCD AOF_idend-AOF_idstart ; id size
- ; Symbol table
- ;
- DCB "OBJ_SYMT"
- DCD AOF_symboltablestart-AOF_objfilestart ; symbol table offset
- DCD AOF_symboltableend-AOF_symboltablestart ; symbol table size
- ; String table
- ;
- DCB "OBJ_STRT"
- DCD AOF_strtablestart-AOF_objfilestart ; string table offset
- DCD AOF_strtableend-AOF_strtablestart ; string table size
- ;
- ; Chunk data
- ; ----------
- ;
- ; ----------
- ; Area chunk
- ; ----------
- ;
- .AOF_areastart
- ; extAOF example
- ;
- ; © Terje Slettebø
- ;
- ;
- ; These example files ('AOFTestA' and 'AOFTestC') demonstrates how you can
- ; reference functions or global variables in AOF files. It shows:
- ;
- ; - Referencing an external function (#import printf)
- ; - Referencing an external global variable (#import globalcvar)
- ; - Defining a function which can be referenced (#export testproc)
- ; - Defining a global variable which can be referenced (#export globalvar)
- ;
- ; It also sets up a zero-initialised area.
- ;
- ;
- ; To assemble this source file to an AOF file, you can either:
- ;
- ; - Drag this source file to the extAOF icon, and then drag the new file to
- ; the extASM assembler. Then it will be assembled to AOF format.
- ;
- ; - Use the 'extASM' mode file for StrongED, in this application directory,
- ; and press shift-F10. The source will then be saved, and it will be sent
- ; to extAOF.
- ;
- ; If you choose the 'Autostart' in the option in the extAOF menu, then
- ; extAOF will automatically send the new file to extASM.
- ;
- ;
- ; When this source is assembled, using the methods described above, you must
- ; then put the filename for the object file (<filepath>.Procedure) in the
- ; "Library" menu entry for the C compiler (for the ANSI C compiler).
- ;
- ; Then you can compile the C source 'AOFTestC'. And then you can run the
- ; executable object file.
- ;
- #name Procedure
-
- .AOF_testareastart
-
-
- .testproc
- STMFD R13!,{R14}
- ADR R0,str
- SWI OS_Write0
- LDR R0,globalcvaradr ; read 'globalcvar' address
- LDR R0,[R0] ; read 'globalcvar'
- ADR R1,numbuffer
- MOV R2,#16
- SWI OS_ConvertInteger4
- SWI OS_Write0 ; print number
- SWI OS_NewLine
- ADR R0,str2
- .AOF_printf_I_0
- BL AOF_printf_I_0+8
- LDMFD R13!,{R15}^
- .str
- DCB "In assembly program, globalcvar (in C)=",0
- ALIGN
- .str2
- DCB "Returning, using printf (in C)",10,13,0 ; '\n' can not be used,
- ALIGN ; it is substituted by the
- .numbuffer ; compiler
- DBB 16
- .globalcvaradr
- .AOF_globalcvar_I_0
- DCD 0
- .globalvar
- DCD 234
- ;
- ; The following sets up a 1024 bytes zero-initialised area. This is only
- ; made when the AOF file is linked, or it is set up at run-time by the
- ; executable file (this is up to the linker). It seems the linker with
- ; ANSI C does the latter. In this way, the AOF file can be smaller, as it
- ; doesn't have to include the zero-initialised data.
- ;
- .AOF_testareaend
- ; Relocation directive table
- ;
- DCD AOF_printf_I_0-AOF_testareastart
- DCD (AOF_printf_Isymbol-AOF_symboltablestart)/16+&60000
- DCD AOF_globalcvar_I_0-AOF_testareastart
- DCD (AOF_globalcvar_Isymbol-AOF_symboltablestart)/16+&a0000
- .AOF_zeroinitstart
-
-
- .datastart
- #set AOF_zeroinitend=AOF_zeroinitstart+1024
-
- .AOF_areaend
- ;
- ; ------------
- ; Header chunk
- ; ------------
- ;
- .AOF_headerstart
- DCD &C5E2D080 ; relocatable object file
- DCD 150 ; version ID
- DCD 2 ; number of areas
- DCD 5 ; number of symbols
- DCD 0 ; entry adr area
- DCD 0 ; entry adr offset
- ;
- ; area name
- DCD AOF_testareastr-AOF_strtablestart
- ; area flags
- DCD &202
- ; area size
- DCD AOF_testareaend-AOF_testareastart
- ; number of relocations
- DCD 2
- ; unused
- DCD 0
- ;
- ; area name
- DCD AOF_zeroinitstr-AOF_strtablestart
- ; area flags
- DCD &1002
- ; area size
- DCD AOF_zeroinitend-AOF_zeroinitstart
- ; number of relocations
- DCD 0
- ; unused
- DCD 0
- ;
- .AOF_headerend
- ; --------------------
- ; Identification chunk
- ; --------------------
- ;
- .AOF_idstart
- DCB "Made by extAOF and extASM",0
- ALIGN
- .AOF_idend
- ;
- ; ------------------
- ; Symbol table chunk
- ; ------------------
- ;
- .AOF_symboltablestart
- ;
- .AOF_globalcvar_Isymbol
- ; symbol name
- DCD AOF_globalcvar_Istr-AOF_strtablestart
- ; symbol flags
- DCD 2
- ; symbol value
- DCD 0
- ; symbol area
- DCD 0
- ;
- .AOF_printf_Isymbol
- ; symbol name
- DCD AOF_printf_Istr-AOF_strtablestart
- ; symbol flags
- DCD 2
- ; symbol value
- DCD 0
- ; symbol area
- DCD 0
- ;
- .AOF_globalvarsymbol
- ; symbol name
- DCD AOF_globalvarstr-AOF_strtablestart
- ; symbol flags
- DCD 3
- ; symbol value
- DCD globalvar-AOF_testareastart
- ; symbol area
- DCD AOF_testareastr-AOF_strtablestart
- ;
- .AOF_testprocsymbol
- ; symbol name
- DCD AOF_testprocstr-AOF_strtablestart
- ; symbol flags
- DCD 3
- ; symbol value
- DCD testproc-AOF_testareastart
- ; symbol area
- DCD AOF_testareastr-AOF_strtablestart
- ;
- .AOF_datastartsymbol
- ; symbol name
- DCD AOF_datastartstr-AOF_strtablestart
- ; symbol flags
- DCD 3
- ; symbol value
- DCD datastart-AOF_zeroinitstart
- ; symbol area
- DCD AOF_zeroinitstr-AOF_strtablestart
- ;
- .AOF_symboltableend
- ; ------------------
- ; String table chunk
- ; ------------------
- ;
- .AOF_strtablestart
- DCD AOF_strtableend-AOF_strtablestart
- ; symbol strings
- ;
- .AOF_globalcvar_Istr
- DCB "globalcvar",0
- .AOF_printf_Istr
- DCB "printf",0
- .AOF_globalvarstr
- DCB "globalvar",0
- .AOF_testprocstr
- DCB "testproc",0
- .AOF_datastartstr
- DCB "datastart",0
- ;
- ; area strings
- .AOF_testareastr
- DCB "AOF_testarea",0
- .AOF_zeroinitstr
- DCB "AOF_zeroinit",0
- ALIGN
- .AOF_strtableend
-