home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / extasm_1 / !extAOF / Examples / C / AOFTestA next >
Text File  |  1995-05-16  |  3KB  |  87 lines

  1. ; extAOF example
  2. ;
  3. ; © Terje Slettebø
  4. ;
  5. ;
  6. ; These example files ('AOFTestA' and 'AOFTestC') demonstrates how you can
  7. ; reference functions or global variables in AOF files. It shows:
  8. ;
  9. ; - Referencing an external function                   (#import printf)
  10. ; - Referencing an external global variable            (#import globalcvar)
  11. ; - Defining a function which can be referenced        (#export testproc)
  12. ; - Defining a global variable which can be referenced (#export globalvar)
  13. ;
  14. ; It also sets up a zero-initialised area.
  15. ;
  16. ;
  17. ; To assemble this source file to an AOF file, you can either:
  18. ;
  19. ; - Drag this source file to the extAOF icon, and then drag the new file to
  20. ;   the extASM assembler. Then it will be assembled to AOF format.
  21. ;
  22. ; - Use the 'extASM' mode file for StrongED, in this application directory,
  23. ;   and press shift-F10. The source will then be saved, and it will be sent
  24. ;   to extAOF.
  25. ;
  26. ; If you choose the 'Autostart' in the option in the extAOF menu, then
  27. ; extAOF will automatically send the new file to extASM.
  28. ;
  29. ;
  30. ; When this source is assembled, using the methods described above, you must
  31. ; then put the filename for the object file (<filepath>.Procedure) in the
  32. ; "Library" menu entry for the C compiler (for the ANSI C compiler).
  33. ;
  34. ; Then you can compile the C source 'AOFTestC'. And then you can run the
  35. ; executable object file.
  36. ;
  37. #name Procedure
  38.  
  39. #area testarea,code
  40.  
  41. #import globalcvar
  42. #import printf
  43. #export globalvar
  44. #export testproc
  45.  
  46. .testproc
  47. STMFD R13!,{R14}
  48. ADR   R0,str
  49. SWI   OS_Write0
  50. LDR   R0,globalcvaradr      ; read 'globalcvar' address
  51. LDR   R0,[R0]               ; read 'globalcvar'
  52. ADR   R1,numbuffer
  53. MOV   R2,#16
  54. SWI   OS_ConvertInteger4
  55. SWI   OS_Write0             ; print number
  56. SWI   OS_NewLine
  57. ADR   R0,str2
  58. BL    printf
  59. LDMFD R13!,{R15}^
  60. .str
  61. DCB   "In assembly program, globalcvar (in C)=",0
  62. ALIGN
  63. .str2
  64. DCB   "Returning, using printf (in C)",10,13,0 ; '\n' can not be used,
  65. ALIGN                                          ; it is substituted by the
  66. .numbuffer                                     ; compiler
  67. DBB   16
  68. .globalcvaradr
  69. DCD   globalcvar
  70. .globalvar
  71. DCD   234
  72. ;
  73. ; The following sets up a 1024 bytes zero-initialised area. This is only
  74. ; made when the AOF file is linked, or it is set up at run-time by the
  75. ; executable file (this is up to the linker). It seems the linker with
  76. ; ANSI C does the latter. In this way, the AOF file can be smaller, as it
  77. ; doesn't have to include the zero-initialised data.
  78. ;
  79. #area zeroinit,noinit
  80.  
  81. #export datastart
  82.  
  83. .datastart
  84. #% 1024
  85.  
  86. #end
  87.