1

I have a problem understnding a branch instruction B arm926ejs_reset_handler which leaps to the label arm926ejs_reset_handler: and thus ignores the code in between. I wonder why would anyone do this?

And some additional explanation. Label __start: is an entry point of the program. Lines that branch instruction ignores are parameters which boot ISROM was supposed to get at startup. But how can boot ISROM get these parameters if we jump over them? It makes no logic to me.

__start:
arm926ejs_reset:
B     arm926ejs_reset_handler

    .word   0x41676d69
    .word   0,0,0,0,0
image_type:
    .word   0x0000000A
sizeOfPermanentCode:    
    .word   (__image_size)
    .word   0,0
bootparameter:  
    .word   0
    .word   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

arm926ejs_reset_handler:
71GA
  • 1,132
  • 6
  • 36
  • 69
  • That is what a branch does, it branches or jumps somewhere. Like a goto in C. If it didnt work that way it would be very broken and you couldnt write programs. Where the program counter is has absolutely nothing to do with what it can access. Other instruction sets use the word jump instead of branch, both mean the same thing in this context, by definition the code execution branches or jumps to another path, leaving the path it was on behind. – old_timer Mar 02 '12 at 14:38
  • also read your arm manuals to understand that the first several/many depending on architecture, memory (word) locations are reset vectors, so to avoid problems you must use either a branch to somewhere or an ldr pc,something to branch to somewhere in order to properly use the exception table. Which is exactly what this code is doing. – old_timer Mar 02 '12 at 14:40
  • start as an entry point is only relevant for loaders (like the operating system loading a linux binary application), this appears to be boot code with an exception table and the start label is irrelevant once this binary is placed in ram/rom to boot the processor. – old_timer Mar 02 '12 at 14:42

2 Answers2

3

There is a difference between data and code - code contains instructions which are executed, while data is used by the code. The fundamental difference is that data (usually) can't be executed.

So as the room in the beginning is used as a storage space for data, the code needs to jump over the data, otherwise the data would be interpreted as code, which would most likely result in illegal instructions and a crash.

Of course the code can access the data if it is located before the current program counter (after the jump) - from the perspective of the code it doesn't make a difference if the data is locate before or after the code.

Gunther Piez
  • 29,760
  • 6
  • 71
  • 103
2

It's just branching over some data - the code can get at this data via indexed addressing using __start or arm926ejs_reset as a base address.

Paul R
  • 208,748
  • 37
  • 389
  • 560