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.

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.


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.


      During the assemble time ORG directive resets the MLC (memory location counter) to the address specified in the ORG directive.

Syntax: ORG note: may be a unsigned absolute value or any symbol or symbol + .

example:- to observe this instruction working you need any assemble listing which uses ORG directive.

location 0000A4 00 89 TAB DC 256AL1(*-TAB) 0001A4 00000194 90 ORG TAB+240 000194 F0F1F2F3F4F5F6F7 91 DC C'1234567'

Here in the above the TAB symbol is assigned to MLC address 0A4. in the next instruction ORG sets the MLC to TAB+240 address location which is x'194' (~ x'A4' + 240 in decimal). basically this set up is setup a table with length 256 and from 240 th location to store some character constants so that I can use it for TR instruction.


its the location in memory where you want the binary program to be loaded to, if any.

I prefer not to use org, and just issue out straight opcode/value to hardware. you can always store values in ax and transfer between bx, cx, dx.

I'm writing my own assembler to dish out opcode/value without having to worry about sending it to memory first before executing,

Its so much faster just to execute opcodes on the spot as they're being read, rather than trying to cache them into memory risking overloading the stack which might burn out your cpu


ORG sets the location where your program is expected to load from. By loading this program to defferent location will refrence incorrect memory address and will cause problems.


Need Your Help

Can LaTeX be used for producing any documentation that accompanies software?

documentation latex documentation-generation

Although related to this question about LaTeX being used outside mathematics and academia, I'm specifically wondering if anyone uses or is familiar with anyone that uses LaTeX for generating any ty...

Java: How to convert List to Map

java list data-structures hashmap data-conversion

Recently I have conversation with a colleague about what would be the optimal way to convert List to Map in Java and if there any specific benefits of doing so.