1. Homepage
  2. Programming
  3. COMP9032 Microprocessors and Interfacing - Lab 1 - AVR Assembly: Square Root Calculator

COMP9032 Microprocessors and Interfacing - Lab 1 - AVR Assembly: Square Root Calculator

Engage in a Conversation
AustraliaUniversity of New South WalesUNSWCOMP9032Microprocessors and InterfacingAVR Assembly

COMP9032 Lab 1 Sept. 2022 CourseNana.COM


CourseNana.COM


CourseNana.COM

For this lab, your work is assessed individually. CourseNana.COM


CourseNana.COM

CourseNana.COM

1. Objectives
In this lab, you will learn
CourseNana.COM

  • AVR instructions, and
  • basic assembly programming.

2. Programming Style CourseNana.COM

The general practice, when you write an assembly program, is to maintain the readability and consistency of your code. For this reason, you are encouraged to adopt the following rules: CourseNana.COM

Starting each source code file with a heading that includes: CourseNana.COM

o your name so that it is easy to see who is responsible for the file, the date of last modification and a version number, and CourseNana.COM

o a description of what the program does, possibly with a pseudo-code for a high-level abstraction. CourseNana.COM

Including appropriate comments that explain the “why", not just the “how" of the program throughout the source code. CourseNana.COM

Using a sensible layout for your code - to make it easy to see the code structure, instructions, and any labels. CourseNana.COM

3. Tasks
There are three tasks in this lab.
CourseNana.COM

3.1 Task 1 (10 marks, due your lab session in Week 3) CourseNana.COM

Write an assembly program to calculate the square root of a one-byte positive number. The result is rounded to integer directly, e.g 7.6 is rounded to 7. CourseNana.COM

Here we assume the input value is stored in register R5, which will be manually set to a value before execution (See explanation on page 5 of Lab 0 on how to set a register value), and the result will be saved in register R6. CourseNana.COM

Run your program in Atmel Studio and demonstrate your work to your tutor. CourseNana.COM

3.2 Task 2 (5 marks, due your lab session in Week 4) CourseNana.COM

The ldi instruction can be used to load a digital character into a register. For example, the instruction, ldi r16, ‘6’, will set the value of register r16 to 0x36, where 0x36 is the ASCII code for character ‘6’ (See the ASCII table shown at the end of this document). CourseNana.COM

Write an assembly program that loads one digital character plus a sign, for a decimal number, into a group of two registers and converts the decimal number to a signed binary number in the 2’s complement format and saves the signed binary in a third register, as illustrated in the figure below, where each block represents a register. CourseNana.COM

ASCII code of 1-digit signed decimal signed binary CourseNana.COM

Figure 1: Decimal number -6 (in ASCII) in a two-register group is converted into signed binary number 11111010 CourseNana.COM

Run your program in AVR Studio and demonstrate your work to your tutor. CourseNana.COM

3.3 Task 3 (15 marks, due your lab session in Week 4) CourseNana.COM

The greatest common divisor (GCD) of two integers can be calculated in a way as given in a C-like pseudo code shown in Figure 2. Based on this calculation approach, write an assembly code to get the GCD of four integers. Here we assume all integers are 16-bit unsigned numbers; They are stored in registers and the values can be set before execution (refer to Page 5 of Lab 0 on how to set a register value). CourseNana.COM

/* below is only part of C function CourseNana.COM

int a, b; CourseNana.COM

while (a!=b) { CourseNana.COM

if (a>b) CourseNana.COM

else CourseNana.COM

/* 16-bit CourseNana.COM

/* Assume a = a - b = b - CourseNana.COM

unsigned integer CourseNana.COM

a, b > 0 */ b;
a;
CourseNana.COM

}
/* a and b both hold the result */ CourseNana.COM

Figure 2: Pseudo Code gcd CourseNana.COM

For this task, you are required to use macro that is discussed in Week 2. CourseNana.COM

Run your program in Atmel Studio and demonstrate your work to your tutor. CourseNana.COM

NOTE: CourseNana.COM

  • You can put your code for each task in the same project in the Atmel Studio for this lab. Run the program for each task by setting it as the entry file, which was explained in Lab 0.
  • All your programs should be well commented and easy to read. Up to 10% marks will be deducted for each program without proper and sufficient comments.
  • Your lab tutor will setup the environment for the assessment in Week 3.

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Australia代写,University of New South Wales代写,UNSW代写,COMP9032代写,Microprocessors and Interfacing代写,AVR Assembly代写,Australia代编,University of New South Wales代编,UNSW代编,COMP9032代编,Microprocessors and Interfacing代编,AVR Assembly代编,Australia代考,University of New South Wales代考,UNSW代考,COMP9032代考,Microprocessors and Interfacing代考,AVR Assembly代考,Australiahelp,University of New South Waleshelp,UNSWhelp,COMP9032help,Microprocessors and Interfacinghelp,AVR Assemblyhelp,Australia作业代写,University of New South Wales作业代写,UNSW作业代写,COMP9032作业代写,Microprocessors and Interfacing作业代写,AVR Assembly作业代写,Australia编程代写,University of New South Wales编程代写,UNSW编程代写,COMP9032编程代写,Microprocessors and Interfacing编程代写,AVR Assembly编程代写,Australiaprogramming help,University of New South Walesprogramming help,UNSWprogramming help,COMP9032programming help,Microprocessors and Interfacingprogramming help,AVR Assemblyprogramming help,Australiaassignment help,University of New South Walesassignment help,UNSWassignment help,COMP9032assignment help,Microprocessors and Interfacingassignment help,AVR Assemblyassignment help,Australiasolution,University of New South Walessolution,UNSWsolution,COMP9032solution,Microprocessors and Interfacingsolution,AVR Assemblysolution,