Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

tips below: Question 1 This question is about the Status Register (SREG) and branch instructions of the AVR architecture. (1) Find a case in byte

image text in transcribed

image text in transcribed

tips below:

image text in transcribed

Question 1 This question is about the Status Register (SREG) and branch instructions of the AVR architecture. (1) Find a case in byte addition that set flags Z, C and V in SREG at the same time. 4 (2) Use the flags in SREG, form the conditions for two hypothetical branch in- structions "BRHI" (branch if higher for unsigned values) and "BRLE" (branch if less or equal for signed values). 5 (3) Suppose we extend the SREG with three more flags NZ, NC, NS. They are used to store the previous values of flags Z, C and S, respectively. In this way, we can actually use two compare instructions together to support more sophis- ticated branch instructions. For example, we can test if a value (e.g., in R16) is in range [2,5) by: cpi R16, 2 cpi R16, 5 If R16-3, we know that Z=0, C=1. S=1 (since R16 5) and NZ = 0, NC=0, NS-0 (since R162 2). Please use the flags in this extended SREG to form the conditions for two hypothetical branch instructions "BRRU" (branch if in range for unsigned value) and "BRRS (branch if in range for signed value)? [6] For (1): Think the condition to make Z-1 and C-1. Since the addition result is 0 (for Z-1), to have an overflow (V-1), we need to add two negative values together. For (2) and (3): A combination of flag expression is needed. Remind, C flag is checked fro unsigned branch, S flag for signed branch. Question 1 This question is about the Status Register (SREG) and branch instructions of the AVR architecture. (1) Find a case in byte addition that set flags Z, C and V in SREG at the same time. 4 (2) Use the flags in SREG, form the conditions for two hypothetical branch in- structions "BRHI" (branch if higher for unsigned values) and "BRLE" (branch if less or equal for signed values). 5 (3) Suppose we extend the SREG with three more flags NZ, NC, NS. They are used to store the previous values of flags Z, C and S, respectively. In this way, we can actually use two compare instructions together to support more sophis- ticated branch instructions. For example, we can test if a value (e.g., in R16) is in range [2,5) by: cpi R16, 2 cpi R16, 5 If R16-3, we know that Z=0, C=1. S=1 (since R16 5) and NZ = 0, NC=0, NS-0 (since R162 2). Please use the flags in this extended SREG to form the conditions for two hypothetical branch instructions "BRRU" (branch if in range for unsigned value) and "BRRS (branch if in range for signed value)? [6] For (1): Think the condition to make Z-1 and C-1. Since the addition result is 0 (for Z-1), to have an overflow (V-1), we need to add two negative values together. For (2) and (3): A combination of flag expression is needed. Remind, C flag is checked fro unsigned branch, S flag for signed branch

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

Students also viewed these Databases questions