<div dir="ltr"><div>HI Ritchie,</div><div>I just write in assembly and use much (in all my firmware) BRA Wx statement.</div><div>It works perfectly.</div><div>An example of code:</div><div><div><br></div><div><span class="" style="white-space:pre"> </span>bra<span class="" style="white-space:pre"> </span>W0</div><div><span class="" style="white-space:pre"> </span>bra<span class="" style="white-space:pre"> </span>LED_SawPositive<span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>bra<span class="" style="white-space:pre"> </span>LED_SawNegative</div><div><span class="" style="white-space:pre"> </span>bra<span class="" style="white-space:pre"> </span>LED_SQUARE<span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>bra<span class="" style="white-space:pre"> </span>LED_Triangle</div><div><span class="" style="white-space:pre"> </span>bra<span class="" style="white-space:pre"> </span>LED_SINE</div><div><span class="" style="white-space:pre"> </span>bra<span class="" style="white-space:pre"> </span>LED_SquaredSine</div><div><span class="" style="white-space:pre"> </span>bra<span class="" style="white-space:pre"> </span>LED_Pulse</div><div><span class="" style="white-space:pre"> </span>bra<span class="" style="white-space:pre"> </span>LED_Noise</div><div>;---------------------------------</div><div>LED_SawPositive:</div><div>......</div><div><span class="" style="white-space:pre"> </span>bra<span class="" style="white-space:pre"> </span>TSEnd</div><div>;---------------------------------</div><div>LED_SawNegative:</div><div>....<span class="" style="white-space:pre"> </span></div><div>....</div><div>....</div></div><div><br></div><div><div>Usually I build everything in one file, but have written a program where there was an include code.</div><div>I put the "include" just after the start, within the program area.</div></div><div><br></div><div>regards,</div><div>Vinicius</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 22, 2016 at 2:16 PM, Richie Burnett <span dir="ltr"><<a href="mailto:rburnett@richieburnett.co.uk" target="_blank">rburnett@richieburnett.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Has anyone else here using Microchips DSPIC tried to implement a computed branch using the "BRA w0" instruction ?<br>
<br>
No matter what I do, I can't get it to work as explained in the programmers reference guide description of the BRA instruction. It says that it should jump to the address (PC+2) + (2*w0) (which makes sense because the program counter would already be ready to pre-fetch the next instruction, and instructions are aligned on 2-word boundaries,) but instead it seems to jump to (PC+2) + w0 but ignores the LSB of w0, (otherwise it would produce a misaligned odd program counter address!) I've checked and checked this and I don't see what I'm doing wrong, and can't find an errata sheet that mentions this problem. Chip being used is dsPIC33FJ128GP804.<br>
<br>
Also can someone tell me the correct way to include additional assembly source files *.s in MPLAB. I just put<br>
<br>
.include "filters.s"<br>
.include "maths.s"<br>
.include "comms.s"<br>
<br>
etc... at the end of main.s but this seems to have completely broken MPLAB 8.92. It assembles fine, programs fine and runs fine, but goes crazy when hitting a breakpoint or single-stepping inside any of the included source files. I'm used to the included file just popping open and the program counter arrow switching between whichever source window it needs to be in as different routines are called. I'm actually getting the program counter arrow moving to lines in the source file that just have comments on them before the actual code starts when it should switch to one of the included source contents. Also FWIW the addresses in the "Disassembly Listing" window are all garbled too! It only does this when I include additional source files, so I must be doing something wrong!?!?<br>
<br>
I'd like to divide the source code up into relevant sections in separate files to make a big project easier to follow, so really want to get this done right.<br>
<br>
Thanks in advance for any suggestions !<br>
<br>
-Richie, <br>
_______________________________________________<br>
Synth-diy mailing list<br>
<a href="mailto:Synth-diy@dropmix.xs4all.nl" target="_blank">Synth-diy@dropmix.xs4all.nl</a><br>
<a href="http://dropmix.xs4all.nl/mailman/listinfo/synth-diy" rel="noreferrer" target="_blank">http://dropmix.xs4all.nl/mailman/listinfo/synth-diy</a><br>
</blockquote></div><br></div>