Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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? :)
 
hantto said:
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?

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
    call.jpg
    28.5 KB · Views: 519
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.
 
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top