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.

12 Bit Instruction Opcodes

Status
Not open for further replies.

Suraj143

Active Member
In 84A I can write a "CALL" or "GOTO" in any place in the program.

I need to know about the "CALL" instruction & the "GOTO" instruction with this chip? I don't think it can use in any place in the program.
 

Attachments

  • Program Counter.PNG
    Program Counter.PNG
    71.8 KB · Views: 152
Hi,
Just checked the datasheet:
GOTO Unconditional Branch
Syntax: [ label ] GOTO k
Operands: 0 ≤ k ≤ 511
Operation: k → PC<8:0>;
STATUS<6:5> → PC<10:9>
Status Affected: None
Encoding: 101k kkkk kkkk
Clearly stated here that 'goto' instruction will affect the first 9 bits in the program memory, branching for more than 9 bits will need to write into bit 9 and 10 of program counter, via STATUS register bit 5 and 6. This is also known as paging.
 
Hi bananasiong thanks for that.

I have PIC16F54.Its memory is 512 bytes.That means I can apply GOTO in any place in the program.

Then what about the "CALL"

I have a subroutine near the end part of the program & I need to call that in the beginning.Can I use "CALL "?
 
Hi,
Check page19 on the datasheet:
Note: Because PC<8> is cleared in the CALL
instruction or any modified PCL instruction,
all subroutine calls or computed
jumps are limited to the first 256 locations
of any program memory page (512 words
long).
So the subroutine should be placed in the first 256 words :)
 
Hi bananasiong if I place my subroutine in the first part of the program can I call it from anywhere in my program?
 
Yes. As long as the subroutine is in the first 256 words. When a CALL is executed, bit 8 of the program counter is cleared (refer to the datasheet under instruction set).
 
You can place subroutines in the second page but you have to call them via a vector (goto) in the first page.

I.E.
Code:
	org	0
Sub	goto	Sub1

	.
	.
	call	Sub
	.
	.


	org	0x100
Sub1	...
	return

Mike.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top