Next: 3.13 Interfacing with Assembler Up: 3.12 Inline Assembler Code Previous: 3.12.2 Naked Functions Contents Index

## 3.12.3 Use of Labels within Inline Assembler

SDCC allows the use of in-line assembler with a few restrictions regarding labels. All labels defined within inline assembler code have to be of the form nnnnn$ where nnnnn is a number less than 100 (which implies a limit of utmost 100 inline assembler labels per function).3.6

> `_asm`
> `mov b,#10`
> `00001$:`
> `djnz b,00001$`
> `_endasm ;`

Inline assembler code cannot reference any C-labels, however it can reference labels defined by the inline assembler, e.g.:

> `foo() {`
> `/* some c code */`
> `_asm`
> `; some assembler code`
> `ljmp 0003$`
> `_endasm;`
> `/* some more c code */`
> `clabel: /* inline assembler cannot reference this label */` 3.7
> `_asm`
> `0003$: ;label (can be referenced by inline assembler only)`
> `_endasm ;`
> `/* some more c code */`
> `}`

In other words inline assembly code can access labels defined in inline assembly within the scope of the function. The same goes the other way, i.e. labels defines in inline assembly can not be accessed by C statements.

Next: 3.13 Interfacing with Assembler Up: 3.12 Inline Assembler Code Previous: 3.12.2 Naked Functions Contents Index