The purpose of this lab is to become familiar with the development
environment and development tools used throughout this course.
Problem Statement
We will use the following program to begin our investigation:
Comments are preceded by a semicolon (;). All text on a line after a semicolon is ignored by the assembler
Line 24 includes a definition file (this is necessary for all assembly files)
Lines 26 and 27 define global constants
Line 29 defines a register to be used as a variable
Line 33 declares start of the data segment
Line 34 has the data segment start at 0x60
Line 35 reserves one byte in SRAM and labels the address with data
Line 37 declares the start of the code/program segment
Line 38 has the next instruction start at 0x00
Line 39 defines a relative jump (rjmp) to Reset, which is a label later in the source
Line 41 has the rest of the code segment start at 0x2A
Line 42 defines the location of the label Reset (note that all labels must be in the left-most column and end with a colon (:))
Lines 43 and 44 set PORTB to output by storing a 0xFF into DDRB
Lines 46 and 47 set data to zero
Line 48 outputs r20 on PORTB
Lines 50-53 implement a waiting loop by loading a register (counter) with time (line 50), decrementing the register (line 52), and branching if not equal to zero back to line 52.
Lines 55-57 increment data, which is in SRAM
Line 58 outputs r20 on PORTB
Line 60 jumps back to start, which is line 48
You should use the following general layout conventions for your assembly programs:
left-most column is reserved for labels only (unless a line is comment only)
second column is reserved for instruction
third column is reserved for operand(s)
fourth column contains (optional) comments, preceded by a semicolon
Pre-laboratory investigation and report (due before the beginning of week 2 lab)
Determine the cycle count for every instruction of the above program.
The cycle count can be found in the instruction set manual (available
online or as help file in AVRStudio).
Calculate the total cycle count and time between line 47 and line 54.
The frequency of the microcontroller oscillator is 8MHz.