Question
Data Memory Map Address Offset Data 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Data Memory Map | ||
Address | Offset | Data |
0 |
|
|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 | 0 |
|
33 | 1 |
|
34 | 2 |
|
35 | 3 |
|
36 | 4 |
|
37 | 5 |
|
38 | 6 |
|
Objective
Learn the basic structure of an assembly program, how to read the 8-bit instruction set reference and become familiar with a few commands.
Lab
Task 1: Walk through the assembly program below and fill out the data memory map (right). If a value changes during the program, you only need to record the final value. Unless otherwise stated all memory locations contain a value of 0.
;Program for task 1
;Definitions
.EQU myData=0x21
.DEF config=R4
;Main
.CSEG
.ORG 0x0000
LDI R16, 0b00001000
MOV R0, R16
LDI R16, 0b10010011
MOV R1, R16
LDI R16, 0b01010101
ANDI R16, 0b00001111
MOV R2, R16
ORI R16, 0b10100101
LDI R17, 20
ADD R17, R16
MOV R3, R16
MOV config, R17
OUT 0, R3
CBI 0, 1
IN R5, 0
STS myData, R0
SBI 1, 6
SBI 1, 7
LDS R6, myData
Task 2: In a few sentences, describe what is being done with the program below. Make sure to use specific data values and addresses.
;Program for task 2
;Definitions
.equ myBit=4
.def temp=R16
;Some data storage
.dseg
someData:
;Main
.cseg
ldi temp, 0b11110000
ldi R17, 3
add temp, R17
sts someData, temp
Task 3: Write an assembly program that computes the value of a function. Your program can assume the input has already been stored in R16 prior to your program running. Without modifying R16, make a calculation using the following equation. (Hint: Use the ADD, SUB, and MUL commands)
f(x) = x2-x+1 where x=R16
Store the value f(x) in SRAM at address 0x100. You can ignore overflows and carry bits.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started