USING MPLAB
I'm loooking for step by step explanation. It is desired to write a subroutine in PIC18F assembly language to compute Z = X1 + X2+ X3 +...+ X8 Assume the X's are unsigned 8-bit and stored in consecutive locations starting at Ox50. Assume FSR1 points to the Xi's. Also, write the main program in PIC18F assembly language to perform all initializations (FSR1 to 0x30, STKPTR to 5), call the subroutine, and then compute Z/8. Discard the remainder. Use FSR1 to point to the X₂. Fill the subroutine suma) with assembly code to perform Z = X₂ In your main program, perform after calling suma
#include <xc.inc> goto start N Z X equ 0x00 equ 0x60 equ 0x50 stop: ; Lab 2 Prelab psect code start: ; load location Ox50 to 0x57 with arbitrary numbers for testing ; you should also use "Memory Fill" to test it with zeros, ones, or even random numbers 0, X sum8: end ; Number of X's ; Final answer is stored here ; Starting point of Xi array FSR1 movlw 1 movwf movlw 2 movwf POSTINCO, a movlw 3 movwf POSTINCO, a movlw 4 POSTINCO, a movwf POSTINCO, a movlw 5 movwf POSTINCO, a movlw bra 6 movwf POSTINCO, a movlw 7 movwf movlw movwf POSTINCO, a 8 POSTINCO, a ; TODO: Your main program code starts here ; - Use FSR1 to point to Xi ; - Call sum8 to generate the sum Divide the resulting sum by 8 using rotate right with carry (you should reset the carry after each rotation) stop : TODO: Your subroutine program codes goes here
USING MPLAB
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am