4 #include "sys/syscall.h"
7 #if !defined(__GO32__) && !defined(_WIN32)
40 static void trace_input
PARAMS ((char *name
, enum op_types type
, int size
));
41 static void trace_output
PARAMS ((enum op_types result
));
42 static int init_text_p
= 0;
43 static asection
*text
;
44 static bfd_vma text_start
;
45 static bfd_vma text_end
;
48 #ifndef SIZE_INSTRUCTION
49 #define SIZE_INSTRUCTION 6
53 #define SIZE_OPERANDS 16
57 #define SIZE_VALUES 11
61 #define SIZE_LOCATION 40
65 trace_input (name
, type
, size
)
77 const char *functionname
;
78 unsigned int linenumber
;
80 if ((v850_debug
& DEBUG_TRACE
) == 0)
87 for (s
= exec_bfd
->sections
; s
; s
= s
->next
)
88 if (strcmp (bfd_get_section_name (exec_bfd
, s
), ".text") == 0)
91 text_start
= bfd_get_section_vma (exec_bfd
, s
);
92 text_end
= text_start
+ bfd_section_size (exec_bfd
, s
);
97 if (text
&& PC
>= text_start
&& PC
< text_end
)
99 filename
= (const char *)0;
100 functionname
= (const char *)0;
102 if (bfd_find_nearest_line (exec_bfd
, text
, (struct symbol_cache_entry
**)0, PC
- text_start
,
103 &filename
, &functionname
, &linenumber
))
108 sprintf (p
, "Line %5d ", linenumber
);
114 sprintf (p
, "Func %s ", functionname
);
119 char *q
= (char *) strrchr (filename
, '/');
120 sprintf (p
, "File %s ", (q
) ? q
+1 : filename
);
129 (*v850_callback
->printf_filtered
) (v850_callback
, "0x%.8x: %-*.*s %-*s",
131 SIZE_LOCATION
, SIZE_LOCATION
, buf
,
132 SIZE_INSTRUCTION
, name
);
139 strcpy (buf
, "unknown");
143 sprintf (buf
, "%d", OP
[0]);
147 sprintf (buf
, "r%d", OP
[0]);
152 case OP_REG_REG_MOVE
:
153 sprintf (buf
, "r%d,r%d", OP
[0], OP
[1]);
158 case OP_IMM_REG_MOVE
:
159 sprintf (buf
, "%d,r%d", OP
[0], OP
[1]);
163 sprintf (buf
, "%d", SEXT9 (OP
[0]));
167 sprintf (buf
, "%d[r30],r%d", OP
[1] * size
, OP
[0]);
171 sprintf (buf
, "r%d,%d[r30]", OP
[0], OP
[1] * size
);
175 sprintf (buf
, "%d[r%d],r%d", SEXT16 (OP
[2]) & ~0x1, OP
[0], OP
[1]);
179 sprintf (buf
, "r%d,%d[r%d]", OP
[1], SEXT16 (OP
[2] & ~0x1), OP
[0]);
183 sprintf (buf
, "%d,r%d", SEXT22 (OP
[0]), OP
[1]);
187 sprintf (buf
, "%d,r%d,r%d", SEXT16 (OP
[0]), OP
[1], OP
[2]);
190 case OP_UIMM_REG_REG
:
191 sprintf (buf
, "%d,r%d,r%d", OP
[0] & 0xffff, OP
[1], OP
[2]);
195 sprintf (buf
, "%d,%d[r%d]", OP
[1] & 0x7, SEXT16 (OP
[2]), OP
[0]);
201 default: cond
= "?"; break;
202 case 0x0: cond
= "v"; break;
203 case 0x1: cond
= "c"; break;
204 case 0x2: cond
= "z"; break;
205 case 0x3: cond
= "nh"; break;
206 case 0x4: cond
= "s"; break;
207 case 0x5: cond
= "t"; break;
208 case 0x6: cond
= "lt"; break;
209 case 0x7: cond
= "le"; break;
210 case 0x8: cond
= "nv"; break;
211 case 0x9: cond
= "nc"; break;
212 case 0xa: cond
= "nz"; break;
213 case 0xb: cond
= "h"; break;
214 case 0xc: cond
= "ns"; break;
215 case 0xd: cond
= "sa"; break;
216 case 0xe: cond
= "ge"; break;
217 case 0xf: cond
= "gt"; break;
220 sprintf (buf
, "%s,r%d", cond
, OP
[1]);
229 sprintf (buf
, "r%d,s%d", OP
[0], OP
[1]);
233 if ((v850_debug
& DEBUG_VALUES
) == 0)
235 (*v850_callback
->printf_filtered
) (v850_callback
, "%s\n", buf
);
239 (*v850_callback
->printf_filtered
) (v850_callback
, "%-*s", SIZE_OPERANDS
, buf
);
250 case OP_REG_REG_MOVE
:
251 values
[0] = State
.regs
[OP
[0]];
257 values
[0] = State
.regs
[OP
[1]];
258 values
[1] = State
.regs
[OP
[0]];
264 values
[0] = SEXT5 (OP
[0]);
269 case OP_IMM_REG_MOVE
:
270 values
[0] = SEXT5 (OP
[0]);
275 values
[0] = State
.pc
;
276 values
[1] = SEXT9 (OP
[0]);
282 values
[0] = OP
[1] * size
;
283 values
[1] = State
.regs
[30];
288 values
[0] = State
.regs
[OP
[0]];
289 values
[1] = OP
[1] * size
;
290 values
[2] = State
.regs
[30];
295 values
[0] = SEXT16 (OP
[2]);
296 values
[1] = State
.regs
[OP
[0]];
301 values
[0] = State
.regs
[OP
[1]];
302 values
[1] = SEXT16 (OP
[2]);
303 values
[2] = State
.regs
[OP
[0]];
308 values
[0] = SEXT22 (OP
[0]);
309 values
[1] = State
.pc
;
314 values
[0] = SEXT16 (OP
[0]) << size
;
315 values
[1] = State
.regs
[OP
[1]];
319 case OP_UIMM_REG_REG
:
320 values
[0] = (OP
[0] & 0xffff) << size
;
321 values
[1] = State
.regs
[OP
[1]];
339 values
[0] = State
.regs
[OP
[0]];
344 values
[0] = State
.sregs
[OP
[1]];
348 for (i
= 0; i
< num_values
; i
++)
349 (*v850_callback
->printf_filtered
) (v850_callback
, "%*s0x%.8lx", SIZE_VALUES
- 10, "", values
[i
]);
352 (*v850_callback
->printf_filtered
) (v850_callback
, "%*s", SIZE_VALUES
, "");
357 trace_output (result
)
358 enum op_types result
;
360 if ((v850_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
380 (*v850_callback
->printf_filtered
) (v850_callback
, " :: 0x%.8lx",
381 (unsigned long)State
.regs
[OP
[0]]);
385 case OP_REG_REG_MOVE
:
387 case OP_IMM_REG_MOVE
:
390 (*v850_callback
->printf_filtered
) (v850_callback
, " :: 0x%.8lx",
391 (unsigned long)State
.regs
[OP
[1]]);
395 case OP_UIMM_REG_REG
:
396 (*v850_callback
->printf_filtered
) (v850_callback
, " :: 0x%.8lx",
397 (unsigned long)State
.regs
[OP
[2]]);
402 (*v850_callback
->printf_filtered
) (v850_callback
, " :: 0x%.8lx",
403 (unsigned long)State
.regs
[OP
[1]]);
407 (*v850_callback
->printf_filtered
) (v850_callback
, " :: 0x%.8lx",
408 (unsigned long)State
.sregs
[OP
[1]]);
412 (*v850_callback
->printf_filtered
) (v850_callback
, "\n");
417 #define trace_input(NAME, IN1, IN2)
418 #define trace_output(RESULT)
429 trace_input ("sld.b", OP_LOAD16
, 1);
433 result
= load_mem (State
.regs
[30] + op2
, 1);
434 State
.regs
[OP
[0]] = SEXT8 (result
);
435 trace_output (OP_LOAD16
);
445 trace_input ("sld.h", OP_LOAD16
, 2);
449 result
= load_mem (State
.regs
[30] + op2
, 2);
450 State
.regs
[OP
[0]] = SEXT16 (result
);
451 trace_output (OP_LOAD16
);
461 trace_input ("sld.w", OP_LOAD16
, 4);
465 result
= load_mem (State
.regs
[30] + op2
, 4);
466 State
.regs
[OP
[0]] = result
;
467 trace_output (OP_LOAD16
);
474 unsigned int op0
, op1
;
477 trace_input ("sst.b", OP_STORE16
, 1);
478 op0
= State
.regs
[OP
[0]];
482 store_mem (State
.regs
[30] + op1
, 1, op0
);
483 trace_output (OP_STORE16
);
490 unsigned int op0
, op1
;
493 trace_input ("sst.h", OP_STORE16
, 2);
494 op0
= State
.regs
[OP
[0]];
498 store_mem (State
.regs
[30] + op1
, 2, op0
);
499 trace_output (OP_STORE16
);
506 unsigned int op0
, op1
;
509 trace_input ("sst.w", OP_STORE16
, 4);
510 op0
= State
.regs
[OP
[0]];
514 store_mem (State
.regs
[30] + op1
, 4, op0
);
515 trace_output (OP_STORE16
);
522 unsigned int op0
, op2
;
525 trace_input ("ld.b", OP_LOAD32
, 1);
526 op0
= State
.regs
[OP
[0]];
527 temp
= SEXT16 (OP
[2]);
529 result
= load_mem (op0
+ op2
, 1);
530 State
.regs
[OP
[1]] = SEXT8 (result
);
531 trace_output (OP_LOAD32
);
538 unsigned int op0
, op2
;
541 trace_input ("ld.h", OP_LOAD32
, 2);
542 op0
= State
.regs
[OP
[0]];
543 temp
= SEXT16 (OP
[2]);
546 result
= load_mem (op0
+ op2
, 2);
547 State
.regs
[OP
[1]] = SEXT16 (result
);
548 trace_output (OP_LOAD32
);
555 unsigned int op0
, op2
;
558 trace_input ("ld.w", OP_LOAD32
, 4);
559 op0
= State
.regs
[OP
[0]];
560 temp
= SEXT16 (OP
[2]);
563 result
= load_mem (op0
+ op2
, 4);
564 State
.regs
[OP
[1]] = result
;
565 trace_output (OP_LOAD32
);
572 unsigned int op0
, op1
, op2
;
575 trace_input ("st.b", OP_STORE32
, 1);
576 op0
= State
.regs
[OP
[0]];
577 op1
= State
.regs
[OP
[1]];
578 temp
= SEXT16 (OP
[2]);
580 store_mem (op0
+ op2
, 1, op1
);
581 trace_output (OP_STORE32
);
588 unsigned int op0
, op1
, op2
;
591 trace_input ("st.h", OP_STORE32
, 2);
592 op0
= State
.regs
[OP
[0]];
593 op1
= State
.regs
[OP
[1]];
594 temp
= SEXT16 (OP
[2] & ~0x1);
596 store_mem (op0
+ op2
, 2, op1
);
597 trace_output (OP_STORE32
);
604 unsigned int op0
, op1
, op2
;
607 trace_input ("st.w", OP_STORE32
, 4);
608 op0
= State
.regs
[OP
[0]];
609 op1
= State
.regs
[OP
[1]];
610 temp
= SEXT16 (OP
[2] & ~0x1);
612 store_mem (op0
+ op2
, 4, op1
);
613 trace_output (OP_STORE32
);
623 trace_input ("bv", OP_COND_BR
, 0);
627 if ((psw
& PSW_OV
) != 0)
631 trace_output (OP_COND_BR
);
641 trace_input ("bl", OP_COND_BR
, 0);
645 if ((psw
& PSW_CY
) != 0)
649 trace_output (OP_COND_BR
);
659 trace_input ("be", OP_COND_BR
, 0);
663 if ((psw
& PSW_Z
) != 0)
667 trace_output (OP_COND_BR
);
677 trace_input ("bnh", OP_COND_BR
, 0);
681 if ((((psw
& PSW_CY
) != 0) | ((psw
& PSW_Z
) != 0)) != 0)
685 trace_output (OP_COND_BR
);
695 trace_input ("bn", OP_COND_BR
, 0);
699 if ((psw
& PSW_S
) != 0)
703 trace_output (OP_COND_BR
);
713 trace_input ("br", OP_COND_BR
, 0);
716 trace_output (OP_COND_BR
);
726 trace_input ("blt", OP_COND_BR
, 0);
730 if ((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0)) != 0)
734 trace_output (OP_COND_BR
);
744 trace_input ("ble", OP_COND_BR
, 0);
748 if ((((psw
& PSW_Z
) != 0)
749 || (((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0))) != 0)
753 trace_output (OP_COND_BR
);
763 trace_input ("bnv", OP_COND_BR
, 0);
767 if ((psw
& PSW_OV
) == 0)
771 trace_output (OP_COND_BR
);
781 trace_input ("bnl", OP_COND_BR
, 0);
785 if ((psw
& PSW_CY
) == 0)
789 trace_output (OP_COND_BR
);
799 trace_input ("bne", OP_COND_BR
, 0);
803 if ((psw
& PSW_Z
) == 0)
807 trace_output (OP_COND_BR
);
817 trace_input ("bh", OP_COND_BR
, 0);
821 if ((((psw
& PSW_CY
) != 0) | ((psw
& PSW_Z
) != 0)) == 0)
825 trace_output (OP_COND_BR
);
835 trace_input ("bp", OP_COND_BR
, 0);
839 if ((psw
& PSW_S
) == 0)
843 trace_output (OP_COND_BR
);
853 trace_input ("bsa", OP_COND_BR
, 0);
857 if ((psw
& PSW_SAT
) != 0)
861 trace_output (OP_COND_BR
);
871 trace_input ("bge", OP_COND_BR
, 0);
875 if ((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0)) == 0)
879 trace_output (OP_COND_BR
);
889 trace_input ("bgt", OP_COND_BR
, 0);
893 if ((((psw
& PSW_Z
) != 0)
894 || (((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0))) == 0)
898 trace_output (OP_COND_BR
);
905 /* interp.c will bump this by +2, so correct for it here. */
906 trace_input ("jmp", OP_REG
, 0);
907 State
.pc
= State
.regs
[OP
[0]] - 2;
908 trace_output (OP_REG
);
911 /* jarl disp22, reg */
915 unsigned int op0
, opc
;
918 trace_input ("jarl", OP_JUMP
, 0);
919 temp
= SEXT22 (OP
[0]);
925 /* Gross. jarl X,r0 is really jr and doesn't save its result. */
927 State
.regs
[OP
[1]] = opc
+ 4;
928 trace_output (OP_JUMP
);
935 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
937 trace_input ("add", OP_REG_REG
, 0);
938 /* Compute the result. */
939 op0
= State
.regs
[OP
[0]];
940 op1
= State
.regs
[OP
[1]];
943 /* Compute the condition codes. */
945 s
= (result
& 0x80000000);
946 cy
= (result
< op0
|| result
< op1
);
947 ov
= ((op0
& 0x80000000) == (op1
& 0x80000000)
948 && (op0
& 0x80000000) != (result
& 0x80000000));
950 /* Store the result and condition codes. */
951 State
.regs
[OP
[1]] = result
;
952 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
953 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
954 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
955 trace_output (OP_REG_REG
);
958 /* add sign_extend(imm5), reg */
962 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
965 trace_input ("add", OP_IMM_REG
, 0);
967 /* Compute the result. */
968 temp
= SEXT5 (OP
[0]);
970 op1
= State
.regs
[OP
[1]];
973 /* Compute the condition codes. */
975 s
= (result
& 0x80000000);
976 cy
= (result
< op0
|| result
< op1
);
977 ov
= ((op0
& 0x80000000) == (op1
& 0x80000000)
978 && (op0
& 0x80000000) != (result
& 0x80000000));
980 /* Store the result and condition codes. */
981 State
.regs
[OP
[1]] = result
;
982 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
983 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
984 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
985 trace_output (OP_IMM_REG
);
988 /* addi sign_extend(imm16), reg, reg */
992 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
995 trace_input ("addi", OP_IMM_REG_REG
, 0);
997 /* Compute the result. */
998 temp
= SEXT16 (OP
[0]);
1000 op1
= State
.regs
[OP
[1]];
1003 /* Compute the condition codes. */
1005 s
= (result
& 0x80000000);
1006 cy
= (result
< op0
|| result
< op1
);
1007 ov
= ((op0
& 0x80000000) == (op1
& 0x80000000)
1008 && (op0
& 0x80000000) != (result
& 0x80000000));
1010 /* Store the result and condition codes. */
1011 State
.regs
[OP
[2]] = result
;
1012 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1013 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1014 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
1015 trace_output (OP_IMM_REG_REG
);
1018 /* sub reg1, reg2 */
1022 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
1024 trace_input ("sub", OP_REG_REG
, 0);
1025 /* Compute the result. */
1026 op0
= State
.regs
[OP
[0]];
1027 op1
= State
.regs
[OP
[1]];
1030 /* Compute the condition codes. */
1032 s
= (result
& 0x80000000);
1034 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1035 && (op1
& 0x80000000) != (result
& 0x80000000));
1037 /* Store the result and condition codes. */
1038 State
.regs
[OP
[1]] = result
;
1039 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1040 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1041 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
1042 trace_output (OP_REG_REG
);
1045 /* subr reg1, reg2 */
1049 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
1051 trace_input ("subr", OP_REG_REG
, 0);
1052 /* Compute the result. */
1053 op0
= State
.regs
[OP
[0]];
1054 op1
= State
.regs
[OP
[1]];
1057 /* Compute the condition codes. */
1059 s
= (result
& 0x80000000);
1061 ov
= ((op0
& 0x80000000) != (op1
& 0x80000000)
1062 && (op0
& 0x80000000) != (result
& 0x80000000));
1064 /* Store the result and condition codes. */
1065 State
.regs
[OP
[1]] = result
;
1066 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1067 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1068 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
1069 trace_output (OP_REG_REG
);
1072 /* mulh reg1, reg2 */
1076 trace_input ("mulh", OP_REG_REG
, 0);
1077 State
.regs
[OP
[1]] = (SEXT16 (State
.regs
[OP
[1]])
1078 * SEXT16 (State
.regs
[OP
[0]]));
1079 trace_output (OP_REG_REG
);
1082 /* mulh sign_extend(imm5), reg2
1088 int value
= SEXT5 (OP
[0]);
1090 trace_input ("mulh", OP_IMM_REG
, 0);
1091 State
.regs
[OP
[1]] = SEXT16 (State
.regs
[OP
[1]]) * value
;
1092 trace_output (OP_IMM_REG
);
1095 /* mulhi imm16, reg1, reg2 */
1099 int value
= SEXT16 (OP
[0]);
1101 trace_input ("mulhi", OP_IMM_REG_REG
, 0);
1102 State
.regs
[OP
[2]] = SEXT16 (State
.regs
[OP
[1]]) * value
;
1103 trace_output (OP_IMM_REG_REG
);
1106 /* divh reg1, reg2 */
1110 unsigned int op0
, op1
, result
, ov
, s
, z
;
1113 trace_input ("divh", OP_REG_REG
, 0);
1115 /* Compute the result. */
1116 temp
= SEXT16 (State
.regs
[OP
[0]]);
1118 op1
= State
.regs
[OP
[1]];
1120 if (op0
== 0xffffffff && op1
== 0x80000000)
1122 result
= 0x80000000;
1136 /* Compute the condition codes. */
1138 s
= (result
& 0x80000000);
1140 /* Store the result and condition codes. */
1141 State
.regs
[OP
[1]] = result
;
1142 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
);
1143 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1144 | (ov
? PSW_OV
: 0));
1145 trace_output (OP_REG_REG
);
1152 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
1154 trace_input ("cmp", OP_REG_REG_CMP
, 0);
1155 /* Compute the result. */
1156 op0
= State
.regs
[OP
[0]];
1157 op1
= State
.regs
[OP
[1]];
1160 /* Compute the condition codes. */
1162 s
= (result
& 0x80000000);
1164 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1165 && (op1
& 0x80000000) != (result
& 0x80000000));
1167 /* Set condition codes. */
1168 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1169 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1170 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
1171 trace_output (OP_REG_REG_CMP
);
1174 /* cmp sign_extend(imm5), reg */
1178 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
;
1181 /* Compute the result. */
1182 trace_input ("cmp", OP_IMM_REG_CMP
, 0);
1183 temp
= SEXT5 (OP
[0]);
1185 op1
= State
.regs
[OP
[1]];
1188 /* Compute the condition codes. */
1190 s
= (result
& 0x80000000);
1192 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1193 && (op1
& 0x80000000) != (result
& 0x80000000));
1195 /* Set condition codes. */
1196 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1197 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1198 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0));
1199 trace_output (OP_IMM_REG_CMP
);
1202 /* setf cccc,reg2 */
1206 /* Hack alert. We turn off a bit in op0 since we really only
1208 unsigned int op0
, psw
, result
= 0;
1210 trace_input ("setf", OP_EX1
, 0);
1217 result
= ((psw
& PSW_OV
) != 0);
1220 result
= ((psw
& PSW_CY
) != 0);
1223 result
= ((psw
& PSW_Z
) != 0);
1226 result
= ((((psw
& PSW_CY
) != 0) | ((psw
& PSW_Z
) != 0)) != 0);
1229 result
= ((psw
& PSW_S
) != 0);
1235 result
= ((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0)) != 0);
1238 result
= (((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0))
1239 || ((psw
& PSW_Z
) != 0)) != 0);
1242 result
= ((psw
& PSW_OV
) == 0);
1245 result
= ((psw
& PSW_CY
) == 0);
1248 result
= ((psw
& PSW_Z
) == 0);
1251 result
= ((((psw
& PSW_CY
) != 0) | ((psw
& PSW_Z
) != 0)) == 0);
1254 result
= ((psw
& PSW_S
) == 0);
1257 result
= ((psw
& PSW_SAT
) != 0);
1260 result
= ((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0)) == 0);
1263 result
= (((((psw
& PSW_S
) != 0) ^ ((psw
& PSW_OV
) != 0))
1264 || ((psw
& PSW_Z
) != 0)) == 0);
1268 State
.regs
[OP
[1]] = result
;
1269 trace_output (OP_EX1
);
1272 /* satadd reg,reg */
1276 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
, sat
;
1278 trace_input ("satadd", OP_REG_REG
, 0);
1279 /* Compute the result. */
1280 op0
= State
.regs
[OP
[0]];
1281 op1
= State
.regs
[OP
[1]];
1284 /* Compute the condition codes. */
1286 s
= (result
& 0x80000000);
1287 cy
= (result
< op0
|| result
< op1
);
1288 ov
= ((op0
& 0x80000000) == (op1
& 0x80000000)
1289 && (op0
& 0x80000000) != (result
& 0x80000000));
1292 /* Store the result and condition codes. */
1293 State
.regs
[OP
[1]] = result
;
1294 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1295 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1296 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0)
1297 | (sat
? PSW_SAT
: 0));
1299 /* Handle saturated results. */
1301 State
.regs
[OP
[1]] = 0x80000000;
1303 State
.regs
[OP
[1]] = 0x7fffffff;
1304 trace_output (OP_REG_REG
);
1307 /* satadd sign_extend(imm5), reg */
1311 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
, sat
;
1315 trace_input ("satadd", OP_IMM_REG
, 0);
1317 /* Compute the result. */
1318 temp
= SEXT5 (OP
[0]);
1320 op1
= State
.regs
[OP
[1]];
1323 /* Compute the condition codes. */
1325 s
= (result
& 0x80000000);
1326 cy
= (result
< op0
|| result
< op1
);
1327 ov
= ((op0
& 0x80000000) == (op1
& 0x80000000)
1328 && (op0
& 0x80000000) != (result
& 0x80000000));
1331 /* Store the result and condition codes. */
1332 State
.regs
[OP
[1]] = result
;
1333 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1334 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1335 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0)
1336 | (sat
? PSW_SAT
: 0));
1338 /* Handle saturated results. */
1340 State
.regs
[OP
[1]] = 0x80000000;
1342 State
.regs
[OP
[1]] = 0x7fffffff;
1343 trace_output (OP_IMM_REG
);
1346 /* satsub reg1, reg2 */
1350 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
, sat
;
1352 trace_input ("satsub", OP_REG_REG
, 0);
1354 /* Compute the result. */
1355 op0
= State
.regs
[OP
[0]];
1356 op1
= State
.regs
[OP
[1]];
1359 /* Compute the condition codes. */
1361 s
= (result
& 0x80000000);
1363 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1364 && (op1
& 0x80000000) != (result
& 0x80000000));
1367 /* Store the result and condition codes. */
1368 State
.regs
[OP
[1]] = result
;
1369 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1370 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1371 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0)
1372 | (sat
? PSW_SAT
: 0));
1374 /* Handle saturated results. */
1376 State
.regs
[OP
[1]] = 0x80000000;
1378 State
.regs
[OP
[1]] = 0x7fffffff;
1379 trace_output (OP_REG_REG
);
1382 /* satsubi sign_extend(imm16), reg */
1386 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
, sat
;
1389 trace_input ("satsubi", OP_IMM_REG
, 0);
1391 /* Compute the result. */
1392 temp
= SEXT16 (OP
[0]);
1394 op1
= State
.regs
[OP
[1]];
1397 /* Compute the condition codes. */
1399 s
= (result
& 0x80000000);
1401 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1402 && (op1
& 0x80000000) != (result
& 0x80000000));
1405 /* Store the result and condition codes. */
1406 State
.regs
[OP
[1]] = result
;
1407 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1408 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1409 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0)
1410 | (sat
? PSW_SAT
: 0));
1412 /* Handle saturated results. */
1414 State
.regs
[OP
[1]] = 0x80000000;
1416 State
.regs
[OP
[1]] = 0x7fffffff;
1417 trace_output (OP_IMM_REG
);
1420 /* satsubr reg,reg */
1424 unsigned int op0
, op1
, result
, z
, s
, cy
, ov
, sat
;
1426 trace_input ("satsubr", OP_REG_REG
, 0);
1428 /* Compute the result. */
1429 op0
= State
.regs
[OP
[0]];
1430 op1
= State
.regs
[OP
[1]];
1433 /* Compute the condition codes. */
1435 s
= (result
& 0x80000000);
1436 cy
= (result
< op0
);
1437 ov
= ((op1
& 0x80000000) != (op0
& 0x80000000)
1438 && (op1
& 0x80000000) != (result
& 0x80000000));
1441 /* Store the result and condition codes. */
1442 State
.regs
[OP
[1]] = result
;
1443 PSW
&= ~(PSW_Z
| PSW_S
| PSW_CY
| PSW_OV
);
1444 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1445 | (cy
? PSW_CY
: 0) | (ov
? PSW_OV
: 0)
1446 | (sat
? PSW_SAT
: 0));
1448 /* Handle saturated results. */
1450 State
.regs
[OP
[1]] = 0x80000000;
1452 State
.regs
[OP
[1]] = 0x7fffffff;
1453 trace_output (OP_REG_REG
);
1460 unsigned int op0
, op1
, result
, z
, s
;
1462 trace_input ("tst", OP_REG_REG_CMP
, 0);
1464 /* Compute the result. */
1465 op0
= State
.regs
[OP
[0]];
1466 op1
= State
.regs
[OP
[1]];
1469 /* Compute the condition codes. */
1471 s
= (result
& 0x80000000);
1473 /* Store the condition codes. */
1474 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
);
1475 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1476 trace_output (OP_REG_REG_CMP
);
1483 trace_input ("mov", OP_REG_REG_MOVE
, 0);
1484 State
.regs
[OP
[1]] = State
.regs
[OP
[0]];
1485 trace_output (OP_REG_REG_MOVE
);
1488 /* mov sign_extend(imm5), reg */
1492 int value
= SEXT5 (OP
[0]);
1494 trace_input ("mov", OP_IMM_REG_MOVE
, 0);
1495 State
.regs
[OP
[1]] = value
;
1496 trace_output (OP_IMM_REG_MOVE
);
1499 /* movea sign_extend(imm16), reg, reg */
1504 int value
= SEXT16 (OP
[0]);
1506 trace_input ("movea", OP_IMM_REG_REG
, 0);
1507 State
.regs
[OP
[2]] = State
.regs
[OP
[1]] + value
;
1508 trace_output (OP_IMM_REG_REG
);
1511 /* movhi imm16, reg, reg */
1515 uint32 value
= (OP
[0] & 0xffff) << 16;
1517 trace_input ("movhi", OP_UIMM_REG_REG
, 16);
1518 State
.regs
[OP
[2]] = State
.regs
[OP
[1]] + value
;
1519 trace_output (OP_UIMM_REG_REG
);
1522 /* sar zero_extend(imm5),reg1 */
1526 unsigned int op0
, op1
, result
, z
, s
, cy
;
1528 trace_input ("sar", OP_IMM_REG
, 0);
1530 op1
= State
.regs
[OP
[1]];
1531 result
= (signed)op1
>> op0
;
1533 /* Compute the condition codes. */
1535 s
= (result
& 0x80000000);
1536 cy
= (op1
& (1 << (op0
- 1)));
1538 /* Store the result and condition codes. */
1539 State
.regs
[OP
[1]] = result
;
1540 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1541 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1542 | (cy
? PSW_CY
: 0));
1543 trace_output (OP_IMM_REG
);
1546 /* sar reg1, reg2 */
1550 unsigned int op0
, op1
, result
, z
, s
, cy
;
1552 trace_input ("sar", OP_REG_REG
, 0);
1553 op0
= State
.regs
[OP
[0]] & 0x1f;
1554 op1
= State
.regs
[OP
[1]];
1555 result
= (signed)op1
>> op0
;
1557 /* Compute the condition codes. */
1559 s
= (result
& 0x80000000);
1560 cy
= (op1
& (1 << (op0
- 1)));
1562 /* Store the result and condition codes. */
1563 State
.regs
[OP
[1]] = result
;
1564 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1565 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1566 | (cy
? PSW_CY
: 0));
1567 trace_output (OP_REG_REG
);
1570 /* shl zero_extend(imm5),reg1 */
1574 unsigned int op0
, op1
, result
, z
, s
, cy
;
1576 trace_input ("shl", OP_IMM_REG
, 0);
1578 op1
= State
.regs
[OP
[1]];
1579 result
= op1
<< op0
;
1581 /* Compute the condition codes. */
1583 s
= (result
& 0x80000000);
1584 cy
= (op1
& (1 << (32 - op0
)));
1586 /* Store the result and condition codes. */
1587 State
.regs
[OP
[1]] = result
;
1588 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1589 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1590 | (cy
? PSW_CY
: 0));
1591 trace_output (OP_IMM_REG
);
1594 /* shl reg1, reg2 */
1598 unsigned int op0
, op1
, result
, z
, s
, cy
;
1600 trace_input ("shl", OP_REG_REG
, 0);
1601 op0
= State
.regs
[OP
[0]] & 0x1f;
1602 op1
= State
.regs
[OP
[1]];
1603 result
= op1
<< op0
;
1605 /* Compute the condition codes. */
1607 s
= (result
& 0x80000000);
1608 cy
= (op1
& (1 << (32 - op0
)));
1610 /* Store the result and condition codes. */
1611 State
.regs
[OP
[1]] = result
;
1612 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1613 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1614 | (cy
? PSW_CY
: 0));
1615 trace_output (OP_REG_REG
);
1618 /* shr zero_extend(imm5),reg1 */
1622 unsigned int op0
, op1
, result
, z
, s
, cy
;
1624 trace_input ("shr", OP_IMM_REG
, 0);
1626 op1
= State
.regs
[OP
[1]];
1627 result
= op1
>> op0
;
1629 /* Compute the condition codes. */
1631 s
= (result
& 0x80000000);
1632 cy
= (op1
& (1 << (op0
- 1)));
1634 /* Store the result and condition codes. */
1635 State
.regs
[OP
[1]] = result
;
1636 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1637 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1638 | (cy
? PSW_CY
: 0));
1639 trace_output (OP_IMM_REG
);
1642 /* shr reg1, reg2 */
1646 unsigned int op0
, op1
, result
, z
, s
, cy
;
1648 trace_input ("shr", OP_REG_REG
, 0);
1649 op0
= State
.regs
[OP
[0]] & 0x1f;
1650 op1
= State
.regs
[OP
[1]];
1651 result
= op1
>> op0
;
1653 /* Compute the condition codes. */
1655 s
= (result
& 0x80000000);
1656 cy
= (op1
& (1 << (op0
- 1)));
1658 /* Store the result and condition codes. */
1659 State
.regs
[OP
[1]] = result
;
1660 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
| PSW_CY
);
1661 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0)
1662 | (cy
? PSW_CY
: 0));
1663 trace_output (OP_REG_REG
);
1670 unsigned int op0
, op1
, result
, z
, s
;
1672 trace_input ("or", OP_REG_REG
, 0);
1674 /* Compute the result. */
1675 op0
= State
.regs
[OP
[0]];
1676 op1
= State
.regs
[OP
[1]];
1679 /* Compute the condition codes. */
1681 s
= (result
& 0x80000000);
1683 /* Store the result and condition codes. */
1684 State
.regs
[OP
[1]] = result
;
1685 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
);
1686 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1687 trace_output (OP_REG_REG
);
1690 /* ori zero_extend(imm16), reg, reg */
1694 unsigned int op0
, op1
, result
, z
, s
;
1696 trace_input ("ori", OP_UIMM_REG_REG
, 0);
1697 op0
= OP
[0] & 0xffff;
1698 op1
= State
.regs
[OP
[1]];
1701 /* Compute the condition codes. */
1703 s
= (result
& 0x80000000);
1705 /* Store the result and condition codes. */
1706 State
.regs
[OP
[2]] = result
;
1707 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
);
1708 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1709 trace_output (OP_UIMM_REG_REG
);
1716 unsigned int op0
, op1
, result
, z
, s
;
1718 trace_input ("and", OP_REG_REG
, 0);
1720 /* Compute the result. */
1721 op0
= State
.regs
[OP
[0]];
1722 op1
= State
.regs
[OP
[1]];
1725 /* Compute the condition codes. */
1727 s
= (result
& 0x80000000);
1729 /* Store the result and condition codes. */
1730 State
.regs
[OP
[1]] = result
;
1731 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
);
1732 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1733 trace_output (OP_REG_REG
);
1736 /* andi zero_extend(imm16), reg, reg */
1740 unsigned int op0
, op1
, result
, z
;
1742 trace_input ("andi", OP_UIMM_REG_REG
, 0);
1743 op0
= OP
[0] & 0xffff;
1744 op1
= State
.regs
[OP
[1]];
1747 /* Compute the condition codes. */
1750 /* Store the result and condition codes. */
1751 State
.regs
[OP
[2]] = result
;
1752 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
);
1753 PSW
|= (z
? PSW_Z
: 0);
1754 trace_output (OP_UIMM_REG_REG
);
1761 unsigned int op0
, op1
, result
, z
, s
;
1763 trace_input ("xor", OP_REG_REG
, 0);
1765 /* Compute the result. */
1766 op0
= State
.regs
[OP
[0]];
1767 op1
= State
.regs
[OP
[1]];
1770 /* Compute the condition codes. */
1772 s
= (result
& 0x80000000);
1774 /* Store the result and condition codes. */
1775 State
.regs
[OP
[1]] = result
;
1776 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
);
1777 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1778 trace_output (OP_REG_REG
);
1781 /* xori zero_extend(imm16), reg, reg */
1785 unsigned int op0
, op1
, result
, z
, s
;
1787 trace_input ("xori", OP_UIMM_REG_REG
, 0);
1788 op0
= OP
[0] & 0xffff;
1789 op1
= State
.regs
[OP
[1]];
1792 /* Compute the condition codes. */
1794 s
= (result
& 0x80000000);
1796 /* Store the result and condition codes. */
1797 State
.regs
[OP
[2]] = result
;
1798 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
);
1799 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1800 trace_output (OP_UIMM_REG_REG
);
1803 /* not reg1, reg2 */
1807 unsigned int op0
, result
, z
, s
;
1809 trace_input ("not", OP_REG_REG_MOVE
, 0);
1810 /* Compute the result. */
1811 op0
= State
.regs
[OP
[0]];
1814 /* Compute the condition codes. */
1816 s
= (result
& 0x80000000);
1818 /* Store the result and condition codes. */
1819 State
.regs
[OP
[1]] = result
;
1820 PSW
&= ~(PSW_Z
| PSW_S
| PSW_OV
);
1821 PSW
|= ((z
? PSW_Z
: 0) | (s
? PSW_S
: 0));
1822 trace_output (OP_REG_REG_MOVE
);
1829 unsigned int op0
, op1
, op2
;
1832 trace_input ("set1", OP_BIT
, 0);
1833 op0
= State
.regs
[OP
[0]];
1835 temp
= SEXT16 (OP
[2]);
1837 temp
= load_mem (op0
+ op2
, 1);
1839 if ((temp
& (1 << op1
)) == 0)
1842 store_mem (op0
+ op2
, 1, temp
);
1843 trace_output (OP_BIT
);
1850 unsigned int op0
, op1
, op2
;
1853 trace_input ("not1", OP_BIT
, 0);
1854 op0
= State
.regs
[OP
[0]];
1856 temp
= SEXT16 (OP
[2]);
1858 temp
= load_mem (op0
+ op2
, 1);
1860 if ((temp
& (1 << op1
)) == 0)
1863 store_mem (op0
+ op2
, 1, temp
);
1864 trace_output (OP_BIT
);
1871 unsigned int op0
, op1
, op2
;
1874 trace_input ("clr1", OP_BIT
, 0);
1875 op0
= State
.regs
[OP
[0]];
1877 temp
= SEXT16 (OP
[2]);
1879 temp
= load_mem (op0
+ op2
, 1);
1881 if ((temp
& (1 << op1
)) == 0)
1883 temp
&= ~(1 << op1
);
1884 store_mem (op0
+ op2
, 1, temp
);
1885 trace_output (OP_BIT
);
1892 unsigned int op0
, op1
, op2
;
1895 trace_input ("tst1", OP_BIT
, 0);
1896 op0
= State
.regs
[OP
[0]];
1898 temp
= SEXT16 (OP
[2]);
1900 temp
= load_mem (op0
+ op2
, 1);
1902 if ((temp
& (1 << op1
)) == 0)
1904 trace_output (OP_BIT
);
1911 State
.exception
= SIGTRAP
;
1919 trace_input ("di", OP_NONE
, 0);
1921 trace_output (OP_NONE
);
1928 trace_input ("ei", OP_NONE
, 0);
1930 trace_output (OP_NONE
);
1937 trace_input ("halt", OP_NONE
, 0);
1938 /* FIXME this should put processor into a mode where NMI still handled */
1939 State
.exception
= SIGQUIT
;
1940 trace_output (OP_NONE
);
1947 trace_input ("reti", OP_NONE
, 0);
1948 trace_output (OP_NONE
);
1950 /* Restore for NMI if only NP on, otherwise is interrupt or exception. */
1951 if ((PSW
& (PSW_NP
| PSW_EP
)) == PSW_NP
)
1967 trace_input ("trap", OP_TRAP
, 0);
1968 trace_output (OP_TRAP
);
1970 /* Trap 31 is used for simulating OS I/O functions */
1974 int save_errno
= errno
;
1977 /* Registers passed to trap 0 */
1979 #define FUNC State.regs[6] /* function number, return value */
1980 #define PARM1 State.regs[7] /* optional parm 1 */
1981 #define PARM2 State.regs[8] /* optional parm 2 */
1982 #define PARM3 State.regs[9] /* optional parm 3 */
1984 /* Registers set by trap 0 */
1986 #define RETVAL State.regs[10] /* return value */
1987 #define RETERR State.regs[11] /* return error code */
1989 /* Turn a pointer in a register into a pointer into real memory. */
1991 #define MEMPTR(x) (map (x))
1995 #if !defined(__GO32__) && !defined(_WIN32)
2000 RETVAL
= execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
),
2001 (char **)MEMPTR (PARM3
));
2005 RETVAL
= execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
), NULL
);
2015 RETVAL
= pipe (host_fd
);
2016 SW (buf
, host_fd
[0]);
2017 buf
+= sizeof(uint16
);
2018 SW (buf
, host_fd
[1]);
2026 RETVAL
= wait (&status
);
2034 RETVAL
= v850_callback
->read (v850_callback
, PARM1
, MEMPTR (PARM2
),
2039 RETVAL
= (int)v850_callback
->write_stdout (v850_callback
,
2040 MEMPTR (PARM2
), PARM3
);
2042 RETVAL
= (int)v850_callback
->write (v850_callback
, PARM1
,
2043 MEMPTR (PARM2
), PARM3
);
2046 RETVAL
= v850_callback
->lseek (v850_callback
, PARM1
, PARM2
, PARM3
);
2049 RETVAL
= v850_callback
->close (v850_callback
, PARM1
);
2052 RETVAL
= v850_callback
->open (v850_callback
, MEMPTR (PARM1
), PARM2
);
2055 if ((PARM1
& 0xffff0000) == 0xdead0000 && (PARM1
& 0xffff) != 0)
2056 State
.exception
= PARM1
& 0xffff; /* get signal encoded by kill */
2057 else if (PARM1
== 0xdead)
2058 State
.exception
= SIGABRT
; /* old libraries */
2060 State
.exception
= SIG_V850_EXIT
; /* PARM1 has exit status encoded */
2063 #if !defined(__GO32__) && !defined(_WIN32)
2064 case SYS_stat
: /* added at hmsi */
2065 /* stat system call */
2067 struct stat host_stat
;
2070 RETVAL
= stat (MEMPTR (PARM1
), &host_stat
);
2074 /* Just wild-assed guesses. */
2075 store_mem (buf
, 2, host_stat
.st_dev
);
2076 store_mem (buf
+ 2, 2, host_stat
.st_ino
);
2077 store_mem (buf
+ 4, 4, host_stat
.st_mode
);
2078 store_mem (buf
+ 8, 2, host_stat
.st_nlink
);
2079 store_mem (buf
+ 10, 2, host_stat
.st_uid
);
2080 store_mem (buf
+ 12, 2, host_stat
.st_gid
);
2081 store_mem (buf
+ 14, 2, host_stat
.st_rdev
);
2082 store_mem (buf
+ 16, 4, host_stat
.st_size
);
2083 store_mem (buf
+ 20, 4, host_stat
.st_atime
);
2084 store_mem (buf
+ 28, 4, host_stat
.st_mtime
);
2085 store_mem (buf
+ 36, 4, host_stat
.st_ctime
);
2090 RETVAL
= chown (MEMPTR (PARM1
), PARM2
, PARM3
);
2093 RETVAL
= chmod (MEMPTR (PARM1
), PARM2
);
2099 RETVAL
= time (&now
);
2100 store_mem (PARM1
, 4, now
);
2108 RETVAL
= times (&tms
);
2109 store_mem (PARM1
, 4, tms
.tms_utime
);
2110 store_mem (PARM1
+ 4, 4, tms
.tms_stime
);
2111 store_mem (PARM1
+ 8, 4, tms
.tms_cutime
);
2112 store_mem (PARM1
+ 12, 4, tms
.tms_cstime
);
2116 case SYS_gettimeofday
:
2120 RETVAL
= gettimeofday (&t
, &tz
);
2121 store_mem (PARM1
, 4, t
.tv_sec
);
2122 store_mem (PARM1
+ 4, 4, t
.tv_usec
);
2123 store_mem (PARM2
, 4, tz
.tz_minuteswest
);
2124 store_mem (PARM2
+ 4, 4, tz
.tz_dsttime
);
2129 /* Cast the second argument to void *, to avoid type mismatch
2130 if a prototype is present. */
2131 RETVAL
= utime (MEMPTR (PARM1
), (void *) MEMPTR (PARM2
));
2142 { /* Trap 0 -> 30 */
2147 ECR
|= 0x40 + OP
[0];
2148 /* Flag that we are now doing exception processing. */
2149 PSW
|= PSW_EP
| PSW_ID
;
2150 PC
= ((OP
[0] < 0x10) ? 0x40 : 0x50) - 4;
2160 trace_input ("ldsr", OP_LDSR
, 0);
2161 op0
= State
.regs
[OP
[0]];
2162 State
.sregs
[OP
[1]] = op0
;
2163 trace_output (OP_LDSR
);
2172 trace_input ("stsr", OP_STSR
, 0);
2173 op0
= State
.sregs
[OP
[1]];
2174 State
.regs
[OP
[0]] = op0
;
2175 trace_output (OP_STSR
);