“.="是什么意思?在 AT&T 汇编语言中是什么意思? [英] what does ".=" means in AT&T assembly language?

查看:30
本文介绍了“.="是什么意思?在 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.

使用您修改的示例:

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 个字节.然后它在位置 _start 和给定值 55 和 AA 的 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 汇编语言中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆