diff options
author | Mike Frysinger <vapier@gentoo.org> | 2022-10-31 21:43:10 +0545 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2022-11-02 20:31:10 +0545 |
commit | ee1cffd3883c1d846ad58c1fb86559bb2f930361 (patch) | |
tree | 650a83e14dc8dcb5e061093643102eca8163b461 /sim/h8300 | |
parent | 26f228db710f54b54aea4d9a05214add0cf9f541 (diff) | |
download | binutils-ee1cffd3883c1d846ad58c1fb86559bb2f930361.zip binutils-ee1cffd3883c1d846ad58c1fb86559bb2f930361.tar.gz binutils-ee1cffd3883c1d846ad58c1fb86559bb2f930361.tar.bz2 |
sim: common: change sim_{fetch,store}_register helpers to use void* buffers
When reading/writing arbitrary data to the system's memory, the unsigned
char pointer type doesn't make that much sense. Switch it to void so we
align a bit with standard C library read/write functions, and to avoid
having to sprinkle casts everywhere.
Diffstat (limited to 'sim/h8300')
-rw-r--r-- | sim/h8300/compile.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c index ada7f72..b8256b1 100644 --- a/sim/h8300/compile.c +++ b/sim/h8300/compile.c @@ -4476,11 +4476,13 @@ sim_read (SIM_DESC sd, SIM_ADDR addr, void *buffer, int size) } static int -h8300_reg_store (SIM_CPU *cpu, int rn, const unsigned char *value, int length) +h8300_reg_store (SIM_CPU *cpu, int rn, const void *buf, int length) { + const unsigned char *value = buf; int longval; int shortval; int intval; + longval = (value[0] << 24) | (value[1] << 16) | (value[2] << 8) | value[3]; shortval = (value[0] << 8) | (value[1]); intval = h8300hmode ? longval : shortval; @@ -4522,8 +4524,9 @@ h8300_reg_store (SIM_CPU *cpu, int rn, const unsigned char *value, int length) } static int -h8300_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *buf, int length) +h8300_reg_fetch (SIM_CPU *cpu, int rn, void *buf, int length) { + unsigned char *value = buf; int v; int longreg = 0; @@ -4567,16 +4570,16 @@ h8300_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *buf, int length) /* In Normal mode PC is 2 byte, but other registers are 4 byte */ if ((h8300hmode || longreg) && !(rn == PC_REGNUM && h8300_normal_mode)) { - buf[0] = v >> 24; - buf[1] = v >> 16; - buf[2] = v >> 8; - buf[3] = v >> 0; + value[0] = v >> 24; + value[1] = v >> 16; + value[2] = v >> 8; + value[3] = v >> 0; return 4; } else { - buf[0] = v >> 8; - buf[1] = v; + value[0] = v >> 8; + value[1] = v; return 2; } } |