aboutsummaryrefslogtreecommitdiff
path: root/sim/m68hc11/dv-m68hc11tim.c
diff options
context:
space:
mode:
authorStephane Carrez <stcarrez@nerim.fr>2000-09-09 21:00:39 +0000
committerStephane Carrez <stcarrez@nerim.fr>2000-09-09 21:00:39 +0000
commit2990a9f484ce9ff796d68d6fbfdad7e8a2ea61b8 (patch)
tree09dfb90559e80e00bd1648861408345259b1e1d4 /sim/m68hc11/dv-m68hc11tim.c
parentc488923f169eed9ac1f7cb8e7d15e53eee97681d (diff)
downloadfsf-binutils-gdb-2990a9f484ce9ff796d68d6fbfdad7e8a2ea61b8.zip
fsf-binutils-gdb-2990a9f484ce9ff796d68d6fbfdad7e8a2ea61b8.tar.gz
fsf-binutils-gdb-2990a9f484ce9ff796d68d6fbfdad7e8a2ea61b8.tar.bz2
* sim-main.h: Define cycle_to_string.
* dv-m68hc11tim.c (cycle_to_string): New function to translate the cpu cycle into some formatted time string. (m68hc11tim_print_timer): Use it. * dv-m68hc11sio.c (m68hc11sio_info): Use cycle_to_string. * dv-m68hc11spi.c (m68hc11spi_info): Likewise. * interrupts.c (interrupts_info): Likewise. * m68hc11_sim.c (cpu_info): Likewise.
Diffstat (limited to 'sim/m68hc11/dv-m68hc11tim.c')
-rw-r--r--sim/m68hc11/dv-m68hc11tim.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/sim/m68hc11/dv-m68hc11tim.c b/sim/m68hc11/dv-m68hc11tim.c
index c830c05..355139f 100644
--- a/sim/m68hc11/dv-m68hc11tim.c
+++ b/sim/m68hc11/dv-m68hc11tim.c
@@ -407,6 +407,24 @@ to_realtime (sim_cpu *cpu, signed64 t)
return (double) (t) / (double) (cpu->cpu_frequency / 4);
}
+const char*
+cycle_to_string (sim_cpu *cpu, signed64 t)
+{
+ double dt;
+ static char buf[64];
+
+ dt = to_realtime (cpu, t);
+ if (dt < 0.001)
+ sprintf (buf, "%llu cycle%s (%3.1f us)", t,
+ (t > 1 ? "s" : ""), dt * 1000000.0);
+ else if (dt < 1.0)
+ sprintf (buf, "%llu cycles (%3.1f ms)", t, dt * 1000.0);
+ else
+ sprintf (buf, "%llu cycles (%3.1f s)", t, dt);
+
+ return buf;
+}
+
static void
m68hc11tim_print_timer (struct hw *me, const char *name,
struct hw_event *event)
@@ -421,15 +439,13 @@ m68hc11tim_print_timer (struct hw *me, const char *name,
else
{
signed64 t;
- double dt;
sim_cpu* cpu;
cpu = STATE_CPU (sd, 0);
t = hw_event_remain_time (me, event);
- dt = to_realtime (cpu, t) * 1000.0;
- sim_io_printf (sd, " Next %s interrupt in %ld cycles (%3.3f ms)\n",
- name, (long) t, dt);
+ sim_io_printf (sd, " Next %s interrupt in %s\n",
+ name, cycle_to_string (cpu, t));
}
}