Aadi
Aadi

Reputation: 65

Interpreting PIC Instruction Words

I'm a second year Electrical & Computer Engineering student at the UWI. I am currently learning the PIC 16F877 Microcontroller and its programming in mainly ASM (with little C) and am confused regarding symbols in its instruction set. Now I understand that instructions may follow varying formats (depending on number of operands, word-size of instruction), however I cannot seem to figure out what the (highlighted) symbols are referring to (yes I understand it's the MSB and LSB of the word, just that I don't know why they're labelled in the way they are, or what they mean)

Section 5 -Table 5-1: Mid-Range MCU Instruction Set, PIC Micro Mid-Range Reference Manual:

Section 5 -Table 5-1: Mid-Range MCU Instruction Set, PIC Micro Mid-Range Reference Manual

Upvotes: 0

Views: 833

Answers (2)

EBlake
EBlake

Reputation: 755

I'm not familiar with that particular document, but I've used the equivalent document for other families of PIC devices. If you look above the table you have highlighted, you should find a section/table describing the meaning of the various shorthand codes used to describe the instruction set (d, f, etc.).

===============

Edit - someone downvoted this answer, so I looked at the document in question. I was wrong: the answer to the question was not above, it was below.

On the page immediately following the one quoted by the OP, in section 5.2, we find figure 5.1 "General Format for Instructions" which explains the meaning of d, f, k, etc.

enter image description here

Upvotes: 0

Ped7g
Ped7g

Reputation: 16606

It's the opcode structure in binary, 14 bits per instruction.

I.e. ADDWF f, d for f=127 and d=1 will be encoded as 00 0111 1111 1111 (07FF opcode in hexadecimal), the "f" and "d" symbols are the arguments of the instruction (for f=48 and d=0 the ADDWF opcode would be 00 0111 0011 0000 = 0730 in hexadecimal).

The "x" in CLRW means probably "anything", the already defined bits are decisively identifying the CLRW instruction and the remaining "x" bits are ignored.

I don't know PIC assembly, so I may be wrong with the "x", but I would be super surprised. Is it this CPU with non-8/16/32 word memory structure, addressing memory by 14 bit words? Makes a bit more difficult to quickly asses memory amount, if you are used to 8 bit bytes and count data/memory according to those.

Upvotes: 1

Related Questions