疑似命令 .align について 投稿者:たかちゃん♪ 投稿日:2005/03/03(Thu) 11:10 No.357 | |
|
はじめまして.最近アセンブラに興味が湧いたのではじめることにしました.junさんのページがとても参考になります.ありがとうございます.
そこで,ひとつ気になったのですが,
https://www.nk.rim.or.jp/~jun/slasm/arm07.html のサンプルコード
>#------------------------------------- ># data セクション >#------------------------------------- > (略) > >msg0: .asciz "hello, world\n" > > .align 2 @ 4バイト境界に設定
で 4バイト境界に設定とありますが, .align 2 だと 2バイト境界なるのではないでしょうか?
info asに.align 8だと8の倍数の境界になるようなことが書いてあったのですが...
素人なもので誤解しているようでしたらすみません. |
| Re: 疑似命令 .align について jun - 2005/03/03(Thu) 12:57 No.358 | |
|
|
info as の Pseudo Ops * Align:: には次のように書かれています。
The way the required alignment is specified varies from system to system. For the a29k, arc, hppa, i386 using ELF, i860, iq2000, m68k, m88k, or32, s390, sparc, tic4x, tic80 and xtensa, the first expression is the alignment request in bytes. For example `.align 8' advances the location counter until it is a multiple of 8. If the location counter is already a multiple of 8, no change is needed. For the tic54x, the first expression is the alignment request in words.
For other systems, including the i386 using a.out format, and the arm and strongarm, it is the number of low-order zero bits the location counter must have after advancement. For example `.align 3' advances the location counter until it a multiple of 8. If the location counter is already a multiple of 8, no change is needed.
つまりCPUによって異なり、arm の場合は「.align n」は 2^n に整列されるようです。 |
| Re: 疑似命令 .align について たかちゃん♪ - 2005/03/03(Thu) 13:18 No.359 | |
|
|
有難うございます.
i386ELF--> そのまま ARM------> 2のべき
ということですね.
i386ELFで.align 3とかすると,2の倍数じゃないっておこられたので,ARMもそうかと思ってしまいました(infoも途中までしか読んでいませんでした)...御迷惑お掛けしました...今後気を付けます(x_x)
|
| Re: 疑似命令 .align について jun - 2005/03/05(Sat) 01:45 No.360 | |
|
|
私もドキドキしながらinfoを調べました。 間違っていなかったので、ほっとしていました。 どうぞ、お気きになさらないように。 |
| PowerPCの .align jun - 2005/03/19(Sat) 16:39 No.371 | |
|
|
info as には「その他のシステム」として明記されていませんが、 玄箱で試したところ、
PowerPC ---> 2のべき
でした。 |
|