This file is indexed.

/usr/share/gputils/header/p18macro.inc is in gputils-common 1.4.0-0.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
; $Id: p18macro.inc 667 2012-02-25 06:45:59Z borutr $

;==========================================================================
;
;         MACROS
;
;==========================================================================
        LIST


StkSetPtrToOffset macro Ptr,Offset
  ; Set pointer Ptr to argument in stack frame at Offset.
          movlw     LOW(Offset)
          addwf     FSR1L,W,ACCESS
          movwf     Ptr,ACCESS
          movlw     HIGH(Offset&0xFFFF)
          addwfc    FSR1H,W,ACCESS
          movwf     Ptr+1
 endm


StkPushPtrToOffset macro Offset
  ; Push pointer onto stack to point to Offset location in stack.
  ; Offset defined before push.
          movlw     LOW(Offset)
          addwf     FSR1L,W,ACCESS
          movwf     INDF1,ACCESS
          movlw     HIGH(Offset&0xFFFF)
          addwfc    FSR1H,W,ACCESS
          movwf     PREINC1,ACCESS
          movf      POSTINC1,F,ACCESS     ; increment FSR1
 endm



StkAddStackPtr macro N
  ; Add N to FSR1
          movlw     LOW(N)
          addwf     FSR1L,F,ACCESS
          movlw     HIGH(N&0xFFFF)
          addwfc    FSR1H,F,ACCESS
 endm


Stk1PushFromFSR0 macro
  ; Get one byte from FSR0 and push on stack.  FSR0, WREG unchanged.
          movff     INDF0,POSTINC1
 endm

Stk2PushFromFSR0 macro
  ; Get two bytes from FSR0 and push on stack. FSR0, WREG unchanged.
          movff     POSTINC0,POSTINC1
          movff     POSTDEC0,POSTINC1
 endm

Stk3PushFromFSR0 macro
  ; Get three bytes from FSR0 and push on stack. FSR0, WREG unchanged.
          movff     POSTINC0,POSTINC1
          movff     POSTINC0,POSTINC1
          movff     POSTDEC0,POSTINC1
          movf      POSTDEC0,F,ACCESS
 endm



Stk1PushFromFSR2 macro
  ; Get one byte from FSR2 and push on stack.  FSR2, WREG unchanged.
          movff     INDF2,POSTINC1
 endm

Stk2PushFromFSR2 macro
  ; Get two bytes from FSR2 and push on stack. FSR2, WREG unchanged.
          movff     POSTINC2,POSTINC1
          movff     POSTDEC2,POSTINC1
 endm

Stk3PushFromFSR2 macro
  ; Get three bytes from FSR2 and push on stack. FSR2, WREG unchanged.
          movff     POSTINC2,POSTINC1
          movff     POSTINC2,POSTINC1
          movff     POSTDEC2,POSTINC1
          movf      POSTDEC2,F,ACCESS
 endm


Stk1PushFromReg macro Reg
  ; Get one byte from Reg and push on stack.  WREG unchanged.
          movff     Reg,POSTINC1
 endm

Stk2PushFromReg macro Reg
  ; Get two bytes from Reg and push on stack.  WREG unchanged.
          movff     Reg,POSTINC1
          movff     Reg+1,POSTINC1
 endm


Stk3PushFromReg macro Reg
  ; Get three bytes from Reg and push on stack.  WREG unchanged.
          movff     Reg,POSTINC1
          movff     Reg+1,POSTINC1
          movff     Reg+2,POSTINC1
 endm


Stk1PopToFSR0 macro
  ; Pop one byte from stack and put it at FSR0 without exposing stack.
  ; WREG changed, FSR0 unchanged.
          movlw     0xFF
          movff     PLUSW1,INDF0
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
 endm


Stk2PopToFSR0 macro
  ; Pop two bytes from stack and put them at FSR0 without exposing stack.
  ; WREG changed, FSR0 unchanged.
          movlw     0xFE
          movff     PLUSW1,POSTINC0
          movlw     0xFF
          movff     PLUSW1,POSTDEC0
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
 endm

Stk3PopToFSR0 macro
  ; Pop three bytes from stack and put them at FSR0 without exposing stack.
  ; WREG changed, FSR0 unchanged.
          movlw     0xFD
          movff     PLUSW1,POSTINC0
          movlw     0xFE
          movff     PLUSW1,POSTINC0
          movlw     0xFF
          movff     PLUSW1,POSTDEC0
          movf      POSTDEC0,F,ACCESS     ; restore FSR0
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
 endm


Stk1PopToFSR2 macro
  ; Pop one byte from stack and put it at FSR2 without exposing stack.
  ; WREG changed, FSR2 unchanged.
          movlw     0xFF
          movff     PLUSW1,INDF2
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
 endm


Stk2PopToFSR2 macro
  ; Pop two bytes from stack and put them at FSR2 without exposing stack.
  ; WREG changed, FSR2 unchanged.
          movlw     0xFE
          movff     PLUSW1,POSTINC2
          movlw     0xFF
          movff     PLUSW1,POSTDEC2
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
 endm

Stk3PopToFSR2 macro
  ; Pop three bytes from stack and put them at FSR2 without exposing stack.
  ; WREG changed, FSR2 unchanged.
          movlw     0xFD
          movff     PLUSW1,POSTINC2
          movlw     0xFE
          movff     PLUSW1,POSTINC2
          movlw     0xFF
          movff     PLUSW1,POSTDEC2
          movf      POSTDEC2,F,ACCESS     ; restore FSR2
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
 endm


Stk1PopToReg macro Reg
  ; Pop one byte from stack and put it at Reg without exposing stack.
  ; WREG changed.
          movlw     0xFF
          movff     PLUSW1,Ptr
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
 endm



Stk2PopToReg macro Reg
  ; Pop two bytes from stack and put them at Reg without exposing stack.
  ; WREG changed.
          movlw     0xFF
          movff     PLUSW1,Reg+1
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
          movlw     0xFF
          movff     PLUSW1,Reg
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
 endm

Stk3PopToReg macro Reg
  ; Pop three bytes from stack and put them at Reg without exposing stack.
  ; WREG changed.
          movlw     0xFF
          movff     PLUSW1,Reg+2
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
          movlw     0xFF
          movff     PLUSW1,Reg+1
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
          movlw     0xFF
          movff     PLUSW1,Reg
          movf      POSTDEC1,F,ACCESS     ; decrement FSR1
 endm



Stk1CpyToFSR0 macro Offset
  ; Copy one byte from stack frame at Offset to FSR0
  ; WREG changed, FSR0 unchanged.
          movlw     LOW(Offset)
          movff     PLUSW1,INDF0
 endm


Stk2CpyToFSR0 macro Offset
  ; Copy two bytes from stack frame at Offset to FSR0
  ; WREG changed, FSR0 unchanged.
          movlw     LOW(Offset)
          movff     PLUSW1,POSTINC0
          movlw     LOW(Offset+1)
          movff     PLUSW1,POSTDEC0
 endm


Stk1CpyToFSR2 macro Offset
  ; Copy one byte from stack frame at Offset to FSR2
  ; WREG changed, FSR2 unchanged.
          movlw     LOW(Offset)
          movff     PLUSW1,INDF2
 endm


Stk2CpyToFSR2 macro Offset
  ; Copy two bytes from stack frame at Offset to FSR2
  ; WREG changed, FSR2 unchanged.
          movlw     LOW(Offset)
          movff     PLUSW1,POSTINC2
          movlw     LOW(Offset+1)
          movff     PLUSW1,POSTDEC2
 endm

Stk4CpyToFSR2 macro Offset
  ; Copy four bytes from stack frame at Offset to FSR2
  ; WREG changed, FSR2 unchanged.
          movlw     LOW(Offset)
          movff     PLUSW1,POSTINC2
          movlw     LOW(Offset+1)
          movff     PLUSW1,POSTINC2
          movlw     LOW(Offset+2)
          movff     PLUSW1,POSTINC2
          movlw     LOW(Offset+3)
          movff     PLUSW1,POSTDEC2
          movf      POSTDEC2,F,ACCESS
          movf      POSTDEC2,F,ACCESS
 endm


Stk1CpyToReg macro Offset,Reg
  ; Copy one byte from stack frame at Offset to Reg
          movlw     LOW(Offset)
          movff     PLUSW1,Reg
 endm


Stk2CpyToReg macro Offset,Reg
  ; Copy two bytes from stack frame at Offset to Reg
          movlw     LOW(Offset)
          movff     PLUSW1,Reg
          movlw     LOW(Offset+1)
          movff     PLUSW1,Reg+1
 endm


Stk3CpyToReg macro Offset,Reg
  ; Copy three bytes from stack frame at Offset to Reg
          movlw     LOW(Offset)
          movff     PLUSW1,Reg
          movlw     LOW(Offset+1)
          movff     PLUSW1,Reg+1
          movlw     LOW(Offset+2)
          movff     PLUSW1,Reg+2
 endm



Stk1CpyFromFSR0 macro Offset
  ; Copy one byte from FSR0 to stack frame at Offset
          movlw     LOW(Offset)
          movff     INDF0,PLUSW1
 endm


Stk2CpyFromFSR0 macro Offset
  ; Copy two bytes from FSR0 to stack frame at Offset
          movlw     Offset
          movff     POSTINC0,PLUSW1
          movlw     Offset+1
          movff     POSTDEC0,PLUSW1
 endm


Stk3CpyFromFSR0 macro Offset
  ; Copy three bytes from FSR0 to stack frame at Offset
          movlw     Offset
          movff     POSTINC0,PLUSW1
          movlw     Offset+1
          movff     POSTDEC0,PLUSW1
          movlw     Offset+2
          movff     POSTDEC0,PLUSW1
 endm


Stk4CpyFromFSR0 macro Offset
  ; Copy four bytes from FSR0 to stack frame at Offset
          movlw     Offset
          movff     POSTINC0,PLUSW1
          movlw     Offset+1
          movff     POSTINC0,PLUSW1
          movlw     Offset+2
          movff     POSTINC0,PLUSW1
          movlw     Offset+3
          movff     POSTDEC0,PLUSW1
          movf      POSTDEC0,F,ACCESS
          movf      POSTDEC0,F,ACCESS
 endm



Stk1CpyFromFSR2 macro Offset
  ; Copy one byte from FSR2 to stack frame at Offset
          movlw     LOW(Offset)
          movff     INDF2,PLUSW1
 endm


Stk2CpyFromFSR2 macro Offset
  ; Copy two bytes from FSR2 to stack frame at Offset
          movlw     Offset
          movff     POSTINC2,PLUSW1
          movlw     Offset+1
          movff     POSTDEC2,PLUSW1
 endm


Stk4CpyFromFSR2 macro Offset
  ; Copy four bytes from FSR2 to stack frame at Offset
          movlw     Offset
          movff     POSTINC2,PLUSW1
          movlw     Offset+1
          movff     POSTINC2,PLUSW1
          movlw     Offset+2
          movff     POSTINC2,PLUSW1
          movlw     Offset+3
          movff     POSTDEC2,PLUSW1
          movf      POSTDEC2,F,ACCESS
          movf      POSTDEC2,F,ACCESS
 endm




Stk1CpyFromReg macro Reg,Offset
  ; Copy one byte from Reg to stack frame at Offset
          movlw     LOW(Offset)
          movff     Reg,PLUSW1
 endm


Stk2CpyFromReg macro Reg,Offset
  ; Copy two bytes from Reg to stack frame at Offset
          movlw     Offset
          movff     Reg,PLUSW1
          movlw     Offset+1
          movff     Reg+1,PLUSW1
 endm


Stk3CpyFromReg macro Reg,Offset
  ; Copy three bytes from Reg to stack frame at Offset
          movlw     Offset
          movff     Reg,PLUSW1
          movlw     Offset+1
          movff     Reg+1,PLUSW1
          movlw     Offset+2
          movff     Reg+2,PLUSW1
 endm




Stk1Inc macro Offset
  ; Increment byte in stack at Offset
          movlw     Offset
          incf      PLUSW1,F,ACCESS
 endm


Stk2Inc macro Offset
  ; Increment 2 bytes in stack at Offset
          movlw     Offset
          incf      PLUSW1,F,ACCESS
          movlw     Offset+1
        btfsc     STATUS,Z
          incf      PLUSW1,F,ACCESS
 endm


Stk3Inc macro Offset
  ; Increment 3 bytes in stack at Offset
          local jEnd
          movlw     Offset
          incf      PLUSW1,F,ACCESS
          bnz       jEnd
          movlw     Offset+1
          incf      PLUSW1,F,ACCESS
          bnz       jEnd
          movlw     Offset+2
          incf      PLUSW1,F,ACCESS
jEnd:
 endm



Stk1Dec macro Offset
  ; Decrement byte in stack at Offset
          movlw     Offset
          decf      PLUSW1,F,ACCESS
 endm


Stk2Dec macro Offset
  ; Decrement 2 bytes in stack at Offset
          local jEnd
          movlw     Offset
          decf      PLUSW1,F,ACCESS
          bc        jEnd
          movlw     Offset+1
          decf      PLUSW1,F,ACCESS
jEnd:
 endm

Stk3Dec macro Offset
  ; Decrement 3 bytes in stack at Offset
          local jEnd
          movlw     Offset
          decf      PLUSW1,F,ACCESS
          bc        jEnd
          movlw     Offset+1
          decf      PLUSW1,F,ACCESS
          bc        jEnd
          movlw     Offset+2
          decf      PLUSW1,F,ACCESS
jEnd:
 endm


Stk1TestForZero macro Offset,jZero
  ; Test 1 byte at Offset.  Branch if zero.  Returns 0 in WREG if zero.
          movlw     Offset
          movf      PLUSW1,W,ACCESS
          bz        jZero
 endm


Stk2TestForZero macro Offset,jZero
  ; Test 2 bytes at Offset.  Branch if zero.  Returns 0 in WREG if zero.
          local     jContinue
          movlw     Offset
          movf      PLUSW1,W,ACCESS
          bnz       jContinue
          movlw     Offset+1
          movf      PLUSW1,W,ACCESS
          bz        jZero
jContinue
 endm


Stk3TestForZero macro Offset,jZero
  ; Test 3 bytes at Offset.  Branch if zero.  Returns 0 in WREG if zero.
          local     jContinue
          movlw     Offset
          movf      PLUSW1,W,ACCESS
          bnz       jContinue
          movlw     Offset+1
          movf      PLUSW1,W,ACCESS
          bnz       jContinue
          movlw     Offset+2
          movf      PLUSW1,W,ACCESS
          bz        jZero
jContinue
 endm

Stk1AddToFSR0 macro Offset
  ; Add 1 byte in stack at Offset to byte at FSR0. Pointer FSR0 unchanged.
          movlw     Offset
          movf      PLUSW1,W,ACCESS
          addwf     INDF0,F,ACCESS
 endm


Stk2AddToFSR0 macro Offset
  ; Add 2 bytes in stack at Offset to 2 bytes at FSR0.  Pointer FSR0 unchanged.
          movlw     Offset
          movf      PLUSW1,W,ACCESS
          addwf     POSTINC0,F,ACCESS
          movlw     Offset+1
          movf      PLUSW1,W,ACCESS
          addwfc    POSTDEC0,F,ACCESS
 endm


Stk3AddToFSR0 macro Offset
  ; Add 3 bytes in stack at Offset to 3 bytes at FSR0.  Pointer FSR0 unchanged.
          movlw     Offset
          movf      PLUSW1,W,ACCESS
          addwf     POSTINC0,F,ACCESS
          movlw     Offset+1
          movf      PLUSW1,W,ACCESS
          addwfc    POSTINC0,F,ACCESS
          movlw     Offset+2
          movf      PLUSW1,W,ACCESS
          addwfc    POSTDEC0,F,ACCESS
          movf      POSTDEC0,F,ACCESS
 endm


Stk4AddToFSR0 macro Offset
  ; Add 4 bytes in stack at Offset to 4 bytes at FSR0. Pointer FSR0 unchanged.
          movlw     Offset
          movf      PLUSW1,W,ACCESS
          addwf     POSTINC0,F,ACCESS
          movlw     Offset+1
          movf      PLUSW1,W,ACCESS
          addwfc    POSTINC0,F,ACCESS
          movlw     Offset+2
          movf      PLUSW1,W,ACCESS
          addwfc    POSTINC0,F,ACCESS
          movlw     Offset+3
          movf      PLUSW1,W,ACCESS
          addwfc    POSTDEC0,F,ACCESS
          movf      POSTDEC0,F,ACCESS
          movf      POSTDEC0,F,ACCESS
 endm


Stk1AddToFSR2 macro Offset
  ; Add 1 byte in stack at Offset to byte at FSR2. Pointer FSR2 unchanged.
          movlw     Offset
          movf      PLUSW1,W,ACCESS
          addwf     INDF2,F,ACCESS
 endm


Stk2AddToFSR2 macro Offset
  ; Add 2 bytes in stack at Offset to 2 bytes at FSR2.  Pointer FSR2 unchanged.
          movlw     Offset
          movf      PLUSW1,W,ACCESS
          addwf     POSTINC2,F,ACCESS
          movlw     Offset+1
          movf      PLUSW1,W,ACCESS
          addwfc    POSTDEC2,F,ACCESS
 endm


Stk3AddToFSR2 macro Offset
  ; Add 3 bytes in stack at Offset to 3 bytes at FSR2.  Pointer FSR2 unchanged.
          movlw     Offset
          movf      PLUSW1,W,ACCESS
          addwf     POSTINC2,F,ACCESS
          movlw     Offset+1
          movf      PLUSW1,W,ACCESS
          addwfc    POSTINC2,F,ACCESS
          movlw     Offset+2
          movf      PLUSW1,W,ACCESS
          addwfc    POSTDEC2,F,ACCESS
          movf      POSTDEC2,F,ACCESS
 endm


Stk4AddToFSR2 macro Offset
  ; Add 4 bytes in stack at Offset to 4 bytes at FSR2. Pointer FSR2 unchanged.
          movlw     Offset
          movf      PLUSW1,W,ACCESS
          addwf     POSTINC2,F,ACCESS
          movlw     Offset+1
          movf      PLUSW1,W,ACCESS
          addwfc    POSTINC2,F,ACCESS
          movlw     Offset+2
          movf      PLUSW1,W,ACCESS
          addwfc    POSTINC2,F,ACCESS
          movlw     Offset+3
          movf      PLUSW1,W,ACCESS
          addwfc    POSTDEC2,F,ACCESS
          movf      POSTDEC2,F,ACCESS
          movf      POSTDEC2,F,ACCESS
 endm




Stk1ShiftLeft macro Offset
  ; Shift left 1 byte in stack at Offset
          bcf       STATUS,C
          movlw     Offset
          rlcf      PLUSW1,F,ACCESS
 endm


Stk2ShiftLeft macro Offset
  ; Shift left 2 bytes in stack at Offset
          bcf       STATUS,C
          movlw     Offset
          rlcf      PLUSW1,F,ACCESS
          movlw     Offset+1
          rlcf      PLUSW1,F,ACCESS
 endm


Stk4ShiftLeft macro Offset
  ; Shift left 4 bytes in stack at Offset
          bcf       STATUS,C
          movlw     Offset
          rlcf      PLUSW1,F,ACCESS
          movlw     Offset+1
          rlcf      PLUSW1,F,ACCESS
          movlw     Offset+2
          rlcf      PLUSW1,F,ACCESS
          movlw     Offset+3
          rlcf      PLUSW1,F,ACCESS
 endm


Stk1Negate macro Offset
  ; Negate 1 byte in stack at Offset
          movlw     Offset
          comf      PLUSW1,F,ACCESS
          incf      PLUSW1,F,ACCESS
 endm


Stk2Negate macro Offset
  ; Negate 2 bytesin stack at Offset
          movlw     Offset
          comf      PLUSW1,F,ACCESS
          incf      PLUSW1,F,ACCESS
          movlw     Offset+1
          btfsc     STATUS,Z
          decf      PLUSW1,F,ACCESS
          comf      PLUSW1,F,ACCESS
 endm


Stk4Negate macro Offset
  ; Negate 4 bytes in stack at Offset
          local jEnd
          movlw     Offset
          comf      PLUSW1,F,ACCESS
          movlw     Offset+1
          comf      PLUSW1,F,ACCESS
          movlw     Offset+2
          comf      PLUSW1,F,ACCESS
          movlw     Offset+3
          comf      PLUSW1,F,ACCESS

          movlw     Offset
          incf      PLUSW1,F,ACCESS
          bnz       jEnd
          movlw     Offset+1
          incf      PLUSW1,F,ACCESS
          bnz       jEnd
          movlw     Offset+2
          incf      PLUSW1,F,ACCESS
          bnz       jEnd
          movlw     Offset+3
          incf      PLUSW1,F,ACCESS
jEnd:
 endm

Stk1NegateFSR2 macro
  ; Negate 1 byte at FSR2.  FSR2 unchanged.
          comf      INDF2,F,ACCESS
          incf      INDF2,F,ACCESS
 endm


Stk2NegateFSR2 macro
  ; Negate 2 bytes at FSR2.  FSR2 unchanged.
          comf      INDF2,F,ACCESS
          incf      POSTINC2,F,ACCESS
          btfsc     STATUS,Z
          decf      INDF2,F,ACCESS
          comf      POSTDEC2,F,ACCESS
 endm


;====== These branches are short ==============

jmpWeqZ macro   Label        ; jmp if W == 0
        movf      WREG,F,ACCESS
        bz        Label
          endm

jmpWneZ macro   Label        ; jmp if W != 0
        tstfsz    WREG,ACCESS
        bra       Label
          endm


jmpFeqZ macro   Reg,Acc,Label
        movf      Reg,F,Acc
        bz        Label
        endm

jmpFneZ macro   Reg,Acc,Label
        movf      Reg,F,Acc
        bnz       Label
        endm

jmpFeqL macro   Reg,Acc,bVal,Label
          movlw     bVal
          subwf     Reg,W,Acc
        bz        Label
        endm

jmpFneL macro   Reg,Acc,bVal,Label
          movlw     bVal
          subwf     Reg,W,Acc
        bnz       Label
        endm

jmpFleL macro   Reg,Acc,bVal,Label
          movlw     bVal
          cpfsgt    Reg,Acc
        bra       Label
        endm

jmpFgeL macro   Reg,Acc,bVal,Label
          movlw     bVal
          cpfslt    Reg,Acc
        bra       Label
        endm


jmpFeqF macro   Reg1,Acc1,Reg2,Acc2,Label
          movf      Reg1,W,Acc1
          subwf     Reg2,W,Acc2
        bz        Label
        endm

jmpFneF macro   Reg1,Acc1,Reg2,Acc2,Label
          movf      Reg1,W,Acc1
          subwf     Reg2,W,Acc2
        bnz       Label
        endm

jmpClr  macro Reg,Bit,Acc,Label
        btfss   Reg,Bit,Acc
        bra       Label
        endm

jmpSet  macro Reg,Bit,Acc,Label
        btfsc   Reg,Bit,Acc
        bra       Label
        endm