Debug mode skip printing the first instruction of the ISR (obviously it is correctly simulated the execution). First I detected this bug analyzing the execution trace of a TinyOS application, and later I checked simulating the udp-sender of contiki. I executed the mspsim from using the mspsim.jar donwnloaded with the contiki 2.5, but I verified the same behaviour in past version.
I attach the elf file and an example trace. Next a few lines to show the bug.
Fragment of udp-sender. asm (msp430-objdump -d udp-sender.elf > udp-sender.asm)
0000d9d8 <timera1>:
d9d8: 0f 12 push r15 <= FIRST INSTRUCTION
d9da: 0e 12 push r14 <= SECOND INSTRUCTION
d9dc: 0d 12 push r13
d9de: 0c 12 push r12
Fragment of udp-sender.mspsim.txt ( java -jar ~/work/contiki/tools/mspsim/mspsim.jar udp-sender.elf > trace.mspsim.txt)
*** Setting up f1611 IO!
MSPSim>Autoloading script: /home/leo/work/contiki/tools/mspsim/scripts/autorun.sc
service controlgui started
service nodegui started
service serialgui started
-----------------------------------------------
MSPSim 0.97 starting firmware: udp-sender.elf
-----------------------------------------------
MSPSim> 4b54: 32 c2 BIC.W #8, SR R2=00db R2=00db SR=--ZC SP=38f8; as = 3 sMem:3001
4b54: 32 c2 BIC.W #8, SR R2=00db R2=00db SR=--ZC SP=38f8; as = 3 sMem:3001
4b54: 32 c2 BIC.W #8, SR R2=00db R2=00db SR=--ZC SP=38f8; as = 3 sMem:3001
4b54: 32 c2 BIC.W #8, SR R2=00db R2=00db SR=--ZC SP=38f8; as = 3 sMem:3001
I:5 d9da: 0e 12 PUSH.W R14 R14=0000 SP=38f2 <= FIRST EXECTUED INSTRUCTION IS THE SECOND ONE OF THE ISR
I:5 d9dc: 0d 12 PUSH.W R13 R13=0078 SP=38f0
I:5 d9de: 0c 12 PUSH.W R12 R12=02ce SP=38ee
I:5 d9e0: 0b 12 PUSH.W R11 R11=0008 SP=38ec
I:5 d9e2: 0a 12 PUSH.W R10 R10=0000 SP=38ea
I:5 d9e4: b0 12 5a dd CALL rtimer_arch_now R0=d9e4 SP=38e8
I found that the print trace get form setting the debug option on, sometimes "replaces" some instruction with the last printed instruction. It seems that also skip some instructions.
Follows an excerpt of the .asm (MultihopOscilloscope app from TinyOS) and the trace:
--------------------------------------------------------------------------------
MultihopOscilloscope.asm
--------------------------------------------------------------------------------
...
0000425a <SchedulerBasicP$TaskBasic$postTask>:
425a: 0b 12 push r11 ;
425c: 4b 4f mov.b r15, r11 ;
425e: b0 12 5c 40 call #16476 ;#0x405c
4262: 4d 4f mov.b r15, r13 ;
4264: 0e 43 clr r14 ;
4266: 4f 4b mov.b r11, r15 ;
4268: ff 93 7e 1e cmp.b #-1, 7806(r15);r3 As==11
426c: 03 20 jnz $+8 ;abs 0x4274
...
--------------------------------------------------------------------------------
trace.txt
--------------------------------------------------------------------------------
...
43736814 425a 0b 12 PUSH.W R11 R11=0001 SP=38dc
43736817 425c 4b 4f MOV.B R15, R11 R11=0001 R15=0011 SR=--ZC SP=38da; as = 0 sMem:3000
43736823 405c 0f 42 MOV.W #0, R15 R15=0011 R2=0003 SR=--ZC SP=38d8; as = 0 sMem:3000
43736823 405c 0f 42 MOV.W #0, R15 R15=0011 R2=0003 SR=--ZC SP=38d8; as = 0 sMem:3000
43736828 4066 5f f3 AND.B #1, R15 R15=0000 R3=0000 SR=--Z- SP=38d8; as = 1 sMem:3000
...