Linux Format

THE PIC INSTRUCTIO­N SET

-

For low-end chips with only a small amount of program memory, you might choose to program in assembly language instead of C. Here we’re assuming that you’ve already done some assembly coding on a different processor and, for that reason, that you only need to learn about PIC specifics. You’ll easily be able to do that as a self-learning exercise, but a few words on the peculiarit­ies of the PIC 16 series instructio­n set will, hopefully, help you get up to speed.

Higher-end PIC devices differ but the thing you’ll probably find surprising about PIC 16 series chips is that they don’t have any conditiona­l branch instructio­n such as BRZ (Branch if Zero). Certainly the chips have the necessary status bits – specifical­ly zero and carry bits – but a different method is used for conditiona­l flow control.

There are four conditiona­l flow control instructio­ns, all of them causing the next instructio­n to be skipped depending on whether a condition is met. These are BTFSS and BTFSC, which execute a bit test followed by a skip on set or clear, respective­ly, and DECFSZ and INCSFSZ, which execute a decrement or increment, respective­ly, followed by a skip if the result is zero. In most cases, the instructio­n following the conditiona­l instructio­n – the one that may or may not be skipped – will be an unconditio­nal branch, with the result that a PIC 16 assembly program will be slightly more like the proverbial spaghetti code than assembly programs for most other processors.

Newspapers in English

Newspapers from Australia