COMP9032 Lab 1

$30.00

Download Details:

  • Name: Lab1-t7pa3k.zip
  • Type: zip
  • Size: 132.12 KB

Category:

Description

5/5 - (1 vote)

Tasks
6.1Task 1 (for Week2, due in Week 3)
Manually convert the function described by gcd.c below (i.e. calculating the greatest
common divisor of two numbers) into AVR assembly code (gcd.asm). Assume the size
of an integer is 1 byte. You need to produce two designs: 1) for minimum code size and
2) for minimum execution time.
Figure 1: Program gcd.c
Assign register r16 to be the C code variable a and r17 the variable b. Note, do not
initialize these registers within your code. (You should be able to initialize these
values in AVR Studio, refer to lab0).
Assemble and run your program in AVR Studio and show your working program to the
lab tutor. Remember to save and delete your work before you leave the laboratory.
6.2 Task 2 (for Week 3, due in Week 4)
Write an AVR assembly program that performs the following function


n
i
i
sum a
1
,
where n and a are 8-bit unsigned integers and sum is 16 bits. Try to minimize the
number of registers used.
Use macro to increase the readability of your program.
int main(void)
{
int a, b; /* Initialized elsewhere */
while (a!=b)
{ /* Assume a, b > 0 */
if (a>b)
a = a – b;
else
b = b – a;
}
return 0; /* a and b both hold the result */
}
3
Assemble and run your program in AVR Studio and show your working program to the
lab tutor.
NOTE:
Each task is worth 5 marks. All your programs should be well commented and
easy to read. Up to 1 mark will be deducted for each program without proper and
sufficient comments.
Please have your work marked in your lab class of the due week.