How are labels used?
Labels are used for any small functionality if we want a chunk of code to be executed in the same location, we will use labels.
Let us understand it through a program in assembly language.
Firstly, we will include a header file.
CODE:
.INCLUDE “M32DEF.INC”
To get to know about the labels let’s start by writing a mini instruction.
LDI R17 0XAA
First of all, load this hex value into the R17 register.
JMP LABEL
Then next use the instruction of JMP on LABEL. We wrote the name of the Label as LABEL.
Then we wrote some more instructions just for applying the labels to check how it works. These instructions are given below.
CMP R17
LDI R18, 0X01
Now we will use the LABEL, LABELS are somehow similar to LOOP. The difference is that we end that loop with some instructions so that it jumps to the initial condition. But in LABELS we end the instructions with a BREAK.
LABEL:
LDI R18, 0X99
LDI R17, 13
BREAK
Then we will run this code to verify it by pressing the F7 key.
As you can see the build is succeeded but the next step is to debug the code. You can debug the code by simply pressing the F10 key. And we will check the status of the process. Which is shown below.
As you can see AA value has been loaded in the R17 register. But when the next instruction runs it will jump to the label.
As you can see in the above instruction, it jumped to the label by skipping the in-between two commands of CMP and LDI. As you can see in the figure above there are no changes in the R17 and R18 registers. It did not load any values in these registers. It runs the instructions of LABEL as shown below in the image.
And in the final step, it will run the instruction of BREAK. This brings the value back to the initial as you can see below.
This is how you can see how Labels work what kind of functionalities they provide and how are they different from loops.
Conclusion
In conclusion, labels play a crucial role in enhancing the readability and structure of the ATmega32 Assembly code developed in Atmel Studio 7. They serve as markers for specific memory locations or program points, making it easier to navigate, understand, and debug complex programs. By defining labels and referencing them in your code, you can create well-organized and efficient programs that are easier to maintain and troubleshoot. Labels are an essential tool for any Assembly programmer working with the ATmega32 microcontroller and
For Complete Trial Watch the Video: LABELS in Atmega32 using ATMEL STUDIO 7 Assembly
For more blogs explore the website: https://ninjatech.live/