# PIC 18F instructions

#### Dritech

Joined Sep 21, 2011
869
Hi all,

Can someone tell me what is the difference between GOTO and BRA ??
Is there a limit on how many times the GOTO instruction can be used??
And the same for the CALL instruction, is there a limit on many times one can use it?

#### nigelwright7557

Joined May 10, 2008
532
They vary on how far the branch can go.
Look up the instruction set and it will explain in detail.

So long as there is room for code you can use as many calls or goto's that you like.

#### spinnaker

Joined Oct 29, 2009
7,835
They vary on how far the branch can go.
Look up the instruction set and it will explain in detail.

So long as there is room for code you can use as many calls or goto's that you like.
There is instruction set documentation in the back of each Pic datasheet that explains how many Cycles each instruction takes.

How many times can one use call? If you mean in recursion or chained calls then it is going to depend on both your stack size and program memory. If you mean just the number of call instructions you can use then it will depend on program memory. Of course a program of nothing but calls id not going to do too much.

#### Dritech

Joined Sep 21, 2011
869
Hi Spinnaker,

I was going to use the call instruction every time i need to write to the LCD.
The coding i am planning to use is as below:

Rich (BB code):
Main coding
...
...
call lcd1
...
...
call lcd2
...
...

lcd1
display: 'pump on'
return

lcd2
display: 'ump off'
return
Will it be structured/organized correctly if i use the above setup ?

#### spinnaker

Joined Oct 29, 2009
7,835
I'm far from an assembler expert. I have not dealt with it since way back in the days the 6502 was popular and assembler was all we had. Actually in those days it was machine language. We didn't have those fancy assemblers.

I program in C now. But I see nothing wrong with doing it the way you want. Have you considered C? It is so much easier.

#### MrChips

Joined Oct 2, 2009
22,114
What you show is ok.

#### Dritech

Joined Sep 21, 2011
869
Have you considered C? It is so much easier.
Since im a beginner in programming, i prefer starting using assembly.

#### LDG

Joined Feb 10, 2012
4
;Write to Display ******************Sub Routines ***************
DatWr
movwf PORTB ;put data on PORTB
bsf PORTC,3 ;select data reg
bcf PORTC,4 ;write mode
call EPulse
return

CmdWr
movwf PORTB ;put command on PORTB
bcf PORTC,3 ;select command reg
bcf PORTC,4 ;select write mode

EPulse ;pulse Eanble on display
bsf PORTC,5 ;enable pulse high
call TPulse
bcf PORTC,5 ;enable pulse low
call TPulse
return

TPulse
movlw H'FF'
movwf 0x6E
TP2
movlw H'0F'
movwf 0x6F
Decp
decfsz 0x6F,1
goto Decp
Decp2
decfsz 0x6E,1
goto TP2
return

Last edited: