1.7 Hello World

The code base for this chapter is SAM4S XPro Bare Metal. It is a zipped Atmel Studio project, and it contains the hello world assembly program in Listing 1.1

. syntax unified

. section . vectors 
. skip 4
. word main

. section . text
. thumb
. type start , %function 
start :
  mov r0, #0x01
  mov r1, #0x02
  mov r2, #0x03 

To run it extract the zip file and open the solution in Atmel Studio. Then assemble the source code and flash it to the MCU.

Resources on the web

  1. ENIAC Computer History Archives Project – remastered original 1946 Film & Narration Army Military
  2. (Video) Programming my 8-bit breadboard computer


1. Using the mov instruction, write a program that swaps the contents of any two registers. Using Listing 1.1 as start point, replace lines 11 to 13 with your own instructions.

In your own words, answer the following questions:

  1. What is the difference between an embedded computer and a gen- eral purpose computer?
  2. What is the difference between processor, microprocessor, and mi- crocontroller?
  3. What is a cross-compiler and why is it needed?

Advanced exercises:

8. Using the xor instruction, write a program that swaps the contents of two registers. To do a = a xor b you have to say, for example, eor r1, r2, where r1 holds a and r2 holds b. The mechanism to swap them is explained in XOR swap algorithm.