Purpose of assembly instructions?

Status
Not open for further replies.

gregmcc

Member
Hi all,

I've started going through a few asm programs to try and understand how all this stuff works and then start my own program. On the following link (https://jap.hu/electronic/cl2-025.zip) there is a file called cl2-025.asm - near the top of the file is:

messages clrf PCLATH
movwf PCL
msg_code dt "enter code: ", 0


From what I've read the PCL and PCLATH are program counters. What is the purpose of the above instructions - why would you want to change the program counter?
 
Hi Gregmmc,

This is a common method for doing table lookups on the PIC... If you were to look at the List file for this program you'd see that the 'dt' assembler directive builds a table of 'RETLW nn' instructions for each character or byte in the 'dt' directive operand... In this case, you enter the 'messages' subroutine with a table index value in the W register and the subroutine returns the table[index] data in W...

I suspect you could get a much better explanation and examples in some of the online tutorials like; https://www.amqrp.org/elmer160/

Regards, Mike
 
Mike,

Thanks for the explanation - makes a lot more sense now

I've also started going though the pic lessons - great link!

Thanks
Greg
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…