Close
0%
0%

Ben's PIC nested if macros

PIC assembly is fun, but GOTOs suck. I wrote this macro library that lets you write nested IF blocks, just like C or other languages.

Similar projects worth following
Working with PIC assembly can be pretty fun, but sometimes making up names for loop/condition labels and keeping track is just a pain. So I wrote this macro library that lets you write nested IF blocks, just like C or other languages.

This is a runtime if macro library. It compiles into
real run-time evaluated nested if blocks. I use it for
just about everything and I hope you will too.

Enjoy this project?

Share

Discussions

matseng wrote 11/25/2016 at 15:39 point

How come there are NOPs after every goto? I don't remember doing that the last time I wrote assembly for the 10 or 16 series - butvitcwas a few years ago so I might have forgotten all about it. ;-)

  Are you sure? yes | no

Ben Hencke wrote 11/25/2016 at 18:17 point

Those nops are actually the 2nd word of the GOTO instructions. This was compiled targeting a pic18f series chip which uses 2 words (4 bytes) per GOTO so that it can support up to 2M of flash addresses. The disassembler reads the 2nd word back as a NOP.  On 16f series chips GOTOs use 1 word. 

There are some brach instructions in the 18f series that take 1 word, but are limited to certain relative address ranges.

  Are you sure? yes | no

matseng wrote 11/26/2016 at 01:12 point

Ah... The 18f.... That explains it. I've never coded in assembly for them, only C. The one's that I do assembly for have an 11bit address field + the pclath register as the destination.

But isn't there a disassembler that can generate and display properly formatted "source" for the two-byte gotos?

  Are you sure? yes | no

Ben Hencke wrote 11/26/2016 at 19:27 point

@matseng, I was just using the Window -> PIC Memory Views -> Program Memory, the disassembly view seems to hide labels (part of what I was trying to demo) but doesn't show any NOPs

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates