To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 3082
3081  |  3083
Subject: 
RE: Any interest in an RCX simulator?
Newsgroups: 
lugnet.robotics
Date: 
Fri, 22 Jan 1999 02:02:54 GMT
Original-From: 
Allen Martin <arm@rendition/saynotospam/.com>
Reply-To: 
<Allen.Martin@rendition{stopspam}.com>
Viewed: 
1275 times
  
Does this mean that GDB has an H8 emulator?  How would I get
a hold of this?


It's in the standard gdb distribution, Matt Cross posted instructions on
how to use it a long time ago, here's a copy:



Hi disassemblers,

I've found something very useful - gdb has a built-in simulator for the
h8/300!  While it's not useful for simulating the RCX as a whole (no
i/o),
it's handy for executing code fragments to see what they do.  I'm using
it
to figure out what the math routines do.

I've figured out some of the rom math routines:

Vector Description
4a 16-bit multiply: r5*r6 -> r6
4c unsigned 16-bit mod: r6%r5 -> r6
4e unsigned 16-bit divide: r6/r5.  Quotient in r6, remainder in r5.
50 signed 16-bit mod: r6%r5 -> r6 (IE -3 % 1 = -1)
52 signed 16-bit divide r6/r5 -> r6

54 unknown
56 unknown
58 unknown

Here's instructions on how to build & use the simulator in gdb:

1) Get gdb-4.17.tar.gz (I got it from prep.ai.mit.edu) & untar it.

2) Apply patches:

- This patch is needed to build gdb for the h8 at all.  I guess it
wasn't
  tested.  This is not a clean patch, but it works:

--- gdb/jv-valprint.c.orig      Tue Oct 27 11:13:28 1998
+++ gdb/jv-valprint.c   Fri Oct 23 13:28:25 1998
@@ -71,7 +71,8 @@
          address += JAVA_OBJECT_SIZE + 4; /* Skip object header and
length. */
          while (i < length && things_printed < print_max)
            {
-             char buf[TARGET_PTR_BIT / HOST_CHAR_BIT];
+                   /* XXX fails on h8300 */
+             char buf[256];
              fputs_filtered (", ", stream);
              wrap_here (n_spaces (2));
              if (i > 0)

- This patch can be used to build gdb on Solaris without gdb.  It may
also
  work on other C compilers that support 'unsigned long long' as a 64
bit
  integer:

--- sim/common/sim-types.h.orig Fri Oct 23 13:17:34 1998
+++ sim/common/sim-types.h      Fri Oct 23 13:18:11 1998
@@ -93,7 +93,21 @@
typedef struct { signed64 a[2]; } signed128;

#else /* Not GNUC or _MSC_VER */
-/* Not supported */
+/* Might as well try: */
+
+typedef long long natural64;
+typedef signed long long signed64;
+typedef unsigned long long unsigned64;
+
+#define UNSIGNED64(X) (X##ULL)
+#define SIGNED64(X) (X##LL)
+
+#define UNSIGNED32(X) (X##UL)
+#define SIGNED32(X) (X##L)
+
+typedef struct { unsigned64 a[2]; } unsigned128;
+typedef struct { signed64 a[2]; } signed128;
+
#endif

/* byte based */

3) Configure gdb using:
./configure --target=h8300-hitachi-hms --prefix=/usr/local

   (you can change the prefix if you like)

4) Build gdb (type 'make').  Install it in final location if you like,
or
   run it from the source tree.


To use the simulator:

- You must build the code to run into some executable format.  You can
load
an srecord file in directly, but a lot of gdb functionality will not
work.
This is what I did to figure out the math routines, so I will discuss
the
commands that do work.

1) Run gdb with no arguments & get to the gdb prompt.

2) Set the file you are debugging:
file rcxrom.srec

3) Connect to the simulator:
target sim

4) Load the executable into the simulator:
load

5) Now you can set breakpoints, examine data, single step, etc.

To set a breakpoint:
break *0x1ae

To jump to an address & start executing:
jump *0x1ae

To dump registers:
info reg

To disassemble an address:
x/i 0x1fe

To dump some memory:
x/8xw 0xcc00

To set a register:
set $r6=5

To step one instruction:
stepi

etc.

-Matt

--
Did you check the web site first?: http://www.crynwr.com/lego-robotics



Message is in Reply To:
  Re: Any interest in an RCX simulator?
 
(...) Does this mean that GDB has an H8 emulator? How would I get a hold of this? --Jim (26 years ago, 22-Jan-99, to lugnet.robotics)

7 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
9 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR