Alan B. Pearce wrote: > > I've written a ton of PIC assembler and am getting tired > > of getting the btfsx sense wrong or being in the wrong bank. > > This is why I use Olins macros. The conditional macros seem to make more > sense, and the banking macros produce code only if they need to (although > there are still occasions where you can get caught out). Yes. To prevent that, I went one step further and wrote a simple preprocessor (a Perl script, see below) that allows me to "declare" the banked symbols. Whenever an instruction makes a reference to such a symbol, this preprocessor inserts Olin's macro call ahead of it. Even this isn't foolproof -- for example, if you reference one of those symbols immediately after a skip instruction and the macro inserts something there. The workaround for that is to explicitly put a dbankif *ahead* of the skip to insure that the macro inserted by my script won't generate any code. At some point, it just becomes simpler to write a compiler. Currently, I'm running two different Perl scripts over the code (hence the reference to "2nd pass" below), then Olin's "prepic" preprocessor, then all of the macros get expanded before the actual assembly happens. Fortunately, this is all managed by a Makefile, so my workflow is actually fairly simple. -- Dave Tweed ========================================================================= #!perl -w use strict; use vars qw/%bankmap/; # preprocessor 2nd pass for PIC assembly language # keeps track of symbols and what bank they're in, inserting bank-switching # directives where needed # If a line contains the pattern "banksym ", it is deleted # from the source code and the relationship is memorized. # If any subsequent line contains , a "dbankif " line is # inserted ahead of it. while (<>) { if (/^\s*banksym\s+(\w+)\s+(\w+)\s*$/) { $bankmap{$2} = $1; } else { (my $temp = $_) =~ s/;.*//; for my $sym (keys %bankmap) { if ($temp =~ /\b$sym\b/) { print " dbankif $bankmap{$sym}\n"; last; } } print; } } ========================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist