; *********************************************************************** ; * * ; * A Simple ARM Assembly Language Program * ; * * ; *********************************************************************** ; Author: John Zaitseff ; Date: 9th September, 2002 ; Version: 1.4 ; This program contains a simple ARM assembly language program. The main ; purpose of this is to show you what such a program looks like: in ; particular, what assembler directives are needed. ; Everything following a semicolon ";" is a comment and is ignored by the ; GNU Assembler. That does not mean that you should do the same! /* C-style comment syntax can also be used, if you so wish */ .text ; Executable code follows this point. All ; actual code (ARM instructions) should ; appear in the ".text" section. .global _start ; "_start" is required by the GNU Linker to ; let it know where the program starts. ; It has to be explicitly declared "global ; to the entire program". _start: ; Entry point of our program. By default, ; "_start" marks the first instruction to ; be executed. It is also a good place to ; put a breakpoint. mov r0,#10 ; Set up parameters into R0 and R1 mov r1,#8 add r2,r0,r1 ; and perform R2 := R0 + R1 ; You can modify the code above to teach yourself about the basic ARM ; arithmetic and logical instructions. Try replacing the "add" with "sub" ; (subtract), "rsb" (reverse subtract), "mul" (multiply), "and" (boolean ; AND), "orr" (boolean OR), "eor" (boolean XOR) or "bic" (bit clear). ; You can also experiment with changing the parameters to other values. ; But be careful: the "mov" instruction is limited as to what values it ; can accept. See page A5-6 of the ARM Architecture Reference Manual ; (page 222 of the PDF document) for more information. The file ; "values.s" also deals with this issue. exit: ; Label the exit portion of the program. ; This label can be anything you like, ; although using "exit" is a good convention. swi 0x11 ; Terminate the program using a software ; interrupt to the Monitor. .end ; Mark the end of the input file