Question: E5.1 and E5.2 The 16-bit stack pointer (SP) points to the byte above the top byte of this stack. The user can push data into

E5.1 and E5.2
The 16-bit stack pointer (SP) points to the byte above the top byte of this stack. The user can push data into the stack and pop data out of the stack. When making subroutine calls, the caller may need to pass certain values required by the subroutine for performing the intended operation. After the computation is completed, the subroutine returns the result back to the caller. Incoming parameters may be passed in regis- ters, data memory (global memory), or the stack. The computation result may be returned in registers, data memory (global memory), or the stack. The subroutine also may need temporary variables for computation purpose. These temporary variables are called local variables and should be allocated in the stack to avoid interference among subroutines. However, for the following two reasons the programmer should assign local variables to registers as much as possible - The AVR instruction set can perform arithmetic and logic operations only on registers. b- routine, assigning local variables to registers, and using registers to return computation results. " The AVR has many CPU registers to be assigned to local variables. The programmer should follow certain rules in using registers to pass parameters to su This text follows the register usage recommendation specified in Table 5.1. The AVR provides only 8-bit by 8-bit multiplication instructions. However, the program- mer can write subroutines to implement multiprecision multiplication and division operations, as demonstrated in this chapter. xercises E5.1 Write a subroutine that can create a time delay that is a multiple of 1 ms. The multiple is passed in register r16, assuming that the CPU clock is 16 MH:z. E5.2 Write a subroutine that can passed in r16, assuming that the CPU clock is 16 MHz create a time delay that is a multiple of 10 ms. The multiple is l integer into another 16-bit signed int
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
