Explain and show usage by giving examples of following assembler directives: ORIGIN,EQU, LTORG, START
Question
Explain and show usage by giving examples of following assembler directives: ORIGIN,EQU, LTORG, START
Solution
Sure, I'd be happy to explain these assembler directives and provide examples of their usage.
- ORIGIN (ORG): This directive is used to set the location counter to a specified value. It is used when the programmer wants to control the placement of code or data in memory.
Example:
ORG 1000H
This sets the location counter to 1000H. The next instruction will be placed at this location in memory.
- EQU: This directive is used to give a name to some value or to a symbol. It is similar to #define in C.
Example:
COUNT EQU 10
This assigns the value 10 to the symbol COUNT. Now, wherever COUNT is used in the program, the assembler will replace it with 10.
- LTORG: This directive is used to tell the assembler to place the literals used in the program in memory. It is used when the programmer wants to control the placement of literals.
Example:
L1: DC 'HELLO'
LTORG
L2: DC 'WORLD'
In this example, the literal 'HELLO' will be placed in memory at the location specified by L1. The LTORG directive then tells the assembler to place any following literals at the next available location in memory.
- START: This directive is used to tell the assembler the starting address of the program. It is the first statement of an assembly language program.
Example:
START 2000
This tells the assembler that the program begins at memory location 2000.
These directives give the programmer more control over how and where their code and data are placed in memory. They are a fundamental part of assembly language programming.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.