ARM assembler: labels

Typically label1 and label2 would be descriptive names.

Look at the code where you have the branch/jump instruction to label1/label2 and there are typically different reasons to going to either label1 or label2.

For instance, if instruction1/2 are part of a common error handler, it is practical to list the name of each error contrition with different label names, although the error handler code is common.

If the assembler code is generated by a high level language compiler and there are for instance nested if-statements, label1 would end the innermost if, while label2 would end the outermost if-statement (or whatever control statement).

Paul

Reply to
Paul Keinanen
Loading thread data ...

Hello,

I observed often that some assembler code may look like this:

label1: label2: instruction1 instruction2 ....

is there any special reason to have two labels in a row? It is GNU assembler, but I believe it doesn't matter much.

Best regards, Roman Mashak.

Reply to
Roman Mashak

"some reason" could be: documentation, or separation of purpose.

'_exception_vectors' refers to a table of vectors. 'reset_vector' refers to a single vector. The fact that they both happen to be the same address is not important in many situations, but the fact that the two concepts exist _is_.

mlp

Reply to
Mark L Pappin

Hello, Paul! You wrote on Mon, 25 Aug 2008 11:42:18 +0300:

PK> Typically label1 and label2 would be descriptive names.

PK> Look at the code where you have the branch/jump instruction to PK> label1/label2 and there are typically different reasons to going to PK> either label1 or label2.

This is snippet from the "AT91sam7s getting started" startup code by Atmel:

[skip includes and defines]

/* Application startup entry point */ .globl reset_handler .align 4

.section .vectors .arm

/* Exception vectors (should be a branch to be detected as a valid code by the rom */ _exception_vectors: reset_vector: ldr pc, =reset_handler undef_vector: b undef_vector /* Undefined Instruction */ .....

'_exception_vectors' is not referred anywhere else in the code. I was asking about such situations. Perhaps Atmel guys writing this code just forgot to erase old label or they might have left it deliberately for some reason.

PK> For instance, if instruction1/2 are part of a common error handler, it PK> is practical to list the name of each error contrition with different PK> label names, although the error handler code is common.

With best regards, Roman Mashak. E-mail: snipped-for-privacy@tusur.ru

Reply to
Roman Mashak

There is another reason -- *.[csS] files are not the only ones that use or define labels. There are e.g. linker scripts...

--
******************************************************************
*  KSI@home    KOI8 Net  < >  The impossible we do immediately.  *
 Click to see the full signature
Reply to
Sergey Kubushin

No harm, no foul as they say in the NBA. Disassembled code produced by compilers quite regularly include numerous labels that are never referenced. It is quicker and easier to include unreferenced labels than to spend a lot of logic deciding which ones are active and which ones aren't. One compiler with which I regularly work inserts a line for every source line, including null statements.

Reply to
Everett M. Greene

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.