diff options
author | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-05-24 22:29:16 +0000 |
---|---|---|
committer | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-05-24 22:29:16 +0000 |
commit | e1f3808e03f73e7a7fa966afbed2455dd052202e (patch) | |
tree | c827e7f3e940e96f3c0da44aeec1a481e5401233 /target-m68k/op_helper.c | |
parent | 3979144c49d62d23c4a31a07cf8282217ed3dde3 (diff) |
Convert m68k target to TCG.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4565 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'target-m68k/op_helper.c')
-rw-r--r-- | target-m68k/op_helper.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/target-m68k/op_helper.c b/target-m68k/op_helper.c index 547f13da5b..f45c4d97c8 100644 --- a/target-m68k/op_helper.c +++ b/target-m68k/op_helper.c @@ -18,6 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "exec.h" +#include "helpers.h" #if defined(CONFIG_USER_ONLY) @@ -161,3 +162,71 @@ void do_interrupt(int is_hw) } #endif + +static void raise_exception(int tt) +{ + env->exception_index = tt; + cpu_loop_exit(); +} + +void HELPER(raise_exception)(uint32_t tt) +{ + raise_exception(tt); +} + +void HELPER(divu)(CPUState *env, uint32_t word) +{ + uint32_t num; + uint32_t den; + uint32_t quot; + uint32_t rem; + uint32_t flags; + + num = env->div1; + den = env->div2; + /* ??? This needs to make sure the throwing location is accurate. */ + if (den == 0) + raise_exception(EXCP_DIV0); + quot = num / den; + rem = num % den; + flags = 0; + /* Avoid using a PARAM1 of zero. This breaks dyngen because it uses + the address of a symbol, and gcc knows symbols can't have address + zero. */ + if (word && quot > 0xffff) + flags |= CCF_V; + if (quot == 0) + flags |= CCF_Z; + else if ((int32_t)quot < 0) + flags |= CCF_N; + env->div1 = quot; + env->div2 = rem; + env->cc_dest = flags; +} + +void HELPER(divs)(CPUState *env, uint32_t word) +{ + int32_t num; + int32_t den; + int32_t quot; + int32_t rem; + int32_t flags; + + num = env->div1; + den = env->div2; + if (den == 0) + raise_exception(EXCP_DIV0); + quot = num / den; + rem = num % den; + flags = 0; + if (word && quot != (int16_t)quot) + flags |= CCF_V; + if (quot == 0) + flags |= CCF_Z; + else if (quot < 0) + flags |= CCF_N; + env->div1 = quot; + env->div2 = rem; + env->cc_dest = flags; +} + |