PIC's call instruction

Status
Not open for further replies.

hantto

Member
Hello!

I've made my own delay subroutine and naturally I want it to be as exact as possible. I use the call instruction to call a smaller delay to get a loger one. I read that the call instruction takes two instruction times to execute. So my question is does it take two instruction times when it jumps to the other place and two instruction times when it jumps back. OR only two instruction times for the whole thing?

Hrm, was that clear enough to understand?
 

The call takes two instructions, I think the return takes only one (as far as I can remember, the datasheet will tell you for sure).
 
I took a look at the datasheet. As I understand it only takes 2 cyckles both jumps together?
 

Attachments

  • call.jpg
    28.5 KB · Views: 520
hantto said:
I took a look at the datasheet. As I understand it only takes 2 cyckles both jumps together?

It says quite clearly there, 'CALL is a two cycle instruction', it doesn't mention 'RETURN' at all - return will take at least one cycle, again the datasheet reference to RETURN will tell you.
 
hantto said:

I've just been and checked the datasheet - RETURN and RETLW are both two cycle instructions as well. So your CALL takes two cycles, and your RETURN takes another two.
 
I think whenever jumping to another instruction, it has to

1-load PCL register with new value
2-fetch the new intruction you wrote..

3-then execute that instruction...

So overall 4 cycles to go to and then back.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…