0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

アセンブラのローカルラベル

Last updated at Posted at 2025-10-02

はじめに

アセンブラのローカルラベルについて色々書いていきます。
GNU Assembler、x86で使える話です。

ローカルラベルとは

アセンブラでは、原則同じラベル(関数名)は使用できません。
ですが、ローカルラベルは同じラベルを何個も使用することができます。

数字:と定義するとローカルラベルになります。
内部でユニークな名前に変換されているため、何個でも定義できるようです。

例:

1:
    nop
1:
    nop
2:
    nop
2:
    nop

ブランチ命令するとき

数字b で前のラベルに飛んで、数字fで後のラベルに飛びます。
数字だけだと、数字の番地に飛びます。

1:
    b 1b --↑に飛ぶ
    b 1f --↓に飛ぶ
    b 1  --1番地に飛ぶ
1:

まとめ

何も知らずにローカルラベルが乱用されていたらびっくりしますね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?