Question

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 H0A Equates are good for defining literals CBLOCK H20 Count1 Count2 Scratch A CBLOck defines a sequential regio:n ; Count1 is in location H20 ; Count2 is in location H21 ; Scratch is in lication H22 ; ENDC ends the definition block ENDC ORG 0x0000 GOTO Init Init ORG 0x0008 BSF STATUS, RPO CLRF TRISB CLRF ANSEL BCF STATUS, RPO SetScr MOVLW H01 MOVWF Scratch MainLoop MOVF Scratch, W MOVWF PORTB Begin Delay Loop MOVLW Count2 MOVWF Index2 Loop MOVLW Count1 MOVWF Index1 SubLoop NOP NOP DECFSZ Index1, F GOTO SubLoop DECFSZ Index2, F GOTO Loop End Delay Loop RRF Scratch, F ANDWF Scratch, F BTFSC STATUS, Z GOTO SetScr GOTO MainLoop Finish END

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

Answer :- CBLOCK in PIC assembly has the same meaning as the ENUM in C language. So the value held by variable Count1 and Count2 are 32 and 33 respectively(decimal value).

The MOVLW, MOVF and NOP instructions take 1 MC,
GOTO instruction takes 2 MC,
DECFSZ takes 1 MC if result is not zero, else it takes 2 MC.

Begin Delay Loop MOVLW Count2 1MC MOVWF Index2- 1 MC Loop MOVLW MOVWF Index1 Count 1 2 MC for 33 times = 66 MC SubLoop NOP 2


Add a comment
Know the answer?
Add Answer to:
Determine exactly how many instruction cycles the delay loop in the code below (between the comment...
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
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