(a) (b) Write an PIC18 instruction sequence to implement the following mathematical expression. R = (P-Q)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(a) (b) Write an PIC18 instruction sequence to implement the following mathematical expression. R = (P-Q)² The variables P and Q are single-byte numbers stored at file registers 0x010 and 0x020, respectively. The double-byte answer, R should be stored at file registers 0x150 and Ox151 using little endian format. Write a subroutine to compare two 8-bit unsigned numbers stored in PRODH and PRODL, and return the smallest between the two in PRODL to the main program. The subroutine should be named getMIN and should start at address 0x003000. Refer to Figure 2 for an example of how the subroutine could be used in main program. SETF _next MOVFF ; partial coding of a main program showing how the subroutine ; getMIN is used TBLRD*+ MOVFF CALL MOVEF DECFSZ BRA ... min_num, A min_num, PRODL [5 Marks] TABLAT, PRODH getMIN, FAST PRODL, min_num lp_cnt, F, A _next - [5 Marks] ; initialize ; put current min into PRODL Figure 2: Incomplete assembly program for Question 3(b). ; copy element into PRODH ; call subroutine to get min number ; update current min (a) (b) Write an PIC18 instruction sequence to implement the following mathematical expression. R = (P-Q)² The variables P and Q are single-byte numbers stored at file registers 0x010 and 0x020, respectively. The double-byte answer, R should be stored at file registers 0x150 and Ox151 using little endian format. Write a subroutine to compare two 8-bit unsigned numbers stored in PRODH and PRODL, and return the smallest between the two in PRODL to the main program. The subroutine should be named getMIN and should start at address 0x003000. Refer to Figure 2 for an example of how the subroutine could be used in main program. SETF _next MOVFF ; partial coding of a main program showing how the subroutine ; getMIN is used TBLRD*+ MOVFF CALL MOVEF DECFSZ BRA ... min_num, A min_num, PRODL [5 Marks] TABLAT, PRODH getMIN, FAST PRODL, min_num lp_cnt, F, A _next - [5 Marks] ; initialize ; put current min into PRODL Figure 2: Incomplete assembly program for Question 3(b). ; copy element into PRODH ; call subroutine to get min number ; update current min
Expert Answer:
Answer rating: 100% (QA)
Based on Part a of the question provided in the image the task is to write a PIC18 assembly language instruction sequence that implements the mathemat... View the full answer
Related Book For
College Mathematics for Business Economics Life Sciences and Social Sciences
ISBN: 978-0321614001
12th edition
Authors: Raymond A. Barnett, Michael R. Ziegler, Karl E. Byleen
Posted Date:
Students also viewed these programming questions
-
Write Verilog code to implement the following state table. Use two always blocks. State changes should occur on the falling edge of the clock. Implement the Z 1 and Z 2 outputs using concurrent...
-
As programs become more complex, it becomes increasingly important to plan or "design" your code before writing it. Designing your code will help you organize its logic. It will also help you keep...
-
How has HR's role as a strategic partner in organizations evolved? How have metrics contributed to HR's role as a strategic partner, if at all? Discuss whether you think HR as a strategic partner is...
-
Coal shipments from a mine for the past 18 weeks are: a. Plot the data as time series, determine the pattern, and explain why an averaging technique would not be appropriate in this case. b. Use an...
-
Quilts R Us (QRU) is considering investing in a new patterning attachment with the cash flow profile shown in the table below. QRU's MARR is 13.5 percent/year. a. What is this investment's external...
-
Angela Moss and Autumn Barber organize a partnership on January 1. Mosss initial net investment is $75,000, consisting of cash ($17,500), equipment ($82,500), and a note payable reflecting a bank...
-
. Do policies exist within the Linux workstation or server environment? If so, what are they? . Are there ways that Windows policies can be leveraged to enhance corporate or security policy?
-
How might male and female communication styles differ across cultures?
-
A male employee prominently posts a centerfold from a female pornographic magazine.
-
What advice would you give me if I had an HRM position in your country?
-
A female supervisor frequently praises the work of a highly competent male employee.
-
What were the greatest difficulties in adapting to this new culture?
-
Describe your countrys culture in terms of form of government, emphasis on individuals versus groups, roles of women in the workforce, benefits provided to employees, and how employees are treated.
-
We want to fit a logistic regression model to some data. The model is of the form y = ho(x) = o(0o + 01x1 + 02x2), and the error function for m datapoints is given by E(0) = -log[II, (ho(x'))"" (1...
-
Which of the following is NOT a magnetic dipole when viewed from far away? a) A permanent bar magnet. b) Several circular loops of wire closely stacked together with the same current running in each...
-
Solve Problem Graphically to two decimal places using a graphing calculator. 3.4 + 2.9x - 1.1x2 0
-
In Problem, test each pair of events for independence: C and F
-
In Exercise, state the linear inequality whose graph is given in the figure. Write the boundary-line equation in the form Ax + By = C, where A, B, and C are integers, before stating the inequality.
-
Determine the solutions of the difference equations below, supposing that the systems they represent are initially relaxed: (a) \(y(n)-\frac{1}{\sqrt{2}} y(n-1)+y(n-2)=2^{-n} \sin \left(\frac{\pi}{4}...
-
Find the general solution for the difference equation in Example 1.9 when \(a=b\). Example 1.9. Solve the difference equation y(n) + ay(n 2) = b" sin(n)u(n) assuming that ab and y(n) = 0, for n < 0....
-
Show that a system described by Equation (1.63) is linear if and only if the auxiliary conditions are zero. Show also that the system is time invariant if the zero auxiliary conditions are defined...
Study smarter with the SolutionInn App