PIC Assembly Language Reference - 243 Appendix D: PIC Assembly Language Reference PIC Assembly is the lowest-lev el programming lanugage for Microchip PIC microcontroll ers. These processors are used on the LogoChip and LogoChip modules, the LogoBoard, the PIC Foundation, and every layer in the Tower system. When using PIC Assembly , user programs are entered on a desktop computer and assembled into byte codes that are transferred to the PIC processor through the serial port of the host computer . Our assembly lang uage differs in some ways fro m the commercially-a vailable one . It is designed to be more human-readable than the standard instruction set, and can be easily modied to support other processors while retaining its user-friendly naming scheme. As in all assembly-level programming, computati on is perfor med in an “accumulator” scratch register , which is modied as needed by the different processor instr uctions . The basic instruction for mat uses square brackets to frame each instruction: [instruction argument] Program location labels are dened by plain text, with no brackets: program-label Constants are used to dene memory location s for both built-in registers and variab le storage. A con- stant is dened like this: [const name address] Memory addresses can be denoted either in decimal or hexidecimal format, as indicated by placing a “$” character in front of the number. The status register, at memory location “$03”, is a special one o n the processor . It has user-readab le ags that represent different conditions , which can be triggered by the results of various instructions . In most cases, the two status ags that one would be most concerned with are: • C - The car ry ag, which is set when an instruction overows a register . • Z - The zero ag, which is set when the result of an instruction is “0”.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
PIC Assembly is the lowest-level programming lanugage for Microchip PIC microcontrollers. These
processors are used on the LogoChip and LogoChip modules, the LogoBoard, the PIC Foundation,
and every layer in the Tower system.
When using PIC Assembly, user programs are entered on a desktop computer and assembled into byte
codes that are transferred to the PIC processor through the serial port of the host computer.
Our assembly language differs in some ways from the commercially-available one. It is designed to be
more human-readable than the standard instruction set, and can be easily modied to support other
processors while retaining its user-friendly naming scheme.
As in all assembly-level programming, computation is performed in an “accumulator” scratch register, which is modied as needed by the different processor instructions.
The basic instruction format uses square brackets to frame each instruction:
[instruction argument]
Program location labels are dened by plain text, with no brackets:
program-label
Constants are used to dene memory locations for both built-in registers and variable storage. A con-
stant is dened like this:
[const name address]
Memory addresses can be denoted either in decimal or hexidecimal format, as indicated by placing a
“$” character in front of the number.
The status register, at memory location “$03”, is a special one on the processor. It has user-readable
ags that represent different conditions, which can be triggered by the results of various instructions.
In most cases, the two status ags that one would be most concerned with are:
• C - The carry ag, which is set when an instruction overows a register.
• Z - The zero ag, which is set when the result of an instruction is “0”.
decsz - decrement skip if zeroRegister Manipulation
Description
Decrements the contents of a register and stores the result in the register. If the result of the
operation is zero, the next program instruction is skipped.
Usage Format
[decsz register]
The register argument is the address of any register.
Status Flags Affected
None
ldecsz - load and decrement skip if zeroRegister Manipulation
Description
Decrements the contents of a register and stores the result in the accumulator. If the resultof the operation is zero, the next program intsruction is skipped.
Usage Format
[ldecsz register]
The register argument is the address of any register.