ARM.SoC.Architecture

The first step of the development process is to

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ld the coding begin. Individual modules should be coded, tested thoroughly (which may require special programs to be designed as 'test-harnesses') and documented, and the program built piece by piece. Today nearly all programming is based on high-level languages, so it is rare for large programs to be built using assembly programming as described here. Sometimes, however, it may be necessary to develop small software components in assembly language to get the best performance for a critical application, so it is useful to know how to write assembly code for these purposes. 72 ARM Assembly Language Programming 3.5 Examples and exercises Once you have the basic flavour of an instruction set the easiest way to learn to write programs is to look at some examples, then attempt to write your own program to do something slightly different. To see whether or not your program works you will need an ARM assembler and either an ARM emulator or hardware with an ARM processor in it. The following sections contain example ARM programs and suggestions for modifications to them. You should get the original program working first, then see if you can edit it to perform the modified function suggested in the exercises. Example 3.1 Print out r1 in hexadecimal. This is a useful little routine which dumps a register to the display in hexadecimal (base 16) notation; it can be used to help debug a program by writing out register values and checking that algorithms are producing the expected results, though in most cases using a debugger is a better way of seeing what is going on inside a program. AREA Hex_Out,CODE,READONLY SWI_WriteC SWI_Exit ENTRY EQU EQU &0 &11 output character in r0 finish program code entry point LDR BL r1, VALUE HexOut get value to print call hexadecimal output VALUE LOOP SWI DCD MOV CMP ADDGT ADDLE SWI MOV SUBS BNE SWI_Exit &12345678 r2, #8 finish test value nibble count = 8 HexOut MOV r0, r0, r0, r0, r1, LSR #28 #9 r0, #"A"-10 r0, #"0" get top nibble 0-9 or A-F? ASCII alphabetic ASCII numeric print character shift left one nibble decrement nibble count if more do next nibble SWI_WriteC r1, r1, LSL #4 r2, r2, #1 LOOP MOV END Exercise 3.1.1 pc, r14 return Modify the above program to output r1 in binary format. For the value loaded into r1...
View Full Document

This document was uploaded on 10/30/2011 for the course CSE 378 380 at SUNY Buffalo.

Ask a homework question - tutors are online