home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
programming
/
extasm_1
/
!extAOF
/
Examples
/
C
/
AOFTestA
next >
Wrap
Text File
|
1995-05-16
|
3KB
|
87 lines
; 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
#area testarea,code
#import globalcvar
#import printf
#export globalvar
#export testproc
.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
BL printf
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
DCD globalcvar
.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.
;
#area zeroinit,noinit
#export datastart
.datastart
#% 1024
#end