gnu汇编中.byte汇编程序指令的用途是什么? [英] What is the use of .byte assembler directive in gnu assembly?

查看:833
本文介绍了gnu汇编中.byte汇编程序指令的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在进行一些带有内联汇编的C代码时,我遇到了.byte(以Dot开头)指令.

While going through some C code having inline assembly I came across the .byte (with a Dot at the beginning) directive.

在检查Web上的程序集引用时,我发现它用于在内存中保留一个字节.

On checking the assembly reference on web I found that it is used to reserve a byte in memory.

但是在代码中,语句前没有标签.因此,我想知道无标签的.byte指令或任何其他数据存储指令在此用途是什么.

But in the code there was no label before the statement. So I was wondering what is use of an unlabeled .byte directive or any other data storage directive for that matter.

例如如果我对.byte 0x0a进行编码,该如何使用?

For e.g. if i code .byte 0x0a, how can i use it ?

推荐答案

有几种可能...我想到的有几个:

There are a few possibilities... here are a couple I can think of off the top of my head:

  1. 您可以相对于.byte指令后 的标签来访问它.示例:

  1. You could access it relative to a label that comes after the .byte directive. Example:

  .byte 0x0a
label:
  mov (label - 1), %eax

  • 基于程序的最终链接布局,也许.byte指令将作为代码执行.通常,在这种情况下,您也会有一个标签,但是...

  • Based on the final linked layout of the program, maybe the .byte directives will get executed as code. Normally you'd have a label in this case too, though...

    某些汇编程序不支持为操作数大小等生成x86指令前缀.在为那些汇编程序编写的代码中,您经常会看到类似这样的内容:

    Some assemblers don't support generating x86 instruction prefixes for operand size, etc. In code written for those assemblers, you'll often see something like:

      .byte 0x66
      mov $12, %eax
    

    要使汇编器发出您想要的代码.

    To make the assembler emit the code you want to have.

    这篇关于gnu汇编中.byte汇编程序指令的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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