diff options
author | Jozef Lawrynowicz <jozef.l@somniumtech.com> | 2017-08-29 14:09:58 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2017-08-29 14:09:58 +0100 |
commit | 3819af136deb7ba6bc2058d7848cf80b33dbe51c (patch) | |
tree | d2751805f421b6b76631776ca574e994730beed9 /sim | |
parent | 34e0882b83aedc6fb9c7532c89afaf8e0043b7ce (diff) | |
download | fsf-binutils-gdb-3819af136deb7ba6bc2058d7848cf80b33dbe51c.zip fsf-binutils-gdb-3819af136deb7ba6bc2058d7848cf80b33dbe51c.tar.gz fsf-binutils-gdb-3819af136deb7ba6bc2058d7848cf80b33dbe51c.tar.bz2 |
Fix simulation of MSP430's open system call.
* sim/msp430/msp430-sim.c (maybe_perform_syscall): Fix passing of
arguments for variadic syscall "open".
Diffstat (limited to 'sim')
-rw-r--r-- | sim/msp430/ChangeLog | 5 | ||||
-rw-r--r-- | sim/msp430/msp430-sim.c | 35 |
2 files changed, 30 insertions, 10 deletions
diff --git a/sim/msp430/ChangeLog b/sim/msp430/ChangeLog index b78b96f..d6634b4 100644 --- a/sim/msp430/ChangeLog +++ b/sim/msp430/ChangeLog @@ -1,3 +1,8 @@ +2017-08-29 Jozef Lawrynowicz <jozef.l@somniumtech.com> + + * sim/msp430/msp430-sim.c (maybe_perform_syscall): Fix passing of + arguments for variadic syscall "open". + 2016-08-15 Mike Frysinger <vapier@gentoo.org> * msp430-sim.c: Delete bfd.h include. diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c index 93b47ab..93a9916 100644 --- a/sim/msp430/msp430-sim.c +++ b/sim/msp430/msp430-sim.c @@ -278,7 +278,7 @@ static int get_op (SIM_DESC sd, MSP430_Opcode_Decoded *opc, int n) { MSP430_Opcode_Operand *op = opc->op + n; - int rv; + int rv = 0; int addr; unsigned char buf[4]; int incval = 0; @@ -465,7 +465,7 @@ static int put_op (SIM_DESC sd, MSP430_Opcode_Decoded *opc, int n, int val) { MSP430_Opcode_Operand *op = opc->op + n; - int rv; + int rv = 0; int addr; unsigned char buf[4]; int incval = 0; @@ -986,11 +986,26 @@ maybe_perform_syscall (SIM_DESC sd, int call_addr) if ((call_addr & ~0x3f) == 0x00180) { /* Syscall! */ + int arg1, arg2, arg3, arg4; int syscall_num = call_addr & 0x3f; - 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]; + } MSP430_CPU (sd)->state.regs[12] = sim_syscall (MSP430_CPU (sd), syscall_num, arg1, arg2, @@ -1012,13 +1027,13 @@ msp430_step_once (SIM_DESC sd) MSP430_Opcode_Decoded opcode_buf; MSP430_Opcode_Decoded *opcode = &opcode_buf; int s1, s2, result; - int u1, u2, uresult; - int c, reg; + int u1 = 0, u2, uresult; + int c = 0, reg; int sp; int carry_to_use; int n_repeats; int rept; - int op_bytes, op_bits; + int op_bytes = 0, op_bits; PC &= 0xfffff; opcode_pc = PC; @@ -1072,7 +1087,7 @@ msp430_step_once (SIM_DESC sd) if (TRACE_ANY_P (MSP430_CPU (sd))) trace_prefix (sd, MSP430_CPU (sd), NULL_CIA, opcode_pc, - TRACE_LINENUM_P (MSP430_CPU (sd)), NULL, 0, ""); + TRACE_LINENUM_P (MSP430_CPU (sd)), NULL, 0, " "); TRACE_DISASM (MSP430_CPU (sd), opcode_pc); |