Add Timers 0 and 1 to SFR window
authorHugo Villeneuve <hugo@hugovil.com>
Thu, 24 Oct 2013 03:07:34 +0000 (23:07 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Wed, 6 Nov 2013 02:50:18 +0000 (21:50 -0500)
src/regwin.c

index f94b8f9..e549c96 100644 (file)
@@ -37,7 +37,7 @@
 
 static GtkWidget *reglist;
 
-#define DATA_ROWS 24
+#define DATA_ROWS 26
 
 enum
 {
@@ -65,7 +65,7 @@ regwin_read(int addr, int width)
                return cpu8051_ReadD(addr);
        else if (width == 4) {
                /* Address is low address. */
-               return (cpu8051_ReadD(addr + 1) << 8) +
+               return (cpu8051_ReadD(addr + 1) << 8) |
                        cpu8051_ReadD(addr);
        } else
                return 0xFFFFFFFF;
@@ -97,6 +97,20 @@ regwin_write_pc(int param, int val)
        cpu8051.pc = (u_int16_t) val;
 }
 
+static unsigned int
+regwin_read_timer(int timer_low_addr)
+{
+       return (cpu8051_ReadD(timer_low_addr + 2) << 8) |
+               cpu8051_ReadD(timer_low_addr);
+}
+
+static void
+regwin_write_timer(int timer_low_addr, int val)
+{
+       cpu8051_WriteD(timer_low_addr + 2, (u_int8_t) ((val & 0x0000FFFF) >> 8));
+       cpu8051_WriteD(timer_low_addr, (u_int8_t) val);
+}
+
 static unsigned int
 regwin_read_bank(int dummy)
 {
@@ -203,6 +217,18 @@ static struct regwin_infos_t regwin_infos[DATA_ROWS] = {
                NULL, NULL,
                _TMOD_,
        },
+       {
+               "TIMER0",
+               HEX_DIGITS_4,
+               regwin_read_timer, regwin_write_timer,
+               _TL0_,
+       },
+       {
+               "TIMER1",
+               HEX_DIGITS_4,
+               regwin_read_timer, regwin_write_timer,
+               _TL1_,
+       },
        {
                "SCON",
                HEX_DIGITS_2,