リスト34 リスト35


〔リスト34〕局所レジスタ変数の定義を行った例のCソース(test103.c)
#include <stdio.h>
//局所レジスタ変数の定義
int hensu[10] asm ("hensu_asm");
int tbl[10];
int main(void)
{
    register int *foo1 asm ("eax");
    register int *foo2 asm ("ebx");
    *foo1   =   100;
    *foo2   =   200;
    hensu[0]    =   1;
    tbl[0]      =   *foo1   *   *foo2;
    return 0;
}


〔リスト35〕局所レジスタ変数の定義を行った例のCソースから生成したアセンブラ(test103.s)
    .file       "test103.c"
    .version    "01.01"
gcc2_compiled.:
.text
    .align  4
.globl  main
    .type   main,@function
main:
    pushl   %ebp
    movl    %esp,%ebp
    pushl   %ebx
    movl    $100,(%eax)
    movl    $200,(%ebx)
    movl    $1,hensu_asm
    movl    (%eax),%eax
    imull   (%ebx),%eax
    movl    %eax,tbl
    xorl    %eax,%eax
    jmp     .L2
.L2:
    movl    -4(%ebp),%ebx
    movl    %ebp,%esp
    popl    %ebp
    ret
.Lfe1:
    .size   main,.Lfe1-main
    .comm   hensu_asm,40,32
    .comm   tbl,40,32
    .ident  "GCC: (GNU) 2.95.3 20010315 (release)"