Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ORG Assembly Instruction do?

can anyone give me a comprehensive description about ORG directive?
When and why is it used in assembly written applications?

Using Nasm on x86 or AMD64.

like image 581
sepisoad Avatar asked Aug 04 '10 15:08

sepisoad


People also ask

What does .org do in assembly?

The ORG statement alters the location counter for the current segment and sets a new origin for subsequent statements. The expression must be a simple relocatable expression with no forward references. Only absolute addresses or symbol values in the current segment may be used.

What does org mean in assembly code?

ORG (abbr. for ORiGin) is an assembly directive (not an instruction). It defines where the machine code (translated assembly program) is to place in memory.

What is the function of an org directive?

The . org directive advances the location counter in the current section to new-location.

What is ORG 100h in assembly language?

"org <100h>" instructs the compiler with the to-be runtime information to evaluate addresses, as binary image will be loaded with offset (and first 100h bytes possibly to be used for PSP etc. in your context)


2 Answers

ORG is used to set the assembler location counter. This may or may not translate to a load address at link time. It can be used to define absolute addresses, e.g. when defining something like interrupt vectors which may need to be at a fixed address, or it can be used to introduce padding or generate a specific alignment for the following code.

like image 70
Paul R Avatar answered Sep 27 '22 02:09

Paul R


ORG is merely an indication on where to put the next piece of code/data, related to the current segment.

It is of no use to use it for fixed addresses, for the eventual address depends on the segment which is not known at assembly time.

like image 32
Michael Chourdakis Avatar answered Sep 23 '22 02:09

Michael Chourdakis