Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Take a look at the code you downloaded for today’s lab. Notice the lines that

ID: 3876364 • Letter: 2

Question

2. Take a look at the code you downloaded for today’s lab. Notice the lines that begin with .def and .equ followed by some type of expression. These are known as pre-compiler directives. Define pre-compiler directive. What is the difference between the .def and .equ directives? (HINT: see Section 5.1 of the AVR Starter Guide).

3.Take another look at the code you downloaded for today’s lab. Read the comment that describes the macro definitions. From that explanation, deter- mine the 8-bit binary value that each of the following expressions evaluates to. Note: the numbers below are decimal values.

(a) (1 << 3) (b) (2 << 2) (c) (8 >> 1) (d) (1 << 0)

(e) (6 >> 1|1 << 6)

Explanation / Answer

2.) Pre Compiler Directive:- It's a pre defined instruction to the compiler for executing certain tasks.
They are generally faster than inline code instructions and hence must only be used when a particluar statement needs to be executed multiple times.

The DEF directive is used to "Define (registers). With this directive you can assign names to registers.

The EQU directive assigns a value to a label. This label can then be used in later expressions. A label assigned to a value by the EQU directive is a constant and can not be changed or redefined.

2.) << - Left Shift Operator

>> - Right Shift Operator

a) 1<<3 : 1 in binary is 0001 Hence 1<<3 is : 1000 ( 1 shifted to the left 3 times and padded by zeros in the right). so answer is 8

On similar lines,

b) 2<<2: - 8

c) 8>>1:- 4

d) 1<<0:- 1

e) 6>>1 | 1<<6 = 3|64 = 67 ( How?)
| is the OR operator.
Here, all the bit positions where the value is one, will become 1 ( as 1 OR x = 1 ; no matter what is x )

64 = 1000000

3 = 0000011

67 = 1000011

so answer is 67



Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote