4 #include "sys/syscall.h"
34 static void trace_input
PARAMS ((char *name
, enum op_types type
, int size
));
35 static void trace_output
PARAMS ((enum op_types result
));
36 static int init_text_p
= 0;
37 static asection
*text
;
38 static bfd_vma text_start
;
39 static bfd_vma text_end
;
42 #ifndef SIZE_INSTRUCTION
43 #define SIZE_INSTRUCTION 6
47 #define SIZE_OPERANDS 16
51 #define SIZE_VALUES 11
55 #define SIZE_LOCATION 40
59 trace_input (name
, type
, size
)
71 const char *functionname
;
72 unsigned int linenumber
;
74 if ((v850_debug
& DEBUG_TRACE
) == 0)
81 for (s
= sim_bfd
->sections
; s
; s
= s
->next
)
82 if (strcmp (bfd_get_section_name (sim_bfd
, s
), ".text") == 0)
85 text_start
= bfd_get_section_vma (sim_bfd
, s
);
86 text_end
= text_start
+ bfd_section_size (sim_bfd
, s
);
91 if (text
&& PC
>= text_start
&& PC
< text_end
)
93 filename
= (const char *)0;
94 functionname
= (const char *)0;
96 if (bfd_find_nearest_line (sim_bfd
, text
, (struct symbol_cache_entry
**)0, PC
- text_start
,
97 &filename
, &functionname
, &linenumber
))
102 sprintf (p
, "Line %5d ", linenumber
);
108 sprintf (p
, "Func %s ", functionname
);
113 char *q
= (char *) strrchr (filename
, '/');
114 sprintf (p
, "File %s ", (q
) ? q
+1 : filename
);
123 (*v850_callback
->printf_filtered
) (v850_callback
, "0x%.8x: %-*.*s %-*s",
125 SIZE_LOCATION
, SIZE_LOCATION
, buf
,
126 SIZE_INSTRUCTION
, name
);
133 strcpy (buf
, "unknown");
137 sprintf (buf
, "%d", OP
[0]);
141 sprintf (buf
, "r%d", OP
[0]);
146 case OP_REG_REG_MOVE
:
147 sprintf (buf
, "r%d,r%d", OP
[0], OP
[1]);
152 case OP_IMM_REG_MOVE
:
153 sprintf (buf
, "%d,r%d", OP
[1], OP
[0]);
157 sprintf (buf
, "%d", SEXT9 (OP
[0]));
161 sprintf (buf
, "%d[r30],r%d", SEXT7 (OP
[1]) * size
, OP
[0]);
165 sprintf (buf
, "r%d,%d[r30]", OP
[0], SEXT7 (OP
[1]) * size
);
169 sprintf (buf
, "%d[r%d],r%d", SEXT16 (OP
[2]), OP
[0], OP
[1]);
173 sprintf (buf
, "r%d,%d[r%d]", OP
[1], SEXT16 (OP
[2]), OP
[0]);
177 sprintf (buf
, "%d,r%d", SEXT22 (OP
[0]), OP
[1]);
181 sprintf (buf
, "%d,r%d,r%d", SEXT16 (OP
[0]), OP
[1], OP
[2]);
184 case OP_UIMM_REG_REG
:
185 sprintf (buf
, "%d,r%d,r%d", OP
[0] & 0xffff, OP
[1], OP
[2]);
189 sprintf (buf
, "%d,%d[r%d]", OP
[1] & 0x7, SEXT16 (OP
[2]), OP
[0]);
195 default: cond
= "?"; break;
196 case 0x0: cond
= "v"; break;
197 case 0x1: cond
= "c"; break;
198 case 0x2: cond
= "z"; break;
199 case 0x3: cond
= "nh"; break;
200 case 0x4: cond
= "s"; break;
201 case 0x5: cond
= "t"; break;
202 case 0x6: cond
= "lt"; break;
203 case 0x7: cond
= "le"; break;
204 case 0x8: cond
= "nv"; break;
205 case 0x9: cond
= "nc"; break;
206 case 0xa: cond
= "nz"; break;
207 case 0xb: cond
= "h"; break;
208 case 0xc: cond
= "ns"; break;
209 case 0xd: cond
= "sa"; break;
210 case 0xe: cond
= "ge"; break;
211 case 0xf: cond
= "gt"; break;
214 sprintf (buf
, "%s,r%d", cond
, OP
[1]);
223 sprintf (buf
, "r%d,s%d", OP
[0], OP
[1]);
227 if ((v850_debug
& DEBUG_VALUES
) == 0)
229 (*v850_callback
->printf_filtered
) (v850_callback
, "%s\n", buf
);
233 (*v850_callback
->printf_filtered
) (v850_callback
, "%-*s", SIZE_OPERANDS
, buf
);
244 case OP_REG_REG_MOVE
:
245 values
[0] = State
.regs
[OP
[0]];
251 values
[0] = State
.regs
[OP
[1]];
252 values
[1] = State
.regs
[OP
[0]];
258 values
[0] = SEXT5 (OP
[0]);
263 case OP_IMM_REG_MOVE
:
264 values
[0] = SEXT5 (OP
[0]);
269 values
[0] = State
.pc
;
270 values
[1] = SEXT9 (OP
[0]);
271 values
[2] = State
.sregs
[5];
276 values
[0] = SEXT7 (OP
[1]) * size
;
277 values
[1] = State
.regs
[30];
282 values
[0] = State
.regs
[OP
[0]];
283 values
[1] = SEXT7 (OP
[1]) * size
;
284 values
[2] = State
.regs
[30];
289 values
[0] = SEXT16 (OP
[2]);
290 values
[1] = State
.regs
[OP
[0]];
295 values
[0] = State
.regs
[OP
[1]];
296 values
[1] = SEXT16 (OP
[2]);
297 values
[2] = State
.regs
[OP
[0]];
302 values
[0] = SEXT22 (OP
[0]);
303 values
[1] = State
.pc
;
308 values
[0] = SEXT16 (OP
[0]) << size
;
309 values
[1] = State
.regs
[OP
[1]];
313 case OP_UIMM_REG_REG
:
314 values
[0] = (OP
[0] & 0xffff) << size
;
315 values
[1] = State
.regs
[OP
[1]];
324 values
[0] = State
.sregs
[5];
333 values
[0] = State
.regs
[OP
[0]];
338 values
[0] = State
.sregs
[OP
[1]];
342 for (i
= 0; i
< num_values
; i
++)
343 (*v850_callback
->printf_filtered
) (v850_callback
, "%*s0x%.8lx", SIZE_VALUES
- 10, "", values
[i
]);
346 (*v850_callback
->printf_filtered
) (v850_callback
, "%*s", SIZE_VALUES
, "");
351 trace_output (result
)
352 enum op_types result
;
354 if ((v850_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
374 (*v850_callback
->printf_filtered
) (v850_callback
, " :: 0x%.8lx",
375 (unsigned long)State
.regs
[OP
[0]]);
379 case OP_REG_REG_MOVE
:
381 case OP_IMM_REG_MOVE
:
384 (*v850_callback
->printf_filtered
) (v850_callback
, " :: 0x%.8lx",
385 (unsigned long)State
.regs
[OP
[1]]);
389 case OP_UIMM_REG_REG
:
390 (*v850_callback
->printf_filtered
) (v850_callback
, " :: 0x%.8lx",
391 (unsigned long)State
.regs
[OP
[2]]);
396 (*v850_callback
->printf_filtered
) (v850_callback
, " :: 0x%.8lx",
397 (unsigned long)State
.regs
[OP
[1]]);
401 (*v850_callback
->printf_filtered
) (v850_callback
, " :: 0x%.8lx",
402 (unsigned long)State
.sregs
[OP
[1]]);
406 (*v850_callback
->printf_filtered
) (v850_callback
, "\n");
411 #define trace_input(NAME, IN1, IN2, IN3)
412 #define trace_output(RESULT)
423 trace_input ("sld.b", OP_LOAD16
, 1);
427 result
= get_byte (State
.mem
+ State
.regs
[30] + op2
);
428 State
.regs
[OP
[0]] = SEXT8 (result
);
429 trace_output (OP_LOAD16
);
439 trace_input ("sld.h", OP_LOAD16
, 2);
443 result
= get_half (State
.mem
+ State
.regs
[30] + op2
);
444 State
.regs
[OP
[0]] = SEXT16 (result
);
445 trace_output (OP_LOAD16
);
455 trace_input ("sld.w", OP_LOAD16
, 4);
459 result
= get_word (State
.mem
+ State
.regs
[30] + op2
);
460 State
.regs
[OP
[0]] = result
;
461 trace_output (OP_LOAD16
);
468 unsigned int op0
, op1
;
471 trace_input ("sst.b", OP_STORE16
, 1);
472 op0
= State
.regs
[OP
[0]];
476 put_byte (State
.mem
+ State
.regs
[30] + op1
, op0
);
477 trace_output (OP_STORE16
);
484 unsigned int op0
, op1
;
487 trace_input ("sst.h", OP_STORE16
, 2);
488 op0
= State
.regs
[OP
[0]];
492 put_half (State
.mem
+ State
.regs
[30] + op1
, op0
);
493 trace_output (OP_STORE16
);
500 unsigned int op0
, op1
;
503 trace_input ("sst.w", OP_STORE16
, 4);
504 op0
= State
.regs
[OP
[0]];
508 put_word (State
.mem
+ State
.regs
[30] + op1
, op0
);
509 trace_output (OP_STORE16
);
516 unsigned int op0
, op2
;
519 trace_input ("ld.b", OP_LOAD32
, 1);
520 op0
= State
.regs
[OP
[0]];
521 temp
= SEXT16 (OP
[2]);
523 result
= get_byte (State
.mem
+ op0
+ op2
);
524 State
.regs
[OP
[1]] = SEXT8 (result
);
525 trace_output (OP_LOAD32
);
532 unsigned int op0
, op2
;
535 trace_input ("ld.h", OP_LOAD32
, 2);
536 op0
= State
.regs
[OP
[0]];
537 temp
= SEXT16 (OP
[2]);
540 result
= get_half (State
.mem
+ op0
+ op2
);
541 State
.regs
[OP
[1]] = SEXT16 (result
);
542 trace_output (OP_LOAD32
);
549 unsigned int op0
, op2
;
552 trace_input ("ld.w", OP_LOAD32
, 4);
553 op0
= State
.regs
[OP
[0]];
554 temp
= SEXT16 (OP
[2]);
557 result
= get_word (State
.mem
+ op0
+ op2
);
558 State
.regs
[OP
[1]] = result
;
559 trace_output (OP_LOAD32
);
566 unsigned int op0
, op1
, op2
;
569 trace_input ("st.b", OP_STORE32
, 1);
570 op0
= State
.regs
[OP
[0]];
571 op1
= State
.regs
[OP
[1]];
572 temp
= SEXT16 (OP
[2]);
574 put_byte (State
.mem
+ op0
+ op2
, op1
);
575 trace_output (OP_STORE32
);
582 unsigned int op0
, op1
, op2
;
585 trace_input ("st.h", OP_STORE32
, 2);
586 op0
= State
.regs
[OP
[0]];
587 op1
= State
.regs
[OP
[1]];
588 temp
= SEXT16 (OP
[2] & ~0x1);
590 put_half (State
.mem
+ op0
+ op2
, op1
);
591 trace_output (OP_STORE32
);
598 unsigned int op0
, op1
, op2
;
601 trace_input ("st.w", OP_STORE32
, 4);
602 op0
= State
.regs
[OP
[0]];
603 op1
= State
.regs
[OP
[1]];
604 temp
= SEXT16 (OP
[2] & ~0x1);
606 put_word (State
.mem
+ op0
+ op2
, op1
);
607 trace_output (OP_STORE32
);
617 trace_input ("bv", OP_COND_BR
, 0);
619 psw
= State
.sregs
[5];
621 if ((psw
& PSW_OV
) != 0)
625 trace_output (OP_COND_BR
);
635 trace_input ("bl", OP_COND_BR
, 0);
637 psw
= State
.sregs
[5];
639 if ((psw
& PSW_CY
) != 0)
643 trace_output (OP_COND_BR
);
653 trace_input ("be", OP_COND_BR
, 0);
655 psw
= State
.sregs
[5];
657 if ((psw
& PSW_Z
) != 0)
661 trace_output (OP_COND_BR
);
671 trace_input ("bnh", OP_COND_BR
, 0);
673 psw
= State
.sregs
[5];
675 if ((((psw
& PSW_CY
) != 0) | ((psw
& PSW_Z
) != 0)) != 0)
679 trace_output (OP_COND_BR
);
689 trace_input ("bn", OP_COND_BR
, 0);
691 psw
= State
.sregs
[5];
693 if ((psw
& PSW_S
) != 0)
697 trace_output (OP_COND_BR
);
707 trace_input ("br", OP_COND_BR
, 0);
710 trace_output (OP_COND_BR
);
720 trace_input ("blt", OP_COND_BR
, 0);
722 psw
= State
.sregs
[5];
724 if ((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0)) != 0)
728 trace_output (OP_COND_BR
);
738 trace_input ("ble", OP_COND_BR
, 0);
740 psw
= State
.sregs
[5];
742 if ((((psw
& PSW_Z
) != 0)
743 || (((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0))) != 0)
747 trace_output (OP_COND_BR
);
757 trace_input ("bnv", OP_COND_BR
, 0);
759 psw
= State
.sregs
[5];
761 if ((psw
& PSW_OV
) == 0)
765 trace_output (OP_COND_BR
);
775 trace_input ("bnl", OP_COND_BR
, 0);
777 psw
= State
.sregs
[5];
779 if ((psw
& PSW_CY
) == 0)
783 trace_output (OP_COND_BR
);
793 trace_input ("bne", OP_COND_BR
, 0);
795 psw
= State
.sregs
[5];
797 if ((psw
& PSW_Z
) == 0)
801 trace_output (OP_COND_BR
);
811 trace_input ("bh", OP_COND_BR
, 0);
813 psw
= State
.sregs
[5];
815 if ((((psw
& PSW_CY
) != 0) | ((psw
& PSW_Z
) != 0)) == 0)
819 trace_output (OP_COND_BR
);
829 trace_input ("bp", OP_COND_BR
, 0);
831 psw
= State
.sregs
[5];
833 if ((psw
& PSW_S
) == 0)
837 trace_output (OP_COND_BR
);
847 trace_input ("bsa", OP_COND_BR
, 0);
849 psw
= State
.sregs
[5];
851 if ((psw
& PSW_SAT
) != 0)
855 trace_output (OP_COND_BR
);
865 trace_input ("bge", OP_COND_BR
, 0);
867 psw
= State
.sregs
[5];
869 if ((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0)) == 0)
873 trace_output (OP_COND_BR
);
883 trace_input ("bgt", OP_COND_BR
, 0);
885 psw
= State
.sregs
[5];
887 if ((((psw
& PSW_Z
) != 0)
888 || (((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0))) == 0)
892 trace_output (OP_COND_BR
);
899 /* interp.c will bump this by +2, so correct for it here. */
900 trace_input ("jmp", OP_REG
, 0);
901 State
.pc
= State
.regs
[OP
[0]] - 2;
902 trace_output (OP_REG
);
905 /* jarl disp22, reg */
909 unsigned int op0
, opc
;
912 trace_input ("jarl", OP_JUMP
, 0);
913 temp
= SEXT22 (OP
[0]);
919 /* Gross. jarl X,r0 is really jr and doesn't save its result. */
921 State
.regs
[OP
[1]] = opc
+ 4;
922 trace_output (OP_JUMP
);
929 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
931 trace_input ("add", OP_REG_REG
, 0);
932 /* Compute the result. */
933 op0
= State
.regs
[OP
[0]];
934 op1
= State
.regs
[OP
[1]];
937 /* Compute the condition codes. */
939 s
= (result
& 0x80000000);
940 cy
= (result
< op0
|| result
< op1
);
941 ov
= ((op0
& 0x80000000) == (op1
& 0x80000000)
942 && (op0
& 0x80000000) != (result
& 0x80000000));
944 /* Store the result and condition codes. */
945 State
.regs
[OP
[1]] = result
;
946 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
947 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
948 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
949 trace_output (OP_REG_REG
);
952 /* add sign_extend(imm5), reg */
956 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
959 trace_input ("add", OP_IMM_REG
, 0);
961 /* Compute the result. */
962 temp
= SEXT5 (OP
[0]);
964 op1
= State
.regs
[OP
[1]];
967 /* Compute the condition codes. */
969 s
= (result
& 0x80000000);
970 cy
= (result
< op0
|| result
< op1
);
971 ov
= ((op0
& 0x80000000) == (op1
& 0x80000000)
972 && (op0
& 0x80000000) != (result
& 0x80000000));
974 /* Store the result and condition codes. */
975 State
.regs
[OP
[1]] = result
;
976 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
977 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
978 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
979 trace_output (OP_IMM_REG
);
982 /* addi sign_extend(imm16), reg, reg */
986 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
989 trace_input ("addi", OP_IMM_REG_REG
, 0);
991 /* Compute the result. */
992 temp
= SEXT16 (OP
[0]);
994 op1
= State
.regs
[OP
[1]];
997 /* Compute the condition codes. */
999 s
= (result
& 0x80000000);
1000 cy
= (result
< op0
|| result
< op1
);
1001 ov
= ((op0
& 0x80000000) == (op1
& 0x80000000)
1002 && (op0
& 0x80000000) != (result
& 0x80000000));
1004 /* Store the result and condition codes. */
1005 State
.regs
[OP
[2]] = result
;
1006 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1007 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1008 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
1009 trace_output (OP_IMM_REG_REG
);
1012 /* sub reg1, reg2 */
1016 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
1018 trace_input ("sub", OP_REG_REG
, 0);
1019 /* Compute the result. */
1020 op0
= State
.regs
[OP
[0]];
1021 op1
= State
.regs
[OP
[1]];
1024 /* Compute the condition codes. */
1026 s
= (result
& 0x80000000);
1028 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1029 && (op1
& 0x80000000) != (result
& 0x80000000));
1031 /* Store the result and condition codes. */
1032 State
.regs
[OP
[1]] = result
;
1033 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1034 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1035 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
1036 trace_output (OP_REG_REG
);
1039 /* subr reg1, reg2 */
1043 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
1045 trace_input ("subr", OP_REG_REG
, 0);
1046 /* Compute the result. */
1047 op0
= State
.regs
[OP
[0]];
1048 op1
= State
.regs
[OP
[1]];
1051 /* Compute the condition codes. */
1053 s
= (result
& 0x80000000);
1055 ov
= ((op0
& 0x80000000) != (op1
& 0x80000000)
1056 && (op0
& 0x80000000) != (result
& 0x80000000));
1058 /* Store the result and condition codes. */
1059 State
.regs
[OP
[1]] = result
;
1060 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1061 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1062 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
1063 trace_output (OP_REG_REG
);
1066 /* mulh reg1, reg2 */
1070 trace_input ("mulh", OP_REG_REG
, 0);
1071 State
.regs
[OP
[1]] = ((State
.regs
[OP
[1]] & 0xffff)
1072 * (State
.regs
[OP
[0]] & 0xffff));
1073 trace_output (OP_REG_REG
);
1076 /* mulh sign_extend(imm5), reg2
1082 int value
= SEXT5 (OP
[0]);
1084 trace_input ("mulh", OP_IMM_REG
, 0);
1085 State
.regs
[OP
[1]] = (State
.regs
[OP
[1]] & 0xffff) * value
;
1086 trace_output (OP_IMM_REG
);
1089 /* mulhi imm16, reg1, reg2 */
1093 int value
= OP
[0] & 0xffff;
1095 trace_input ("mulhi", OP_IMM_REG_REG
, 0);
1096 State
.regs
[OP
[2]] = (State
.regs
[OP
[1]] & 0xffff) * value
;
1097 trace_output (OP_IMM_REG_REG
);
1100 /* divh reg1, reg2 */
1104 unsigned int op0
, op1
, result
, ov
, s
, z
;
1107 trace_input ("divh", OP_REG_REG
, 0);
1109 /* Compute the result. */
1110 temp
= SEXT16 (State
.regs
[OP
[0]]);
1112 op1
= State
.regs
[OP
[1]];
1114 if (op0
== 0xffffffff && op1
== 0x80000000)
1116 result
= 0x80000000;
1130 /* Compute the condition codes. */
1132 s
= (result
& 0x80000000);
1134 /* Store the result and condition codes. */
1135 State
.regs
[OP
[1]] = result
;
1136 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
);
1137 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1138 | (ov
? PSW_OV
: 0));
1139 trace_output (OP_REG_REG
);
1146 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
1148 trace_input ("cmp", OP_REG_REG_CMP
, 0);
1149 /* Compute the result. */
1150 op0
= State
.regs
[OP
[0]];
1151 op1
= State
.regs
[OP
[1]];
1154 /* Compute the condition codes. */
1156 s
= (result
& 0x80000000);
1158 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1159 && (op1
& 0x80000000) != (result
& 0x80000000));
1161 /* Set condition codes. */
1162 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1163 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1164 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
1165 trace_output (OP_REG_REG_CMP
);
1168 /* cmp sign_extend(imm5), reg */
1172 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
1175 /* Compute the result. */
1176 trace_input ("cmp", OP_IMM_REG_CMP
, 0);
1177 temp
= SEXT5 (OP
[0]);
1179 op1
= State
.regs
[OP
[1]];
1182 /* Compute the condition codes. */
1184 s
= (result
& 0x80000000);
1186 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1187 && (op1
& 0x80000000) != (result
& 0x80000000));
1189 /* Set condition codes. */
1190 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1191 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1192 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
1193 trace_output (OP_IMM_REG_CMP
);
1196 /* setf cccc,reg2 */
1200 /* Hack alert. We turn off a bit in op0 since we really only
1202 unsigned int op0
, psw
, result
= 0;
1204 trace_input ("setf", OP_EX1
, 0);
1206 psw
= State
.sregs
[5];
1211 result
= ((psw
& PSW_OV
) != 0);
1214 result
= ((psw
& PSW_CY
) != 0);
1217 result
= ((psw
& PSW_Z
) != 0);
1220 result
= ((((psw
& PSW_CY
) != 0) | ((psw
& PSW_Z
) != 0)) != 0);
1223 result
= ((psw
& PSW_S
) != 0);
1229 result
= ((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0)) != 0);
1232 result
= (((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0))
1233 || ((psw
& PSW_Z
) != 0)) != 0);
1236 result
= ((psw
& PSW_OV
) == 0);
1239 result
= ((psw
& PSW_CY
) == 0);
1242 result
= ((psw
& PSW_Z
) == 0);
1245 result
= ((((psw
& PSW_CY
) != 0) | ((psw
& PSW_Z
) != 0)) == 0);
1248 result
= ((psw
& PSW_S
) == 0);
1251 result
= ((psw
& PSW_SAT
) != 0);
1254 result
= ((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0)) == 0);
1257 result
= (((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0))
1258 || ((psw
& PSW_Z
) != 0)) == 0);
1262 State
.regs
[OP
[1]] = result
;
1263 trace_output (OP_EX1
);
1266 /* satadd reg,reg */
1270 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
, sat
;
1272 trace_input ("satadd", OP_REG_REG
, 0);
1273 /* Compute the result. */
1274 op0
= State
.regs
[OP
[0]];
1275 op1
= State
.regs
[OP
[1]];
1278 /* Compute the condition codes. */
1280 s
= (result
& 0x80000000);
1281 cy
= (result
< op0
|| result
< op1
);
1282 ov
= ((op0
& 0x80000000) == (op1
& 0x80000000)
1283 && (op0
& 0x80000000) != (result
& 0x80000000));
1286 /* Store the result and condition codes. */
1287 State
.regs
[OP
[1]] = result
;
1288 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1289 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1290 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0)
1291 | (sat
? PSW_SAT
: 0));
1293 /* Handle saturated results. */
1295 State
.regs
[OP
[1]] = 0x80000000;
1297 State
.regs
[OP
[1]] = 0x7fffffff;
1298 trace_output (OP_REG_REG
);
1301 /* satadd sign_extend(imm5), reg */
1305 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
, sat
;
1309 trace_input ("satadd", OP_IMM_REG
, 0);
1311 /* Compute the result. */
1312 temp
= SEXT5 (OP
[0]);
1314 op1
= State
.regs
[OP
[1]];
1317 /* Compute the condition codes. */
1319 s
= (result
& 0x80000000);
1320 cy
= (result
< op0
|| result
< op1
);
1321 ov
= ((op0
& 0x80000000) == (op1
& 0x80000000)
1322 && (op0
& 0x80000000) != (result
& 0x80000000));
1325 /* Store the result and condition codes. */
1326 State
.regs
[OP
[1]] = result
;
1327 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1328 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1329 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0)
1330 | (sat
? PSW_SAT
: 0));
1332 /* Handle saturated results. */
1334 State
.regs
[OP
[1]] = 0x80000000;
1336 State
.regs
[OP
[1]] = 0x7fffffff;
1337 trace_output (OP_IMM_REG
);
1340 /* satsub reg1, reg2 */
1344 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
, sat
;
1346 trace_input ("satsub", OP_REG_REG
, 0);
1348 /* Compute the result. */
1349 op0
= State
.regs
[OP
[0]];
1350 op1
= State
.regs
[OP
[1]];
1353 /* Compute the condition codes. */
1355 s
= (result
& 0x80000000);
1357 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1358 && (op1
& 0x80000000) != (result
& 0x80000000));
1361 /* Store the result and condition codes. */
1362 State
.regs
[OP
[1]] = result
;
1363 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1364 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1365 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0)
1366 | (sat
? PSW_SAT
: 0));
1368 /* Handle saturated results. */
1370 State
.regs
[OP
[1]] = 0x80000000;
1372 State
.regs
[OP
[1]] = 0x7fffffff;
1373 trace_output (OP_REG_REG
);
1376 /* satsubi sign_extend(imm16), reg */
1380 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
, sat
;
1383 trace_input ("satsubi", OP_IMM_REG
, 0);
1385 /* Compute the result. */
1386 temp
= SEXT16 (OP
[0]);
1388 op1
= State
.regs
[OP
[1]];
1391 /* Compute the condition codes. */
1393 s
= (result
& 0x80000000);
1395 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1396 && (op1
& 0x80000000) != (result
& 0x80000000));
1399 /* Store the result and condition codes. */
1400 State
.regs
[OP
[1]] = result
;
1401 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1402 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1403 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0)
1404 | (sat
? PSW_SAT
: 0));
1406 /* Handle saturated results. */
1408 State
.regs
[OP
[1]] = 0x80000000;
1410 State
.regs
[OP
[1]] = 0x7fffffff;
1411 trace_output (OP_IMM_REG
);
1414 /* satsubr reg,reg */
1418 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
, sat
;
1420 trace_input ("satsubr", OP_REG_REG
, 0);
1422 /* Compute the result. */
1423 op0
= State
.regs
[OP
[0]];
1424 op1
= State
.regs
[OP
[1]];
1427 /* Compute the condition codes. */
1429 s
= (result
& 0x80000000);
1430 cy
= (result
< op0
);
1431 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1432 && (op1
& 0x80000000) != (result
& 0x80000000));
1435 /* Store the result and condition codes. */
1436 State
.regs
[OP
[1]] = result
;
1437 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1438 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1439 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0)
1440 | (sat
? PSW_SAT
: 0));
1442 /* Handle saturated results. */
1444 State
.regs
[OP
[1]] = 0x80000000;
1446 State
.regs
[OP
[1]] = 0x7fffffff;
1447 trace_output (OP_REG_REG
);
1454 unsigned int op0
, op1
, result
, z
, s
;
1456 trace_input ("tst", OP_REG_REG_CMP
, 0);
1458 /* Compute the result. */
1459 op0
= State
.regs
[OP
[0]];
1460 op1
= State
.regs
[OP
[1]];
1463 /* Compute the condition codes. */
1465 s
= (result
& 0x80000000);
1467 /* Store the condition codes. */
1468 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
);
1469 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1470 trace_output (OP_REG_REG_CMP
);
1477 trace_input ("mov", OP_REG_REG_MOVE
, 0);
1478 State
.regs
[OP
[1]] = State
.regs
[OP
[0]];
1479 trace_output (OP_REG_REG_MOVE
);
1482 /* mov sign_extend(imm5), reg */
1486 int value
= SEXT5 (OP
[0]);
1488 trace_input ("mov", OP_IMM_REG_MOVE
, 0);
1489 State
.regs
[OP
[1]] = value
;
1490 trace_output (OP_IMM_REG_MOVE
);
1493 /* movea sign_extend(imm16), reg, reg */
1498 int value
= SEXT16 (OP
[0]);
1500 trace_input ("movea", OP_IMM_REG_REG
, 0);
1501 State
.regs
[OP
[2]] = State
.regs
[OP
[1]] + value
;
1502 trace_output (OP_IMM_REG_REG
);
1505 /* movhi imm16, reg, reg */
1509 uint32 value
= (OP
[0] & 0xffff) << 16;
1511 trace_input ("movhi", OP_UIMM_REG_REG
, 16);
1512 State
.regs
[OP
[2]] = State
.regs
[OP
[1]] + value
;
1513 trace_output (OP_UIMM_REG_REG
);
1516 /* sar zero_extend(imm5),reg1 */
1520 unsigned int op0
, op1
, result
, z
, s
, cy
;
1522 trace_input ("sar", OP_IMM_REG
, 0);
1524 op1
= State
.regs
[OP
[1]];
1525 result
= (signed)op1
>> op0
;
1527 /* Compute the condition codes. */
1529 s
= (result
& 0x80000000);
1530 cy
= (op1
& (1 << (op0
- 1)));
1532 /* Store the result and condition codes. */
1533 State
.regs
[OP
[1]] = result
;
1534 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1535 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1536 | (cy
? PSW_CY
: 0));
1537 trace_output (OP_IMM_REG
);
1540 /* sar reg1, reg2 */
1544 unsigned int op0
, op1
, result
, z
, s
, cy
;
1546 trace_input ("sar", OP_REG_REG
, 0);
1547 op0
= State
.regs
[OP
[0]] & 0x1f;
1548 op1
= State
.regs
[OP
[1]];
1549 result
= (signed)op1
>> op0
;
1551 /* Compute the condition codes. */
1553 s
= (result
& 0x80000000);
1554 cy
= (op1
& (1 << (op0
- 1)));
1556 /* Store the result and condition codes. */
1557 State
.regs
[OP
[1]] = result
;
1558 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1559 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1560 | (cy
? PSW_CY
: 0));
1561 trace_output (OP_REG_REG
);
1564 /* shl zero_extend(imm5),reg1 */
1568 unsigned int op0
, op1
, result
, z
, s
, cy
;
1570 trace_input ("shl", OP_IMM_REG
, 0);
1572 op1
= State
.regs
[OP
[1]];
1573 result
= op1
<< op0
;
1575 /* Compute the condition codes. */
1577 s
= (result
& 0x80000000);
1578 cy
= (op1
& (1 << (32 - op0
)));
1580 /* Store the result and condition codes. */
1581 State
.regs
[OP
[1]] = result
;
1582 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1583 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1584 | (cy
? PSW_CY
: 0));
1585 trace_output (OP_IMM_REG
);
1588 /* shl reg1, reg2 */
1592 unsigned int op0
, op1
, result
, z
, s
, cy
;
1594 trace_input ("shl", OP_REG_REG
, 0);
1595 op0
= State
.regs
[OP
[0]] & 0x1f;
1596 op1
= State
.regs
[OP
[1]];
1597 result
= op1
<< op0
;
1599 /* Compute the condition codes. */
1601 s
= (result
& 0x80000000);
1602 cy
= (op1
& (1 << (32 - op0
)));
1604 /* Store the result and condition codes. */
1605 State
.regs
[OP
[1]] = result
;
1606 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1607 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1608 | (cy
? PSW_CY
: 0));
1609 trace_output (OP_REG_REG
);
1612 /* shr zero_extend(imm5),reg1 */
1616 unsigned int op0
, op1
, result
, z
, s
, cy
;
1618 trace_input ("shr", OP_IMM_REG
, 0);
1620 op1
= State
.regs
[OP
[1]];
1621 result
= op1
>> op0
;
1623 /* Compute the condition codes. */
1625 s
= (result
& 0x80000000);
1626 cy
= (op1
& (1 << (op0
- 1)));
1628 /* Store the result and condition codes. */
1629 State
.regs
[OP
[1]] = result
;
1630 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1631 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1632 | (cy
? PSW_CY
: 0));
1633 trace_output (OP_IMM_REG
);
1636 /* shr reg1, reg2 */
1640 unsigned int op0
, op1
, result
, z
, s
, cy
;
1642 trace_input ("shr", OP_REG_REG
, 0);
1643 op0
= State
.regs
[OP
[0]] & 0x1f;
1644 op1
= State
.regs
[OP
[1]];
1645 result
= op1
>> op0
;
1647 /* Compute the condition codes. */
1649 s
= (result
& 0x80000000);
1650 cy
= (op1
& (1 << (op0
- 1)));
1652 /* Store the result and condition codes. */
1653 State
.regs
[OP
[1]] = result
;
1654 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1655 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1656 | (cy
? PSW_CY
: 0));
1657 trace_output (OP_REG_REG
);
1664 unsigned int op0
, op1
, result
, z
, s
;
1666 trace_input ("or", OP_REG_REG
, 0);
1668 /* Compute the result. */
1669 op0
= State
.regs
[OP
[0]];
1670 op1
= State
.regs
[OP
[1]];
1673 /* Compute the condition codes. */
1675 s
= (result
& 0x80000000);
1677 /* Store the result and condition codes. */
1678 State
.regs
[OP
[1]] = result
;
1679 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
);
1680 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1681 trace_output (OP_REG_REG
);
1684 /* ori zero_extend(imm16), reg, reg */
1688 unsigned int op0
, op1
, result
, z
, s
;
1690 trace_input ("ori", OP_UIMM_REG_REG
, 0);
1691 op0
= OP
[0] & 0xffff;
1692 op1
= State
.regs
[OP
[1]];
1695 /* Compute the condition codes. */
1697 s
= (result
& 0x80000000);
1699 /* Store the result and condition codes. */
1700 State
.regs
[OP
[2]] = result
;
1701 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
);
1702 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1703 trace_output (OP_UIMM_REG_REG
);
1710 unsigned int op0
, op1
, result
, z
, s
;
1712 trace_input ("and", OP_REG_REG
, 0);
1714 /* Compute the result. */
1715 op0
= State
.regs
[OP
[0]];
1716 op1
= State
.regs
[OP
[1]];
1719 /* Compute the condition codes. */
1721 s
= (result
& 0x80000000);
1723 /* Store the result and condition codes. */
1724 State
.regs
[OP
[1]] = result
;
1725 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
);
1726 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1727 trace_output (OP_REG_REG
);
1730 /* andi zero_extend(imm16), reg, reg */
1734 unsigned int op0
, op1
, result
, z
;
1736 trace_input ("andi", OP_UIMM_REG_REG
, 0);
1737 op0
= OP
[0] & 0xffff;
1738 op1
= State
.regs
[OP
[1]];
1741 /* Compute the condition codes. */
1744 /* Store the result and condition codes. */
1745 State
.regs
[OP
[2]] = result
;
1746 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
);
1747 State
.sregs
[5] |= (z
? PSW_Z
: 0);
1748 trace_output (OP_UIMM_REG_REG
);
1755 unsigned int op0
, op1
, result
, z
, s
;
1757 trace_input ("xor", OP_REG_REG
, 0);
1759 /* Compute the result. */
1760 op0
= State
.regs
[OP
[0]];
1761 op1
= State
.regs
[OP
[1]];
1764 /* Compute the condition codes. */
1766 s
= (result
& 0x80000000);
1768 /* Store the result and condition codes. */
1769 State
.regs
[OP
[1]] = result
;
1770 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
);
1771 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1772 trace_output (OP_REG_REG
);
1775 /* xori zero_extend(imm16), reg, reg */
1779 unsigned int op0
, op1
, result
, z
, s
;
1781 trace_input ("xori", OP_UIMM_REG_REG
, 0);
1782 op0
= OP
[0] & 0xffff;
1783 op1
= State
.regs
[OP
[1]];
1786 /* Compute the condition codes. */
1788 s
= (result
& 0x80000000);
1790 /* Store the result and condition codes. */
1791 State
.regs
[OP
[2]] = result
;
1792 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
);
1793 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1794 trace_output (OP_UIMM_REG_REG
);
1797 /* not reg1, reg2 */
1801 unsigned int op0
, result
, z
, s
;
1803 trace_input ("not", OP_REG_REG_MOVE
, 0);
1804 /* Compute the result. */
1805 op0
= State
.regs
[OP
[0]];
1808 /* Compute the condition codes. */
1810 s
= (result
& 0x80000000);
1812 /* Store the result and condition codes. */
1813 State
.regs
[OP
[1]] = result
;
1814 State
.sregs
[5] &= ~(PSW_Z
| PSW_S
| PSW_OV
);
1815 State
.sregs
[5] |= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1816 trace_output (OP_REG_REG_MOVE
);
1823 unsigned int op0
, op1
, op2
;
1826 trace_input ("set1", OP_BIT
, 0);
1827 op0
= State
.regs
[OP
[0]];
1829 temp
= SEXT16 (OP
[2]);
1831 temp
= get_byte (State
.mem
+ op0
+ op2
);
1832 State
.sregs
[5] &= ~PSW_Z
;
1833 if ((temp
& (1 << op1
)) == 0)
1834 State
.sregs
[5] |= PSW_Z
;
1836 put_byte (State
.mem
+ op0
+ op2
, temp
);
1837 trace_output (OP_BIT
);
1844 unsigned int op0
, op1
, op2
;
1847 trace_input ("not1", OP_BIT
, 0);
1848 op0
= State
.regs
[OP
[0]];
1850 temp
= SEXT16 (OP
[2]);
1852 temp
= get_byte (State
.mem
+ op0
+ op2
);
1853 State
.sregs
[5] &= ~PSW_Z
;
1854 if ((temp
& (1 << op1
)) == 0)
1855 State
.sregs
[5] |= PSW_Z
;
1857 put_byte (State
.mem
+ op0
+ op2
, temp
);
1858 trace_output (OP_BIT
);
1865 unsigned int op0
, op1
, op2
;
1868 trace_input ("clr1", OP_BIT
, 0);
1869 op0
= State
.regs
[OP
[0]];
1871 temp
= SEXT16 (OP
[2]);
1873 temp
= get_byte (State
.mem
+ op0
+ op2
);
1874 State
.sregs
[5] &= ~PSW_Z
;
1875 if ((temp
& (1 << op1
)) == 0)
1876 State
.sregs
[5] |= PSW_Z
;
1877 temp
&= ~(1 << op1
);
1878 put_byte (State
.mem
+ op0
+ op2
, temp
);
1879 trace_output (OP_BIT
);
1886 unsigned int op0
, op1
, op2
;
1889 trace_input ("tst1", OP_BIT
, 0);
1890 op0
= State
.regs
[OP
[0]];
1892 temp
= SEXT16 (OP
[2]);
1894 temp
= get_byte (State
.mem
+ op0
+ op2
);
1895 State
.sregs
[5] &= ~PSW_Z
;
1896 if ((temp
& (1 << op1
)) == 0)
1897 State
.sregs
[5] |= PSW_Z
;
1898 trace_output (OP_BIT
);
1905 trace_input ("di", OP_NONE
, 0);
1906 State
.sregs
[5] |= PSW_ID
;
1907 trace_output (OP_NONE
);
1914 trace_input ("ei", OP_NONE
, 0);
1915 State
.sregs
[5] &= ~PSW_ID
;
1916 trace_output (OP_NONE
);
1919 /* halt, not supported */
1923 trace_input ("halt", OP_NONE
, 0);
1924 State
.exception
= SIGQUIT
;
1925 trace_output (OP_NONE
);
1928 /* reti, not supported */
1932 trace_input ("reti", OP_NONE
, 0);
1933 trace_output (OP_NONE
);
1937 /* trap, not supportd */
1943 trace_input ("trap", OP_TRAP
, 0);
1944 trace_output (OP_TRAP
);
1946 /* Trap 0 is used for simulating low-level I/O */
1950 int save_errno
= errno
;
1953 /* Registers passed to trap 0 */
1955 #define FUNC State.regs[6] /* function number, return value */
1956 #define PARM1 State.regs[7] /* optional parm 1 */
1957 #define PARM2 State.regs[8] /* optional parm 2 */
1958 #define PARM3 State.regs[9] /* optional parm 3 */
1960 /* Registers set by trap 0 */
1962 #define RETVAL State.regs[10] /* return value */
1963 #define RETERR State.regs[11] /* return error code */
1965 /* Turn a pointer in a register into a pointer into real memory. */
1967 #define MEMPTR(x) ((char *)((x) + State.mem))
1972 #if !defined(__GO32__) && !defined(_WIN32)
1977 RETVAL
= execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
),
1978 (char **)MEMPTR (PARM3
));
1981 RETVAL
= execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
), NULL
);
1990 RETVAL
= pipe (host_fd
);
1991 SW (buf
, host_fd
[0]);
1992 buf
+= sizeof(uint16
);
1993 SW (buf
, host_fd
[1]);
2001 RETVAL
= wait (&status
);
2009 RETVAL
= v850_callback
->read (v850_callback
, PARM1
, MEMPTR (PARM2
),
2014 RETVAL
= (int)v850_callback
->write_stdout (v850_callback
,
2015 MEMPTR (PARM2
), PARM3
);
2017 RETVAL
= (int)v850_callback
->write (v850_callback
, PARM1
,
2018 MEMPTR (PARM2
), PARM3
);
2021 RETVAL
= v850_callback
->lseek (v850_callback
, PARM1
, PARM2
, PARM3
);
2024 RETVAL
= v850_callback
->close (v850_callback
, PARM1
);
2027 RETVAL
= v850_callback
->open (v850_callback
, MEMPTR (PARM1
), PARM2
);
2030 /* EXIT - caller can look in PARM1 to work out the
2032 if (PARM1
== 0xdead || PARM1
== 0x1)
2033 State
.exception
= SIGABRT
;
2035 State
.exception
= SIGQUIT
;
2039 case SYS_stat
: /* added at hmsi */
2040 /* stat system call */
2042 struct stat host_stat
;
2045 RETVAL
= stat (MEMPTR (PARM1
), &host_stat
);
2049 /* The hard-coded offsets and sizes were determined by using
2050 * the D10V compiler on a test program that used struct stat.
2052 SW (buf
, host_stat
.st_dev
);
2053 SW (buf
+2, host_stat
.st_ino
);
2054 SW (buf
+4, host_stat
.st_mode
);
2055 SW (buf
+6, host_stat
.st_nlink
);
2056 SW (buf
+8, host_stat
.st_uid
);
2057 SW (buf
+10, host_stat
.st_gid
);
2058 SW (buf
+12, host_stat
.st_rdev
);
2059 SLW (buf
+16, host_stat
.st_size
);
2060 SLW (buf
+20, host_stat
.st_atime
);
2061 SLW (buf
+28, host_stat
.st_mtime
);
2062 SLW (buf
+36, host_stat
.st_ctime
);
2068 RETVAL
= chown (MEMPTR (PARM1
), PARM2
, PARM3
);
2071 RETVAL
= chmod (MEMPTR (PARM1
), PARM2
);
2074 /* Cast the second argument to void *, to avoid type mismatch
2075 if a prototype is present. */
2076 RETVAL
= utime (MEMPTR (PARM1
), (void *) MEMPTR (PARM2
));
2084 else if (OP
[0] == 1 )
2086 char *fstr
= State
.regs
[2] + State
.mem
;
2097 trace_input ("ldsr", OP_LDSR
, 0);
2098 op0
= State
.regs
[OP
[0]];
2099 State
.sregs
[OP
[1]] = op0
;
2100 trace_output (OP_LDSR
);
2103 /* stsr, not supported */
2109 trace_input ("stsr", OP_STSR
, 0);
2110 op0
= State
.sregs
[OP
[1]];
2111 State
.regs
[OP
[0]] = op0
;
2112 trace_output (OP_STSR
);