]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - sim/d10v/simops.c
74625a38e29d3a05ef6afadb4233808c6810ec35
13 #include "sys/syscall.h"
15 extern char *strrchr ();
48 move_to_cr (int cr
, reg_t val
)
53 State
.SM
= (val
& PSW_SM_BIT
) != 0;
54 State
.EA
= (val
& PSW_EA_BIT
) != 0;
55 State
.DB
= (val
& PSW_DB_BIT
) != 0;
56 State
.DM
= (val
& PSW_DM_BIT
) != 0;
57 State
.IE
= (val
& PSW_IE_BIT
) != 0;
58 State
.RP
= (val
& PSW_RP_BIT
) != 0;
59 State
.MD
= (val
& PSW_MD_BIT
) != 0;
60 State
.FX
= (val
& PSW_FX_BIT
) != 0;
61 State
.ST
= (val
& PSW_ST_BIT
) != 0;
62 State
.F0
= (val
& PSW_F0_BIT
) != 0;
63 State
.F1
= (val
& PSW_F1_BIT
) != 0;
64 State
.C
= (val
& PSW_C_BIT
) != 0;
65 if (State
.ST
&& !State
.FX
)
67 (*d10v_callback
->printf_filtered
)
69 "ERROR at PC 0x%x: ST can only be set when FX is set.\n",
71 State
.exception
= SIGILL
;
73 State
.cregs
[PSW_CR
] = (val
& ~0x4032);
76 State
.cregs
[BPSW_CR
] = (val
& ~0x4032);
80 State
.cregs
[cr
] = (val
& ~0x1);
83 State
.cregs
[cr
] = val
;
95 if (State
.SM
) val
|= PSW_SM_BIT
;
96 if (State
.EA
) val
|= PSW_EA_BIT
;
97 if (State
.DB
) val
|= PSW_DB_BIT
;
98 if (State
.DM
) val
|= PSW_DM_BIT
;
99 if (State
.IE
) val
|= PSW_IE_BIT
;
100 if (State
.RP
) val
|= PSW_RP_BIT
;
101 if (State
.MD
) val
|= PSW_MD_BIT
;
102 if (State
.FX
) val
|= PSW_FX_BIT
;
103 if (State
.ST
) val
|= PSW_ST_BIT
;
104 if (State
.F0
) val
|= PSW_F0_BIT
;
105 if (State
.F1
) val
|= PSW_F1_BIT
;
106 if (State
.C
) val
|= PSW_C_BIT
;
109 val
= State
.cregs
[cr
];
117 static void trace_input_func
PARAMS ((char *name
,
122 #define trace_input(name, in1, in2, in3) do { if (d10v_debug) trace_input_func (name, in1, in2, in3); } while (0)
124 static void trace_output_func
PARAMS ((enum op_types result
));
126 #define trace_output(result) do { if (d10v_debug) trace_output_func (result); } while (0)
128 #ifndef SIZE_INSTRUCTION
129 #define SIZE_INSTRUCTION 8
132 #ifndef SIZE_OPERANDS
133 #define SIZE_OPERANDS 18
137 #define SIZE_VALUES 13
140 #ifndef SIZE_LOCATION
141 #define SIZE_LOCATION 20
148 #ifndef SIZE_LINE_NUMBER
149 #define SIZE_LINE_NUMBER 4
153 trace_input_func (name
, in1
, in2
, in3
)
166 const char *filename
;
167 const char *functionname
;
168 unsigned int linenumber
;
171 if ((d10v_debug
& DEBUG_TRACE
) == 0)
174 switch (State
.ins_type
)
177 case INS_UNKNOWN
: type
= " ?"; break;
178 case INS_LEFT
: type
= " L"; break;
179 case INS_RIGHT
: type
= " R"; break;
180 case INS_LEFT_PARALLEL
: type
= "*L"; break;
181 case INS_RIGHT_PARALLEL
: type
= "*R"; break;
182 case INS_LEFT_COND_TEST
: type
= "?L"; break;
183 case INS_RIGHT_COND_TEST
: type
= "?R"; break;
184 case INS_LEFT_COND_EXE
: type
= "&L"; break;
185 case INS_RIGHT_COND_EXE
: type
= "&R"; break;
186 case INS_LONG
: type
= " B"; break;
189 if ((d10v_debug
& DEBUG_LINE_NUMBER
) == 0)
190 (*d10v_callback
->printf_filtered
) (d10v_callback
,
192 SIZE_PC
, (unsigned)PC
,
194 SIZE_INSTRUCTION
, name
);
199 byte_pc
= decode_pc ();
200 if (text
&& byte_pc
>= text_start
&& byte_pc
< text_end
)
202 filename
= (const char *)0;
203 functionname
= (const char *)0;
205 if (bfd_find_nearest_line (prog_bfd
, text
, (struct symbol_cache_entry
**)0, byte_pc
- text_start
,
206 &filename
, &functionname
, &linenumber
))
211 sprintf (p
, "#%-*d ", SIZE_LINE_NUMBER
, linenumber
);
216 sprintf (p
, "%-*s ", SIZE_LINE_NUMBER
+1, "---");
217 p
+= SIZE_LINE_NUMBER
+2;
222 sprintf (p
, "%s ", functionname
);
227 char *q
= strrchr (filename
, '/');
228 sprintf (p
, "%s ", (q
) ? q
+1 : filename
);
237 (*d10v_callback
->printf_filtered
) (d10v_callback
,
238 "0x%.*x %s: %-*.*s %-*s ",
239 SIZE_PC
, (unsigned)PC
,
241 SIZE_LOCATION
, SIZE_LOCATION
, buf
,
242 SIZE_INSTRUCTION
, name
);
250 for (i
= 0; i
< 3; i
++)
265 sprintf (p
, "%sr%d", comma
, OP
[i
]);
273 sprintf (p
, "%scr%d", comma
, OP
[i
]);
279 case OP_ACCUM_OUTPUT
:
280 case OP_ACCUM_REVERSE
:
281 sprintf (p
, "%sa%d", comma
, OP
[i
]);
287 sprintf (p
, "%s%d", comma
, OP
[i
]);
293 sprintf (p
, "%s%d", comma
, SEXT8(OP
[i
]));
299 sprintf (p
, "%s%d", comma
, SEXT4(OP
[i
]));
305 sprintf (p
, "%s%d", comma
, SEXT3(OP
[i
]));
311 sprintf (p
, "%s@r%d", comma
, OP
[i
]);
317 sprintf (p
, "%s@(%d,r%d)", comma
, (int16
)OP
[i
], OP
[i
+1]);
323 sprintf (p
, "%s@r%d+", comma
, OP
[i
]);
329 sprintf (p
, "%s@r%d-", comma
, OP
[i
]);
335 sprintf (p
, "%s@-r%d", comma
, OP
[i
]);
343 sprintf (p
, "%sf0", comma
);
346 sprintf (p
, "%sf1", comma
);
349 sprintf (p
, "%sc", comma
);
357 if ((d10v_debug
& DEBUG_VALUES
) == 0)
361 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%s", buf
);
366 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%-*s", SIZE_OPERANDS
, buf
);
369 for (i
= 0; i
< 3; i
++)
375 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s", SIZE_VALUES
, "");
381 case OP_ACCUM_OUTPUT
:
383 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s", SIZE_VALUES
, "---");
391 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
392 (uint16
)State
.regs
[OP
[i
]]);
396 tmp
= (long)((((uint32
) State
.regs
[OP
[i
]]) << 16) | ((uint32
) State
.regs
[OP
[i
]+1]));
397 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.8lx", SIZE_VALUES
-10, "", tmp
);
402 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
403 (uint16
)State
.cregs
[OP
[i
]]);
407 case OP_ACCUM_REVERSE
:
408 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.2x%.8lx", SIZE_VALUES
-12, "",
409 ((int)(State
.a
[OP
[i
]] >> 32) & 0xff),
410 ((unsigned long)State
.a
[OP
[i
]]) & 0xffffffff);
414 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
419 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
420 (uint16
)SEXT4(OP
[i
]));
424 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
425 (uint16
)SEXT8(OP
[i
]));
429 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
430 (uint16
)SEXT3(OP
[i
]));
435 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*sF0 = %d", SIZE_VALUES
-6, "",
439 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*sF1 = %d", SIZE_VALUES
-6, "",
443 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*sC = %d", SIZE_VALUES
-5, "",
449 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
451 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
452 (uint16
)State
.regs
[OP
[++i
]]);
456 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
457 (uint16
)State
.regs
[0]);
461 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
462 (uint16
)State
.regs
[1]);
466 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
467 (uint16
)State
.regs
[2]);
471 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
472 (uint16
)State
.regs
[0]);
473 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
474 (uint16
)State
.regs
[1]);
481 (*d10v_callback
->flush_stdout
) (d10v_callback
);
485 trace_output_func (result
)
486 enum op_types result
;
488 if ((d10v_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
500 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.4x F0=%d F1=%d C=%d\n", SIZE_VALUES
-6, "",
501 (uint16
)State
.regs
[OP
[0]],
502 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
507 tmp
= (long)((((uint32
) State
.regs
[OP
[0]]) << 16) | ((uint32
) State
.regs
[OP
[0]+1]));
508 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.8lx F0=%d F1=%d C=%d\n", SIZE_VALUES
-10, "", tmp
,
509 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
514 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.4x F0=%d F1=%d C=%d\n", SIZE_VALUES
-6, "",
515 (uint16
)State
.cregs
[OP
[0]],
516 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
520 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.4x F0=%d F1=%d C=%d\n", SIZE_VALUES
-6, "",
521 (uint16
)State
.cregs
[OP
[1]],
522 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
526 case OP_ACCUM_OUTPUT
:
527 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.2x%.8lx F0=%d F1=%d C=%d\n", SIZE_VALUES
-12, "",
528 ((int)(State
.a
[OP
[0]] >> 32) & 0xff),
529 ((unsigned long)State
.a
[OP
[0]]) & 0xffffffff,
530 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
533 case OP_ACCUM_REVERSE
:
534 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.2x%.8lx F0=%d F1=%d C=%d\n", SIZE_VALUES
-12, "",
535 ((int)(State
.a
[OP
[1]] >> 32) & 0xff),
536 ((unsigned long)State
.a
[OP
[1]]) & 0xffffffff,
537 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
542 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s F0=%d F1=%d C=%d\n", SIZE_VALUES
, "",
543 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
547 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.4x F0=%d F1=%d C=%d\n", SIZE_VALUES
-6, "",
548 (uint16
)State
.regs
[0],
549 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
553 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.4x%.4x F0=%d F1=%d C=%d\n", SIZE_VALUES
-10, "",
554 (uint16
)State
.regs
[0], (uint16
)State
.regs
[1],
555 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
560 (*d10v_callback
->flush_stdout
) (d10v_callback
);
564 #define trace_input(NAME, IN1, IN2, IN3)
565 #define trace_output(RESULT)
572 trace_input ("abs", OP_REG
, OP_VOID
, OP_VOID
);
574 if ((int16
)(State
.regs
[OP
[0]]) < 0)
576 State
.regs
[OP
[0]] = -(int16
)(State
.regs
[OP
[0]]);
581 trace_output (OP_REG
);
590 trace_input ("abs", OP_ACCUM
, OP_VOID
, OP_VOID
);
592 State
.a
[OP
[0]] = SEXT40(State
.a
[OP
[0]]);
594 if (State
.a
[OP
[0]] < 0 )
596 tmp
= -State
.a
[OP
[0]];
600 State
.a
[OP
[0]] = MAX32
;
601 else if (tmp
< MIN32
)
602 State
.a
[OP
[0]] = MIN32
;
604 State
.a
[OP
[0]] = tmp
& MASK40
;
607 State
.a
[OP
[0]] = tmp
& MASK40
;
612 trace_output (OP_ACCUM
);
619 uint16 tmp
= State
.regs
[OP
[0]];
620 trace_input ("add", OP_REG
, OP_REG
, OP_VOID
);
621 State
.regs
[OP
[0]] += State
.regs
[OP
[1]];
622 if ( tmp
> State
.regs
[OP
[0]])
626 trace_output (OP_REG
);
634 tmp
= SEXT40(State
.a
[OP
[0]]) + (SEXT16 (State
.regs
[OP
[1]]) << 16 | State
.regs
[OP
[1]+1]);
636 trace_input ("add", OP_ACCUM
, OP_REG
, OP_VOID
);
640 State
.a
[OP
[0]] = MAX32
;
641 else if ( tmp
< MIN32
)
642 State
.a
[OP
[0]] = MIN32
;
644 State
.a
[OP
[0]] = tmp
& MASK40
;
647 State
.a
[OP
[0]] = tmp
& MASK40
;
648 trace_output (OP_ACCUM
);
656 tmp
= SEXT40(State
.a
[OP
[0]]) + SEXT40(State
.a
[OP
[1]]);
658 trace_input ("add", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
662 State
.a
[OP
[0]] = MAX32
;
663 else if ( tmp
< MIN32
)
664 State
.a
[OP
[0]] = MIN32
;
666 State
.a
[OP
[0]] = tmp
& MASK40
;
669 State
.a
[OP
[0]] = tmp
& MASK40
;
670 trace_output (OP_ACCUM
);
678 uint32 a
= (State
.regs
[OP
[0]]) << 16 | State
.regs
[OP
[0]+1];
679 uint32 b
= (State
.regs
[OP
[1]]) << 16 | State
.regs
[OP
[1]+1];
681 trace_input ("add2w", OP_DREG
, OP_DREG
, OP_VOID
);
684 State
.regs
[OP
[0]] = tmp
>> 16;
685 State
.regs
[OP
[0]+1] = tmp
& 0xFFFF;
686 trace_output (OP_DREG
);
693 uint16 tmp
= State
.regs
[OP
[1]];
694 State
.regs
[OP
[0]] = tmp
+ OP
[2];
696 trace_input ("add3", OP_REG_OUTPUT
, OP_REG
, OP_CONSTANT16
);
697 State
.C
= (State
.regs
[OP
[0]] < tmp
);
698 trace_output (OP_REG
);
706 tmp
= SEXT40(State
.a
[OP
[2]]) + SEXT40 ((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]);
708 trace_input ("addac3", OP_DREG_OUTPUT
, OP_DREG
, OP_ACCUM
);
709 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
710 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
711 trace_output (OP_DREG
);
719 tmp
= SEXT40(State
.a
[OP
[1]]) + SEXT40(State
.a
[OP
[2]]);
721 trace_input ("addac3", OP_DREG_OUTPUT
, OP_ACCUM
, OP_ACCUM
);
722 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
723 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
724 trace_output (OP_DREG
);
734 trace_input ("addac3s", OP_DREG_OUTPUT
, OP_DREG
, OP_ACCUM
);
735 tmp
= SEXT40(State
.a
[OP
[2]]) + SEXT40 ((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]);
738 State
.regs
[OP
[0]] = 0x7fff;
739 State
.regs
[OP
[0]+1] = 0xffff;
742 else if (tmp
< MIN32
)
744 State
.regs
[OP
[0]] = 0x8000;
745 State
.regs
[OP
[0]+1] = 0;
750 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
751 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
754 trace_output (OP_DREG
);
764 trace_input ("addac3s", OP_DREG_OUTPUT
, OP_ACCUM
, OP_ACCUM
);
765 tmp
= SEXT40(State
.a
[OP
[1]]) + SEXT40(State
.a
[OP
[2]]);
768 State
.regs
[OP
[0]] = 0x7fff;
769 State
.regs
[OP
[0]+1] = 0xffff;
772 else if (tmp
< MIN32
)
774 State
.regs
[OP
[0]] = 0x8000;
775 State
.regs
[OP
[0]+1] = 0;
780 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
781 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
784 trace_output (OP_DREG
);
791 uint tmp
= State
.regs
[OP
[0]];
795 trace_input ("addi", OP_REG
, OP_CONSTANT16
, OP_VOID
);
796 State
.regs
[OP
[0]] += OP
[1];
797 State
.C
= (State
.regs
[OP
[0]] < tmp
);
798 trace_output (OP_REG
);
805 trace_input ("and", OP_REG
, OP_REG
, OP_VOID
);
806 State
.regs
[OP
[0]] &= State
.regs
[OP
[1]];
807 trace_output (OP_REG
);
814 trace_input ("and3", OP_REG_OUTPUT
, OP_REG
, OP_CONSTANT16
);
815 State
.regs
[OP
[0]] = State
.regs
[OP
[1]] & OP
[2];
816 trace_output (OP_REG
);
823 trace_input ("bclri", OP_REG
, OP_CONSTANT16
, OP_VOID
);
824 State
.regs
[OP
[0]] &= ~(0x8000 >> OP
[1]);
825 trace_output (OP_REG
);
832 trace_input ("bl.s", OP_CONSTANT8
, OP_R0
, OP_R1
);
833 State
.regs
[13] = PC
+1;
834 JMP( PC
+ SEXT8 (OP
[0]));
835 trace_output (OP_VOID
);
842 trace_input ("bl.l", OP_CONSTANT16
, OP_R0
, OP_R1
);
843 State
.regs
[13] = PC
+1;
845 trace_output (OP_VOID
);
852 trace_input ("bnoti", OP_REG
, OP_CONSTANT16
, OP_VOID
);
853 State
.regs
[OP
[0]] ^= 0x8000 >> OP
[1];
854 trace_output (OP_REG
);
861 trace_input ("bra.s", OP_CONSTANT8
, OP_VOID
, OP_VOID
);
862 JMP (PC
+ SEXT8 (OP
[0]));
863 trace_output (OP_VOID
);
870 trace_input ("bra.l", OP_CONSTANT16
, OP_VOID
, OP_VOID
);
872 trace_output (OP_VOID
);
879 trace_input ("brf0f.s", OP_CONSTANT8
, OP_VOID
, OP_VOID
);
881 JMP (PC
+ SEXT8 (OP
[0]));
882 trace_output (OP_FLAG
);
889 trace_input ("brf0f.l", OP_CONSTANT16
, OP_VOID
, OP_VOID
);
892 trace_output (OP_FLAG
);
899 trace_input ("brf0t.s", OP_CONSTANT8
, OP_VOID
, OP_VOID
);
901 JMP (PC
+ SEXT8 (OP
[0]));
902 trace_output (OP_FLAG
);
909 trace_input ("brf0t.l", OP_CONSTANT16
, OP_VOID
, OP_VOID
);
912 trace_output (OP_FLAG
);
919 trace_input ("bseti", OP_REG
, OP_CONSTANT16
, OP_VOID
);
920 State
.regs
[OP
[0]] |= 0x8000 >> OP
[1];
921 trace_output (OP_REG
);
928 trace_input ("btsti", OP_REG
, OP_CONSTANT16
, OP_VOID
);
930 State
.F0
= (State
.regs
[OP
[0]] & (0x8000 >> OP
[1])) ? 1 : 0;
931 trace_output (OP_FLAG
);
938 trace_input ("clrac", OP_ACCUM_OUTPUT
, OP_VOID
, OP_VOID
);
940 trace_output (OP_ACCUM
);
947 trace_input ("cmp", OP_REG
, OP_REG
, OP_VOID
);
949 State
.F0
= ((int16
)(State
.regs
[OP
[0]]) < (int16
)(State
.regs
[OP
[1]])) ? 1 : 0;
950 trace_output (OP_FLAG
);
957 trace_input ("cmp", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
959 State
.F0
= (SEXT40(State
.a
[OP
[0]]) < SEXT40(State
.a
[OP
[1]])) ? 1 : 0;
960 trace_output (OP_FLAG
);
967 trace_input ("cmpeq", OP_REG
, OP_REG
, OP_VOID
);
969 State
.F0
= (State
.regs
[OP
[0]] == State
.regs
[OP
[1]]) ? 1 : 0;
970 trace_output (OP_FLAG
);
977 trace_input ("cmpeq", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
979 State
.F0
= ((State
.a
[OP
[0]] & MASK40
) == (State
.a
[OP
[1]] & MASK40
)) ? 1 : 0;
980 trace_output (OP_FLAG
);
987 trace_input ("cmpeqi.s", OP_REG
, OP_CONSTANT4
, OP_VOID
);
989 State
.F0
= (State
.regs
[OP
[0]] == (reg_t
)SEXT4(OP
[1])) ? 1 : 0;
990 trace_output (OP_FLAG
);
997 trace_input ("cmpeqi.l", OP_REG
, OP_CONSTANT16
, OP_VOID
);
999 State
.F0
= (State
.regs
[OP
[0]] == (reg_t
)OP
[1]) ? 1 : 0;
1000 trace_output (OP_FLAG
);
1007 trace_input ("cmpi.s", OP_REG
, OP_CONSTANT4
, OP_VOID
);
1008 State
.F1
= State
.F0
;
1009 State
.F0
= ((int16
)(State
.regs
[OP
[0]]) < (int16
)SEXT4(OP
[1])) ? 1 : 0;
1010 trace_output (OP_FLAG
);
1017 trace_input ("cmpi.l", OP_REG
, OP_CONSTANT16
, OP_VOID
);
1018 State
.F1
= State
.F0
;
1019 State
.F0
= ((int16
)(State
.regs
[OP
[0]]) < (int16
)(OP
[1])) ? 1 : 0;
1020 trace_output (OP_FLAG
);
1027 trace_input ("cmpu", OP_REG
, OP_REG
, OP_VOID
);
1028 State
.F1
= State
.F0
;
1029 State
.F0
= (State
.regs
[OP
[0]] < State
.regs
[OP
[1]]) ? 1 : 0;
1030 trace_output (OP_FLAG
);
1037 trace_input ("cmpui", OP_REG
, OP_CONSTANT16
, OP_VOID
);
1038 State
.F1
= State
.F0
;
1039 State
.F0
= (State
.regs
[OP
[0]] < (reg_t
)OP
[1]) ? 1 : 0;
1040 trace_output (OP_FLAG
);
1049 trace_input ("cpfg", OP_FLAG_OUTPUT
, OP_FLAG
, OP_VOID
);
1057 else if (OP
[1] == 1)
1063 trace_output (OP_FLAG
);
1070 /* d10v_callback->printf_filtered(d10v_callback, "***** DBT ***** PC=%x\n",PC); */
1071 State
.exception
= SIGTRAP
;
1078 uint16 foo
, tmp
, tmpf
;
1080 trace_input ("divs", OP_DREG
, OP_REG
, OP_VOID
);
1081 foo
= (State
.regs
[OP
[0]] << 1) | (State
.regs
[OP
[0]+1] >> 15);
1082 tmp
= (int16
)foo
- (int16
)(State
.regs
[OP
[1]]);
1083 tmpf
= (foo
>= State
.regs
[OP
[1]]) ? 1 : 0;
1084 State
.regs
[OP
[0]] = (tmpf
== 1) ? tmp
: foo
;
1085 State
.regs
[OP
[0]+1] = (State
.regs
[OP
[0]+1] << 1) | tmpf
;
1086 trace_output (OP_DREG
);
1093 trace_input ("exef0f", OP_VOID
, OP_VOID
, OP_VOID
);
1094 State
.exe
= (State
.F0
== 0);
1095 trace_output (OP_FLAG
);
1102 trace_input ("exef0t", OP_VOID
, OP_VOID
, OP_VOID
);
1103 State
.exe
= (State
.F0
!= 0);
1104 trace_output (OP_FLAG
);
1111 trace_input ("exef1f", OP_VOID
, OP_VOID
, OP_VOID
);
1112 State
.exe
= (State
.F1
== 0);
1113 trace_output (OP_FLAG
);
1120 trace_input ("exef1t", OP_VOID
, OP_VOID
, OP_VOID
);
1121 State
.exe
= (State
.F1
!= 0);
1122 trace_output (OP_FLAG
);
1129 trace_input ("exefaf", OP_VOID
, OP_VOID
, OP_VOID
);
1130 State
.exe
= (State
.F0
== 0) & (State
.F1
== 0);
1131 trace_output (OP_FLAG
);
1138 trace_input ("exefat", OP_VOID
, OP_VOID
, OP_VOID
);
1139 State
.exe
= (State
.F0
== 0) & (State
.F1
!= 0);
1140 trace_output (OP_FLAG
);
1147 trace_input ("exetaf", OP_VOID
, OP_VOID
, OP_VOID
);
1148 State
.exe
= (State
.F0
!= 0) & (State
.F1
== 0);
1149 trace_output (OP_FLAG
);
1156 trace_input ("exetat", OP_VOID
, OP_VOID
, OP_VOID
);
1157 State
.exe
= (State
.F0
!= 0) & (State
.F1
!= 0);
1158 trace_output (OP_FLAG
);
1168 trace_input ("exp", OP_REG_OUTPUT
, OP_DREG
, OP_VOID
);
1169 if (((int16
)State
.regs
[OP
[1]]) >= 0)
1170 tmp
= (State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1];
1172 tmp
= ~((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]);
1179 State
.regs
[OP
[0]] = i
-1;
1180 trace_output (OP_REG
);
1185 State
.regs
[OP
[0]] = 16;
1186 trace_output (OP_REG
);
1196 trace_input ("exp", OP_REG_OUTPUT
, OP_ACCUM
, OP_VOID
);
1197 tmp
= SEXT40(State
.a
[OP
[1]]);
1199 tmp
= ~tmp
& MASK40
;
1201 foo
= 0x4000000000LL
;
1206 State
.regs
[OP
[0]] = i
-9;
1207 trace_output (OP_REG
);
1212 State
.regs
[OP
[0]] = 16;
1213 trace_output (OP_REG
);
1220 trace_input ("jl", OP_REG
, OP_R0
, OP_R1
);
1221 State
.regs
[13] = PC
+1;
1222 JMP (State
.regs
[OP
[0]]);
1223 trace_output (OP_VOID
);
1230 trace_input ("jmp", OP_REG
,
1231 (OP
[0] == 13) ? OP_R0
: OP_VOID
,
1232 (OP
[0] == 13) ? OP_R1
: OP_VOID
);
1234 JMP (State
.regs
[OP
[0]]);
1235 trace_output (OP_VOID
);
1242 trace_input ("ld", OP_REG_OUTPUT
, OP_MEMREF2
, OP_VOID
);
1243 State
.regs
[OP
[0]] = RW (OP
[1] + State
.regs
[OP
[2]]);
1244 trace_output (OP_REG
);
1251 trace_input ("ld", OP_REG_OUTPUT
, OP_POSTDEC
, OP_VOID
);
1252 State
.regs
[OP
[0]] = RW (State
.regs
[OP
[1]]);
1253 INC_ADDR(State
.regs
[OP
[1]],-2);
1254 trace_output (OP_REG
);
1261 trace_input ("ld", OP_REG_OUTPUT
, OP_POSTINC
, OP_VOID
);
1262 State
.regs
[OP
[0]] = RW (State
.regs
[OP
[1]]);
1263 INC_ADDR(State
.regs
[OP
[1]],2);
1264 trace_output (OP_REG
);
1271 trace_input ("ld", OP_REG_OUTPUT
, OP_MEMREF
, OP_VOID
);
1272 State
.regs
[OP
[0]] = RW (State
.regs
[OP
[1]]);
1273 trace_output (OP_REG
);
1280 uint16 addr
= State
.regs
[OP
[2]];
1281 trace_input ("ld2w", OP_REG_OUTPUT
, OP_MEMREF2
, OP_VOID
);
1282 State
.regs
[OP
[0]] = RW (OP
[1] + addr
);
1283 State
.regs
[OP
[0]+1] = RW (OP
[1] + addr
+ 2);
1284 trace_output (OP_DREG
);
1291 uint16 addr
= State
.regs
[OP
[1]];
1292 trace_input ("ld2w", OP_REG_OUTPUT
, OP_POSTDEC
, OP_VOID
);
1293 State
.regs
[OP
[0]] = RW (addr
);
1294 State
.regs
[OP
[0]+1] = RW (addr
+2);
1295 INC_ADDR(State
.regs
[OP
[1]],-4);
1296 trace_output (OP_DREG
);
1303 uint16 addr
= State
.regs
[OP
[1]];
1304 trace_input ("ld2w", OP_REG_OUTPUT
, OP_POSTINC
, OP_VOID
);
1305 State
.regs
[OP
[0]] = RW (addr
);
1306 State
.regs
[OP
[0]+1] = RW (addr
+2);
1307 INC_ADDR(State
.regs
[OP
[1]],4);
1308 trace_output (OP_DREG
);
1315 uint16 addr
= State
.regs
[OP
[1]];
1316 trace_input ("ld2w", OP_REG_OUTPUT
, OP_MEMREF
, OP_VOID
);
1317 State
.regs
[OP
[0]] = RW (addr
);
1318 State
.regs
[OP
[0]+1] = RW (addr
+2);
1319 trace_output (OP_DREG
);
1326 trace_input ("ldb", OP_REG_OUTPUT
, OP_MEMREF2
, OP_VOID
);
1327 State
.regs
[OP
[0]] = SEXT8 (RB (OP
[1] + State
.regs
[OP
[2]]));
1328 trace_output (OP_REG
);
1335 trace_input ("ldb", OP_REG_OUTPUT
, OP_MEMREF
, OP_VOID
);
1336 State
.regs
[OP
[0]] = SEXT8 (RB (State
.regs
[OP
[1]]));
1337 trace_output (OP_REG
);
1344 trace_input ("ldi.s", OP_REG_OUTPUT
, OP_CONSTANT4
, OP_VOID
);
1345 State
.regs
[OP
[0]] = SEXT4(OP
[1]);
1346 trace_output (OP_REG
);
1353 trace_input ("ldi.l", OP_REG_OUTPUT
, OP_CONSTANT16
, OP_VOID
);
1354 State
.regs
[OP
[0]] = OP
[1];
1355 trace_output (OP_REG
);
1362 trace_input ("ldub", OP_REG_OUTPUT
, OP_MEMREF2
, OP_VOID
);
1363 State
.regs
[OP
[0]] = RB (OP
[1] + State
.regs
[OP
[2]]);
1364 trace_output (OP_REG
);
1371 trace_input ("ldub", OP_REG_OUTPUT
, OP_MEMREF
, OP_VOID
);
1372 State
.regs
[OP
[0]] = RB (State
.regs
[OP
[1]]);
1373 trace_output (OP_REG
);
1382 trace_input ("mac", OP_ACCUM
, OP_REG
, OP_REG
);
1383 tmp
= SEXT40 ((int16
)(State
.regs
[OP
[1]]) * (int16
)(State
.regs
[OP
[2]]));
1386 tmp
= SEXT40( (tmp
<< 1) & MASK40
);
1388 if (State
.ST
&& tmp
> MAX32
)
1391 tmp
+= SEXT40(State
.a
[OP
[0]]);
1395 State
.a
[OP
[0]] = MAX32
;
1396 else if (tmp
< MIN32
)
1397 State
.a
[OP
[0]] = MIN32
;
1399 State
.a
[OP
[0]] = tmp
& MASK40
;
1402 State
.a
[OP
[0]] = tmp
& MASK40
;
1403 trace_output (OP_ACCUM
);
1412 trace_input ("macsu", OP_ACCUM
, OP_REG
, OP_REG
);
1413 tmp
= SEXT40 ((int16
)State
.regs
[OP
[1]] * State
.regs
[OP
[2]]);
1415 tmp
= SEXT40( (tmp
<< 1) & MASK40
);
1417 State
.a
[OP
[0]] = (SEXT40 (State
.a
[OP
[0]]) + tmp
) & MASK40
;
1418 trace_output (OP_ACCUM
);
1429 trace_input ("macu", OP_ACCUM
, OP_REG
, OP_REG
);
1430 src1
= (uint16
) State
.regs
[OP
[1]];
1431 src2
= (uint16
) State
.regs
[OP
[2]];
1435 State
.a
[OP
[0]] = (State
.a
[OP
[0]] + tmp
) & MASK40
;
1436 trace_output (OP_ACCUM
);
1443 trace_input ("max", OP_REG
, OP_REG
, OP_VOID
);
1444 State
.F1
= State
.F0
;
1445 if ((int16
)State
.regs
[OP
[1]] > (int16
)State
.regs
[OP
[0]])
1447 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1452 trace_output (OP_REG
);
1461 trace_input ("max", OP_ACCUM
, OP_DREG
, OP_VOID
);
1462 State
.F1
= State
.F0
;
1463 tmp
= SEXT16 (State
.regs
[OP
[1]]) << 16 | State
.regs
[OP
[1]+1];
1464 if (tmp
> SEXT40(State
.a
[OP
[0]]))
1466 State
.a
[OP
[0]] = tmp
& MASK40
;
1471 trace_output (OP_ACCUM
);
1478 trace_input ("max", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
1479 State
.F1
= State
.F0
;
1480 if (SEXT40(State
.a
[OP
[1]]) > SEXT40(State
.a
[OP
[0]]))
1482 State
.a
[OP
[0]] = State
.a
[OP
[1]];
1487 trace_output (OP_ACCUM
);
1495 trace_input ("min", OP_REG
, OP_REG
, OP_VOID
);
1496 State
.F1
= State
.F0
;
1497 if ((int16
)State
.regs
[OP
[1]] < (int16
)State
.regs
[OP
[0]])
1499 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1504 trace_output (OP_REG
);
1513 trace_input ("min", OP_ACCUM
, OP_DREG
, OP_VOID
);
1514 State
.F1
= State
.F0
;
1515 tmp
= SEXT16 (State
.regs
[OP
[1]]) << 16 | State
.regs
[OP
[1]+1];
1516 if (tmp
< SEXT40(State
.a
[OP
[0]]))
1518 State
.a
[OP
[0]] = tmp
& MASK40
;
1523 trace_output (OP_ACCUM
);
1530 trace_input ("min", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
1531 State
.F1
= State
.F0
;
1532 if (SEXT40(State
.a
[OP
[1]]) < SEXT40(State
.a
[OP
[0]]))
1534 State
.a
[OP
[0]] = State
.a
[OP
[1]];
1539 trace_output (OP_ACCUM
);
1548 trace_input ("msb", OP_ACCUM
, OP_REG
, OP_REG
);
1549 tmp
= SEXT40 ((int16
)(State
.regs
[OP
[1]]) * (int16
)(State
.regs
[OP
[2]]));
1552 tmp
= SEXT40 ((tmp
<< 1) & MASK40
);
1554 if (State
.ST
&& tmp
> MAX32
)
1557 tmp
= SEXT40(State
.a
[OP
[0]]) - tmp
;
1561 State
.a
[OP
[0]] = MAX32
;
1562 else if (tmp
< MIN32
)
1563 State
.a
[OP
[0]] = MIN32
;
1565 State
.a
[OP
[0]] = tmp
& MASK40
;
1568 State
.a
[OP
[0]] = tmp
& MASK40
;
1569 trace_output (OP_ACCUM
);
1578 trace_input ("msbsu", OP_ACCUM
, OP_REG
, OP_REG
);
1579 tmp
= SEXT40 ((int16
)State
.regs
[OP
[1]] * State
.regs
[OP
[2]]);
1581 tmp
= SEXT40( (tmp
<< 1) & MASK40
);
1583 State
.a
[OP
[0]] = (SEXT40 (State
.a
[OP
[0]]) - tmp
) & MASK40
;
1584 trace_output (OP_ACCUM
);
1595 trace_input ("msbu", OP_ACCUM
, OP_REG
, OP_REG
);
1596 src1
= (uint16
) State
.regs
[OP
[1]];
1597 src2
= (uint16
) State
.regs
[OP
[2]];
1602 State
.a
[OP
[0]] = (State
.a
[OP
[0]] - tmp
) & MASK40
;
1603 trace_output (OP_ACCUM
);
1610 trace_input ("mul", OP_REG
, OP_REG
, OP_VOID
);
1611 State
.regs
[OP
[0]] *= State
.regs
[OP
[1]];
1612 trace_output (OP_REG
);
1621 trace_input ("mulx", OP_ACCUM_OUTPUT
, OP_REG
, OP_REG
);
1622 tmp
= SEXT40 ((int16
)(State
.regs
[OP
[1]]) * (int16
)(State
.regs
[OP
[2]]));
1625 tmp
= SEXT40 ((tmp
<< 1) & MASK40
);
1627 if (State
.ST
&& tmp
> MAX32
)
1628 State
.a
[OP
[0]] = MAX32
;
1630 State
.a
[OP
[0]] = tmp
& MASK40
;
1631 trace_output (OP_ACCUM
);
1640 trace_input ("mulxsu", OP_ACCUM_OUTPUT
, OP_REG
, OP_REG
);
1641 tmp
= SEXT40 ((int16
)(State
.regs
[OP
[1]]) * State
.regs
[OP
[2]]);
1646 State
.a
[OP
[0]] = tmp
& MASK40
;
1647 trace_output (OP_ACCUM
);
1658 trace_input ("mulxu", OP_ACCUM_OUTPUT
, OP_REG
, OP_REG
);
1659 src1
= (uint16
) State
.regs
[OP
[1]];
1660 src2
= (uint16
) State
.regs
[OP
[2]];
1665 State
.a
[OP
[0]] = tmp
& MASK40
;
1666 trace_output (OP_ACCUM
);
1673 trace_input ("mv", OP_REG_OUTPUT
, OP_REG
, OP_VOID
);
1674 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1675 trace_output (OP_REG
);
1682 trace_input ("mv2w", OP_DREG_OUTPUT
, OP_DREG
, OP_VOID
);
1683 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1684 State
.regs
[OP
[0]+1] = State
.regs
[OP
[1]+1];
1685 trace_output (OP_DREG
);
1692 trace_input ("mv2wfac", OP_DREG_OUTPUT
, OP_ACCUM
, OP_VOID
);
1693 State
.regs
[OP
[0]] = (State
.a
[OP
[1]] >> 16) & 0xffff;
1694 State
.regs
[OP
[0]+1] = State
.a
[OP
[1]] & 0xffff;
1695 trace_output (OP_DREG
);
1702 trace_input ("mv2wtac", OP_DREG
, OP_ACCUM_OUTPUT
, OP_VOID
);
1703 State
.a
[OP
[1]] = (SEXT16 (State
.regs
[OP
[0]]) << 16 | State
.regs
[OP
[0]+1]) & MASK40
;
1704 trace_output (OP_ACCUM_REVERSE
);
1711 trace_input ("mvac", OP_ACCUM_OUTPUT
, OP_ACCUM
, OP_VOID
);
1712 State
.a
[OP
[0]] = State
.a
[OP
[1]];
1713 trace_output (OP_ACCUM
);
1720 trace_input ("mvb", OP_REG_OUTPUT
, OP_REG
, OP_VOID
);
1721 State
.regs
[OP
[0]] = SEXT8 (State
.regs
[OP
[1]] & 0xff);
1722 trace_output (OP_REG
);
1729 trace_input ("mf0f", OP_REG_OUTPUT
, OP_REG
, OP_VOID
);
1731 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1732 trace_output (OP_REG
);
1739 trace_input ("mf0t", OP_REG_OUTPUT
, OP_REG
, OP_VOID
);
1741 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1742 trace_output (OP_REG
);
1749 trace_input ("mvfacg", OP_REG_OUTPUT
, OP_ACCUM
, OP_VOID
);
1750 State
.regs
[OP
[0]] = (State
.a
[OP
[1]] >> 32) & 0xff;
1751 trace_output (OP_ACCUM
);
1758 trace_input ("mvfachi", OP_REG_OUTPUT
, OP_ACCUM
, OP_VOID
);
1759 State
.regs
[OP
[0]] = (State
.a
[OP
[1]] >> 16) & 0xffff;
1760 trace_output (OP_REG
);
1767 trace_input ("mvfaclo", OP_REG_OUTPUT
, OP_ACCUM
, OP_VOID
);
1768 State
.regs
[OP
[0]] = State
.a
[OP
[1]] & 0xffff;
1769 trace_output (OP_REG
);
1776 trace_input ("mvfc", OP_REG_OUTPUT
, OP_CR
, OP_VOID
);
1777 State
.regs
[OP
[0]] = move_from_cr (OP
[1]);
1778 trace_output (OP_REG
);
1785 trace_input ("mvtacg", OP_REG
, OP_ACCUM
, OP_VOID
);
1786 State
.a
[OP
[1]] &= MASK32
;
1787 State
.a
[OP
[1]] |= (int64
)(State
.regs
[OP
[0]] & 0xff) << 32;
1788 trace_output (OP_ACCUM_REVERSE
);
1797 trace_input ("mvtachi", OP_REG
, OP_ACCUM
, OP_VOID
);
1798 tmp
= State
.a
[OP
[1]] & 0xffff;
1799 State
.a
[OP
[1]] = (SEXT16 (State
.regs
[OP
[0]]) << 16 | tmp
) & MASK40
;
1800 trace_output (OP_ACCUM_REVERSE
);
1807 trace_input ("mvtaclo", OP_REG
, OP_ACCUM
, OP_VOID
);
1808 State
.a
[OP
[1]] = (SEXT16 (State
.regs
[OP
[0]])) & MASK40
;
1809 trace_output (OP_ACCUM_REVERSE
);
1816 trace_input ("mvtc", OP_REG
, OP_CR_OUTPUT
, OP_VOID
);
1817 move_to_cr (OP
[1], State
.regs
[OP
[0]]);
1818 trace_output (OP_CR_REVERSE
);
1825 trace_input ("mvub", OP_REG_OUTPUT
, OP_REG
, OP_VOID
);
1826 State
.regs
[OP
[0]] = State
.regs
[OP
[1]] & 0xff;
1827 trace_output (OP_REG
);
1834 trace_input ("neg", OP_REG
, OP_VOID
, OP_VOID
);
1835 State
.regs
[OP
[0]] = 0 - State
.regs
[OP
[0]];
1836 trace_output (OP_REG
);
1845 trace_input ("neg", OP_ACCUM
, OP_VOID
, OP_VOID
);
1846 tmp
= -SEXT40(State
.a
[OP
[0]]);
1850 State
.a
[OP
[0]] = MAX32
;
1851 else if (tmp
< MIN32
)
1852 State
.a
[OP
[0]] = MIN32
;
1854 State
.a
[OP
[0]] = tmp
& MASK40
;
1857 State
.a
[OP
[0]] = tmp
& MASK40
;
1858 trace_output (OP_ACCUM
);
1866 trace_input ("nop", OP_VOID
, OP_VOID
, OP_VOID
);
1868 ins_type_counters
[ (int)State
.ins_type
]--; /* don't count nops as normal instructions */
1869 switch (State
.ins_type
)
1872 ins_type_counters
[ (int)INS_UNKNOWN
]++;
1875 case INS_LEFT_PARALLEL
:
1876 /* Don't count a parallel op that includes a NOP as a true parallel op */
1877 ins_type_counters
[ (int)INS_RIGHT_PARALLEL
]--;
1878 ins_type_counters
[ (int)INS_RIGHT
]++;
1879 ins_type_counters
[ (int)INS_LEFT_NOPS
]++;
1883 case INS_LEFT_COND_EXE
:
1884 ins_type_counters
[ (int)INS_LEFT_NOPS
]++;
1887 case INS_RIGHT_PARALLEL
:
1888 /* Don't count a parallel op that includes a NOP as a true parallel op */
1889 ins_type_counters
[ (int)INS_LEFT_PARALLEL
]--;
1890 ins_type_counters
[ (int)INS_LEFT
]++;
1891 ins_type_counters
[ (int)INS_RIGHT_NOPS
]++;
1895 case INS_RIGHT_COND_EXE
:
1896 ins_type_counters
[ (int)INS_RIGHT_NOPS
]++;
1900 trace_output (OP_VOID
);
1907 trace_input ("not", OP_REG
, OP_VOID
, OP_VOID
);
1908 State
.regs
[OP
[0]] = ~(State
.regs
[OP
[0]]);
1909 trace_output (OP_REG
);
1916 trace_input ("or", OP_REG
, OP_REG
, OP_VOID
);
1917 State
.regs
[OP
[0]] |= State
.regs
[OP
[1]];
1918 trace_output (OP_REG
);
1925 trace_input ("or3", OP_REG_OUTPUT
, OP_REG
, OP_CONSTANT16
);
1926 State
.regs
[OP
[0]] = State
.regs
[OP
[1]] | OP
[2];
1927 trace_output (OP_REG
);
1935 int shift
= SEXT3 (OP
[2]);
1937 trace_input ("rac", OP_DREG_OUTPUT
, OP_ACCUM
, OP_CONSTANT3
);
1940 (*d10v_callback
->printf_filtered
) (d10v_callback
,
1941 "ERROR at PC 0x%x: instruction only valid for A0\n",
1943 State
.exception
= SIGILL
;
1946 State
.F1
= State
.F0
;
1947 tmp
= SEXT56 ((State
.a
[0] << 16) | (State
.a
[1] & 0xffff));
1953 tmp
>>= 16; /* look at bits 0:43 */
1954 if (tmp
> SEXT44 (SIGNED64 (0x0007fffffff)))
1956 State
.regs
[OP
[0]] = 0x7fff;
1957 State
.regs
[OP
[0]+1] = 0xffff;
1960 else if (tmp
< SEXT44 (SIGNED64 (0xfff80000000)))
1962 State
.regs
[OP
[0]] = 0x8000;
1963 State
.regs
[OP
[0]+1] = 0;
1968 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
1969 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
1972 trace_output (OP_DREG
);
1980 int shift
= SEXT3 (OP
[2]);
1982 trace_input ("rachi", OP_REG_OUTPUT
, OP_ACCUM
, OP_CONSTANT3
);
1983 State
.F1
= State
.F0
;
1985 tmp
= SEXT40 (State
.a
[OP
[1]]) << shift
;
1987 tmp
= SEXT40 (State
.a
[OP
[1]]) >> -shift
;
1990 if (tmp
> SEXT44 (SIGNED64 (0x0007fffffff)))
1992 State
.regs
[OP
[0]] = 0x7fff;
1995 else if (tmp
< SEXT44 (SIGNED64 (0xfff80000000)))
1997 State
.regs
[OP
[0]] = 0x8000;
2002 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
2005 trace_output (OP_REG
);
2012 trace_input ("rep", OP_REG
, OP_CONSTANT16
, OP_VOID
);
2015 RPT_C
= State
.regs
[OP
[0]];
2019 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: rep with count=0 is illegal.\n");
2020 State
.exception
= SIGILL
;
2024 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: rep must include at least 4 instructions.\n");
2025 State
.exception
= SIGILL
;
2027 trace_output (OP_VOID
);
2034 trace_input ("repi", OP_CONSTANT16
, OP_CONSTANT16
, OP_VOID
);
2041 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: repi with count=0 is illegal.\n");
2042 State
.exception
= SIGILL
;
2046 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: repi must include at least 4 instructions.\n");
2047 State
.exception
= SIGILL
;
2049 trace_output (OP_VOID
);
2056 d10v_callback
->printf_filtered(d10v_callback
, "ERROR: rtd - NOT IMPLEMENTED\n");
2057 State
.exception
= SIGILL
;
2064 trace_input ("rte", OP_VOID
, OP_VOID
, OP_VOID
);
2065 move_to_cr (PSW_CR
, BPSW
);
2067 trace_output (OP_VOID
);
2076 trace_input ("sadd", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
2077 tmp
= SEXT40(State
.a
[OP
[0]]) + (SEXT40(State
.a
[OP
[1]]) >> 16);
2081 State
.a
[OP
[0]] = MAX32
;
2082 else if (tmp
< MIN32
)
2083 State
.a
[OP
[0]] = MIN32
;
2085 State
.a
[OP
[0]] = tmp
& MASK40
;
2088 State
.a
[OP
[0]] = tmp
& MASK40
;
2089 trace_output (OP_ACCUM
);
2096 trace_input ("setf0f", OP_REG_OUTPUT
, OP_VOID
, OP_VOID
);
2097 State
.regs
[OP
[0]] = (State
.F0
== 0) ? 1 : 0;
2098 trace_output (OP_REG
);
2105 trace_input ("setf0t", OP_REG_OUTPUT
, OP_VOID
, OP_VOID
);
2106 State
.regs
[OP
[0]] = (State
.F0
== 1) ? 1 : 0;
2107 trace_output (OP_REG
);
2114 trace_input ("sleep", OP_VOID
, OP_VOID
, OP_VOID
);
2116 trace_output (OP_VOID
);
2123 trace_input ("sll", OP_REG
, OP_REG
, OP_VOID
);
2124 State
.regs
[OP
[0]] <<= (State
.regs
[OP
[1]] & 0xf);
2125 trace_output (OP_REG
);
2133 trace_input ("sll", OP_ACCUM
, OP_REG
, OP_VOID
);
2134 if ((State
.regs
[OP
[1]] & 31) <= 16)
2135 tmp
= SEXT40 (State
.a
[OP
[0]]) << (State
.regs
[OP
[1]] & 31);
2138 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: shift value %d too large.\n", State
.regs
[OP
[1]] & 31);
2139 State
.exception
= SIGILL
;
2146 State
.a
[OP
[0]] = MAX32
;
2147 else if (tmp
< 0xffffff80000000LL
)
2148 State
.a
[OP
[0]] = MIN32
;
2150 State
.a
[OP
[0]] = tmp
& MASK40
;
2153 State
.a
[OP
[0]] = tmp
& MASK40
;
2154 trace_output (OP_ACCUM
);
2161 trace_input ("slli", OP_REG
, OP_CONSTANT16
, OP_VOID
);
2162 State
.regs
[OP
[0]] <<= OP
[1];
2163 trace_output (OP_REG
);
2175 trace_input ("slli", OP_ACCUM
, OP_CONSTANT16
, OP_VOID
);
2176 tmp
= SEXT40(State
.a
[OP
[0]]) << OP
[1];
2181 State
.a
[OP
[0]] = MAX32
;
2182 else if (tmp
< 0xffffff80000000LL
)
2183 State
.a
[OP
[0]] = MIN32
;
2185 State
.a
[OP
[0]] = tmp
& MASK40
;
2188 State
.a
[OP
[0]] = tmp
& MASK40
;
2189 trace_output (OP_ACCUM
);
2196 trace_input ("slx", OP_REG
, OP_FLAG
, OP_VOID
);
2197 State
.regs
[OP
[0]] = (State
.regs
[OP
[0]] << 1) | State
.F0
;
2198 trace_output (OP_REG
);
2205 trace_input ("sra", OP_REG
, OP_REG
, OP_VOID
);
2206 State
.regs
[OP
[0]] = ((int16
)(State
.regs
[OP
[0]])) >> (State
.regs
[OP
[1]] & 0xf);
2207 trace_output (OP_REG
);
2214 trace_input ("sra", OP_ACCUM
, OP_REG
, OP_VOID
);
2215 if ((State
.regs
[OP
[1]] & 31) <= 16)
2216 State
.a
[OP
[0]] = (SEXT40(State
.a
[OP
[0]]) >> (State
.regs
[OP
[1]] & 31)) & MASK40
;
2219 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: shift value %d too large.\n", State
.regs
[OP
[1]] & 31);
2220 State
.exception
= SIGILL
;
2224 trace_output (OP_ACCUM
);
2231 trace_input ("srai", OP_REG
, OP_CONSTANT16
, OP_VOID
);
2232 State
.regs
[OP
[0]] = ((int16
)(State
.regs
[OP
[0]])) >> OP
[1];
2233 trace_output (OP_REG
);
2243 trace_input ("srai", OP_ACCUM
, OP_CONSTANT16
, OP_VOID
);
2244 State
.a
[OP
[0]] = (SEXT40(State
.a
[OP
[0]]) >> OP
[1]) & MASK40
;
2245 trace_output (OP_ACCUM
);
2252 trace_input ("srl", OP_REG
, OP_REG
, OP_VOID
);
2253 State
.regs
[OP
[0]] >>= (State
.regs
[OP
[1]] & 0xf);
2254 trace_output (OP_REG
);
2261 trace_input ("srl", OP_ACCUM
, OP_REG
, OP_VOID
);
2262 if ((State
.regs
[OP
[1]] & 31) <= 16)
2263 State
.a
[OP
[0]] = (uint64
)((State
.a
[OP
[0]] & MASK40
) >> (State
.regs
[OP
[1]] & 31));
2266 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: shift value %d too large.\n", State
.regs
[OP
[1]] & 31);
2267 State
.exception
= SIGILL
;
2271 trace_output (OP_ACCUM
);
2278 trace_input ("srli", OP_REG
, OP_CONSTANT16
, OP_VOID
);
2279 State
.regs
[OP
[0]] >>= OP
[1];
2280 trace_output (OP_REG
);
2290 trace_input ("srli", OP_ACCUM
, OP_CONSTANT16
, OP_VOID
);
2291 State
.a
[OP
[0]] = (uint64
)(State
.a
[OP
[0]] & MASK40
) >> OP
[1];
2292 trace_output (OP_ACCUM
);
2301 trace_input ("srx", OP_REG
, OP_FLAG
, OP_VOID
);
2302 tmp
= State
.F0
<< 15;
2303 State
.regs
[OP
[0]] = (State
.regs
[OP
[0]] >> 1) | tmp
;
2304 trace_output (OP_REG
);
2311 trace_input ("st", OP_REG
, OP_MEMREF2
, OP_VOID
);
2312 SW (OP
[1] + State
.regs
[OP
[2]], State
.regs
[OP
[0]]);
2313 trace_output (OP_VOID
);
2320 trace_input ("st", OP_REG
, OP_MEMREF
, OP_VOID
);
2321 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2322 trace_output (OP_VOID
);
2329 trace_input ("st", OP_REG
, OP_PREDEC
, OP_VOID
);
2332 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: cannot pre-decrement any registers but r15 (SP).\n");
2333 State
.exception
= SIGILL
;
2336 State
.regs
[OP
[1]] -= 2;
2337 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2338 trace_output (OP_VOID
);
2345 trace_input ("st", OP_REG
, OP_POSTINC
, OP_VOID
);
2346 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2347 INC_ADDR (State
.regs
[OP
[1]],2);
2348 trace_output (OP_VOID
);
2355 trace_input ("st", OP_REG
, OP_POSTDEC
, OP_VOID
);
2358 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: cannot post-decrement register r15 (SP).\n");
2359 State
.exception
= SIGILL
;
2362 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2363 INC_ADDR (State
.regs
[OP
[1]],-2);
2364 trace_output (OP_VOID
);
2371 trace_input ("st2w", OP_DREG
, OP_MEMREF2
, OP_VOID
);
2372 SW (State
.regs
[OP
[2]]+OP
[1], State
.regs
[OP
[0]]);
2373 SW (State
.regs
[OP
[2]]+OP
[1]+2, State
.regs
[OP
[0]+1]);
2374 trace_output (OP_VOID
);
2381 trace_input ("st2w", OP_DREG
, OP_MEMREF
, OP_VOID
);
2382 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2383 SW (State
.regs
[OP
[1]]+2, State
.regs
[OP
[0]+1]);
2384 trace_output (OP_VOID
);
2391 trace_input ("st2w", OP_DREG
, OP_PREDEC
, OP_VOID
);
2394 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: cannot pre-decrement any registers but r15 (SP).\n");
2395 State
.exception
= SIGILL
;
2398 State
.regs
[OP
[1]] -= 4;
2399 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2400 SW (State
.regs
[OP
[1]]+2, State
.regs
[OP
[0]+1]);
2401 trace_output (OP_VOID
);
2408 trace_input ("st2w", OP_DREG
, OP_POSTINC
, OP_VOID
);
2409 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2410 SW (State
.regs
[OP
[1]]+2, State
.regs
[OP
[0]+1]);
2411 INC_ADDR (State
.regs
[OP
[1]],4);
2412 trace_output (OP_VOID
);
2419 trace_input ("st2w", OP_DREG
, OP_POSTDEC
, OP_VOID
);
2422 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: cannot post-decrement register r15 (SP).\n");
2423 State
.exception
= SIGILL
;
2426 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2427 SW (State
.regs
[OP
[1]]+2, State
.regs
[OP
[0]+1]);
2428 INC_ADDR (State
.regs
[OP
[1]],-4);
2429 trace_output (OP_VOID
);
2436 trace_input ("stb", OP_REG
, OP_MEMREF2
, OP_VOID
);
2437 SB (State
.regs
[OP
[2]]+OP
[1], State
.regs
[OP
[0]]);
2438 trace_output (OP_VOID
);
2445 trace_input ("stb", OP_REG
, OP_MEMREF
, OP_VOID
);
2446 SB (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2447 trace_output (OP_VOID
);
2454 trace_input ("stop", OP_VOID
, OP_VOID
, OP_VOID
);
2455 State
.exception
= SIG_D10V_STOP
;
2456 trace_output (OP_VOID
);
2465 trace_input ("sub", OP_REG
, OP_REG
, OP_VOID
);
2466 /* see ../common/sim-alu.h for a more extensive discussion on how to
2467 compute the carry/overflow bits. */
2468 tmp
= State
.regs
[OP
[0]] - State
.regs
[OP
[1]];
2469 State
.C
= ((uint16
) State
.regs
[OP
[0]] >= (uint16
) State
.regs
[OP
[1]]);
2470 State
.regs
[OP
[0]] = tmp
;
2471 trace_output (OP_REG
);
2480 trace_input ("sub", OP_ACCUM
, OP_DREG
, OP_VOID
);
2481 tmp
= SEXT40(State
.a
[OP
[0]]) - (SEXT16 (State
.regs
[OP
[1]]) << 16 | State
.regs
[OP
[1]+1]);
2485 State
.a
[OP
[0]] = MAX32
;
2486 else if ( tmp
< MIN32
)
2487 State
.a
[OP
[0]] = MIN32
;
2489 State
.a
[OP
[0]] = tmp
& MASK40
;
2492 State
.a
[OP
[0]] = tmp
& MASK40
;
2494 trace_output (OP_ACCUM
);
2504 trace_input ("sub", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
2505 tmp
= SEXT40(State
.a
[OP
[0]]) - SEXT40(State
.a
[OP
[1]]);
2509 State
.a
[OP
[0]] = MAX32
;
2510 else if ( tmp
< MIN32
)
2511 State
.a
[OP
[0]] = MIN32
;
2513 State
.a
[OP
[0]] = tmp
& MASK40
;
2516 State
.a
[OP
[0]] = tmp
& MASK40
;
2518 trace_output (OP_ACCUM
);
2527 trace_input ("sub2w", OP_DREG
, OP_DREG
, OP_VOID
);
2528 a
= (uint32
)((State
.regs
[OP
[0]] << 16) | State
.regs
[OP
[0]+1]);
2529 b
= (uint32
)((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]);
2530 /* see ../common/sim-alu.h for a more extensive discussion on how to
2531 compute the carry/overflow bits */
2534 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
2535 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
2536 trace_output (OP_DREG
);
2545 trace_input ("subac3", OP_DREG_OUTPUT
, OP_DREG
, OP_ACCUM
);
2546 tmp
= SEXT40 ((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]) - SEXT40 (State
.a
[OP
[2]]);
2547 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
2548 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
2549 trace_output (OP_DREG
);
2558 trace_input ("subac3", OP_DREG_OUTPUT
, OP_ACCUM
, OP_ACCUM
);
2559 tmp
= SEXT40(State
.a
[OP
[1]]) - SEXT40(State
.a
[OP
[2]]);
2560 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
2561 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
2562 trace_output (OP_DREG
);
2571 trace_input ("subac3s", OP_DREG_OUTPUT
, OP_DREG
, OP_ACCUM
);
2572 State
.F1
= State
.F0
;
2573 tmp
= SEXT40 ((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]) - SEXT40(State
.a
[OP
[2]]);
2576 State
.regs
[OP
[0]] = 0x7fff;
2577 State
.regs
[OP
[0]+1] = 0xffff;
2580 else if (tmp
< MIN32
)
2582 State
.regs
[OP
[0]] = 0x8000;
2583 State
.regs
[OP
[0]+1] = 0;
2588 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
2589 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
2592 trace_output (OP_DREG
);
2601 trace_input ("subac3s", OP_DREG_OUTPUT
, OP_ACCUM
, OP_ACCUM
);
2602 State
.F1
= State
.F0
;
2603 tmp
= SEXT40(State
.a
[OP
[1]]) - SEXT40(State
.a
[OP
[2]]);
2606 State
.regs
[OP
[0]] = 0x7fff;
2607 State
.regs
[OP
[0]+1] = 0xffff;
2610 else if (tmp
< MIN32
)
2612 State
.regs
[OP
[0]] = 0x8000;
2613 State
.regs
[OP
[0]+1] = 0;
2618 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
2619 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
2622 trace_output (OP_DREG
);
2633 trace_input ("subi", OP_REG
, OP_CONSTANT16
, OP_VOID
);
2634 /* see ../common/sim-alu.h for a more extensive discussion on how to
2635 compute the carry/overflow bits. */
2636 /* since OP[1] is never <= 0, -OP[1] == ~OP[1]+1 can never overflow */
2637 tmp
= ((unsigned)(unsigned16
) State
.regs
[OP
[0]]
2638 + (unsigned)(unsigned16
) ( - OP
[1]));
2639 State
.C
= (tmp
>= (1 << 16));
2640 State
.regs
[OP
[0]] = tmp
;
2641 trace_output (OP_REG
);
2648 trace_input ("trap", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
2649 trace_output (OP_VOID
);
2655 uint16 vec
= OP
[0] + TRAP_VECTOR_START
;
2657 move_to_cr (BPSW_CR
, PSW
);
2658 move_to_cr (PSW_CR
, PSW
& PSW_SM_BIT
);
2662 case 15: /* new system call trap */
2663 /* Trap 15 is used for simulating low-level I/O */
2667 /* Registers passed to trap 0 */
2669 #define FUNC State.regs[4] /* function number */
2670 #define PARM1 State.regs[0] /* optional parm 1 */
2671 #define PARM2 State.regs[1] /* optional parm 2 */
2672 #define PARM3 State.regs[2] /* optional parm 3 */
2673 #define PARM4 State.regs[3] /* optional parm 3 */
2675 /* Registers set by trap 0 */
2677 #define RETVAL State.regs[0] /* return value */
2678 #define RETVAL_HIGH State.regs[0] /* return value */
2679 #define RETVAL_LOW State.regs[1] /* return value */
2680 #define RETERR State.regs[4] /* return error code */
2682 /* Turn a pointer in a register into a pointer into real memory. */
2684 #define MEMPTR(x) ((char *)(dmem_addr(x)))
2688 #if !defined(__GO32__) && !defined(_WIN32)
2691 trace_input ("<fork>", OP_VOID
, OP_VOID
, OP_VOID
);
2692 trace_output (OP_R0
);
2696 trace_input ("<getpid>", OP_VOID
, OP_VOID
, OP_VOID
);
2698 trace_output (OP_R0
);
2702 trace_input ("<kill>", OP_REG
, OP_REG
, OP_VOID
);
2703 if (PARM1
== getpid ())
2705 trace_output (OP_VOID
);
2706 State
.exception
= PARM2
;
2714 case 1: os_sig
= SIGHUP
; break;
2717 case 2: os_sig
= SIGINT
; break;
2720 case 3: os_sig
= SIGQUIT
; break;
2723 case 4: os_sig
= SIGILL
; break;
2726 case 5: os_sig
= SIGTRAP
; break;
2729 case 6: os_sig
= SIGABRT
; break;
2730 #elif defined(SIGIOT)
2731 case 6: os_sig
= SIGIOT
; break;
2734 case 7: os_sig
= SIGEMT
; break;
2737 case 8: os_sig
= SIGFPE
; break;
2740 case 9: os_sig
= SIGKILL
; break;
2743 case 10: os_sig
= SIGBUS
; break;
2746 case 11: os_sig
= SIGSEGV
; break;
2749 case 12: os_sig
= SIGSYS
; break;
2752 case 13: os_sig
= SIGPIPE
; break;
2755 case 14: os_sig
= SIGALRM
; break;
2758 case 15: os_sig
= SIGTERM
; break;
2761 case 16: os_sig
= SIGURG
; break;
2764 case 17: os_sig
= SIGSTOP
; break;
2767 case 18: os_sig
= SIGTSTP
; break;
2770 case 19: os_sig
= SIGCONT
; break;
2773 case 20: os_sig
= SIGCHLD
; break;
2774 #elif defined(SIGCLD)
2775 case 20: os_sig
= SIGCLD
; break;
2778 case 21: os_sig
= SIGTTIN
; break;
2781 case 22: os_sig
= SIGTTOU
; break;
2784 case 23: os_sig
= SIGIO
; break;
2785 #elif defined (SIGPOLL)
2786 case 23: os_sig
= SIGPOLL
; break;
2789 case 24: os_sig
= SIGXCPU
; break;
2792 case 25: os_sig
= SIGXFSZ
; break;
2795 case 26: os_sig
= SIGVTALRM
; break;
2798 case 27: os_sig
= SIGPROF
; break;
2801 case 28: os_sig
= SIGWINCH
; break;
2804 case 29: os_sig
= SIGLOST
; break;
2807 case 30: os_sig
= SIGUSR1
; break;
2810 case 31: os_sig
= SIGUSR2
; break;
2816 trace_output (OP_VOID
);
2817 (*d10v_callback
->printf_filtered
) (d10v_callback
, "Unknown signal %d\n", PARM2
);
2818 (*d10v_callback
->flush_stdout
) (d10v_callback
);
2819 State
.exception
= SIGILL
;
2823 RETVAL
= kill (PARM1
, PARM2
);
2824 trace_output (OP_R0
);
2830 RETVAL
= execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
),
2831 (char **)MEMPTR (PARM3
));
2832 trace_input ("<execve>", OP_R0
, OP_R1
, OP_R2
);
2833 trace_output (OP_R0
);
2838 RETVAL
= execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
), NULL
);
2839 trace_input ("<execv>", OP_R0
, OP_R1
, OP_VOID
);
2840 trace_output (OP_R0
);
2850 RETVAL
= pipe (host_fd
);
2851 SW (buf
, host_fd
[0]);
2852 buf
+= sizeof(uint16
);
2853 SW (buf
, host_fd
[1]);
2854 trace_input ("<pipe>", OP_R0
, OP_VOID
, OP_VOID
);
2855 trace_output (OP_R0
);
2864 RETVAL
= wait (&status
);
2867 trace_input ("<wait>", OP_R0
, OP_VOID
, OP_VOID
);
2868 trace_output (OP_R0
);
2874 trace_input ("<getpid>", OP_VOID
, OP_VOID
, OP_VOID
);
2876 trace_output (OP_R0
);
2880 trace_input ("<kill>", OP_REG
, OP_REG
, OP_VOID
);
2881 trace_output (OP_VOID
);
2882 State
.exception
= PARM2
;
2887 RETVAL
= d10v_callback
->read (d10v_callback
, PARM1
, MEMPTR (PARM2
),
2889 trace_input ("<read>", OP_R0
, OP_R1
, OP_R2
);
2890 trace_output (OP_R0
);
2895 RETVAL
= (int)d10v_callback
->write_stdout (d10v_callback
,
2896 MEMPTR (PARM2
), PARM3
);
2898 RETVAL
= (int)d10v_callback
->write (d10v_callback
, PARM1
,
2899 MEMPTR (PARM2
), PARM3
);
2900 trace_input ("<write>", OP_R0
, OP_R1
, OP_R2
);
2901 trace_output (OP_R0
);
2906 unsigned long ret
= d10v_callback
->lseek (d10v_callback
, PARM1
,
2907 (((unsigned long)PARM2
) << 16) || (unsigned long)PARM3
,
2909 RETVAL_HIGH
= ret
>> 16;
2910 RETVAL_LOW
= ret
& 0xffff;
2912 trace_input ("<lseek>", OP_R0
, OP_R1
, OP_R2
);
2913 trace_output (OP_R0R1
);
2917 RETVAL
= d10v_callback
->close (d10v_callback
, PARM1
);
2918 trace_input ("<close>", OP_R0
, OP_VOID
, OP_VOID
);
2919 trace_output (OP_R0
);
2923 RETVAL
= d10v_callback
->open (d10v_callback
, MEMPTR (PARM1
), PARM2
);
2924 trace_input ("<open>", OP_R0
, OP_R1
, OP_R2
);
2925 trace_output (OP_R0
);
2926 trace_input ("<open>", OP_R0
, OP_R1
, OP_R2
);
2927 trace_output (OP_R0
);
2931 State
.exception
= SIG_D10V_EXIT
;
2932 trace_input ("<exit>", OP_R0
, OP_VOID
, OP_VOID
);
2933 trace_output (OP_VOID
);
2937 /* stat system call */
2939 struct stat host_stat
;
2942 RETVAL
= stat (MEMPTR (PARM1
), &host_stat
);
2946 /* The hard-coded offsets and sizes were determined by using
2947 * the D10V compiler on a test program that used struct stat.
2949 SW (buf
, host_stat
.st_dev
);
2950 SW (buf
+2, host_stat
.st_ino
);
2951 SW (buf
+4, host_stat
.st_mode
);
2952 SW (buf
+6, host_stat
.st_nlink
);
2953 SW (buf
+8, host_stat
.st_uid
);
2954 SW (buf
+10, host_stat
.st_gid
);
2955 SW (buf
+12, host_stat
.st_rdev
);
2956 SLW (buf
+16, host_stat
.st_size
);
2957 SLW (buf
+20, host_stat
.st_atime
);
2958 SLW (buf
+28, host_stat
.st_mtime
);
2959 SLW (buf
+36, host_stat
.st_ctime
);
2961 trace_input ("<stat>", OP_R0
, OP_R1
, OP_VOID
);
2962 trace_output (OP_R0
);
2966 RETVAL
= chown (MEMPTR (PARM1
), PARM2
, PARM3
);
2967 trace_input ("<chown>", OP_R0
, OP_R1
, OP_R2
);
2968 trace_output (OP_R0
);
2972 RETVAL
= chmod (MEMPTR (PARM1
), PARM2
);
2973 trace_input ("<chmod>", OP_R0
, OP_R1
, OP_R2
);
2974 trace_output (OP_R0
);
2979 /* Cast the second argument to void *, to avoid type mismatch
2980 if a prototype is present. */
2981 RETVAL
= utime (MEMPTR (PARM1
), (void *) MEMPTR (PARM2
));
2982 trace_input ("<utime>", OP_R0
, OP_R1
, OP_R2
);
2983 trace_output (OP_R0
);
2990 unsigned long ret
= time (PARM1
? MEMPTR (PARM1
) : NULL
);
2991 RETVAL_HIGH
= ret
>> 16;
2992 RETVAL_LOW
= ret
& 0xffff;
2994 trace_input ("<time>", OP_R0
, OP_R1
, OP_R2
);
2995 trace_output (OP_R0R1
);
3002 RETERR
= (RETVAL
== (uint16
) -1) ? d10v_callback
->get_errno(d10v_callback
) : 0;
3012 trace_input ("tst0i", OP_REG
, OP_CONSTANT16
, OP_VOID
);
3013 State
.F1
= State
.F0
;
3014 State
.F0
= (State
.regs
[OP
[0]] & OP
[1]) ? 1 : 0;
3015 trace_output (OP_FLAG
);
3022 trace_input ("tst1i", OP_REG
, OP_CONSTANT16
, OP_VOID
);
3023 State
.F1
= State
.F0
;
3024 State
.F0
= (~(State
.regs
[OP
[0]]) & OP
[1]) ? 1 : 0;
3025 trace_output (OP_FLAG
);
3032 trace_input ("wait", OP_VOID
, OP_VOID
, OP_VOID
);
3034 trace_output (OP_VOID
);
3041 trace_input ("xor", OP_REG
, OP_REG
, OP_VOID
);
3042 State
.regs
[OP
[0]] ^= State
.regs
[OP
[1]];
3043 trace_output (OP_REG
);
3050 trace_input ("xor3", OP_REG_OUTPUT
, OP_REG
, OP_CONSTANT16
);
3051 State
.regs
[OP
[0]] = State
.regs
[OP
[1]] ^ OP
[2];
3052 trace_output (OP_REG
);