3c4a0af7dc9a62aae5fa31fce5e52625b3f7d847
13 #include "sys/syscall.h"
15 extern char *strrchr ();
47 static void trace_input_func
PARAMS ((char *name
,
52 #define trace_input(name, in1, in2, in3) do { if (d10v_debug) trace_input_func (name, in1, in2, in3); } while (0)
54 static void trace_output_func
PARAMS ((enum op_types result
));
56 #define trace_output(result) do { if (d10v_debug) trace_output_func (result); } while (0)
58 #ifndef SIZE_INSTRUCTION
59 #define SIZE_INSTRUCTION 8
63 #define SIZE_OPERANDS 18
67 #define SIZE_VALUES 13
71 #define SIZE_LOCATION 20
78 #ifndef SIZE_LINE_NUMBER
79 #define SIZE_LINE_NUMBER 4
83 trace_input_func (name
, in1
, in2
, in3
)
97 const char *functionname
;
98 unsigned int linenumber
;
101 if ((d10v_debug
& DEBUG_TRACE
) == 0)
104 switch (State
.ins_type
)
107 case INS_UNKNOWN
: type
= " ?"; break;
108 case INS_LEFT
: type
= " L"; break;
109 case INS_RIGHT
: type
= " R"; break;
110 case INS_LEFT_PARALLEL
: type
= "*L"; break;
111 case INS_RIGHT_PARALLEL
: type
= "*R"; break;
112 case INS_LEFT_COND_TEST
: type
= "?L"; break;
113 case INS_RIGHT_COND_TEST
: type
= "?R"; break;
114 case INS_LEFT_COND_EXE
: type
= "&L"; break;
115 case INS_RIGHT_COND_EXE
: type
= "&R"; break;
116 case INS_LONG
: type
= " B"; break;
119 if ((d10v_debug
& DEBUG_LINE_NUMBER
) == 0)
120 (*d10v_callback
->printf_filtered
) (d10v_callback
,
122 SIZE_PC
, (unsigned)PC
,
124 SIZE_INSTRUCTION
, name
);
129 byte_pc
= decode_pc ();
130 if (text
&& byte_pc
>= text_start
&& byte_pc
< text_end
)
132 filename
= (const char *)0;
133 functionname
= (const char *)0;
135 if (bfd_find_nearest_line (exec_bfd
, text
, (struct symbol_cache_entry
**)0, byte_pc
- text_start
,
136 &filename
, &functionname
, &linenumber
))
141 sprintf (p
, "#%-*d ", SIZE_LINE_NUMBER
, linenumber
);
146 sprintf (p
, "%-*s ", SIZE_LINE_NUMBER
+1, "---");
147 p
+= SIZE_LINE_NUMBER
+2;
152 sprintf (p
, "%s ", functionname
);
157 char *q
= strrchr (filename
, '/');
158 sprintf (p
, "%s ", (q
) ? q
+1 : filename
);
167 (*d10v_callback
->printf_filtered
) (d10v_callback
,
168 "0x%.*x %s: %-*.*s %-*s ",
169 SIZE_PC
, (unsigned)PC
,
171 SIZE_LOCATION
, SIZE_LOCATION
, buf
,
172 SIZE_INSTRUCTION
, name
);
180 for (i
= 0; i
< 3; i
++)
195 sprintf (p
, "%sr%d", comma
, OP
[i
]);
203 sprintf (p
, "%scr%d", comma
, OP
[i
]);
209 case OP_ACCUM_OUTPUT
:
210 case OP_ACCUM_REVERSE
:
211 sprintf (p
, "%sa%d", comma
, OP
[i
]);
217 sprintf (p
, "%s%d", comma
, OP
[i
]);
223 sprintf (p
, "%s%d", comma
, SEXT8(OP
[i
]));
229 sprintf (p
, "%s%d", comma
, SEXT4(OP
[i
]));
235 sprintf (p
, "%s%d", comma
, SEXT3(OP
[i
]));
241 sprintf (p
, "%s@r%d", comma
, OP
[i
]);
247 sprintf (p
, "%s@(%d,r%d)", comma
, (int16
)OP
[i
], OP
[i
+1]);
253 sprintf (p
, "%s@r%d+", comma
, OP
[i
]);
259 sprintf (p
, "%s@r%d-", comma
, OP
[i
]);
265 sprintf (p
, "%s@-r%d", comma
, OP
[i
]);
273 sprintf (p
, "%sf0", comma
);
276 sprintf (p
, "%sf1", comma
);
279 sprintf (p
, "%sc", comma
);
287 if ((d10v_debug
& DEBUG_VALUES
) == 0)
291 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%s", buf
);
296 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%-*s", SIZE_OPERANDS
, buf
);
299 for (i
= 0; i
< 3; i
++)
305 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s", SIZE_VALUES
, "");
311 case OP_ACCUM_OUTPUT
:
313 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s", SIZE_VALUES
, "---");
321 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
322 (uint16
)State
.regs
[OP
[i
]]);
326 tmp
= (long)((((uint32
) State
.regs
[OP
[i
]]) << 16) | ((uint32
) State
.regs
[OP
[i
]+1]));
327 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.8lx", SIZE_VALUES
-10, "", tmp
);
332 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
333 (uint16
)State
.cregs
[OP
[i
]]);
337 case OP_ACCUM_REVERSE
:
338 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.2x%.8lx", SIZE_VALUES
-12, "",
339 ((int)(State
.a
[OP
[i
]] >> 32) & 0xff),
340 ((unsigned long)State
.a
[OP
[i
]]) & 0xffffffff);
344 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
349 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
350 (uint16
)SEXT4(OP
[i
]));
354 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
355 (uint16
)SEXT8(OP
[i
]));
359 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
360 (uint16
)SEXT3(OP
[i
]));
365 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*sF0 = %d", SIZE_VALUES
-6, "",
369 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*sF1 = %d", SIZE_VALUES
-6, "",
373 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*sC = %d", SIZE_VALUES
-5, "",
379 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
381 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
382 (uint16
)State
.regs
[OP
[++i
]]);
386 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
387 (uint16
)State
.regs
[2]);
391 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
392 (uint16
)State
.regs
[3]);
396 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
397 (uint16
)State
.regs
[4]);
401 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
402 (uint16
)State
.regs
[2]);
403 (*d10v_callback
->printf_filtered
) (d10v_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
404 (uint16
)State
.regs
[3]);
411 (*d10v_callback
->flush_stdout
) (d10v_callback
);
415 trace_output_func (result
)
416 enum op_types result
;
418 if ((d10v_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
430 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.4x F0=%d F1=%d C=%d\n", SIZE_VALUES
-6, "",
431 (uint16
)State
.regs
[OP
[0]],
432 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
437 tmp
= (long)((((uint32
) State
.regs
[OP
[0]]) << 16) | ((uint32
) State
.regs
[OP
[0]+1]));
438 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.8lx F0=%d F1=%d C=%d\n", SIZE_VALUES
-10, "", tmp
,
439 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
444 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.4x F0=%d F1=%d C=%d\n", SIZE_VALUES
-6, "",
445 (uint16
)State
.cregs
[OP
[0]],
446 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
450 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.4x F0=%d F1=%d C=%d\n", SIZE_VALUES
-6, "",
451 (uint16
)State
.cregs
[OP
[1]],
452 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
456 case OP_ACCUM_OUTPUT
:
457 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.2x%.8lx F0=%d F1=%d C=%d\n", SIZE_VALUES
-12, "",
458 ((int)(State
.a
[OP
[0]] >> 32) & 0xff),
459 ((unsigned long)State
.a
[OP
[0]]) & 0xffffffff,
460 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
463 case OP_ACCUM_REVERSE
:
464 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.2x%.8lx F0=%d F1=%d C=%d\n", SIZE_VALUES
-12, "",
465 ((int)(State
.a
[OP
[1]] >> 32) & 0xff),
466 ((unsigned long)State
.a
[OP
[1]]) & 0xffffffff,
467 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
472 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s F0=%d F1=%d C=%d\n", SIZE_VALUES
, "",
473 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
477 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.4x F0=%d F1=%d C=%d\n", SIZE_VALUES
-6, "",
478 (uint16
)State
.regs
[2],
479 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
483 (*d10v_callback
->printf_filtered
) (d10v_callback
, " :: %*s0x%.4x%.4x F0=%d F1=%d C=%d\n", SIZE_VALUES
-10, "",
484 (uint16
)State
.regs
[2], (uint16
)State
.regs
[3],
485 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
490 (*d10v_callback
->flush_stdout
) (d10v_callback
);
494 #define trace_input(NAME, IN1, IN2, IN3)
495 #define trace_output(RESULT)
502 trace_input ("abs", OP_REG
, OP_VOID
, OP_VOID
);
504 if ((int16
)(State
.regs
[OP
[0]]) < 0)
506 State
.regs
[OP
[0]] = -(int16
)(State
.regs
[OP
[0]]);
511 trace_output (OP_REG
);
520 trace_input ("abs", OP_ACCUM
, OP_VOID
, OP_VOID
);
522 State
.a
[OP
[0]] = SEXT40(State
.a
[OP
[0]]);
524 if (State
.a
[OP
[0]] < 0 )
526 tmp
= -State
.a
[OP
[0]];
530 State
.a
[OP
[0]] = MAX32
;
531 else if (tmp
< MIN32
)
532 State
.a
[OP
[0]] = MIN32
;
534 State
.a
[OP
[0]] = tmp
& MASK40
;
537 State
.a
[OP
[0]] = tmp
& MASK40
;
542 trace_output (OP_ACCUM
);
549 uint16 tmp
= State
.regs
[OP
[0]];
550 trace_input ("add", OP_REG
, OP_REG
, OP_VOID
);
551 State
.regs
[OP
[0]] += State
.regs
[OP
[1]];
552 if ( tmp
> State
.regs
[OP
[0]])
556 trace_output (OP_REG
);
564 tmp
= SEXT40(State
.a
[OP
[0]]) + (SEXT16 (State
.regs
[OP
[1]]) << 16 | State
.regs
[OP
[1]+1]);
566 trace_input ("add", OP_ACCUM
, OP_REG
, OP_VOID
);
570 State
.a
[OP
[0]] = MAX32
;
571 else if ( tmp
< MIN32
)
572 State
.a
[OP
[0]] = MIN32
;
574 State
.a
[OP
[0]] = tmp
& MASK40
;
577 State
.a
[OP
[0]] = tmp
& MASK40
;
578 trace_output (OP_ACCUM
);
586 tmp
= SEXT40(State
.a
[OP
[0]]) + SEXT40(State
.a
[OP
[1]]);
588 trace_input ("add", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
592 State
.a
[OP
[0]] = MAX32
;
593 else if ( tmp
< MIN32
)
594 State
.a
[OP
[0]] = MIN32
;
596 State
.a
[OP
[0]] = tmp
& MASK40
;
599 State
.a
[OP
[0]] = tmp
& MASK40
;
600 trace_output (OP_ACCUM
);
608 uint32 a
= (State
.regs
[OP
[0]]) << 16 | State
.regs
[OP
[0]+1];
609 uint32 b
= (State
.regs
[OP
[1]]) << 16 | State
.regs
[OP
[1]+1];
611 trace_input ("add2w", OP_DREG
, OP_DREG
, OP_VOID
);
614 State
.regs
[OP
[0]] = tmp
>> 16;
615 State
.regs
[OP
[0]+1] = tmp
& 0xFFFF;
616 trace_output (OP_DREG
);
623 uint16 tmp
= State
.regs
[OP
[1]];
624 State
.regs
[OP
[0]] = tmp
+ OP
[2];
626 trace_input ("add3", OP_REG_OUTPUT
, OP_REG
, OP_CONSTANT16
);
627 State
.C
= (State
.regs
[OP
[0]] < tmp
);
628 trace_output (OP_REG
);
636 tmp
= SEXT40(State
.a
[OP
[2]]) + SEXT40 ((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]);
638 trace_input ("addac3", OP_DREG_OUTPUT
, OP_DREG
, OP_ACCUM
);
639 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
640 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
641 trace_output (OP_DREG
);
649 tmp
= SEXT40(State
.a
[OP
[1]]) + SEXT40(State
.a
[OP
[2]]);
651 trace_input ("addac3", OP_DREG_OUTPUT
, OP_ACCUM
, OP_ACCUM
);
652 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
653 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
654 trace_output (OP_DREG
);
664 trace_input ("addac3s", OP_DREG_OUTPUT
, OP_DREG
, OP_ACCUM
);
665 tmp
= SEXT40(State
.a
[OP
[2]]) + SEXT40 ((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]);
668 State
.regs
[OP
[0]] = 0x7fff;
669 State
.regs
[OP
[0]+1] = 0xffff;
672 else if (tmp
< MIN32
)
674 State
.regs
[OP
[0]] = 0x8000;
675 State
.regs
[OP
[0]+1] = 0;
680 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
681 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
684 trace_output (OP_DREG
);
694 trace_input ("addac3s", OP_DREG_OUTPUT
, OP_ACCUM
, OP_ACCUM
);
695 tmp
= SEXT40(State
.a
[OP
[1]]) + SEXT40(State
.a
[OP
[2]]);
698 State
.regs
[OP
[0]] = 0x7fff;
699 State
.regs
[OP
[0]+1] = 0xffff;
702 else if (tmp
< MIN32
)
704 State
.regs
[OP
[0]] = 0x8000;
705 State
.regs
[OP
[0]+1] = 0;
710 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
711 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
714 trace_output (OP_DREG
);
721 uint tmp
= State
.regs
[OP
[0]];
725 trace_input ("addi", OP_REG
, OP_CONSTANT16
, OP_VOID
);
726 State
.regs
[OP
[0]] += OP
[1];
727 State
.C
= (State
.regs
[OP
[0]] < tmp
);
728 trace_output (OP_REG
);
735 trace_input ("and", OP_REG
, OP_REG
, OP_VOID
);
736 State
.regs
[OP
[0]] &= State
.regs
[OP
[1]];
737 trace_output (OP_REG
);
744 trace_input ("and3", OP_REG_OUTPUT
, OP_REG
, OP_CONSTANT16
);
745 State
.regs
[OP
[0]] = State
.regs
[OP
[1]] & OP
[2];
746 trace_output (OP_REG
);
753 trace_input ("bclri", OP_REG
, OP_CONSTANT16
, OP_VOID
);
754 State
.regs
[OP
[0]] &= ~(0x8000 >> OP
[1]);
755 trace_output (OP_REG
);
762 trace_input ("bl.s", OP_CONSTANT8
, OP_R2
, OP_R3
);
763 State
.regs
[13] = PC
+1;
764 JMP( PC
+ SEXT8 (OP
[0]));
765 trace_output (OP_VOID
);
772 trace_input ("bl.l", OP_CONSTANT16
, OP_R2
, OP_R3
);
773 State
.regs
[13] = PC
+1;
775 trace_output (OP_VOID
);
782 trace_input ("bnoti", OP_REG
, OP_CONSTANT16
, OP_VOID
);
783 State
.regs
[OP
[0]] ^= 0x8000 >> OP
[1];
784 trace_output (OP_REG
);
791 trace_input ("bra.s", OP_CONSTANT8
, OP_VOID
, OP_VOID
);
792 JMP (PC
+ SEXT8 (OP
[0]));
793 trace_output (OP_VOID
);
800 trace_input ("bra.l", OP_CONSTANT16
, OP_VOID
, OP_VOID
);
802 trace_output (OP_VOID
);
809 trace_input ("brf0f.s", OP_CONSTANT8
, OP_VOID
, OP_VOID
);
811 JMP (PC
+ SEXT8 (OP
[0]));
812 trace_output (OP_FLAG
);
819 trace_input ("brf0f.l", OP_CONSTANT16
, OP_VOID
, OP_VOID
);
822 trace_output (OP_FLAG
);
829 trace_input ("brf0t.s", OP_CONSTANT8
, OP_VOID
, OP_VOID
);
831 JMP (PC
+ SEXT8 (OP
[0]));
832 trace_output (OP_FLAG
);
839 trace_input ("brf0t.l", OP_CONSTANT16
, OP_VOID
, OP_VOID
);
842 trace_output (OP_FLAG
);
849 trace_input ("bseti", OP_REG
, OP_CONSTANT16
, OP_VOID
);
850 State
.regs
[OP
[0]] |= 0x8000 >> OP
[1];
851 trace_output (OP_REG
);
858 trace_input ("btsti", OP_REG
, OP_CONSTANT16
, OP_VOID
);
860 State
.F0
= (State
.regs
[OP
[0]] & (0x8000 >> OP
[1])) ? 1 : 0;
861 trace_output (OP_FLAG
);
868 trace_input ("clrac", OP_ACCUM_OUTPUT
, OP_VOID
, OP_VOID
);
870 trace_output (OP_ACCUM
);
877 trace_input ("cmp", OP_REG
, OP_REG
, OP_VOID
);
879 State
.F0
= ((int16
)(State
.regs
[OP
[0]]) < (int16
)(State
.regs
[OP
[1]])) ? 1 : 0;
880 trace_output (OP_FLAG
);
887 trace_input ("cmp", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
889 State
.F0
= (SEXT40(State
.a
[OP
[0]]) < SEXT40(State
.a
[OP
[1]])) ? 1 : 0;
890 trace_output (OP_FLAG
);
897 trace_input ("cmpeq", OP_REG
, OP_REG
, OP_VOID
);
899 State
.F0
= (State
.regs
[OP
[0]] == State
.regs
[OP
[1]]) ? 1 : 0;
900 trace_output (OP_FLAG
);
907 trace_input ("cmpeq", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
909 State
.F0
= ((State
.a
[OP
[0]] & MASK40
) == (State
.a
[OP
[1]] & MASK40
)) ? 1 : 0;
910 trace_output (OP_FLAG
);
917 trace_input ("cmpeqi.s", OP_REG
, OP_CONSTANT4
, OP_VOID
);
919 State
.F0
= (State
.regs
[OP
[0]] == (reg_t
)SEXT4(OP
[1])) ? 1 : 0;
920 trace_output (OP_FLAG
);
927 trace_input ("cmpeqi.l", OP_REG
, OP_CONSTANT16
, OP_VOID
);
929 State
.F0
= (State
.regs
[OP
[0]] == (reg_t
)OP
[1]) ? 1 : 0;
930 trace_output (OP_FLAG
);
937 trace_input ("cmpi.s", OP_REG
, OP_CONSTANT4
, OP_VOID
);
939 State
.F0
= ((int16
)(State
.regs
[OP
[0]]) < (int16
)SEXT4(OP
[1])) ? 1 : 0;
940 trace_output (OP_FLAG
);
947 trace_input ("cmpi.l", OP_REG
, OP_CONSTANT16
, OP_VOID
);
949 State
.F0
= ((int16
)(State
.regs
[OP
[0]]) < (int16
)(OP
[1])) ? 1 : 0;
950 trace_output (OP_FLAG
);
957 trace_input ("cmpu", OP_REG
, OP_REG
, OP_VOID
);
959 State
.F0
= (State
.regs
[OP
[0]] < State
.regs
[OP
[1]]) ? 1 : 0;
960 trace_output (OP_FLAG
);
967 trace_input ("cmpui", OP_REG
, OP_CONSTANT16
, OP_VOID
);
969 State
.F0
= (State
.regs
[OP
[0]] < (reg_t
)OP
[1]) ? 1 : 0;
970 trace_output (OP_FLAG
);
979 trace_input ("cpfg", OP_FLAG_OUTPUT
, OP_FLAG
, OP_VOID
);
993 trace_output (OP_FLAG
);
1000 /* d10v_callback->printf_filtered(d10v_callback, "***** DBT ***** PC=%x\n",PC); */
1001 State
.exception
= SIGTRAP
;
1008 uint16 foo
, tmp
, tmpf
;
1010 trace_input ("divs", OP_DREG
, OP_REG
, OP_VOID
);
1011 foo
= (State
.regs
[OP
[0]] << 1) | (State
.regs
[OP
[0]+1] >> 15);
1012 tmp
= (int16
)foo
- (int16
)(State
.regs
[OP
[1]]);
1013 tmpf
= (foo
>= State
.regs
[OP
[1]]) ? 1 : 0;
1014 State
.regs
[OP
[0]] = (tmpf
== 1) ? tmp
: foo
;
1015 State
.regs
[OP
[0]+1] = (State
.regs
[OP
[0]+1] << 1) | tmpf
;
1016 trace_output (OP_DREG
);
1023 trace_input ("exef0f", OP_VOID
, OP_VOID
, OP_VOID
);
1024 State
.exe
= (State
.F0
== 0);
1025 trace_output (OP_FLAG
);
1032 trace_input ("exef0t", OP_VOID
, OP_VOID
, OP_VOID
);
1033 State
.exe
= (State
.F0
!= 0);
1034 trace_output (OP_FLAG
);
1041 trace_input ("exef1f", OP_VOID
, OP_VOID
, OP_VOID
);
1042 State
.exe
= (State
.F1
== 0);
1043 trace_output (OP_FLAG
);
1050 trace_input ("exef1t", OP_VOID
, OP_VOID
, OP_VOID
);
1051 State
.exe
= (State
.F1
!= 0);
1052 trace_output (OP_FLAG
);
1059 trace_input ("exefaf", OP_VOID
, OP_VOID
, OP_VOID
);
1060 State
.exe
= (State
.F0
== 0) & (State
.F1
== 0);
1061 trace_output (OP_FLAG
);
1068 trace_input ("exefat", OP_VOID
, OP_VOID
, OP_VOID
);
1069 State
.exe
= (State
.F0
== 0) & (State
.F1
!= 0);
1070 trace_output (OP_FLAG
);
1077 trace_input ("exetaf", OP_VOID
, OP_VOID
, OP_VOID
);
1078 State
.exe
= (State
.F0
!= 0) & (State
.F1
== 0);
1079 trace_output (OP_FLAG
);
1086 trace_input ("exetat", OP_VOID
, OP_VOID
, OP_VOID
);
1087 State
.exe
= (State
.F0
!= 0) & (State
.F1
!= 0);
1088 trace_output (OP_FLAG
);
1098 trace_input ("exp", OP_REG_OUTPUT
, OP_DREG
, OP_VOID
);
1099 if (((int16
)State
.regs
[OP
[1]]) >= 0)
1100 tmp
= (State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1];
1102 tmp
= ~((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]);
1109 State
.regs
[OP
[0]] = i
-1;
1110 trace_output (OP_REG
);
1115 State
.regs
[OP
[0]] = 16;
1116 trace_output (OP_REG
);
1126 trace_input ("exp", OP_REG_OUTPUT
, OP_ACCUM
, OP_VOID
);
1127 tmp
= SEXT40(State
.a
[OP
[1]]);
1129 tmp
= ~tmp
& MASK40
;
1131 foo
= 0x4000000000LL
;
1136 State
.regs
[OP
[0]] = i
-9;
1137 trace_output (OP_REG
);
1142 State
.regs
[OP
[0]] = 16;
1143 trace_output (OP_REG
);
1150 trace_input ("jl", OP_REG
, OP_R2
, OP_R3
);
1151 State
.regs
[13] = PC
+1;
1152 JMP (State
.regs
[OP
[0]]);
1153 trace_output (OP_VOID
);
1160 trace_input ("jmp", OP_REG
,
1161 (OP
[0] == 13) ? OP_R2
: OP_VOID
,
1162 (OP
[0] == 13) ? OP_R3
: OP_VOID
);
1164 JMP (State
.regs
[OP
[0]]);
1165 trace_output (OP_VOID
);
1172 trace_input ("ld", OP_REG_OUTPUT
, OP_MEMREF2
, OP_VOID
);
1173 State
.regs
[OP
[0]] = RW (OP
[1] + State
.regs
[OP
[2]]);
1174 trace_output (OP_REG
);
1181 trace_input ("ld", OP_REG_OUTPUT
, OP_POSTDEC
, OP_VOID
);
1184 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: cannot post-decrement register r15 (SP).\n");
1185 State
.exception
= SIGILL
;
1188 State
.regs
[OP
[0]] = RW (State
.regs
[OP
[1]]);
1189 INC_ADDR(State
.regs
[OP
[1]],-2);
1190 trace_output (OP_REG
);
1197 trace_input ("ld", OP_REG_OUTPUT
, OP_POSTINC
, OP_VOID
);
1198 State
.regs
[OP
[0]] = RW (State
.regs
[OP
[1]]);
1199 INC_ADDR(State
.regs
[OP
[1]],2);
1200 trace_output (OP_REG
);
1207 trace_input ("ld", OP_REG_OUTPUT
, OP_MEMREF
, OP_VOID
);
1208 State
.regs
[OP
[0]] = RW (State
.regs
[OP
[1]]);
1209 trace_output (OP_REG
);
1216 uint16 addr
= State
.regs
[OP
[2]];
1217 trace_input ("ld2w", OP_REG_OUTPUT
, OP_MEMREF2
, OP_VOID
);
1218 State
.regs
[OP
[0]] = RW (OP
[1] + addr
);
1219 State
.regs
[OP
[0]+1] = RW (OP
[1] + addr
+ 2);
1220 trace_output (OP_DREG
);
1227 uint16 addr
= State
.regs
[OP
[1]];
1228 trace_input ("ld2w", OP_REG_OUTPUT
, OP_POSTDEC
, OP_VOID
);
1231 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: cannot post-decrement register r15 (SP).\n");
1232 State
.exception
= SIGILL
;
1235 State
.regs
[OP
[0]] = RW (addr
);
1236 State
.regs
[OP
[0]+1] = RW (addr
+2);
1237 INC_ADDR(State
.regs
[OP
[1]],-4);
1238 trace_output (OP_DREG
);
1245 uint16 addr
= State
.regs
[OP
[1]];
1246 trace_input ("ld2w", OP_REG_OUTPUT
, OP_POSTINC
, OP_VOID
);
1247 State
.regs
[OP
[0]] = RW (addr
);
1248 State
.regs
[OP
[0]+1] = RW (addr
+2);
1249 INC_ADDR(State
.regs
[OP
[1]],4);
1250 trace_output (OP_DREG
);
1257 uint16 addr
= State
.regs
[OP
[1]];
1258 trace_input ("ld2w", OP_REG_OUTPUT
, OP_MEMREF
, OP_VOID
);
1259 State
.regs
[OP
[0]] = RW (addr
);
1260 State
.regs
[OP
[0]+1] = RW (addr
+2);
1261 trace_output (OP_DREG
);
1268 trace_input ("ldb", OP_REG_OUTPUT
, OP_MEMREF2
, OP_VOID
);
1269 State
.regs
[OP
[0]] = SEXT8 (RB (OP
[1] + State
.regs
[OP
[2]]));
1270 trace_output (OP_REG
);
1277 trace_input ("ldb", OP_REG_OUTPUT
, OP_MEMREF
, OP_VOID
);
1278 State
.regs
[OP
[0]] = SEXT8 (RB (State
.regs
[OP
[1]]));
1279 trace_output (OP_REG
);
1286 trace_input ("ldi.s", OP_REG_OUTPUT
, OP_CONSTANT4
, OP_VOID
);
1287 State
.regs
[OP
[0]] = SEXT4(OP
[1]);
1288 trace_output (OP_REG
);
1295 trace_input ("ldi.l", OP_REG_OUTPUT
, OP_CONSTANT16
, OP_VOID
);
1296 State
.regs
[OP
[0]] = OP
[1];
1297 trace_output (OP_REG
);
1304 trace_input ("ldub", OP_REG_OUTPUT
, OP_MEMREF2
, OP_VOID
);
1305 State
.regs
[OP
[0]] = RB (OP
[1] + State
.regs
[OP
[2]]);
1306 trace_output (OP_REG
);
1313 trace_input ("ldub", OP_REG_OUTPUT
, OP_MEMREF
, OP_VOID
);
1314 State
.regs
[OP
[0]] = RB (State
.regs
[OP
[1]]);
1315 trace_output (OP_REG
);
1324 trace_input ("mac", OP_ACCUM
, OP_REG
, OP_REG
);
1325 tmp
= SEXT40 ((int16
)(State
.regs
[OP
[1]]) * (int16
)(State
.regs
[OP
[2]]));
1328 tmp
= SEXT40( (tmp
<< 1) & MASK40
);
1330 if (State
.ST
&& tmp
> MAX32
)
1333 tmp
+= SEXT40(State
.a
[OP
[0]]);
1337 State
.a
[OP
[0]] = MAX32
;
1338 else if (tmp
< MIN32
)
1339 State
.a
[OP
[0]] = MIN32
;
1341 State
.a
[OP
[0]] = tmp
& MASK40
;
1344 State
.a
[OP
[0]] = tmp
& MASK40
;
1345 trace_output (OP_ACCUM
);
1354 trace_input ("macsu", OP_ACCUM
, OP_REG
, OP_REG
);
1355 tmp
= SEXT40 ((int16
)State
.regs
[OP
[1]] * State
.regs
[OP
[2]]);
1357 tmp
= SEXT40( (tmp
<< 1) & MASK40
);
1359 State
.a
[OP
[0]] = (SEXT40 (State
.a
[OP
[0]]) + tmp
) & MASK40
;
1360 trace_output (OP_ACCUM
);
1369 trace_input ("macu", OP_ACCUM
, OP_REG
, OP_REG
);
1370 tmp
= SEXT40 (State
.regs
[OP
[1]] * State
.regs
[OP
[2]]);
1372 tmp
= SEXT40( (tmp
<< 1) & MASK40
);
1373 State
.a
[OP
[0]] = (SEXT40 (State
.a
[OP
[0]]) + tmp
) & MASK40
;
1374 trace_output (OP_ACCUM
);
1381 trace_input ("max", OP_REG
, OP_REG
, OP_VOID
);
1382 State
.F1
= State
.F0
;
1383 if ((int16
)State
.regs
[OP
[1]] > (int16
)State
.regs
[OP
[0]])
1385 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1390 trace_output (OP_REG
);
1399 trace_input ("max", OP_ACCUM
, OP_DREG
, OP_VOID
);
1400 State
.F1
= State
.F0
;
1401 tmp
= SEXT16 (State
.regs
[OP
[1]]) << 16 | State
.regs
[OP
[1]+1];
1402 if (tmp
> SEXT40(State
.a
[OP
[0]]))
1404 State
.a
[OP
[0]] = tmp
& MASK40
;
1409 trace_output (OP_ACCUM
);
1416 trace_input ("max", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
1417 State
.F1
= State
.F0
;
1418 if (SEXT40(State
.a
[OP
[1]]) > SEXT40(State
.a
[OP
[0]]))
1420 State
.a
[OP
[0]] = State
.a
[OP
[1]];
1425 trace_output (OP_ACCUM
);
1433 trace_input ("min", OP_REG
, OP_REG
, OP_VOID
);
1434 State
.F1
= State
.F0
;
1435 if ((int16
)State
.regs
[OP
[1]] < (int16
)State
.regs
[OP
[0]])
1437 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1442 trace_output (OP_REG
);
1451 trace_input ("min", OP_ACCUM
, OP_DREG
, OP_VOID
);
1452 State
.F1
= State
.F0
;
1453 tmp
= SEXT16 (State
.regs
[OP
[1]]) << 16 | State
.regs
[OP
[1]+1];
1454 if (tmp
< SEXT40(State
.a
[OP
[0]]))
1456 State
.a
[OP
[0]] = tmp
& MASK40
;
1461 trace_output (OP_ACCUM
);
1468 trace_input ("min", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
1469 State
.F1
= State
.F0
;
1470 if (SEXT40(State
.a
[OP
[1]]) < SEXT40(State
.a
[OP
[0]]))
1472 State
.a
[OP
[0]] = State
.a
[OP
[1]];
1477 trace_output (OP_ACCUM
);
1486 trace_input ("msb", OP_ACCUM
, OP_REG
, OP_REG
);
1487 tmp
= SEXT40 ((int16
)(State
.regs
[OP
[1]]) * (int16
)(State
.regs
[OP
[2]]));
1490 tmp
= SEXT40 ((tmp
<< 1) & MASK40
);
1492 if (State
.ST
&& tmp
> MAX32
)
1495 tmp
= SEXT40(State
.a
[OP
[0]]) - tmp
;
1499 State
.a
[OP
[0]] = MAX32
;
1500 else if (tmp
< MIN32
)
1501 State
.a
[OP
[0]] = MIN32
;
1503 State
.a
[OP
[0]] = tmp
& MASK40
;
1506 State
.a
[OP
[0]] = tmp
& MASK40
;
1507 trace_output (OP_ACCUM
);
1516 trace_input ("msbsu", OP_ACCUM
, OP_REG
, OP_REG
);
1517 tmp
= SEXT40 ((int16
)State
.regs
[OP
[1]] * State
.regs
[OP
[2]]);
1519 tmp
= SEXT40( (tmp
<< 1) & MASK40
);
1521 State
.a
[OP
[0]] = (SEXT40 (State
.a
[OP
[0]]) - tmp
) & MASK40
;
1522 trace_output (OP_ACCUM
);
1531 trace_input ("msbu", OP_ACCUM
, OP_REG
, OP_REG
);
1532 tmp
= SEXT40 (State
.regs
[OP
[1]] * State
.regs
[OP
[2]]);
1534 tmp
= SEXT40( (tmp
<< 1) & MASK40
);
1536 State
.a
[OP
[0]] = (SEXT40 (State
.a
[OP
[0]]) - tmp
) & MASK40
;
1537 trace_output (OP_ACCUM
);
1544 trace_input ("mul", OP_REG
, OP_REG
, OP_VOID
);
1545 State
.regs
[OP
[0]] *= State
.regs
[OP
[1]];
1546 trace_output (OP_REG
);
1555 trace_input ("mulx", OP_ACCUM_OUTPUT
, OP_REG
, OP_REG
);
1556 tmp
= SEXT40 ((int16
)(State
.regs
[OP
[1]]) * (int16
)(State
.regs
[OP
[2]]));
1559 tmp
= SEXT40 ((tmp
<< 1) & MASK40
);
1561 if (State
.ST
&& tmp
> MAX32
)
1562 State
.a
[OP
[0]] = MAX32
;
1564 State
.a
[OP
[0]] = tmp
& MASK40
;
1565 trace_output (OP_ACCUM
);
1574 trace_input ("mulxsu", OP_ACCUM_OUTPUT
, OP_REG
, OP_REG
);
1575 tmp
= SEXT40 ((int16
)(State
.regs
[OP
[1]]) * State
.regs
[OP
[2]]);
1580 State
.a
[OP
[0]] = tmp
& MASK40
;
1581 trace_output (OP_ACCUM
);
1590 trace_input ("mulxu", OP_ACCUM_OUTPUT
, OP_REG
, OP_REG
);
1591 tmp
= SEXT40 (State
.regs
[OP
[1]] * State
.regs
[OP
[2]]);
1596 State
.a
[OP
[0]] = tmp
& MASK40
;
1597 trace_output (OP_ACCUM
);
1604 trace_input ("mv", OP_REG_OUTPUT
, OP_REG
, OP_VOID
);
1605 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1606 trace_output (OP_REG
);
1613 trace_input ("mv2w", OP_DREG_OUTPUT
, OP_DREG
, OP_VOID
);
1614 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1615 State
.regs
[OP
[0]+1] = State
.regs
[OP
[1]+1];
1616 trace_output (OP_DREG
);
1623 trace_input ("mv2wfac", OP_DREG_OUTPUT
, OP_ACCUM
, OP_VOID
);
1624 State
.regs
[OP
[0]] = (State
.a
[OP
[1]] >> 16) & 0xffff;
1625 State
.regs
[OP
[0]+1] = State
.a
[OP
[1]] & 0xffff;
1626 trace_output (OP_DREG
);
1633 trace_input ("mv2wtac", OP_DREG
, OP_ACCUM_OUTPUT
, OP_VOID
);
1634 State
.a
[OP
[1]] = (SEXT16 (State
.regs
[OP
[0]]) << 16 | State
.regs
[OP
[0]+1]) & MASK40
;
1635 trace_output (OP_ACCUM_REVERSE
);
1642 trace_input ("mvac", OP_ACCUM_OUTPUT
, OP_ACCUM
, OP_VOID
);
1643 State
.a
[OP
[0]] = State
.a
[OP
[1]];
1644 trace_output (OP_ACCUM
);
1651 trace_input ("mvb", OP_REG_OUTPUT
, OP_REG
, OP_VOID
);
1652 State
.regs
[OP
[0]] = SEXT8 (State
.regs
[OP
[1]] & 0xff);
1653 trace_output (OP_REG
);
1660 trace_input ("mf0f", OP_REG_OUTPUT
, OP_REG
, OP_VOID
);
1662 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1663 trace_output (OP_REG
);
1670 trace_input ("mf0t", OP_REG_OUTPUT
, OP_REG
, OP_VOID
);
1672 State
.regs
[OP
[0]] = State
.regs
[OP
[1]];
1673 trace_output (OP_REG
);
1680 trace_input ("mvfacg", OP_REG_OUTPUT
, OP_ACCUM
, OP_VOID
);
1681 State
.regs
[OP
[0]] = (State
.a
[OP
[1]] >> 32) & 0xff;
1682 trace_output (OP_ACCUM
);
1689 trace_input ("mvfachi", OP_REG_OUTPUT
, OP_ACCUM
, OP_VOID
);
1690 State
.regs
[OP
[0]] = (State
.a
[OP
[1]] >> 16) & 0xffff;
1691 trace_output (OP_REG
);
1698 trace_input ("mvfaclo", OP_REG_OUTPUT
, OP_ACCUM
, OP_VOID
);
1699 State
.regs
[OP
[0]] = State
.a
[OP
[1]] & 0xffff;
1700 trace_output (OP_REG
);
1707 trace_input ("mvfc", OP_REG_OUTPUT
, OP_CR
, OP_VOID
);
1710 /* PSW is treated specially */
1712 if (State
.SM
) PSW
|= 0x8000;
1713 if (State
.EA
) PSW
|= 0x2000;
1714 if (State
.DB
) PSW
|= 0x1000;
1715 if (State
.IE
) PSW
|= 0x400;
1716 if (State
.RP
) PSW
|= 0x200;
1717 if (State
.MD
) PSW
|= 0x100;
1718 if (State
.FX
) PSW
|= 0x80;
1719 if (State
.ST
) PSW
|= 0x40;
1720 if (State
.F0
) PSW
|= 8;
1721 if (State
.F1
) PSW
|= 4;
1722 if (State
.C
) PSW
|= 1;
1724 State
.regs
[OP
[0]] = State
.cregs
[OP
[1]];
1725 trace_output (OP_REG
);
1732 trace_input ("mvtacg", OP_REG
, OP_ACCUM
, OP_VOID
);
1733 State
.a
[OP
[1]] &= MASK32
;
1734 State
.a
[OP
[1]] |= (int64
)(State
.regs
[OP
[0]] & 0xff) << 32;
1735 trace_output (OP_ACCUM_REVERSE
);
1744 trace_input ("mvtachi", OP_REG
, OP_ACCUM
, OP_VOID
);
1745 tmp
= State
.a
[OP
[1]] & 0xffff;
1746 State
.a
[OP
[1]] = (SEXT16 (State
.regs
[OP
[0]]) << 16 | tmp
) & MASK40
;
1747 trace_output (OP_ACCUM_REVERSE
);
1754 trace_input ("mvtaclo", OP_REG
, OP_ACCUM
, OP_VOID
);
1755 State
.a
[OP
[1]] = (SEXT16 (State
.regs
[OP
[0]])) & MASK40
;
1756 trace_output (OP_ACCUM_REVERSE
);
1763 trace_input ("mvtc", OP_REG
, OP_CR_OUTPUT
, OP_VOID
);
1764 State
.cregs
[OP
[1]] = State
.regs
[OP
[0]];
1767 /* PSW is treated specially */
1768 State
.SM
= (PSW
& 0x8000) ? 1 : 0;
1769 State
.EA
= (PSW
& 0x2000) ? 1 : 0;
1770 State
.DB
= (PSW
& 0x1000) ? 1 : 0;
1771 State
.IE
= (PSW
& 0x400) ? 1 : 0;
1772 State
.RP
= (PSW
& 0x200) ? 1 : 0;
1773 State
.MD
= (PSW
& 0x100) ? 1 : 0;
1774 State
.FX
= (PSW
& 0x80) ? 1 : 0;
1775 State
.ST
= (PSW
& 0x40) ? 1 : 0;
1776 State
.F0
= (PSW
& 8) ? 1 : 0;
1777 State
.F1
= (PSW
& 4) ? 1 : 0;
1779 if (State
.ST
&& !State
.FX
)
1781 (*d10v_callback
->printf_filtered
) (d10v_callback
,
1782 "ERROR at PC 0x%x: ST can only be set when FX is set.\n",
1784 State
.exception
= SIGILL
;
1787 trace_output (OP_CR_REVERSE
);
1794 trace_input ("mvub", OP_REG_OUTPUT
, OP_REG
, OP_VOID
);
1795 State
.regs
[OP
[0]] = State
.regs
[OP
[1]] & 0xff;
1796 trace_output (OP_REG
);
1803 trace_input ("neg", OP_REG
, OP_VOID
, OP_VOID
);
1804 State
.regs
[OP
[0]] = 0 - State
.regs
[OP
[0]];
1805 trace_output (OP_REG
);
1814 trace_input ("neg", OP_ACCUM
, OP_VOID
, OP_VOID
);
1815 tmp
= -SEXT40(State
.a
[OP
[0]]);
1819 State
.a
[OP
[0]] = MAX32
;
1820 else if (tmp
< MIN32
)
1821 State
.a
[OP
[0]] = MIN32
;
1823 State
.a
[OP
[0]] = tmp
& MASK40
;
1826 State
.a
[OP
[0]] = tmp
& MASK40
;
1827 trace_output (OP_ACCUM
);
1835 trace_input ("nop", OP_VOID
, OP_VOID
, OP_VOID
);
1837 ins_type_counters
[ (int)State
.ins_type
]--; /* don't count nops as normal instructions */
1838 switch (State
.ins_type
)
1841 ins_type_counters
[ (int)INS_UNKNOWN
]++;
1844 case INS_LEFT_PARALLEL
:
1845 /* Don't count a parallel op that includes a NOP as a true parallel op */
1846 ins_type_counters
[ (int)INS_RIGHT_PARALLEL
]--;
1847 ins_type_counters
[ (int)INS_RIGHT
]++;
1848 ins_type_counters
[ (int)INS_LEFT_NOPS
]++;
1852 case INS_LEFT_COND_EXE
:
1853 ins_type_counters
[ (int)INS_LEFT_NOPS
]++;
1856 case INS_RIGHT_PARALLEL
:
1857 /* Don't count a parallel op that includes a NOP as a true parallel op */
1858 ins_type_counters
[ (int)INS_LEFT_PARALLEL
]--;
1859 ins_type_counters
[ (int)INS_LEFT
]++;
1860 ins_type_counters
[ (int)INS_RIGHT_NOPS
]++;
1864 case INS_RIGHT_COND_EXE
:
1865 ins_type_counters
[ (int)INS_RIGHT_NOPS
]++;
1869 trace_output (OP_VOID
);
1876 trace_input ("not", OP_REG
, OP_VOID
, OP_VOID
);
1877 State
.regs
[OP
[0]] = ~(State
.regs
[OP
[0]]);
1878 trace_output (OP_REG
);
1885 trace_input ("or", OP_REG
, OP_REG
, OP_VOID
);
1886 State
.regs
[OP
[0]] |= State
.regs
[OP
[1]];
1887 trace_output (OP_REG
);
1894 trace_input ("or3", OP_REG_OUTPUT
, OP_REG
, OP_CONSTANT16
);
1895 State
.regs
[OP
[0]] = State
.regs
[OP
[1]] | OP
[2];
1896 trace_output (OP_REG
);
1904 int shift
= SEXT3 (OP
[2]);
1906 trace_input ("rac", OP_DREG_OUTPUT
, OP_ACCUM
, OP_CONSTANT3
);
1909 (*d10v_callback
->printf_filtered
) (d10v_callback
,
1910 "ERROR at PC 0x%x: instruction only valid for A0\n",
1912 State
.exception
= SIGILL
;
1915 State
.F1
= State
.F0
;
1917 tmp
= ((State
.a
[0] << 16) | (State
.a
[1] & 0xffff)) << shift
;
1919 tmp
= ((State
.a
[0] << 16) | (State
.a
[1] & 0xffff)) >> -shift
;
1920 tmp
= ( SEXT60(tmp
) + 0x8000 ) >> 16;
1923 State
.regs
[OP
[0]] = 0x7fff;
1924 State
.regs
[OP
[0]+1] = 0xffff;
1927 else if (tmp
< MIN32
)
1929 State
.regs
[OP
[0]] = 0x8000;
1930 State
.regs
[OP
[0]+1] = 0;
1935 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
1936 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
1939 trace_output (OP_DREG
);
1947 int shift
= SEXT3 (OP
[2]);
1949 trace_input ("rachi", OP_REG_OUTPUT
, OP_ACCUM
, OP_CONSTANT3
);
1950 State
.F1
= State
.F0
;
1952 tmp
= SEXT44 (State
.a
[1]) << shift
;
1954 tmp
= SEXT44 (State
.a
[1]) >> -shift
;
1959 State
.regs
[OP
[0]] = 0x7fff;
1962 else if (tmp
< 0xfff80000000LL
)
1964 State
.regs
[OP
[0]] = 0x8000;
1969 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
1972 trace_output (OP_REG
);
1979 trace_input ("rep", OP_REG
, OP_CONSTANT16
, OP_VOID
);
1982 RPT_C
= State
.regs
[OP
[0]];
1986 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: rep with count=0 is illegal.\n");
1987 State
.exception
= SIGILL
;
1991 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: rep must include at least 4 instructions.\n");
1992 State
.exception
= SIGILL
;
1994 trace_output (OP_VOID
);
2001 trace_input ("repi", OP_CONSTANT16
, OP_CONSTANT16
, OP_VOID
);
2008 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: repi with count=0 is illegal.\n");
2009 State
.exception
= SIGILL
;
2013 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: repi must include at least 4 instructions.\n");
2014 State
.exception
= SIGILL
;
2016 trace_output (OP_VOID
);
2023 d10v_callback
->printf_filtered(d10v_callback
, "ERROR: rtd - NOT IMPLEMENTED\n");
2024 State
.exception
= SIGILL
;
2031 trace_input ("rte", OP_VOID
, OP_VOID
, OP_VOID
);
2034 trace_output (OP_VOID
);
2043 trace_input ("sadd", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
2044 tmp
= SEXT40(State
.a
[OP
[0]]) + (SEXT40(State
.a
[OP
[1]]) >> 16);
2048 State
.a
[OP
[0]] = MAX32
;
2049 else if (tmp
< MIN32
)
2050 State
.a
[OP
[0]] = MIN32
;
2052 State
.a
[OP
[0]] = tmp
& MASK40
;
2055 State
.a
[OP
[0]] = tmp
& MASK40
;
2056 trace_output (OP_ACCUM
);
2063 trace_input ("setf0f", OP_REG_OUTPUT
, OP_VOID
, OP_VOID
);
2064 State
.regs
[OP
[0]] = (State
.F0
== 0) ? 1 : 0;
2065 trace_output (OP_REG
);
2072 trace_input ("setf0t", OP_REG_OUTPUT
, OP_VOID
, OP_VOID
);
2073 State
.regs
[OP
[0]] = (State
.F0
== 1) ? 1 : 0;
2074 trace_output (OP_REG
);
2081 trace_input ("sleep", OP_VOID
, OP_VOID
, OP_VOID
);
2083 trace_output (OP_VOID
);
2090 trace_input ("sll", OP_REG
, OP_REG
, OP_VOID
);
2091 State
.regs
[OP
[0]] <<= (State
.regs
[OP
[1]] & 0xf);
2092 trace_output (OP_REG
);
2100 trace_input ("sll", OP_ACCUM
, OP_REG
, OP_VOID
);
2101 if ((State
.regs
[OP
[1]] & 31) <= 16)
2102 tmp
= SEXT40 (State
.a
[OP
[0]]) << (State
.regs
[OP
[1]] & 31);
2105 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: shift value %d too large.\n", State
.regs
[OP
[1]] & 31);
2106 State
.exception
= SIGILL
;
2113 State
.a
[OP
[0]] = MAX32
;
2114 else if (tmp
< 0xffffff80000000LL
)
2115 State
.a
[OP
[0]] = MIN32
;
2117 State
.a
[OP
[0]] = tmp
& MASK40
;
2120 State
.a
[OP
[0]] = tmp
& MASK40
;
2121 trace_output (OP_ACCUM
);
2128 trace_input ("slli", OP_REG
, OP_CONSTANT16
, OP_VOID
);
2129 State
.regs
[OP
[0]] <<= OP
[1];
2130 trace_output (OP_REG
);
2142 trace_input ("slli", OP_ACCUM
, OP_CONSTANT16
, OP_VOID
);
2143 tmp
= SEXT40(State
.a
[OP
[0]]) << OP
[1];
2148 State
.a
[OP
[0]] = MAX32
;
2149 else if (tmp
< 0xffffff80000000LL
)
2150 State
.a
[OP
[0]] = MIN32
;
2152 State
.a
[OP
[0]] = tmp
& MASK40
;
2155 State
.a
[OP
[0]] = tmp
& MASK40
;
2156 trace_output (OP_ACCUM
);
2163 trace_input ("slx", OP_REG
, OP_FLAG
, OP_VOID
);
2164 State
.regs
[OP
[0]] = (State
.regs
[OP
[0]] << 1) | State
.F0
;
2165 trace_output (OP_REG
);
2172 trace_input ("sra", OP_REG
, OP_REG
, OP_VOID
);
2173 State
.regs
[OP
[0]] = ((int16
)(State
.regs
[OP
[0]])) >> (State
.regs
[OP
[1]] & 0xf);
2174 trace_output (OP_REG
);
2181 trace_input ("sra", OP_ACCUM
, OP_REG
, OP_VOID
);
2182 if ((State
.regs
[OP
[1]] & 31) <= 16)
2183 State
.a
[OP
[0]] = (SEXT40(State
.a
[OP
[0]]) >> (State
.regs
[OP
[1]] & 31)) & MASK40
;
2186 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: shift value %d too large.\n", State
.regs
[OP
[1]] & 31);
2187 State
.exception
= SIGILL
;
2191 trace_output (OP_ACCUM
);
2198 trace_input ("srai", OP_REG
, OP_CONSTANT16
, OP_VOID
);
2199 State
.regs
[OP
[0]] = ((int16
)(State
.regs
[OP
[0]])) >> OP
[1];
2200 trace_output (OP_REG
);
2210 trace_input ("srai", OP_ACCUM
, OP_CONSTANT16
, OP_VOID
);
2211 State
.a
[OP
[0]] = (SEXT40(State
.a
[OP
[0]]) >> OP
[1]) & MASK40
;
2212 trace_output (OP_ACCUM
);
2219 trace_input ("srl", OP_REG
, OP_REG
, OP_VOID
);
2220 State
.regs
[OP
[0]] >>= (State
.regs
[OP
[1]] & 0xf);
2221 trace_output (OP_REG
);
2228 trace_input ("srl", OP_ACCUM
, OP_REG
, OP_VOID
);
2229 if ((State
.regs
[OP
[1]] & 31) <= 16)
2230 State
.a
[OP
[0]] = (uint64
)((State
.a
[OP
[0]] & MASK40
) >> (State
.regs
[OP
[1]] & 31));
2233 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: shift value %d too large.\n", State
.regs
[OP
[1]] & 31);
2234 State
.exception
= SIGILL
;
2238 trace_output (OP_ACCUM
);
2245 trace_input ("srli", OP_REG
, OP_CONSTANT16
, OP_VOID
);
2246 State
.regs
[OP
[0]] >>= OP
[1];
2247 trace_output (OP_REG
);
2257 trace_input ("srli", OP_ACCUM
, OP_CONSTANT16
, OP_VOID
);
2258 State
.a
[OP
[0]] = (uint64
)(State
.a
[OP
[0]] & MASK40
) >> OP
[1];
2259 trace_output (OP_ACCUM
);
2268 trace_input ("srx", OP_REG
, OP_FLAG
, OP_VOID
);
2269 tmp
= State
.F0
<< 15;
2270 State
.regs
[OP
[0]] = (State
.regs
[OP
[0]] >> 1) | tmp
;
2271 trace_output (OP_REG
);
2278 trace_input ("st", OP_REG
, OP_MEMREF2
, OP_VOID
);
2279 SW (OP
[1] + State
.regs
[OP
[2]], State
.regs
[OP
[0]]);
2280 trace_output (OP_VOID
);
2287 trace_input ("st", OP_REG
, OP_MEMREF
, OP_VOID
);
2288 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2289 trace_output (OP_VOID
);
2296 trace_input ("st", OP_REG
, OP_PREDEC
, OP_VOID
);
2299 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: cannot pre-decrement any registers but r15 (SP).\n");
2300 State
.exception
= SIGILL
;
2303 State
.regs
[OP
[1]] -= 2;
2304 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2305 trace_output (OP_VOID
);
2312 trace_input ("st", OP_REG
, OP_POSTINC
, OP_VOID
);
2313 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2314 INC_ADDR (State
.regs
[OP
[1]],2);
2315 trace_output (OP_VOID
);
2322 trace_input ("st", OP_REG
, OP_POSTDEC
, OP_VOID
);
2325 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: cannot post-decrement register r15 (SP).\n");
2326 State
.exception
= SIGILL
;
2329 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2330 INC_ADDR (State
.regs
[OP
[1]],-2);
2331 trace_output (OP_VOID
);
2338 trace_input ("st2w", OP_DREG
, OP_MEMREF2
, OP_VOID
);
2339 SW (State
.regs
[OP
[2]]+OP
[1], State
.regs
[OP
[0]]);
2340 SW (State
.regs
[OP
[2]]+OP
[1]+2, State
.regs
[OP
[0]+1]);
2341 trace_output (OP_VOID
);
2348 trace_input ("st2w", OP_DREG
, OP_MEMREF
, OP_VOID
);
2349 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2350 SW (State
.regs
[OP
[1]]+2, State
.regs
[OP
[0]+1]);
2351 trace_output (OP_VOID
);
2358 trace_input ("st2w", OP_DREG
, OP_PREDEC
, OP_VOID
);
2361 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: cannot pre-decrement any registers but r15 (SP).\n");
2362 State
.exception
= SIGILL
;
2365 State
.regs
[OP
[1]] -= 4;
2366 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2367 SW (State
.regs
[OP
[1]]+2, State
.regs
[OP
[0]+1]);
2368 trace_output (OP_VOID
);
2375 trace_input ("st2w", OP_DREG
, OP_POSTDEC
, OP_VOID
);
2378 (*d10v_callback
->printf_filtered
) (d10v_callback
, "ERROR: cannot post-decrement register r15 (SP).\n");
2379 State
.exception
= SIGILL
;
2382 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2383 SW (State
.regs
[OP
[1]]+2, State
.regs
[OP
[0]+1]);
2384 INC_ADDR (State
.regs
[OP
[1]],4);
2385 trace_output (OP_VOID
);
2392 trace_input ("st2w", OP_DREG
, OP_POSTINC
, OP_VOID
);
2393 SW (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2394 SW (State
.regs
[OP
[1]]+2, State
.regs
[OP
[0]+1]);
2395 INC_ADDR (State
.regs
[OP
[1]],-4);
2396 trace_output (OP_VOID
);
2403 trace_input ("stb", OP_REG
, OP_MEMREF2
, OP_VOID
);
2404 SB (State
.regs
[OP
[2]]+OP
[1], State
.regs
[OP
[0]]);
2405 trace_output (OP_VOID
);
2412 trace_input ("stb", OP_REG
, OP_MEMREF
, OP_VOID
);
2413 SB (State
.regs
[OP
[1]], State
.regs
[OP
[0]]);
2414 trace_output (OP_VOID
);
2421 trace_input ("stop", OP_VOID
, OP_VOID
, OP_VOID
);
2422 State
.exception
= SIG_D10V_STOP
;
2423 trace_output (OP_VOID
);
2432 trace_input ("sub", OP_REG
, OP_REG
, OP_VOID
);
2433 tmp
= State
.regs
[OP
[0]] - State
.regs
[OP
[1]];
2434 State
.C
= (tmp
> State
.regs
[OP
[0]]);
2435 State
.regs
[OP
[0]] = tmp
;
2436 trace_output (OP_REG
);
2445 trace_input ("sub", OP_ACCUM
, OP_DREG
, OP_VOID
);
2446 tmp
= SEXT40(State
.a
[OP
[0]]) - (SEXT16 (State
.regs
[OP
[1]]) << 16 | State
.regs
[OP
[1]+1]);
2450 State
.a
[OP
[0]] = MAX32
;
2451 else if ( tmp
< MIN32
)
2452 State
.a
[OP
[0]] = MIN32
;
2454 State
.a
[OP
[0]] = tmp
& MASK40
;
2457 State
.a
[OP
[0]] = tmp
& MASK40
;
2459 trace_output (OP_ACCUM
);
2469 trace_input ("sub", OP_ACCUM
, OP_ACCUM
, OP_VOID
);
2470 tmp
= SEXT40(State
.a
[OP
[0]]) - SEXT40(State
.a
[OP
[1]]);
2474 State
.a
[OP
[0]] = MAX32
;
2475 else if ( tmp
< MIN32
)
2476 State
.a
[OP
[0]] = MIN32
;
2478 State
.a
[OP
[0]] = tmp
& MASK40
;
2481 State
.a
[OP
[0]] = tmp
& MASK40
;
2483 trace_output (OP_ACCUM
);
2492 trace_input ("sub2w", OP_DREG
, OP_DREG
, OP_VOID
);
2493 a
= (uint32
)((State
.regs
[OP
[0]] << 16) | State
.regs
[OP
[0]+1]);
2494 b
= (uint32
)((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]);
2496 State
.C
= (tmp
> a
);
2497 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
2498 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
2499 trace_output (OP_DREG
);
2508 trace_input ("subac3", OP_DREG_OUTPUT
, OP_DREG
, OP_ACCUM
);
2509 tmp
= SEXT40 ((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]) - SEXT40 (State
.a
[OP
[2]]);
2510 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
2511 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
2512 trace_output (OP_DREG
);
2521 trace_input ("subac3", OP_DREG_OUTPUT
, OP_ACCUM
, OP_ACCUM
);
2522 tmp
= SEXT40(State
.a
[OP
[1]]) - SEXT40(State
.a
[OP
[2]]);
2523 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
2524 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
2525 trace_output (OP_DREG
);
2534 trace_input ("subac3s", OP_DREG_OUTPUT
, OP_DREG
, OP_ACCUM
);
2535 State
.F1
= State
.F0
;
2536 tmp
= SEXT40 ((State
.regs
[OP
[1]] << 16) | State
.regs
[OP
[1]+1]) - SEXT40(State
.a
[OP
[2]]);
2539 State
.regs
[OP
[0]] = 0x7fff;
2540 State
.regs
[OP
[0]+1] = 0xffff;
2543 else if (tmp
< MIN32
)
2545 State
.regs
[OP
[0]] = 0x8000;
2546 State
.regs
[OP
[0]+1] = 0;
2551 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
2552 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
2555 trace_output (OP_DREG
);
2564 trace_input ("subac3s", OP_DREG_OUTPUT
, OP_ACCUM
, OP_ACCUM
);
2565 State
.F1
= State
.F0
;
2566 tmp
= SEXT40(State
.a
[OP
[1]]) - SEXT40(State
.a
[OP
[2]]);
2569 State
.regs
[OP
[0]] = 0x7fff;
2570 State
.regs
[OP
[0]+1] = 0xffff;
2573 else if (tmp
< MIN32
)
2575 State
.regs
[OP
[0]] = 0x8000;
2576 State
.regs
[OP
[0]+1] = 0;
2581 State
.regs
[OP
[0]] = (tmp
>> 16) & 0xffff;
2582 State
.regs
[OP
[0]+1] = tmp
& 0xffff;
2585 trace_output (OP_DREG
);
2596 trace_input ("subi", OP_REG
, OP_CONSTANT16
, OP_VOID
);
2597 tmp
= State
.regs
[OP
[0]] - OP
[1];
2598 State
.C
= (tmp
> State
.regs
[OP
[0]]);
2599 State
.regs
[OP
[0]] = tmp
;
2600 trace_output (OP_REG
);
2607 trace_input ("trap", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
2608 trace_output (OP_VOID
);
2614 (*d10v_callback
->printf_filtered
) (d10v_callback
, "Unknown trap code %d\n", OP
[0]);
2615 State
.exception
= SIGILL
;
2617 /* Use any other traps for batch debugging. */
2620 static int first_time
= 1;
2625 (*d10v_callback
->printf_filtered
) (d10v_callback
, "Trap # PC ");
2626 for (i
= 0; i
< 16; i
++)
2627 (*d10v_callback
->printf_filtered
) (d10v_callback
, " %sr%d", (i
> 9) ? "" : " ", i
);
2628 (*d10v_callback
->printf_filtered
) (d10v_callback
, " a0 a1 f0 f1 c\n");
2631 (*d10v_callback
->printf_filtered
) (d10v_callback
, "Trap %2d 0x%.4x:", (int)OP
[0], (int)PC
);
2633 for (i
= 0; i
< 16; i
++)
2634 (*d10v_callback
->printf_filtered
) (d10v_callback
, " %.4x", (int) State
.regs
[i
]);
2636 for (i
= 0; i
< 2; i
++)
2637 (*d10v_callback
->printf_filtered
) (d10v_callback
, " %.2x%.8lx",
2638 ((int)(State
.a
[i
] >> 32) & 0xff),
2639 ((unsigned long)State
.a
[i
]) & 0xffffffff);
2641 (*d10v_callback
->printf_filtered
) (d10v_callback
, " %d %d %d\n",
2642 State
.F0
!= 0, State
.F1
!= 0, State
.C
!= 0);
2643 (*d10v_callback
->flush_stdout
) (d10v_callback
);
2648 /* Trap 0 is used for simulating low-level I/O */
2652 /* Registers passed to trap 0 */
2654 #define FUNC State.regs[6] /* function number */
2655 #define PARM1 State.regs[2] /* optional parm 1 */
2656 #define PARM2 State.regs[3] /* optional parm 2 */
2657 #define PARM3 State.regs[4] /* optional parm 3 */
2658 #define PARM4 State.regs[5] /* optional parm 3 */
2660 /* Registers set by trap 0 */
2662 #define RETVAL State.regs[2] /* return value */
2663 #define RETVAL_HIGH State.regs[2] /* return value */
2664 #define RETVAL_LOW State.regs[3] /* return value */
2665 #define RETERR State.regs[4] /* return error code */
2667 /* Turn a pointer in a register into a pointer into real memory. */
2669 #define MEMPTR(x) ((char *)(dmem_addr(x)))
2673 #if !defined(__GO32__) && !defined(_WIN32)
2676 trace_input ("<fork>", OP_VOID
, OP_VOID
, OP_VOID
);
2677 trace_output (OP_R2
);
2681 trace_input ("<getpid>", OP_VOID
, OP_VOID
, OP_VOID
);
2683 trace_output (OP_R2
);
2687 trace_input ("<kill>", OP_REG
, OP_REG
, OP_VOID
);
2688 if (PARM1
== getpid ())
2690 trace_output (OP_VOID
);
2691 State
.exception
= PARM2
;
2699 case 1: os_sig
= SIGHUP
; break;
2702 case 2: os_sig
= SIGINT
; break;
2705 case 3: os_sig
= SIGQUIT
; break;
2708 case 4: os_sig
= SIGILL
; break;
2711 case 5: os_sig
= SIGTRAP
; break;
2714 case 6: os_sig
= SIGABRT
; break;
2715 #elif defined(SIGIOT)
2716 case 6: os_sig
= SIGIOT
; break;
2719 case 7: os_sig
= SIGEMT
; break;
2722 case 8: os_sig
= SIGFPE
; break;
2725 case 9: os_sig
= SIGKILL
; break;
2728 case 10: os_sig
= SIGBUS
; break;
2731 case 11: os_sig
= SIGSEGV
; break;
2734 case 12: os_sig
= SIGSYS
; break;
2737 case 13: os_sig
= SIGPIPE
; break;
2740 case 14: os_sig
= SIGALRM
; break;
2743 case 15: os_sig
= SIGTERM
; break;
2746 case 16: os_sig
= SIGURG
; break;
2749 case 17: os_sig
= SIGSTOP
; break;
2752 case 18: os_sig
= SIGTSTP
; break;
2755 case 19: os_sig
= SIGCONT
; break;
2758 case 20: os_sig
= SIGCHLD
; break;
2759 #elif defined(SIGCLD)
2760 case 20: os_sig
= SIGCLD
; break;
2763 case 21: os_sig
= SIGTTIN
; break;
2766 case 22: os_sig
= SIGTTOU
; break;
2769 case 23: os_sig
= SIGIO
; break;
2770 #elif defined (SIGPOLL)
2771 case 23: os_sig
= SIGPOLL
; break;
2774 case 24: os_sig
= SIGXCPU
; break;
2777 case 25: os_sig
= SIGXFSZ
; break;
2780 case 26: os_sig
= SIGVTALRM
; break;
2783 case 27: os_sig
= SIGPROF
; break;
2786 case 28: os_sig
= SIGWINCH
; break;
2789 case 29: os_sig
= SIGLOST
; break;
2792 case 30: os_sig
= SIGUSR1
; break;
2795 case 31: os_sig
= SIGUSR2
; break;
2801 trace_output (OP_VOID
);
2802 (*d10v_callback
->printf_filtered
) (d10v_callback
, "Unknown signal %d\n", PARM2
);
2803 (*d10v_callback
->flush_stdout
) (d10v_callback
);
2804 State
.exception
= SIGILL
;
2808 RETVAL
= kill (PARM1
, PARM2
);
2809 trace_output (OP_R2
);
2815 RETVAL
= execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
),
2816 (char **)MEMPTR (PARM3
));
2817 trace_input ("<execve>", OP_R2
, OP_R3
, OP_R4
);
2818 trace_output (OP_R2
);
2822 RETVAL
= execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
), NULL
);
2823 trace_input ("<execv>", OP_R2
, OP_R3
, OP_VOID
);
2824 trace_output (OP_R2
);
2833 RETVAL
= pipe (host_fd
);
2834 SW (buf
, host_fd
[0]);
2835 buf
+= sizeof(uint16
);
2836 SW (buf
, host_fd
[1]);
2837 trace_input ("<pipe>", OP_R2
, OP_VOID
, OP_VOID
);
2838 trace_output (OP_R2
);
2846 RETVAL
= wait (&status
);
2849 trace_input ("<wait>", OP_R2
, OP_VOID
, OP_VOID
);
2850 trace_output (OP_R2
);
2855 trace_input ("<getpid>", OP_VOID
, OP_VOID
, OP_VOID
);
2857 trace_output (OP_R2
);
2861 trace_input ("<kill>", OP_REG
, OP_REG
, OP_VOID
);
2862 trace_output (OP_VOID
);
2863 State
.exception
= PARM2
;
2868 RETVAL
= d10v_callback
->read (d10v_callback
, PARM1
, MEMPTR (PARM2
),
2870 trace_input ("<read>", OP_R2
, OP_R3
, OP_R4
);
2871 trace_output (OP_R2
);
2876 RETVAL
= (int)d10v_callback
->write_stdout (d10v_callback
,
2877 MEMPTR (PARM2
), PARM3
);
2879 RETVAL
= (int)d10v_callback
->write (d10v_callback
, PARM1
,
2880 MEMPTR (PARM2
), PARM3
);
2881 trace_input ("<write>", OP_R2
, OP_R3
, OP_R4
);
2882 trace_output (OP_R2
);
2887 unsigned long ret
= d10v_callback
->lseek (d10v_callback
, PARM1
,
2888 (((unsigned long)PARM2
) << 16) || (unsigned long)PARM3
,
2890 RETVAL_HIGH
= ret
>> 16;
2891 RETVAL_LOW
= ret
& 0xffff;
2893 trace_input ("<lseek>", OP_R2
, OP_R3
, OP_R4
);
2894 trace_output (OP_R2R3
);
2898 RETVAL
= d10v_callback
->close (d10v_callback
, PARM1
);
2899 trace_input ("<close>", OP_R2
, OP_VOID
, OP_VOID
);
2900 trace_output (OP_R2
);
2904 RETVAL
= d10v_callback
->open (d10v_callback
, MEMPTR (PARM1
), PARM2
);
2905 trace_input ("<open>", OP_R2
, OP_R3
, OP_R4
);
2906 trace_output (OP_R2
);
2907 trace_input ("<open>", OP_R2
, OP_R3
, OP_R4
);
2908 trace_output (OP_R2
);
2912 State
.exception
= SIG_D10V_EXIT
;
2913 trace_input ("<exit>", OP_R2
, OP_VOID
, OP_VOID
);
2914 trace_output (OP_VOID
);
2918 /* stat system call */
2920 struct stat host_stat
;
2923 RETVAL
= stat (MEMPTR (PARM1
), &host_stat
);
2927 /* The hard-coded offsets and sizes were determined by using
2928 * the D10V compiler on a test program that used struct stat.
2930 SW (buf
, host_stat
.st_dev
);
2931 SW (buf
+2, host_stat
.st_ino
);
2932 SW (buf
+4, host_stat
.st_mode
);
2933 SW (buf
+6, host_stat
.st_nlink
);
2934 SW (buf
+8, host_stat
.st_uid
);
2935 SW (buf
+10, host_stat
.st_gid
);
2936 SW (buf
+12, host_stat
.st_rdev
);
2937 SLW (buf
+16, host_stat
.st_size
);
2938 SLW (buf
+20, host_stat
.st_atime
);
2939 SLW (buf
+28, host_stat
.st_mtime
);
2940 SLW (buf
+36, host_stat
.st_ctime
);
2942 trace_input ("<stat>", OP_R2
, OP_R3
, OP_VOID
);
2943 trace_output (OP_R2
);
2947 RETVAL
= chown (MEMPTR (PARM1
), PARM2
, PARM3
);
2948 trace_input ("<chown>", OP_R2
, OP_R3
, OP_R4
);
2949 trace_output (OP_R2
);
2953 RETVAL
= chmod (MEMPTR (PARM1
), PARM2
);
2954 trace_input ("<chmod>", OP_R2
, OP_R3
, OP_R4
);
2955 trace_output (OP_R2
);
2959 /* Cast the second argument to void *, to avoid type mismatch
2960 if a prototype is present. */
2961 RETVAL
= utime (MEMPTR (PARM1
), (void *) MEMPTR (PARM2
));
2962 trace_input ("<utime>", OP_R2
, OP_R3
, OP_R4
);
2963 trace_output (OP_R2
);
2968 unsigned long ret
= time (PARM1
? MEMPTR (PARM1
) : NULL
);
2969 RETVAL_HIGH
= ret
>> 16;
2970 RETVAL_LOW
= ret
& 0xffff;
2972 trace_input ("<time>", OP_R2
, OP_R3
, OP_R4
);
2973 trace_output (OP_R2R3
);
2979 RETERR
= d10v_callback
->get_errno(d10v_callback
);
2984 /* Trap 1 prints a string */
2986 char *fstr
= dmem_addr(State
.regs
[2]);
2987 fputs (fstr
, stdout
);
2992 /* Trap 2 calls printf */
2994 char *fstr
= dmem_addr(State
.regs
[2]);
2995 (*d10v_callback
->printf_filtered
) (d10v_callback
, fstr
,
2996 (int16
)State
.regs
[3],
2997 (int16
)State
.regs
[4],
2998 (int16
)State
.regs
[5]);
2999 (*d10v_callback
->flush_stdout
) (d10v_callback
);
3004 /* Trap 3 writes a character */
3005 putchar (State
.regs
[2]);
3015 trace_input ("tst0i", OP_REG
, OP_CONSTANT16
, OP_VOID
);
3016 State
.F1
= State
.F0
;
3017 State
.F0
= (State
.regs
[OP
[0]] & OP
[1]) ? 1 : 0;
3018 trace_output (OP_FLAG
);
3025 trace_input ("tst1i", OP_REG
, OP_CONSTANT16
, OP_VOID
);
3026 State
.F1
= State
.F0
;
3027 State
.F0
= (~(State
.regs
[OP
[0]]) & OP
[1]) ? 1 : 0;
3028 trace_output (OP_FLAG
);
3035 trace_input ("wait", OP_VOID
, OP_VOID
, OP_VOID
);
3037 trace_output (OP_VOID
);
3044 trace_input ("xor", OP_REG
, OP_REG
, OP_VOID
);
3045 State
.regs
[OP
[0]] ^= State
.regs
[OP
[1]];
3046 trace_output (OP_REG
);
3053 trace_input ("xor3", OP_REG_OUTPUT
, OP_REG
, OP_CONSTANT16
);
3054 State
.regs
[OP
[0]] = State
.regs
[OP
[1]] ^ OP
[2];
3055 trace_output (OP_REG
);
This page took 0.092963 seconds and 4 git commands to generate.