diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2017-06-01 00:01:11 +0200 |
---|---|---|
committer | Richard Henderson <rth@twiddle.net> | 2017-06-06 15:20:42 -0700 |
commit | fdc0a7474aa271bdcf88dd63008fb10d8a4b4824 (patch) | |
tree | dc0143bc5c73bd6203fea15b8d16b412a75a66ea /target/s390x/mem_helper.c | |
parent | 256dab6fe8872a041823a18e78d7d7a86d0e9618 (diff) |
target/s390x: implement MOVE WITH OFFSET
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Message-Id: <20170531220129.27724-13-aurelien@aurel32.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'target/s390x/mem_helper.c')
-rw-r--r-- | target/s390x/mem_helper.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index f80b7a5f06..facac4b6d7 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -256,6 +256,37 @@ void HELPER(mvn)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) } } +/* move with offset */ +void HELPER(mvo)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) +{ + uintptr_t ra = GETPC(); + int len_dest = l >> 4; + int len_src = l & 0xf; + uint8_t byte_dest, byte_src; + int i; + + src += len_src; + dest += len_dest; + + /* Handle rightmost byte */ + byte_src = cpu_ldub_data_ra(env, src, ra); + byte_dest = cpu_ldub_data_ra(env, dest, ra); + byte_dest = (byte_dest & 0x0f) | (byte_src << 4); + cpu_stb_data_ra(env, dest, byte_dest, ra); + + /* Process remaining bytes from right to left */ + for (i = 1; i <= len_dest; i++) { + byte_dest = byte_src >> 4; + if (len_src - i >= 0) { + byte_src = cpu_ldub_data_ra(env, src - i, ra); + } else { + byte_src = 0; + } + byte_dest |= byte_src << 4; + cpu_stb_data_ra(env, dest - i, byte_dest, ra); + } +} + /* compare unsigned byte arrays */ static uint32_t do_helper_clc(CPUS390XState *env, uint32_t l, uint64_t s1, uint64_t s2, uintptr_t ra) |