Question

#include <p18F8722.inc>                              radix     dec sum_hi  &n

#include <p18F8722.inc>

                             radix     dec

sum_hi               set         0x01

sum_lo               set         0x00

lp_cnt                  set         0x02                   

kk                         equ       D'50'

                             org        0x00

                             goto      start

                             org        0x08

                             retfie

                             org        0x18

                             retfie

start                    movlw kk

                             movwf lp_cnt

                             clrf         sum_hi,A

                             clrf         sum_lo,A

                             movlw upper(array)

                             movwf TBLPTRU,A

                             movlw high(array)

                             movwf TBLPTRH,A

                             movlw low(array)

                             movwf TBLPTRL,A

loop                     tblrd*+

                             btfsc      TABLAT,0,A

                             goto      next

                             movf     TABLAT,W,A

                             addwf   sum_lo,F,A

                             clrf         WREG,A

                             addwfc sum_hi,F,A

next                     decfsz   lp_cnt,F,A

                             goto      loop

                             nop

array                   db          01,02,03,04,05,06,07,08,09,10

                             db          11,12,13,14,15,16,17,18,19,20

                             db          21,22,23,24,25,26,27,28,29,30

                             db          31,32,33,34,35,36,37,38,39,40

                             db          41,42,43,44,45,46,47,48,49,50

              end

Write or alter the code above to determine the smallest unsigned byte in the array below, and put the result in 0x50 of the Access file register.

array db 14,09,59,52,15,36,07,48,29,11

db 15,22,13,94,45,16,47,28,49,23

db 44,52,83,74,25,26,29,78,39,60

db 31,42,33,34,04,36,37,38,39,41

db 51,42,13,54,45,26,37,42,19,40

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <p18F8722.inc>

                             radix     dec

sum_hi               set         0x01

sum_lo               set         0x00

lp_cnt                  set         0x02                 

kk                         equ       D'50'

                             org        0x00

                             goto      start

                             org        0x08

                             retfie

                             org        0x18

                             retfie

start                    movlw kk

                             movwf lp_cnt

                             clrf         sum_hi,A

                             clrf         sum_lo,A

                             movlw upper(array)

                             movwf TBLPTRU,A

                             movlw high(array)

                             movwf TBLPTRH,A

                             movlw low(array)

                             movwf TBLPTRL,A

loop                     tblrd*+

                             btfsc      TABLAT,0,A

                             goto      next

                             movf     TABLAT,W,A

                             addwf   sum_lo,F,A

                             clrf         WREG,A

                             addwfc sum_hi,F,A

next                     decfsz   lp_cnt,F,A

                             goto      loop

                             nop

array   db   14,09,59,52,15,36,07,48,29,11

           db 15,22,13,94,45,16,47,28,49,23

           db 44,52,83,74,25,26,29,78,39,60

           db 31,42,33,34,04,36,37,38,39,41

           db 51,42,13,54,45,26,37,42,19,40

           len dw $-array
         
           short db ?

end start

            
end

Add a comment
Know the answer?
Add Answer to:
#include <p18F8722.inc>                              radix     dec sum_hi  &n
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Determine exactly how many instruction cycles the delay loop in the code below (between the comment...

    Determine exactly how many instruction cycles the delay loop in the code below (between the comment lines Begin Delay Loop and End Delay Loop) takes as a function of the variables Count1 and Count2. **Please Explain** MaxCount EQU H'0A Equates are good for defining literals CBLOCK H'20 Count1 Count2 Scratch A CBLOck defines a sequential regio:n ; Count1 is in location H'20 ; Count2 is in location H'21 ; Scratch is in lication H'22 ; ENDC ends the definition block...

  • Consider the following assembly language code. The clock frequency is 4 MHz- and all initialization steps...

    Consider the following assembly language code. The clock frequency is 4 MHz- and all initialization steps have been done correctly (like setting up digital I/O, the oscillator configuration, etc.) Constants Bit Pattern EQU H'20' LoopCtr EQU H'21' Max Count EQU .23; Main program loop MainLoop CLRF BitPattern CALL Output BSF BitPattern, 1 CALL Output RRF BitPattern CALL Output BSF BitPattern, 1 CALL Output GOTO MainLoop Output MOVF BitPattern, W MOVWF PORTB MOVLW MaxCount MOVWF LoopCtr Loop NOP DECFSZ LoopCtr GOTO...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT