本文介绍了什么是“.=" AT& T汇编语言意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写引导程序.内容如下:

I am trying to code a boot program.The contents like following:

.text
balabala
.globl _start
_start:
balabala

.=_start+510
.byte 0x55,0xaa

顺便说一句,我也无法理解".byte 0x55,0xaa"的意思?它的功能是什么?它如何工作?细节越多越好.

And by the way,I also cannt understand ".byte 0x55,0xaa" means?what is its function and how does it work?The more details,the better.

推荐答案

汇编器将数据和指令转换为字节.与编译器不同,汇编指令和内存之间通常存在1:1的匹配.这 .传统上,使用符号来指示距当前程序段开始的当前偏移量.

The assembler converts data and instructions into bytes. Unlike a compiler, there is generally a 1:1 matching between assembly instructions and memory. The . symbol has traditionally been used to indicate the current offset from the start of the current program section.

最常用于确定对象的大小.

It is most commonly used to determine the size of objects.

使用您的示例进行修改:

Using your example modified:

SOMEDATA:
    .byte 0x55,0xaa

这将分配2个字节,其值分别为55和AA,并将内部标签SOMEDATA分配给具有该数据的位置.

This allocates 2 bytes with the value 55 and AA and assigns the internal label SOMEDATA to the location with that data.

如果我之后立即添加

SOMEDATA:
    .byte 0x55,0xaa
SOMEDATALENGTH = . - SOMEDATA

,它将定义一个给出分配的字节数的符号(在这种情况下为2).一些汇编器具有复杂的宏功能,可以描述复杂的数据结构.使用 .在建立这样的结构中很常见.

that would define a symbol giving the number of bytes allocated (2 in this case). Some assemblers have complex macro capabilities that can describe elaborate data structures. Using . is very common in setting up such structures.

某些汇编器允许分配给.上面的符号.

Some assemblers allow assignment to the . symbol as above.

_start:
.=_start+510
 .byte 0x55,0xaa

这将导致分配器增加510个字节.然后,在给定值55和AA的位置_start和2个字节之间创建510字节的间隙.通常,间隙用零填充,但这取决于汇编程序.

This causes the allocator to be incremented by 510 bytes. It then creates a 510 byte gap between the location _start and the 2 bytes given the value 55 and AA. Usually the gap is filled with zeros but that depends upon the assembler.

这篇关于什么是“.=" AT& T汇编语言意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 15:57