简体   繁体   English

ORG 汇编指令有什么作用?

[英]What does ORG Assembly Instruction do?

can anyone give me a comprehensive description about ORG directive?谁能给我一个关于 ORG 指令的全面描述?
When and why is it used in assembly written applications?何时以及为何在汇编编写的应用程序中使用它?

Using Nasm on x86 or AMD64.在 x86 或 AMD64 上使用 Nasm。

ORG is used to set the assembler location counter . ORG 用于设置汇编器位置计数器 This may or may not translate to a load address at link time.这可能会或可能不会在链接时转换为加载地址。 It can be used to define absolute addresses, eg 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. ORG 仅指示与当前段相关的下一段代码/数据的放置位置。

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 + .语法:ORG 注意:可以是无符号绝对值或任何符号或符号 + 。

example:- to observe this instruction working you need any assemble listing which uses ORG directive.示例:- 要观察该指令的工作情况,您需要任何使用 ORG 指令的汇编列表。

location地点
0000A4 00 89 TAB DC 256AL1(*-TAB) 0000A4 00 89 制表符 DC 256AL1(*-制表符)
0001A4 00000194 90 ORG TAB+240 0001A4 00000194 90 组织标签+240
000194 F0F1F2F3F4F5F6F7 91 DC C'1234567' 000194 F0F1F2F3F4F5F6F7 91 直流 C'1234567'

Here in the above the TAB symbol is assigned to MLC address 0A4.上面的 TAB 符号分配给 MLC 地址 0A4。 in the next instruction ORG sets the MLC to TAB+240 address location which is x'194' (~ x'A4' + 240 in decimal).在下一条指令中,ORG 将 MLC 设置为 TAB+240 地址位置,即 x'194'(~ x'A4' + 240 十进制)。 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.基本上这个设置是设置一个长度为 256 和从第 240 个位置存储一些字符常量的表,以便我可以将它用于 TR 指令。

ORG means origin ORG is used for specific addressing in microprocessor and microcontroller programming. ORG 表示源 ORG 用于微处理器和微控制器编程中的特定寻址。

For example:例如:

.org 0000H

This means we want to start our program from the 0000H address.这意味着我们要从0000H地址开始我们的程序。

ORG sets the location where your program is expected to load from. ORG设置程序预期加载的位置。 By loading this program to defferent location will refrence incorrect memory address and will cause problems. 通过将此程序加载到不同的位置将引用不正确的内存地址并将导致问题。

ORG xxxx ORG is not an assembly language instruction; ORG xxxx ORG 不是汇编语言指令; it is an assembler directive instruction.它是一个汇编指令指令。 It tells the assembler that the instruction from here onwards should be placed at location starting xxxx它告诉汇编器从这里开始的指令应该放在从 xxxx 开始的位置

ORG (abbr. for ORiGin) is an assembly directive and is not an instruction. ORG(ORiGin 的缩写)是汇编指令,而不是指令。 It defines where the machine code (translated assembly program) is to place in memory.它定义了机器代码(翻译后的汇编程序)在内存中的位置。 As for ORG 100H this deals with 80x86 COM program format (COMMAND) which consists of only one segment with a maximum of 64k bytes.至于ORG 100H ,它处理 80x86 COM 程序格式 (COMMAND),它只包含一个最大 64k 字节的段。 Also, It can be used to define absolute addresses, introduce padding, or generate a specific alignment...此外,它还可以用于定义绝对地址、引入填充或生成特定对齐...

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.我不喜欢使用 org,而只是直接向硬件发出操作码/值。 you can always store values in ax and transfer between bx, cx, dx.您始终可以将值存储在 ax 中并在 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仅在读取操作码时就地执行操作码要快得多,而不是尝试将它们缓存到内存中,这可能会导致堆栈过载,从而烧毁您的 CPU

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM