[Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread Mark Rages
This is a follow-on to a previous discussion, which discussion quickly
drifted into language-lawyering:

https://www.mail-archive.com/mspgcc-users@lists.sourceforge.net/msg10619.html

I am trying to use the msp430 simulator built into gdb and am having
trouble getting anywhere.

I'm using Ubuntu 12.04 and the msp430 tools from the repository. (I think
they're actually from Debian.)

I've made the following test program:

volatile int a=0;

int main(void) {
  while (1)
a++;
}

Now I want to load it into the simulator, and watch a change.

I compile it like so;
$ msp430-gcc --version
msp430-gcc (GNU GCC patched mspgcc-20110716) 4.5.3
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ msp430-gcc -o test.elf test.c

And load it into gdb like so:
$ msp430-gdb test.elf
GNU gdb (GDB) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as --host=i486-linux-gnu --target=msp430.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /home/markrages/hello_msp/test.elf...done.
(gdb) target sim
Connected to the simulator.
(gdb) load
(gdb) run
Starting program: /home/markrages/hello_msp/test.elf
Segmentation fault (core dumped)

Well, that is unhelpful.  Maybe I'll try with an older version of
msp430-gdb.

$ /usr/local/msp430/bin/msp430-gdb test.elf
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as --host=i686-pc-linux-gnu --target=msp430...
(gdb) target sim
Connected to the simulator.
(gdb) load
(gdb) run
Starting program: /home/markrages/hello_msp/test.elf
Segmentation fault (core dumped)

OK, how about the Java MSP430 simulator mspsim?
$ make run
java -classpath
build/:lib/jcommon-1.0.14.jar:lib/jfreechart-1.0.11.jar:lib/jipv6.jar:lib/json-simple-1.1.1.jar
se.sics.mspsim.Main
Usage: se.sics.mspsim.platform.sky.SkyNode firmware
make: *** [run] Error 1

No problem, I'll just run the thing myself and supply the executable as
argument.

$ java -classpath
build/:lib/jcommon-1.0.14.jar:lib/jfreechart-1.0.11.jar:lib/jipv6.jar:lib/json-simple-1.1.1.jar
se.sics.mspsim.Main ~/hello_msp/test.elf
MSPSim does not currently support the platform 'elf'.

Ah, that's going to be a problem.

Does anyone have other ideas for me to try?

Regards,
Mark
markrages@gmail
--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread DJ Delorie

Could you try the gdb from the FSF's source tree?  It's version 7.7
and has the RH simulator in it.  However, I don't think the profiling
results from the RH simulator will be useful to you if you want
cycle-accurate counts, but it will show you every single instruction
being executed.

Also, there's a standalone simulator msp430-elf-run that has some
profiling command line options, not sure if those would be helpful.

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread Mark Rages
I am not concerned about cycles at the moment, just bit-exact simulation of
the CPU.

The msp430-run program looks useful, thank you.  (Except the msp430-run
programs packaged by Debian segfault immediately.)

I've compiled gdb-7.7 with --target=msp430 and it works!

Is there any best way to pass data in / out of the simulator?  I guess I
can use the run program and set up a memory region for the input data,
and write a little main() to feed it into through the algorithm.  But if
there's an easier way, I'd like to hear about it before I do it the hard
way.

Regards,
Mark


On Tue, Jun 3, 2014 at 11:01 AM, DJ Delorie d...@redhat.com wrote:


 Could you try the gdb from the FSF's source tree?  It's version 7.7
 and has the RH simulator in it.  However, I don't think the profiling
 results from the RH simulator will be useful to you if you want
 cycle-accurate counts, but it will show you every single instruction
 being executed.

 Also, there's a standalone simulator msp430-elf-run that has some
 profiling command line options, not sure if those would be helpful.




-- 
Regards,
Mark
markrages@gmail
--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread DJ Delorie

 Is there any best way to pass data in / out of the simulator?  I
 guess I can use the run program and set up a memory region for the
 input data, and write a little main() to feed it into through the
 algorithm.  But if there's an easier way, I'd like to hear about it
 before I do it the hard way.

If you link in your input data via a linker script, and write() out
the output data to stdout and redirect it, it should be pretty easy to
set up.

msp430-elf-run also has command line options to map files to memory
regions, see msp430-elf-run --help for help.

(er, a note about msp430-elf-run - the --trace-vpu command traces
register changes, not the vpu)

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread Mark Rages
On Tue, Jun 3, 2014 at 11:57 AM, DJ Delorie d...@redhat.com wrote:


  Is there any best way to pass data in / out of the simulator?  I
  guess I can use the run program and set up a memory region for the
  input data, and write a little main() to feed it into through the
  algorithm.  But if there's an easier way, I'd like to hear about it
  before I do it the hard way.

 If you link in your input data via a linker script, and write() out
 the output data to stdout and redirect it, it should be pretty easy to
 set up.


Wait, a write() syscall made in the msp430 binary can show up on stdout of
the simulator?  How does that work?  Do I need to link in any special
function for that?


 (er, a note about msp430-elf-run - the --trace-vpu command traces
 register changes, not the vpu)


I don't know what a vpu is, so I am spared from confusion...

Regards,
Mark
markrages@gmail
--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread Peter Bigot
On Tue, Jun 3, 2014 at 1:10 PM, Mark Rages markra...@gmail.com wrote:
 On Tue, Jun 3, 2014 at 11:57 AM, DJ Delorie d...@redhat.com wrote:


  Is there any best way to pass data in / out of the simulator?  I
  guess I can use the run program and set up a memory region for the
  input data, and write a little main() to feed it into through the
  algorithm.  But if there's an easier way, I'd like to hear about it
  before I do it the hard way.

 If you link in your input data via a linker script, and write() out
 the output data to stdout and redirect it, it should be pretty easy to
 set up.


 Wait, a write() syscall made in the msp430 binary can show up on stdout of
 the simulator?  How does that work?  Do I need to link in any special
 function for that?

You need to be using msp430-elf-gcc for that feature, not mspgcc as
described in your first email.  I don't believe msp430-elf is packaged
by debian yet, though you can probably use the precompiled version
available from TI (details elsewhere in the archive).

Peter

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread DJ Delorie

 Wait, a write() syscall made in the msp430 binary can show up on stdout of
 the simulator?  How does that work?  Do I need to link in any special
 function for that?

The RH simulator (msp430-elf-run, not msp430-run) supports TI's CIO
interface, at least for write(), which means the RH simulator can
write to stdout (we use it for testing).  CIO supports a range of file
I/O operations, but we only implemented write().

The code in libgloss (part of newlib) has an implementation of CIO
and write() that works with the simulator.

 I don't know what a vpu is, so I am spared from confusion...

I dodn't know either, but it was an unused command line option so I
used it :-)

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread DJ Delorie

 You need to be using msp430-elf-gcc for that feature, not mspgcc as

Right, as previously agreed on, we're using msp430-foo for the
non-RH tools, and msp430-elf-foo for the RH tools.

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread Peter Bigot
On Tue, Jun 3, 2014 at 1:26 PM, DJ Delorie d...@redhat.com wrote:

 Wait, a write() syscall made in the msp430 binary can show up on stdout of
 the simulator?  How does that work?  Do I need to link in any special
 function for that?

 The RH simulator (msp430-elf-run, not msp430-run) supports TI's CIO
 interface, at least for write(), which means the RH simulator can
 write to stdout (we use it for testing).  CIO supports a range of file
 I/O operations, but we only implemented write().

 The code in libgloss (part of newlib) has an implementation of CIO
 and write() that works with the simulator.

Somewhat off the specific topic but relevant to the feature: when I
last asked there was no public documentation on this CIO interface.
It communicates with something through an undocumented structure
__CIOBUF__TYPE___ but provides no information on what parameters are
expected for the dozen functions listed (of which two are
implemented).  Looking at the source, I guess it's probably related to
the more complete tic6x CIO implementation.

Will TI be providing sufficient documentation on the CIO API that the
msp430 implementation can be completed, thus making the system
interface usable in other frameworks?

I personally would wish that newlib prefer APIs that are not
proprietary.  My intent for my own msp430-elf projects is to implement
a msp430 libgloss approach that's much closer to what was done in the
arm target for libgloss.  If there's a chance that'd be adopted
upstream as an alternative to the CIO one, it'd motivate me to make
that a priority.

(FWIW: I now have official support for msp430-elf in BSP430, and lack
of a robust system interface is all that's stopping me from being able
to develop real applications in the new toolchain.)

Peter

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread DJ Delorie

 Will TI be providing sufficient documentation on the CIO API that the
 msp430 implementation can be completed, thus making the system
 interface usable in other frameworks?

I have enough information to finish the msp interface, I've just had
no reason to do so so far.  CIO doesn't have exit() though so the RH
simulator *also* has its own syscall interface, just for that call.
If you just want to exit cleanly a branch-to-self opcode will also
trigger an exit(0) from the RH simulator.

 I personally would wish that newlib prefer APIs that are not
 proprietary.  My intent for my own msp430-elf projects is to implement
 a msp430 libgloss approach that's much closer to what was done in the
 arm target for libgloss.  If there's a chance that'd be adopted
 upstream as an alternative to the CIO one, it'd motivate me to make
 that a priority.

CIO was used at TI's request, to be compatible with their simulators
and their hardware drivers - I.e. a CIO library in your app would work
in the simulator *and* on real hardware - I think this works with
msp430-elf-gdb also.

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread Peter Bigot
On Tue, Jun 3, 2014 at 1:55 PM, DJ Delorie d...@redhat.com wrote:

 Will TI be providing sufficient documentation on the CIO API that the
 msp430 implementation can be completed, thus making the system
 interface usable in other frameworks?

 I have enough information to finish the msp interface, I've just had
 no reason to do so so far.

That doesn't really help the rest of us, though.

  CIO doesn't have exit() though so the RH
 simulator *also* has its own syscall interface, just for that call.
 If you just want to exit cleanly a branch-to-self opcode will also
 trigger an exit(0) from the RH simulator.

Which is fine, but I'm not interested in interfacing with either the
TI or RH simulators.  I'm interfacing with other external hardware
including LCDs and FAT file systems, and I want to re-use the standard
libc interface at the application layer.

 I personally would wish that newlib prefer APIs that are not
 proprietary.  My intent for my own msp430-elf projects is to implement
 a msp430 libgloss approach that's much closer to what was done in the
 arm target for libgloss.  If there's a chance that'd be adopted
 upstream as an alternative to the CIO one, it'd motivate me to make
 that a priority.

 CIO was used at TI's request, to be compatible with their simulators
 and their hardware drivers - I.e. a CIO library in your app would work
 in the simulator *and* on real hardware - I think this works with
 msp430-elf-gdb also.

Perfectly understandable that since TI's paying you to do this, they
get to choose the default implementation.

Like Mark, one of my needs is for input as well as output.  For ARM, I
can take a binary toolchain from launchpad with a pre-built newlib and
substitute a new system interface that meets my requirements.  As long
as I can do the same thing for the msp430 one, I'll have no issues
with the default solution being CIO.

Peter

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread DJ Delorie

 Is this documented?  How can I write drivers to this standard?

That's the catch.  It's not documented.  I have a sample
implementation from TI that I used (with permission) to write the
simulator/libgloss code.

In general, though, the target side works like this: fill up a
command buffer at __CIOBUF__ and branch/call an opcode at C$$IO$$

The host sets a breakpoint at C$$IO$$.  When it's hit, it reads
the command from __CIOBUF__ and does it, which may involve
reading data from the buffer and/or writing results back,
then resumes the target.

The target then looks at __CIOBUF__ to get the results of the syscall.

The target side of this is at newlib's libgloss/msp430/ (part in cio.* and
part in write.c)

The simulator side of this is at gdb's sim/msp430/msp430-sim.c in
msp430_cio().  A lot of the to/from buffering is common.

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread DJ Delorie

 That doesn't really help the rest of us, though.

Yup, I've complained to TI about that.  I'll bring it up again.

 I'm interfacing with other external hardware including LCDs and FAT
 file systems, and I want to re-use the standard libc interface at
 the application layer.

Could you elaborate on this?  Are you talking about real hardware
talking to real peripherals, or is there a host involved?

 Like Mark, one of my needs is for input as well as output.  For ARM, I
 can take a binary toolchain from launchpad with a pre-built newlib and
 substitute a new system interface that meets my requirements.  As long
 as I can do the same thing for the msp430 one, I'll have no issues
 with the default solution being CIO.

None of the CIO stuff interferes with the ANSI routines in
newlib/libc.  You still use printf() and fopen() etc.  The CIO code is
at the very bottom in libgloss, where it provides a CIO-specific
write() call.

If you have some other low-level I/O routines, like a serial port or
lcd, just provide your own read() and write() functions and the rest
of newlib will just work.

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread Peter Bigot
On Tue, Jun 3, 2014 at 2:55 PM, DJ Delorie d...@redhat.com wrote:
 file systems, and I want to re-use the standard libc interface at
 the application layer.

 Could you elaborate on this?  Are you talking about real hardware
 talking to real peripherals, or is there a host involved?

I'd already outlined my expectations in the earlier thread; see for
example 
http://www.mail-archive.com/mspgcc-users@lists.sourceforge.net/msg12038.html.
 If the msp430 version supplies a weak definition of _write() (not
write()) that goes through CIO, we're good because I can replace it
with one that delegates to a descriptor-specific implementation.  If
the definitions aren't weak, we're probably not good.

I'll hold off on further comment until I have an opportunity to see
what actually needs to be done to make this work.  I expect something
that allows me to do for the msp430 what I did for ARM as described
at: http://pabigot.github.io/bspacm/newlib.html#newlib_sys

Peter

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread DJ Delorie

 I'd already outlined my expectations in the earlier thread; see for
 example 
 http://www.mail-archive.com/mspgcc-users@lists.sourceforge.net/msg12038.html.
  If the msp430 version supplies a weak definition of _write() (not
 write())

newlib uses either write() or _write() depending on which the
underlying libraries provide.  There's no difference between then as
far as which you provide.  If you'd like to propose changing which of
the two newlib looks for by default, I'm OK with that.  There's no
standard there, and newlib doesn't provide a write() that calls
_write_r() regardless.

 that goes through CIO, we're good because I can replace it

*If* you link in libgloss (you don't have to), *and* you don't provide
a copy of write(), *then* a copy that uses CIO is linked in via
-lgloss.  So go ahead and replace it.

 with one that delegates to a descriptor-specific implementation.  If
 the definitions aren't weak, we're probably not good.

It's in a library, one per object.  If you provide your own, the
linker won't link in the libgloss version.  It doesn't need to be
weak.

 I'll hold off on further comment until I have an opportunity to see
 what actually needs to be done to make this work.  I expect something
 that allows me to do for the msp430 what I did for ARM as described
 at: http://pabigot.github.io/bspacm/newlib.html#newlib_sys

You can do that with the RH newlib as long as you don't link in
libgloss's versions of the low-level routines - i.e. remove -lgloss
from your link line and add -lbspacm.

--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread Mark Rages
On Tue, Jun 3, 2014 at 12:55 PM, DJ Delorie d...@redhat.com wrote:


  Will TI be providing sufficient documentation on the CIO API that the
  msp430 implementation can be completed, thus making the system
  interface usable in other frameworks?

 I have enough information to finish the msp interface, I've just had
 no reason to do so so far.  CIO doesn't have exit() though so the RH
 simulator *also* has its own syscall interface, just for that call.
 If you just want to exit cleanly a branch-to-self opcode will also
 trigger an exit(0) from the RH simulator.


Can you elaborate on branch-to-self opcode?

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

Regards,
Mark
markrages@gmail
--
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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread DJ Delorie

 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
0x18N 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


Re: [Mspgcc-users] MSP430 simulator in gdb

2014-06-03 Thread DJ Delorie

 You can do that with the RH newlib as long as you don't link in
 libgloss's versions of the low-level routines - i.e. remove -lgloss
 from your link line and add -lbspacm.

To clarify: don't link in -lnosys if you're not compiling with -msim
or don't link in -lsim if you are compiling with -msim

Both of these are linked at the same point as libc and libgcc, by the
gcc driver, depending on whether or not you use the -msim option.

Both are from libgloss, but have slightly different versions of some
functions to compensate for the differences between the simulator and
real hardware, mostly the non-CIO system calls like exit().

--
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