AVRStudio7 Intro
AVRStudio7 Intro
Unfortunately, Atmel Studio only supports Windows. If you want to install Atmel Studio on a non-Windows
computer, consider setting up a Windows virtual machine. Obtain necessary software for setting up a
Windows virtual machine from the following links.
• VMware Workstation (for Linux) or VMware Fusion (for Mac OS):
https://taggi.cse.unsw.edu.au/FAQ/VMware_Academic_Program/
• Microsoft Windows: https://taggi.cse.unsw.edu.au/FAQ/Microsoft_Imagine_and_ELMS/
You will then be presented with the New Project window. Underneath the Installed tab, select the
Assembler option, select AVR Assembler Project and name the project “lab00-1”.
Once you click OK on this screen, you will be taken to the device selection window. Either scroll or search
for “ATmega2560”, select it and click OK.
If the editor has not yet opened “main.asm”, then open that file. The contents of the file should be a
simple assembly file scaffold similar to the below screenshot.
Now replace the entire contents of this file with the following code snippet.
Press Alt+F5 to start executing the program and to halt at the first instruction. The screen will c hange and
some new windows will appear. If a window appears obstructing the view of your source code, you can
drag and drop windows in order to rearrange them.
Now you should go to Debug->Windows->Processor Status and drag the new window to the side. This
window contains important views that will help you debug your assembly programs including the registers,
status register and stack pointer. The yellow arrow denotes the instruction to be performed next.
The screen will change and some new windows will appear. If a window appears obstructing the view of
your source code, you can drag and drop windows in order to rearrange them.
Now you should go to Debug->Windows->Processor Status and drag the new window to the side. This
window contains important views that will help you debug your assembly programs including the
registers, status register and stack pointer. The yellow arrow denotes the instruction to be performed
next.
You can now step through the program by individual instruction by pressing F10 (step over). Do this now.
Focusing your attention on the processor status window, you can see all 32 registers and their current
values are displayed. The instruction just performed was to load an immediate value of 8 into the 16th
register (r16) and you can see the processor status indicates this has happened. Notice that the value is in
red denoting that the value has changed from the previous step. Press F10 to step again.
You have now reached the end of the program (continuing to press F10 will have no effect as the
instruction jumps to itself effectively making an infinite loop). Note that R17 has changed and the value is
highlighted red. Press the stop button to stop the simulator.
Now press F5 alone (remember that pressing Alt+F5 will cause the simulator to break on the first
instruction). The simulator will progress until it hits the breakpoint on the add instruction.
As indicated by the raised carry flag, the stored value in R16 has become too large to fit in an 8-bit integer
so rather than containing 300 as expected it contains 0x2C (44).