A Programmer’s view of the PIC

What is a programmer?

In the world of embedded systems, a programmer can be a person who writes software for a microcontroller or a device for downloading programs onto a microcontroller.

Useful documents

Harvard architecture

Just the number

A little detail

Special Function Registers are similar to the memory-mapped I/O of larger processors. Program Space Visibility is similar to virtual memory.

Registers

The Special Function Registers are similar to two types of registers found in larger computers.

The PIC processor also contains shadow registers (see the programmer view on page 19).

PIC SFR’s are described in great detail in the processor data sheet (starting at page 29).

Assembling language programming

You can write the following on the PIC.

     MOV   X,W9
     ADD   W9,#4,W10
     MOV   W10,Y
     BRA   NZ,FACT

But every one of the following instructions are illegal on the PIC processor used in class.

     MOV   X,Z
     ADD   W7,#57,W3
     MUL   W9,#4,W10
     BRA   W3,NZ,FACT

More more thing about integers

On the PIC processor stores integers in 16 bits or 2 addressable bytes. If 2013, also known as 0x7DD, is stored in two bytes starting at memory location 0xA00; what is stored in byte 0xA00 and what is stored in byte 0xA01.

In a little-endian computer, such as the PIC or Intel x86-64, byte 0xA00 contains value 0xDD and byte 0xA01 contains value 0x07. It’s the other way around on a big-endian computer.

The Network byte order of the Internet Protocol is big-endian. Programmers writing low-level networking code have to call routines such as htons to avoid misunderstandings.