- int arg1 = MSP430_CPU (sd)->state.regs[12];
- int arg2 = MSP430_CPU (sd)->state.regs[13];
- int arg3 = MSP430_CPU (sd)->state.regs[14];
- int arg4 = MSP430_CPU (sd)->state.regs[15];
+
+ /* syscall_num == 2 is used for the variadic function "open".
+ The arguments are set up differently for variadic functions.
+ See slaa534.pdf distributed by TI. */
+ if (syscall_num == 2)
+ {
+ arg1 = MSP430_CPU (sd)->state.regs[12];
+ arg2 = mem_get_val (sd, SP, 16);
+ arg3 = mem_get_val (sd, SP + 2, 16);
+ arg4 = mem_get_val (sd, SP + 4, 16);
+ }
+ else
+ {
+ arg1 = MSP430_CPU (sd)->state.regs[12];
+ arg2 = MSP430_CPU (sd)->state.regs[13];
+ arg3 = MSP430_CPU (sd)->state.regs[14];
+ arg4 = MSP430_CPU (sd)->state.regs[15];
+ }