> Can you elaborate on "branch-to-self" opcode?

Any branch opcode that branches to itself, i.e. a one-opcode infinite
loop.

1:      BR      #1b

This also works with any indirect or conditional branch, as long as
the target of the branch is the address of the branch opcode.  Here's
the code in the simulator at the end of the branch handler ("u1" is
the true/false conditional, which is "true" for unconditional branches
of cours):

      if (u1)
        {
          if (TRACE_BRANCH_P (MSP430_CPU (sd)))
            trace_generic (sd, MSP430_CPU (sd), TRACE_BRANCH_IDX,
                           "J%s: pc %#x -> %#x sr %#x, taken",
                           cond_string (opcode->cond), PC, i, SR);
          PC = i;
          if (PC == opcode_pc)
            exit (0);
        }
      else
        if (TRACE_BRANCH_P (MSP430_CPU (sd)))
          trace_generic (sd, MSP430_CPU (sd), TRACE_BRANCH_IDX,
                         "J%s: pc %#x to %#x sr %#x, not taken",
                         cond_string (opcode->cond), PC, i, SR);

The other way to call exit() (in the RH simulator) is to call 0x181 as
if it were the C function exit().  The simulator traps "call to
0x18<N>" and does a syscall <N> instead of the call.  This is a
non-standard interface though, but the only way to call exit() with a
non-zero return code.

> What is the inline asm syntax that will give me this?

Just do this:

  for(;;);

or this:

  #define exit() __asm__ volatile ("1: BR #1b")

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to