0

.text section of disassemble code

__exit:
 0x0: 0xe59f1008 LDR R1, [PC, #0x8] ; [0x10] 0x20026 (131110)
 0x4: 0xe3a00018 MOV R0, #24 ; 0x18
 0x8: 0xef123456 SVC #0x123456
 0xc: 0xeafffffb B __exit

I am calling the exit() function in my main function. The above assembly code is appearing in a disassemble window .

How to execute the B __exit instruction?

My source code is main(){ __exit(arg); }

This is a related question to arm semihosting.

Community
  • 1
  • 1

1 Answers1

2

The b __exit only loops you back to the beginning of the function.

In an embedded environment, there is typically no program exit; rather, you either go into an endless loop or restart from the beginning.

This fragment goes into an endless loop, invoking the semihosting SVC for an explicit breakpoint, thus bringing you into the debugger. Restarting from there will execute the branch and reexecute the code leading to the breakpoint.

Simon Richter
  • 28,572
  • 1
  • 42
  • 64
  • after B __exit call following dissassembly routine appears DC32 131110 can some one help how i will get all these statement covered c source code – user2262711 May 01 '14 at 07:16
  • The following code is not used; the `b` instruction makes sure of that. – Simon Richter May 01 '14 at 21:55
  • It is quite possible that there is no C code, or if there is, it is going to be a macro resolving to an `asm` statement. – Simon Richter May 01 '14 at 21:56
  • Richer can u explain in detail about this "Restarting from there will execute the branch and reexecute the code leading to the breakpoint". – user2262711 May 06 '14 at 17:28
  • When that code is executed, the semihosting call will break into the debugger, with the "next instruction" pointing at `b __exit`, and the device stopped. Restarting the device will execute the branch instruction, and re-execute the semihosting call. – Simon Richter May 07 '14 at 06:45
  • Richer "Restartin the device".??is it posiblle in simulator without connecting a device(Board) – user2262711 May 10 '14 at 14:41
  • The simulator should behave identically to the device. – Simon Richter May 11 '14 at 01:05
  • So i need to execute the script in release mode then it will break into debugger mode.and how to do the restart of device in debugger mode. – user2262711 May 16 '14 at 05:33