#include "bfd.h"
-typedef signed8 int8;
-typedef unsigned8 uint8;
-typedef signed16 int16;
-typedef unsigned16 uint16;
-typedef signed32 int32;
-typedef unsigned32 uint32;
-typedef unsigned32 reg_t;
-typedef unsigned64 reg64_t;
+typedef uint32_t reg_t;
+typedef uint64_t reg64_t;
/* The current state of the processor; registers, memory, etc. */
macro's that store the instruction where the old simops expects
it. */
-extern uint32 OP[4];
+extern uint32_t OP[4];
#if 0
OP[0] = inst & 0x1f; /* RRRRR -> reg1 */
OP[1] = (inst >> 11) & 0x1f; /* rrrrr -> reg2 */
#ifdef DEBUG
void trace_input (char *name, enum op_types type, int size);
void trace_output (enum op_types result);
-void trace_result (int has_result, unsigned32 result);
+void trace_result (int has_result, uint32_t result);
extern int trace_num_values;
-extern unsigned32 trace_values[];
-extern unsigned32 trace_pc;
+extern uint32_t trace_values[];
+extern uint32_t trace_pc;
extern const char *trace_name;
extern int trace_module;
do { \
if (TRACE_FPU_P (CPU)) \
{ \
- unsigned64 f0; \
+ uint64_t f0; \
sim_fpu_to64 (&f0, (V0)); \
trace_input_fp1 (SD, CPU, TRACE_FPU_IDX, f0); \
} \
do { \
if (TRACE_FPU_P (CPU)) \
{ \
- unsigned64 f0, f1; \
+ uint64_t f0, f1; \
sim_fpu_to64 (&f0, (V0)); \
sim_fpu_to64 (&f1, (V1)); \
trace_input_fp2 (SD, CPU, TRACE_FPU_IDX, f0, f1); \
do { \
if (TRACE_FPU_P (CPU)) \
{ \
- unsigned64 f0, f1, f2; \
+ uint64_t f0, f1, f2; \
sim_fpu_to64 (&f0, (V0)); \
sim_fpu_to64 (&f1, (V1)); \
sim_fpu_to64 (&f2, (V2)); \
if (TRACE_FPU_P (CPU)) \
{ \
int d0 = (V0); \
- unsigned64 f1, f2; \
+ uint64_t f1, f2; \
TRACE_DATA *data = CPU_TRACE_DATA (CPU); \
TRACE_IDX (data) = TRACE_FPU_IDX; \
sim_fpu_to64 (&f1, (V1)); \
do { \
if (TRACE_FPU_P (CPU)) \
{ \
- unsigned64 f0; \
+ uint64_t f0; \
sim_fpu_to64 (&f0, (R0)); \
trace_result_fp1 (SD, CPU, TRACE_FPU_IDX, f0); \
} \
extern void divun ( unsigned int N,
unsigned long int als,
unsigned long int sfi,
- unsigned32 /*unsigned long int*/ * quotient_ptr,
- unsigned32 /*unsigned long int*/ * remainder_ptr,
+ uint32_t /*unsigned long int*/ * quotient_ptr,
+ uint32_t /*unsigned long int*/ * remainder_ptr,
int *overflow_ptr
);
extern void divn ( unsigned int N,
unsigned long int als,
unsigned long int sfi,
- signed32 /*signed long int*/ * quotient_ptr,
- signed32 /*signed long int*/ * remainder_ptr,
+ int32_t /*signed long int*/ * quotient_ptr,
+ int32_t /*signed long int*/ * remainder_ptr,
int *overflow_ptr
);
extern int type1_regs[];
#define SAT16(X) \
do \
{ \
- signed64 z = (X); \
+ int64_t z = (X); \
if (z > 0x7fff) \
{ \
SESR |= SESR_OV | SESR_SOV; \
#define SAT32(X) \
do \
{ \
- signed64 z = (X); \
+ int64_t z = (X); \
if (z > 0x7fffffff) \
{ \
SESR |= SESR_OV | SESR_SOV; \
#define ABS16(X) \
do \
{ \
- signed64 z = (X) & 0xffff; \
+ int64_t z = (X) & 0xffff; \
if (z == 0x8000) \
{ \
SESR |= SESR_OV | SESR_SOV; \
#define ABS32(X) \
do \
{ \
- signed64 z = (X) & 0xffffffff; \
+ int64_t z = (X) & 0xffffffff; \
if (z == 0x80000000) \
{ \
SESR |= SESR_OV | SESR_SOV; \
#endif
-unsigned32 trace_values[3];
+uint32_t trace_values[3];
int trace_num_values;
-unsigned32 trace_pc;
+uint32_t trace_pc;
const char * trace_name;
int trace_module;
}
void
-trace_result (int has_result, unsigned32 result)
+trace_result (int has_result, uint32_t result)
{
char buf[1000];
char *chp;
while (1)
{
- unsigned32 a = sim_core_read_4 (STATE_CPU (sd, 0),
+ uint32_t a = sim_core_read_4 (STATE_CPU (sd, 0),
PC, read_map, addr + nr * 4);
if (a == 0) break;
buf[nr] = fetch_str (sd, a);
buf = PARM1;
RETVAL = pipe (host_fd);
SW (buf, host_fd[0]);
- buf += sizeof (uint16);
+ buf += sizeof (uint16_t);
SW (buf, host_fd[1]);
RETERR = errno;
}
unsigned int N,
unsigned long int als,
unsigned long int sfi,
- unsigned32 /*unsigned long int*/ * quotient_ptr,
- unsigned32 /*unsigned long int*/ * remainder_ptr,
+ uint32_t /*unsigned long int*/ * quotient_ptr,
+ uint32_t /*unsigned long int*/ * remainder_ptr,
int * overflow_ptr
)
{
unsigned int N,
unsigned long int als,
unsigned long int sfi,
- signed32 /*signed long int*/ * quotient_ptr,
- signed32 /*signed long int*/ * remainder_ptr,
+ int32_t /*signed long int*/ * quotient_ptr,
+ int32_t /*signed long int*/ * remainder_ptr,
int * overflow_ptr
)
{
int
OP_1C207E0 (void)
{
- unsigned32 /*unsigned long int*/ quotient;
- unsigned32 /*unsigned long int*/ remainder;
+ uint32_t /*unsigned long int*/ quotient;
+ uint32_t /*unsigned long int*/ remainder;
unsigned long int divide_by;
unsigned long int divide_this;
int overflow = 0;
int
OP_1C007E0 (void)
{
- signed32 /*signed long int*/ quotient;
- signed32 /*signed long int*/ remainder;
+ int32_t /*signed long int*/ quotient;
+ int32_t /*signed long int*/ remainder;
signed long int divide_by;
signed long int divide_this;
int overflow = 0;
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
- divide_by = (signed32) State.regs[ OP[0] ];
- divide_this = (signed32) (State.regs[ OP[1] ] << imm5);
+ divide_by = (int32_t) State.regs[ OP[0] ];
+ divide_this = (int32_t) (State.regs[ OP[1] ] << imm5);
divn (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
int
OP_18207E0 (void)
{
- unsigned32 /*unsigned long int*/ quotient;
- unsigned32 /*unsigned long int*/ remainder;
+ uint32_t /*unsigned long int*/ quotient;
+ uint32_t /*unsigned long int*/ remainder;
unsigned long int divide_by;
unsigned long int divide_this;
int overflow = 0;
int
OP_18007E0 (void)
{
- signed32 /*signed long int*/ quotient;
- signed32 /*signed long int*/ remainder;
+ int32_t /*signed long int*/ quotient;
+ int32_t /*signed long int*/ remainder;
signed long int divide_by;
signed long int divide_this;
int overflow = 0;
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
divide_by = EXTEND16 (State.regs[ OP[0] ]);
- divide_this = (signed32) (State.regs[ OP[1] ] << imm5);
+ divide_this = (int32_t) (State.regs[ OP[1] ] << imm5);
divn (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
/* Compute the result. */
- divide_by = (signed32) State.regs[ OP[0] ];
+ divide_by = (int32_t) State.regs[ OP[0] ];
divide_this = State.regs[ OP[1] ];
if (divide_by == 0)
}
else
{
- divide_this = (signed32) divide_this;
+ divide_this = (int32_t) divide_this;
State.regs[ OP[1] ] = quotient = divide_this / divide_by;
State.regs[ OP[2] >> 11 ] = remainder = divide_this % divide_by;
}
else
{
- divide_this = (signed32) divide_this;
+ divide_this = (int32_t) divide_this;
State.regs[ OP[1] ] = quotient = divide_this / divide_by;
State.regs[ OP[2] >> 11 ] = remainder = divide_this % divide_by;
*op2p = result;
}
-unsigned32
+uint32_t
load_data_mem (SIM_DESC sd,
SIM_ADDR addr,
int len)
{
- uint32 data;
+ uint32_t data;
switch (len)
{
store_data_mem (SIM_DESC sd,
SIM_ADDR addr,
int len,
- unsigned32 data)
+ uint32_t data)
{
switch (len)
{
*v850e3v5
"bsh r<reg2>, r<reg3>"
{
- unsigned32 value;
+ uint32_t value;
TRACE_ALU_INPUT1 (GR[reg2]);
value = (MOVED32 (GR[reg2], 23, 16, 31, 24)
"bsw r<reg2>, r<reg3>"
{
#define WORDHASNULLBYTE(x) (((x) - 0x01010101) & ~(x)&0x80808080)
- unsigned32 value;
+ uint32_t value;
TRACE_ALU_INPUT1 (GR[reg2]);
value = GR[reg2];
*v850e3v5
"callt <imm6>"
{
- unsigned32 adr;
- unsigned32 off;
+ uint32_t adr;
+ uint32_t off;
CTPC = cia + 2;
CTPSW = PSW;
adr = (CTBP & ~1) + (imm6 << 1);
"caxi [reg1], reg2, reg3"
{
unsigned int z,s,cy,ov;
- unsigned32 addr;
- unsigned32 token,result;
+ uint32_t addr;
+ uint32_t token,result;
addr = GR[reg1];
rrrrr!0,000010,RRRRR!0:I:::divh
"divh r<reg1>, r<reg2>"
{
- unsigned32 ov, s, z;
+ uint32_t ov, s, z;
signed long int op0, op1, result;
trace_input ("divh", OP_REG_REG, 0);
}
else
{
- result = (signed32) op1 / op0;
+ result = (int32_t) op1 / op0;
ov = 0;
/* Compute the condition codes. */
*v850e3v5
"hsh r<reg2>, r<reg3>"
{
- unsigned32 value;
+ uint32_t value;
TRACE_ALU_INPUT1 (GR[reg2]);
value = 0xffff & GR[reg2];
*v850e3v5
"hsw r<reg2>, r<reg3>"
{
- unsigned32 value;
+ uint32_t value;
TRACE_ALU_INPUT1 (GR[reg2]);
value = GR[reg2];
*v850e2v3
*v850e3v5
{
- unsigned32 addr = GR[reg1] + disp23;
- unsigned32 result = EXTEND8 (load_data_mem (sd, addr, 1));
+ uint32_t addr = GR[reg1] + disp23;
+ uint32_t result = EXTEND8 (load_data_mem (sd, addr, 1));
GR[reg3] = result;
TRACE_LD (addr, result);
}
*v850e3v5
"ld.h <disp23>[r<reg1>], r<reg3>"
{
- unsigned32 addr = GR[reg1] + disp23;
- unsigned32 result = EXTEND16 (load_data_mem (sd, addr, 2));
+ uint32_t addr = GR[reg1] + disp23;
+ uint32_t result = EXTEND16 (load_data_mem (sd, addr, 2));
GR[reg3] = result;
TRACE_LD (addr, result);
}
*v850e3v5
"ld.w <disp23>[r<reg1>], r<reg3>"
{
- unsigned32 addr = GR[reg1] + disp23;
- unsigned32 result = load_data_mem (sd, addr, 4);
+ uint32_t addr = GR[reg1] + disp23;
+ uint32_t result = load_data_mem (sd, addr, 4);
GR[reg3] = result;
TRACE_LD (addr, result);
}
*v850e3v5
"ld.dw <disp23>[r<reg1>], r<reg3>"
{
- unsigned32 addr = GR[reg1] + disp23;
- unsigned32 result = load_data_mem (sd, addr, 4);
+ uint32_t addr = GR[reg1] + disp23;
+ uint32_t result = load_data_mem (sd, addr, 4);
GR[reg3] = result;
TRACE_LD (addr, result);
result = load_data_mem (sd, addr + 4, 4);
*v850e3v5
"ld.bu <disp23>[r<reg1>], r<reg3>"
{
- unsigned32 addr = GR[reg1] + disp23;
- unsigned32 result = load_data_mem (sd, addr, 1);
+ uint32_t addr = GR[reg1] + disp23;
+ uint32_t result = load_data_mem (sd, addr, 1);
GR[reg3] = result;
TRACE_LD (addr, result);
}
*v850e3v5
"ld.hu <disp23>[r<reg1>], r<reg3>"
{
- unsigned32 addr = GR[reg1] + disp23;
- unsigned32 result = load_data_mem (sd, addr, 2);
+ uint32_t addr = GR[reg1] + disp23;
+ uint32_t result = load_data_mem (sd, addr, 2);
GR[reg3] = result;
TRACE_LD (addr, result);
}
"ldsr r<reg1>, s<regID>":(selID == 0)
"ldsr r<reg1>, s<regID>, <selID>"
{
- uint32 sreg = GR[reg1];
+ uint32_t sreg = GR[reg1];
TRACE_ALU_INPUT1 (GR[reg1]);
/* FIXME: For now we ignore the selID. */
"sld.bu <disp7>[ep], r<reg2>":(PSW & PSW_US)
"sld.b <disp7>[ep], r<reg2>"
{
- unsigned32 addr = EP + disp7;
- unsigned32 result = load_mem (addr, 1);
+ uint32_t addr = EP + disp7;
+ uint32_t result = load_mem (addr, 1);
if (PSW & PSW_US)
{
GR[reg2] = result;
"sld.hu <disp8>[ep], r<reg2>":(PSW & PSW_US)
"sld.h <disp8>[ep], r<reg2>"
{
- unsigned32 addr = EP + disp8;
- unsigned32 result = load_mem (addr, 2);
+ uint32_t addr = EP + disp8;
+ uint32_t result = load_mem (addr, 2);
if (PSW & PSW_US)
{
GR[reg2] = result;
rrrrr,1010,dddddd,0:IV:::sld.w
"sld.w <disp8>[ep], r<reg2>"
{
- unsigned32 addr = EP + disp8;
- unsigned32 result = load_mem (addr, 4);
+ uint32_t addr = EP + disp8;
+ uint32_t result = load_mem (addr, 4);
GR[reg2] = result;
TRACE_LD (addr, result);
}
"sld.b <disp4>[ep], r<reg2>":(PSW & PSW_US)
"sld.bu <disp4>[ep], r<reg2>"
{
- unsigned32 addr = EP + disp4;
- unsigned32 result = load_mem (addr, 1);
+ uint32_t addr = EP + disp4;
+ uint32_t result = load_mem (addr, 1);
if (PSW & PSW_US)
{
result = EXTEND8 (result);
"sld.h <disp5>[ep], r<reg2>":(PSW & PSW_US)
"sld.hu <disp5>[ep], r<reg2>"
{
- unsigned32 addr = EP + disp5;
- unsigned32 result = load_mem (addr, 2);
+ uint32_t addr = EP + disp5;
+ uint32_t result = load_mem (addr, 2);
if (PSW & PSW_US)
{
result = EXTEND16 (result);
*v850e3v5
"st.b r<reg3>, <disp23>[r<reg1>]"
{
- unsigned32 addr = GR[reg1] + disp23;
+ uint32_t addr = GR[reg1] + disp23;
store_data_mem (sd, addr, 1, GR[reg3]);
TRACE_ST (addr, GR[reg3]);
}
*v850e3v5
"st.h r<reg3>, <disp23>[r<reg1>]"
{
- unsigned32 addr = GR[reg1] + disp23;
+ uint32_t addr = GR[reg1] + disp23;
store_data_mem (sd, addr, 2, GR[reg3]);
TRACE_ST (addr, GR[reg3]);
}
*v850e3v5
"st.w r<reg3>, <disp23>[r<reg1>]"
{
- unsigned32 addr = GR[reg1] + disp23;
+ uint32_t addr = GR[reg1] + disp23;
store_data_mem (sd, addr, 4, GR[reg3]);
TRACE_ST (addr, GR[reg3]);
}
*v850e3v5
"st.dw r<reg3>, <disp23>[r<reg1>]"
{
- unsigned32 addr = GR[reg1] + disp23;
+ uint32_t addr = GR[reg1] + disp23;
store_data_mem (sd, addr, 4, GR[reg3]);
TRACE_ST (addr, GR[reg3]);
store_data_mem (sd, addr + 4, 4, GR[reg3 + 1]);
rrrrr,111111,regID + 0000000001000000:IX:::stsr
"stsr s<regID>, r<reg2>"
{
- uint32 sreg = 0;
+ uint32_t sreg = 0;
if ((idecode_issue == idecode_v850e2_issue
|| idecode_issue == idecode_v850e3v5_issue
*v850e3v5
"cvtf.dl r<reg2e>, r<reg3e>"
{
- signed64 ans;
+ int64_t ans;
sim_fpu wop;
sim_fpu_status status;
*v850e3v5
"cvtf.dw r<reg2e>, r<reg3>"
{
- int32 ans;
+ int32_t ans;
sim_fpu wop;
sim_fpu_status status;
*v850e3v5
"cvtf.ld r<reg2e>, r<reg3e>"
{
- signed64 op;
+ int64_t op;
sim_fpu wop;
sim_fpu_status status;
- op = ((signed64)GR[reg2e+1] << 32L) | GR[reg2e];
+ op = ((int64_t)GR[reg2e+1] << 32L) | GR[reg2e];
TRACE_FP_INPUT_WORD2 (GR[reg2e], GR[reg2e+1]);
sim_fpu_i64to (&wop, op, FPSR_GET_ROUND());
*v850e3v5
"cvtf.ls r<reg2e>, r<reg3>"
{
- signed64 op;
+ int64_t op;
sim_fpu wop;
sim_fpu_status status;
- op = ((signed64)GR[reg2e+1] << 32L) | GR[reg2e];
+ op = ((int64_t)GR[reg2e+1] << 32L) | GR[reg2e];
TRACE_FP_INPUT_WORD2 (GR[reg2e], GR[reg2e+1]);
sim_fpu_i64to (&wop, op, FPSR_GET_ROUND());
*v850e3v5
"cvtf.sl r<reg2>, r<reg3e>"
{
- signed64 ans;
+ int64_t ans;
sim_fpu wop;
sim_fpu_status status;
*v850e3v5
"cvtf.sw r<reg2>, r<reg3>"
{
- int32 ans;
+ int32_t ans;
sim_fpu wop;
sim_fpu_status status;
*v850e3v5
"trncf.dl r<reg2e>, r<reg3e>"
{
- signed64 ans;
+ int64_t ans;
sim_fpu wop;
sim_fpu_status status;
*v850e3v5
"trncf.dul r<reg2e>, r<reg3e>"
{
- unsigned64 ans;
+ uint64_t ans;
sim_fpu wop;
sim_fpu_status status;
*v850e3v5
"trncf.dw r<reg2e>, r<reg3>"
{
- int32 ans;
+ int32_t ans;
sim_fpu wop;
sim_fpu_status status;
*v850e3v5
"trncf.duw r<reg2e>, r<reg3>"
{
- uint32 ans;
+ uint32_t ans;
sim_fpu wop;
sim_fpu_status status;
*v850e3v5
"trncf.sl r<reg2>, r<reg3e>"
{
- signed64 ans;
+ int64_t ans;
sim_fpu wop;
sim_fpu_status status;
*v850e3v5
"trncf.sul r<reg2>, r<reg3e>"
{
- unsigned64 ans;
+ uint64_t ans;
sim_fpu wop;
sim_fpu_status status;
*v850e3v5
"trncf.sw r<reg2>, r<reg3>"
{
- int32 ans;
+ int32_t ans;
sim_fpu wop;
sim_fpu_status status;
*v850e3v5
"trncf.suw r<reg2>, r<reg3>"
{
- uint32 ans;
+ uint32_t ans;
sim_fpu wop;
sim_fpu_status status;
"modadd r<reg2e>"
{
reg_t r;
- int32 inc;
+ int32_t inc;
reg_t max;
TRACE_ALU_INPUT1 (GR[reg2e]);