解释汇编程序列表

as 命令的 -l 标志生成汇编语言文件的列表。

as 命令的 -l 标志生成汇编语言文件的列表。

假定程序员想要显示 "hello , world" 字样。 C 程序将如下所示:

   main ( )
   {
        printf ("hello, world\n");
   }
使用以下命令组装 hello.s 文件:

as -l hello.s
生成名为 hello.lst的输出文件。 hello.lst 的完整汇编程序列表如下所示:

hello.s                             V4.0                01/25/1994
File# Line#  Mode Name    Loc Ctr   Object Code         Source
0       1 |                                      #############################
0       2 |                                      # C source code
0       3 |                                      #############################
0       4 |                                      #   hello()
0       5 |                                      #   {
0       6 |                                      #    printf("hello,world\n");
0       7 |                                      #   }
0       8 |                                      #############################
0       9 |                                      #   Compile as follows:
0      10 |                                      #   cc -o helloworld hello.s
0      11 |                                      #
0      12 |                                      #############################
0      13 |                                       .file  "hello.s"
0      14 |                                      #Static data entry in
0      15 |                                      #T(able)O(f)C(ontents)
0      16 |                                       .toc
0      17 |  COM  data   00000000  00000040       T.data:   .tc data[tc],data[rw]
0      18 |                                       .globl main[ds]
0      19 |                                      #main[ds] contains definitions for
0      20 |                                      #runtime linkage of function main
0      21 |                                       .csect   main[ds]
0      22 |  COM  main   00000000  00000000        .long   .main[PR]
0      23 |  COM  main   00000004  00000050        .long   TOC[tc0]
0      24 |  COM  main   00000008  00000000        .long   0
0      25 |                                      #Function entry in
0      26 |                                      #T(able)O(f)C(ontents)
0      27 |                                       .toc
0      28 |  COM  .main  00000000  00000034       T.hello: .tc .main[tc],main[ds]
0      29 |                                       .globl   .main[PR]
0      30 |
0      31 |                                      #Set routine stack variables
0      32 |                                      #Values are specific to
0      33 |                                      #the current routine and can
0      34 |                                      #vary from routine to routine
0      35 |                        00000020        .set   argarea,     32
0      36 |                        00000018        .set   linkarea,    24
0      37 |                        00000000        .set   locstckarea, 0
0      38 |                        00000001        .set   ngprs,       1
0      39 |                        00000000        .set   nfprs,       0
0      40 |                        0000003c        .set   szdsa,       8*nfprs+4*ngprs+linkarea+
                                                                         argarea+locstckarea
0      41 |
0      42 |                                      #Main routine
0      43 |                                       .csect           .main[PR]
0      44 |
0      45 |
0      46 |                                      #PROLOG: Called Routines
0      47 |                                      #        Responsibilities
0      48 |                                       #Get link reg.
0      49 |  COM  .main  00000000  7c0802a6          mflr  0
0      50 |                                       #Not required to Get/Save CR
0      51 |                                       #because current routine does
0      52 |                                       #not alter it.
0      53 |
0      54 |                                       #Not required to Save FPR's
0      55 |                                       #14-31 because current routine
0      56 |                                       #does not alter them.
0      57 |
0      58 |                                       #Save GPR 31.
0      59 |  COM  .main  00000004  bfe1fffc         stm   31, -8*nfprs-4*ngprs(1)
0      60 |                                       #Save LR if non-leaf routine.
0      61 |  COM  .main  00000008  90010008         st    0, 8(1)
0      62 |                                       #Decrement stack ptr and save
0      63 |                                       #back chain.
0      64 |  COM  .main  0000000c  9421ffc4         stu   1, -szdsa(1)
0      65 |
0      66 |
0      67 |                                      #Program body
0      68 |                                      #Load static data address
0      69 |  COM  .main  00000010  81c20000        l      14,T.data(2)
0      70 |                                       #Line 3, file hello.c
0      71 |                                      #Load address of data string
0      72 |                                      #from data addr.
0      73 |                                      #This is a parameter to printf()
0      74 |  COM  .main  00000014  386e0000        cal    3,_helloworld(14)
0      75 |                                      #Call printf function
0      76 |  COM  .main  00000018  4bffffe9        bl     .printf[PR]
0      77 |  COM  .main  0000001c  4def7b82        cror   15, 15, 15
0      78 |
0      79 |
0      80 |                                      #EPILOG: Return Sequence
0      81 |                                       #Get saved LR.
0      82 |  COM  .main  00000020  80010044         l     0, szdsa+8(1)
0      83 |
0      84 |                                       #Routine did not save CR.
0      85 |                                       #Restore of CR not necessary.
0      86 |
0      87 |                                       #Restore stack ptr
0      88 |  COM  .main  00000024  3021003c         ai    1, 1, szdsa
0      89 |                                       #Restore GPR 31.
0      90 |  COM  .main  00000028  bbe1fffc         lm    31, -8*nfprs-4*ngprs(1)
0      91 |
0      92 |                                       #Routine did not save FPR's.
0      93 |                                       #Restore of FPR's not necessary.
0      94 |
0      95 |                                       #Move return address
0      96 |                                       #to Link Register.
0      97 |  COM  .main  0000002c  7c0803a6              mtlr0
0      98 |                                       #Return to address
0      99 |                                       #held in Link Register.
0     100 |  COM  .main  00000030  4e800021              brl
0     101 |
0     102 |
0     103 |                                      #External variables
0     104 |                                          .extern.printf[PR]
0     105 |
0     106 |                                      ##############################
0     107 |                                                  #Data
0     108 |                                      ##############################
0     109 |                                      #String data placed in
0     110 |                                      #static csect data[rw]
0     111 |                                             .csect data[rw]
0     112 |                                             .align2
0     113 |                                      _helloworld:
0     114 |  COM  data   00000000  68656c6c        .byte  0x68,0x65,0x6c,0x6c
0     115 |  COM  data   00000004  6f2c776f        .byte  0x6f,0x2c,0x77,0x6f
0     116 |  COM  data   00000008  726c640a        .byte  0x72,0x6c,0x64,0xa,0x0
          |  COM  data   0000000c  00

汇编程序列表的第一行给出了两条信息:

  • 源文件的名称 (在本例中为 hello.s)
  • 创建列表文件的日期

汇编程序列表包含多列。 列标题为:

描述
File# 列出源文件编号。 M4 宏处理器 (-l 选项) 随附的文件按在其中找到语句的文件的编号显示。
Line# 指汇编程序源代码的行号。
Mode 指示此指令的当前组装方式。
Name 列出产生此源代码行的 csect 的名称。
Loc Ctr 列出汇编程序的位置计数器中包含的值。 该列表仅显示用于生成对象代码的汇编语言指令的位置计数器值。
Object Code 显示汇编程序的每行生成的对象代码的十六进制表示。 由于每个指令都是 32 位,因此汇编程序列表中的每行最多显示 4 个字节。 汇编程序源代码行中的任何剩余字节显示在以下一行或多行上。
注: 如果传递两个失败,那么汇编程序列表将不包含对象代码。
Source 列出程序的汇编程序源代码。 每行将显示 100 个 ASCII 字符的限制。

如果在命令行上使用 -s 选项标志,那么汇编程序列表包含助记符交叉引用信息。

如果组装方式位于 PowerPC® 类别 (comppc601) 中,那么一个列标题为 PowerPC®。 此列包含在源程序中使用了 POWER ® 系列助记符的每个实例的 PowerPC® 助记符。 any 组装方式不属于任何类别,但在 PowerPC® 类别中被视为相同。

如果组装方式位于 POWER ® 系列类别 (pwrpwr2) 中,那么一个列标题为 POWER ® 系列。 此列包含源程序中使用 PowerPC® 助记符的每个实例的 POWER ® 系列助记符。

以下汇编程序列表使用 com 组合件方式。 源程序使用 POWER ® 系列助记符。 汇编程序列表具有 PowerPC® 助记符交叉引用。

L_dfmt_1.s                              V4.0                01/26/1994
File# Line#  Mode  Name   Loc Ctr  Object Code  PowerPC      Source
0       1 |
0       2 |                                                 #%% -L
0       3 |                                                  machine   "com"
0       4 |                                                  csect dfmt[PR]
0       5 |                                                  using data,5
0       6 |  COM  dfmt   00000000  8025000c       lwz        l1,d1             # 8025000c
0       7 |  COM  dfmt   00000004  b8c50018       lmw        lm    6,d0        # b8650018
0       8 |  COM  dfmt   00000008  b0e50040                  sth   7,d8        # b0e50040
0       9 |  COM  dfmt   0000000c  80230020       lwz        l     1,0x20(3)   # 80230020
0      10 |  COM  dfmt   00000010  30220003       addic      ai    1,2,3       # 30220003
0      11 |  COM  dfmt   00000014  0cd78300       twi        ti    6,23,-32000 # 0cd78300
0      12 |  COM  dfmt    00000018  2c070af0                 cmpi  0,7,2800    # 2c070af0
0      13 |  COM  dfmt   0000001c  2c070af0                  cmpi  0,0,7,2800  # 2c070af0
0      14 |  COM  dfmt   00000020  30220003       subic      si    1,2,-3      # 30220003
0      15 |  COM  dfmt   00000024  34220003       subic.     si.   1,2,-3      # 34220003
0      16 |  COM  dfmt   00000028  703e00ff       andi.      andil.30,1,0xFF   # 703e00ff
0      17 |  COM  dfmt   0000002c  2b9401f4                  cmpli 7,20,500    # 2b9401f4
0      18 |  COM  dfmt   00000030  0c2501a4       twlgti     tlgti 5,420       # 0c2501a4
0      19 |  COM  dfmt   00000034  34220003       addic.     ai.   1,2,3       # 34220003
0      20 |  COM  dfmt   00000038  2c9ff380                  cmpi  1,31,-3200  # 2c9ff380
0      21 |  COM  dfmt   0000003c  281f0c80                  cmpli 0,31,3200   # 281f0c80
0      22 |  COM  dfmt   00000040  8ba5000c                  lbz   29,d1       # 8ba5000c
0      23 |  COM  dfmt   00000044  85e5000c       lwzu       lu    15,d1       # 85e5000c
0      24 |  COM  dfmt   00000048  1df5fec0       mulli      muli  15,21,-320  # 1df5fec0
0      25 |  COM  dfmt   0000004c  62af0140       ori        oril  15,21,320   # 62af0140
0      26 |  COM  dfmt   00000050  91e5000c       stw        st    15,d1       # 91e5000c
0      27 |  COM  dfmt   00000054  bde5000c       stmw       stm   15,d1       # bde5000c
0      28 |  COM  dfmt   00000058  95e5000c       stwu       stu   15,d1       # 95e5000c
0      29 |  COM  dfmt   0000005c  69ef0960       xori       xoril 15,15,2400  # 69ef0960
0      30 |  COM  dfmt   00000060  6d8c0960       xoris      xoriu 12,12,2400  # 6d8c0960
0      31 |  COM  dfmt   00000064  3a9eff38                  addi  20,30,-200  # 3a9eff38
0      32 |
0      33 |                                                     .csect also[RW]
0      34 |                                                data:
0      35 |  COM  also   00000000  00000000                 .long  0,0,0
          |              00000004    ....
          |  COM  also   00000008  00000000
0      36 |  COM  also   0000000c  00000003              d1:.long  3,4,5   # d1 = 0xC = 12
          |  COM  also   00000010  00000004
          |  COM  also   00000014  00000005
0      37 |  COM  also   00000018  00000068                 d0:    .long   data # d0 = 0x18 = 24
0      38 |  COM  also   0000001c  00000000                 data2: .space  36
          |              00000020    ....
          |  COM  also   0000003c  000000000
       39 |  COM  also   00000040  000023e0                 d8:    .long   9184  # d8 = 0x40 = 64
0      40 |  COM  also   00000044  ffffffff                 d9:    .long   0xFFFFFFFF # d9 = 0x44
0      41 |                                            #
0      42 |                                            # 0000 00000000 00000000 00000000 00000003
0      43 |                                            # 0010 00000004 00000005 0000000C 00000000
0      44 |                                            # 0020 00000000 00000000 00000000 00000000
0      45 |                                            # 0030 000023E0
以下汇编程序列表使用 pwr 组合件方式。 源程序使用 PowerPC® 助记符。 汇编程序列表具有 POWER ® 系列助记符交叉引用。

 L_dfmt_2.s                              V4.0                01/26/1994
File# Line#  Mode Name    Loc Ctr  Object Code  POWER       Source
0       1 |                                                #%% -L
0       2 |                                                .machine  "pwr"
0       3 |                                                .csect dfmt[PR]
0       4 |                                                .using data,5
0       5 |  PWR  dfmt   00000000  8025000c       l         lwz      1,d1
0       6 |  PWR  dfmt   00000004  b8650018       lm        lmw      3,d0
0       7 |  PWR  dfmt   00000008  b0e50040                 sth      7,d8
0       8 |  PWR  dfmt   0000000c  80230020       l         lwz      1,0x20(3)
0       9 |  PWR  dfmt   00000010  30220003       ai        addic    1,2,3
0      10 |  PWR  dfmt   00000014  0cd78300       ti        twi      6,23,-32000
0      11 |  PWR  dfmt   00000018  2c070af0                 cmpi     0,7,2800
0      12 |  PWR  dfmt   0000001c  2c070af0                 cmpi     0,0,7,2800
0      13 |  PWR  dfmt   00000020  30220003       si        subic    1,2,-3
0      14 |  PWR  dfmt   00000024  34220003       si.       subic.   1,2,-3
0      15 |  PWR  dfmt   00000028  703e00ff       andil.    andi.    30,1,0xFF
0      16 |  PWR  dfmt   0000002c  2b9401f4                 cmpli    7,20,500
0      17 |  PWR  dfmt   00000030  0c2501a4       tlgti     twlgti   5,420
0      18 |  PWR  dfmt   00000034  34220003       ai.       addic.   1,2,3
0      19 |  PWR  dfmt   00000038  2c9ff380                 cmpi     1,31,-3200
0      20 |  PWR  dfmt   0000003c  281f0c80                 cmpli    0,31,3200
0      21 |  PWR  dfmt   00000040  8ba5000c                 lbz      29,d1
0      22 |  PWR  dfmt   00000044  85e5000c       lu        lwzu     15,d1
0      23 |  PWR  dfmt   00000048  1df5fec0       muli      mulli    15,21,-320
0      24 |  PWR  dfmt   0000004c  62af0140       oril      ori      15,21,320
0      25 |  PWR  dfmt   00000050  91e5000c       st        stw      15,d1
0      26 |  PWR  dfmt   00000054  bde5000c       stm       stmw     15,d1
0      27 |  PWR  dfmt   00000058  95e5000c       stu       stwu     15,d1
0      28 |  PWR  dfmt   0000005c  69ef0960       xoril     xori     15,15,2400
0      29 |  PWR  dfmt   00000060  6d8c0960       xoriu     xoris    12,12,2400
0      30 |  PWR  dfmt   00000064  3a9eff38                 addi     20,30,-200
0      31 |
0      32 |
0      33 |                                                         .csect also[RW]
0      34 |                                           data:
0      35 |  PWR  also   00000000  00000000                .long     0,0,0
          |              00000004    ....
          |  PWR  also   00000008  00000000
0      36 |  PWR  also   0000000c  00000003             d1: long     3,4,5
          |  PWR  also   00000010  00000004                          # d1 = 0xc = 12
          |  PWR  also   00000014  00000005
0      37 |  PWR  also   00000018  00000068             d0: long     data       # d0 = 0x18 = 24
0      38 |  PWR  also   0000001c  00000000          data2: space  36
          |              00000020    ....
          |  PWR  also   0000003c  00000000
0      39 |  PWR  also   00000040  000023e0             d8: long     9184       # d8 = 0x40 = 64
0      40 |  PWR  also   00000044  ffffffff             d9: long     0xFFFFFFFF # d9 = 0x44
0      41 |                                                #
0      42 |                                            # 0000 00000000 00000000 00000000 00000003
0      43 |                                            # 0010 00000004 00000005 0000000C 00000000
0      44 |                                            # 0020 00000000 00000000 00000000 00000000
0      45 |                                            # 0030 000023E0