SECTION VI-18: Coming from other microprocessors to the PIC18

If you have a background in programming other microprocessors / microcontrollers, making the transition from these devices to the PIC18 can be easier if we remember some facts about the PIC18. They are mentioned below:

  • The access bank section of the register of the PIC18 with its address range of 00 - 7FH can be viewed as large a number of registers, except they do not have names like other processors. We can assign any register names we want, however, as long as we are not using any of the reserved names used by special funstion registers, WREG, and so on. Here is an example if we are used to the 8051 or some other RISC processor.

 

R0 EQU 0
R1 EQU 1
R2 EQU 2
R3 EQU 3
.... .... ....

 

Or look at the following for the x86:

 

BL EQU 0
BH EQU 1
CL EQU 2
CH EQU 4
DL EQU 5
DH EQU 6

 

In both of the above we can use any fileReg address of 00 - 7FH.

  • WREG is exactly like the accumulator in other microprocessors. It must be involved in all arithmetic and logic operations.
  • To move data to locations in the file register or special function register, we must first move it to WREG. We use the MOVLW instruction first to load the value into the WREG and then use MOVWF to move it to a desired location in the fileReg. No value can be moved directly to SFR or fileReg.

 

More From Iamtechnical.com

Advertisement:

SiteLock