Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need some help with code assembly for attiny 1 6 2 6 . I cant seem to do ex 2 . 1 and 2
I need some help with code assembly for attiny I cant seem to do ex and
section init
entry:
ldi rxFF
mov r r
ldi rx
ldi rxCC
mov r r
DO NOT EDIT ABOVE THIS LINE
WARNING:
Do not modify the data in the following registers unless
specified by the exercise:
REx
REx
REx
REx
Ex
Write assembly code to add the numbers and together and
store the result in register R
Hint:
Recall the "ldi" instruction loads a value into a register, and
the "mov" instruction copies a value between registers.
ldi r ; Load into r
ldi r ; Load into r
add r r ; Add r to r
mov r r ; Move the result to r
Write your code for Ex above this line.
mov r r
call avremurout
Ex
Using the "and" instruction, clear only bits and of R
mov r r ; Copy the value of R to R
; Use an "and" instruction to clear the desired bits in R
andi rb ; Clear bits and in R
mov r r ; Move the result back to R if necessary
Write your code for Ex above this line.
mov r r
call avremurout
Ex
Using the "ori" instruction, set only bits and of R
ori rb
Write your code for Ex above this line.
mov r r
call avremurout
Ex
Using exactly one instruction, add to the value of R
Hint:
You can find a full list of arithmetic instructions summarised
in Table of the AVR Instruction Set Manual.
inc r ; Increment the value in r by
Write your code for Ex above this line.
mov r r
call avremurout
Ex
Write assembly code to add to storing the result in
register pair R:Rlow byte in R
ldi rx
ldi rxD
adiw rxC
Write your code for Ex above this line.
mov r r
call avremurout
mov r r
call avremurout
Ex
Follow the steps below to complete this exercise.
Step : Encode the decimal value as a two's complement, bit number.
Step : Write down the result of Step as a hexadecimal literal.
Step : Swap the two nibbles of the hexadecimal literal you wrote in Step
Step : Load the result of Step into register R
ldi rb ; Load the high nibble into r
Write your code for Ex above this line.
mov r r
call avremurout
Ex
Write assembly code to subtract the value in R from using
the "add" instruction, storing the result in R
ldi r ; Load into r
sub r r ; Subtract the value in r from and store the result in r
mov r r ; Move the result to r
Write your code for Ex above this line.
mov r r
call avremurout
Ex
Write assembly code to multiply the number by using the
lsl instruction, storing the result in R
ldi r ; Load the value into R
lsl r ; Multiply R by using the "Logical Shift Left" instruction.
mov r r ; Copy the result from R to R
Write your code for Ex above this line.
mov r r
call avremurout
Ex
Write assembly code to divide the number by using the "asr"
instruction, storing the result in R
ldi rxDB ; Load into rtwos complement
asr r ; Arithmetic shift right to divide by
mov r r ; Move the result to r
Write your code for Ex above this line.
mov r r
call avremurout
Ex
Write assembly code to toggle the most significant bit, and least
significant bits of R
ldi rx ; Load a mask with the most significant bit set binary:
eor r r ; Toggle the most significant bit of r
ldi rxF ; Load a mask with the least significant bits set binary:
eor r r ; Toggle the least significant bits of r
Write your code for Ex above this line.
mov r r
call avremurout
END OF TUTORIAL EXERCISES
DO NOT EDIT BELOW THIS LINE
ldi rx DISPEN PB DISPDP PB
sts x r Set as outputs
sts x r Drive high
break
ldi rx DISPDP PB
ldi rx
loop:
Delay
com r
brne loop
inc r
brne loop
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