summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@specifix.com>2003-04-13 17:06:29 +0000
committerMichael Snyder <msnyder@specifix.com>2003-04-13 17:06:29 +0000
commit8b9babcaacaafd5942c05cf098049e3f151e0c31 (patch)
treef38e28f83517c22dd7e4c63e872a10029322e0a3 /sim
parent938b128484b45e8486f0453b8f0401651b298ed8 (diff)
downloadgdb-8b9babcaacaafd5942c05cf098049e3f151e0c31.tar.gz
2003-04-13 Michael Snyder <msnyder@redhat.com>
* compile.c (sim_resume): Implement 'daa' and 'das' instructions.
Diffstat (limited to 'sim')
-rw-r--r--sim/h8300/ChangeLog4
-rw-r--r--sim/h8300/compile.c51
2 files changed, 55 insertions, 0 deletions
diff --git a/sim/h8300/ChangeLog b/sim/h8300/ChangeLog
index c3d79ba750c..600e9cc08a9 100644
--- a/sim/h8300/ChangeLog
+++ b/sim/h8300/ChangeLog
@@ -1,3 +1,7 @@
+2003-04-13 Michael Snyder <msnyder@redhat.com>
+
+ * compile.c (sim_resume): Implement 'daa' and 'das' instructions.
+
2003-03-20 D.Venkatasubramanian <dvenkat@noida.hcltech.com>
* compile.c (cmdline_location): Added function to
diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
index 54a06591338..0e4b6d2b291 100644
--- a/sim/h8300/compile.c
+++ b/sim/h8300/compile.c
@@ -2138,6 +2138,57 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
}
goto next;
+ case O (O_DAA, SB):
+ /* Decimal Adjust Addition. This is for BCD arithmetic. */
+ res = GET_B_REG (code->src.reg);
+ if (!c && (0 <= (res >> 4) && (res >> 4) <= 9)
+ && !h && (0 <= (res & 0xf) && (res & 0xf) <= 9))
+ res = res; /* Value added == 0. */
+ else if (!c && (0 <= (res >> 4) && (res >> 4) <= 8)
+ && !h && (10 <= (res & 0xf) && (res & 0xf) <= 15))
+ res = res + 0x6; /* Value added == 6. */
+ else if (!c && (0 <= (res >> 4) && (res >> 4) <= 9)
+ && h && (0 <= (res & 0xf) && (res & 0xf) <= 3))
+ res = res + 0x6; /* Value added == 6. */
+ else if (!c && (10 <= (res >> 4) && (res >> 4) <= 15)
+ && !h && (0 <= (res & 0xf) && (res & 0xf) <= 9))
+ res = res + 0x60; /* Value added == 60. */
+ else if (!c && (9 <= (res >> 4) && (res >> 4) <= 15)
+ && !h && (10 <= (res & 0xf) && (res & 0xf) <= 15))
+ res = res + 0x66; /* Value added == 66. */
+ else if (!c && (10 <= (res >> 4) && (res >> 4) <= 15)
+ && h && (0 <= (res & 0xf) && (res & 0xf) <= 3))
+ res = res + 0x66; /* Value added == 66. */
+ else if (c && (1 <= (res >> 4) && (res >> 4) <= 2)
+ && !h && (0 <= (res & 0xf) && (res & 0xf) <= 9))
+ res = res + 0x160; /* Value added == 60, plus 'carry'. */
+ else if (c && (1 <= (res >> 4) && (res >> 4) <= 2)
+ && !h && (10 <= (res & 0xf) && (res & 0xf) <= 15))
+ res = res + 0x166; /* Value added == 66, plus 'carry'. */
+ else if (c && (1 <= (res >> 4) && (res >> 4) <= 3)
+ && h && (0 <= (res & 0xf) && (res & 0xf) <= 3))
+ res = res + 0x166; /* Value added == 66, plus 'carry'. */
+
+ goto alu8;
+
+ case O (O_DAS, SB):
+ /* Decimal Adjust Subtraction. This is for BCD arithmetic. */
+ res = GET_B_REG (code->src.reg); /* FIXME fetch, fetch2... */
+ if (!c && (0 <= (res >> 4) && (res >> 4) <= 9)
+ && !h && (0 <= (res & 0xf) && (res & 0xf) <= 9))
+ res = res; /* Value added == 0. */
+ else if (!c && (0 <= (res >> 4) && (res >> 4) <= 8)
+ && h && (6 <= (res & 0xf) && (res & 0xf) <= 15))
+ res = res + 0xfa; /* Value added == 0xfa. */
+ else if (c && (7 <= (res >> 4) && (res >> 4) <= 15)
+ && !h && (0 <= (res & 0xf) && (res & 0xf) <= 9))
+ res = res + 0xa0; /* Value added == 0xa0. */
+ else if (c && (6 <= (res >> 4) && (res >> 4) <= 15)
+ && h && (6 <= (res & 0xf) && (res & 0xf) <= 15))
+ res = res + 0x9a; /* Value added == 0x9a. */
+
+ goto alu8;
+
default:
illegal:
cpu.state = SIM_STATE_STOPPED;