[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Assembler Language Reference

.dsect Pseudo-op

Purpose

Identifies the beginning or the continuation of a dummy control section.

Syntax

.dsect Name

Description

The .dsect pseudo-op identifies the beginning or the continuation of a dummy control section. Actual data declared in a dummy control section is ignored; only the location counter is incremented. All labels in a dummy section are considered to be offsets relative to the beginning of the dummy section. A dsect that has the same name as a previous dsect is a continuation of that dummy control section.

The .dsect pseudo-op can declare a data template that can then be used to map out a block of storage. The .using pseudo-op is involved in doing this.

Parameters

Name Specifies a dummy control section.

Examples

  1. The following example demonstrates the use of the .dsect pseudo-op:

            .dsect datal
    d1:     .long 0
    
                            # 1 Fullwordd2:     .short 0,0,0,0,0,0,0,0,0,0       # 10 Halfwords
    d3:     .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0      # 15 bytes
    
            .align 3                   #Align to a double word.
    d4:     .space 64                  #Space 64 bytes
    
    .csect main[PR]
    .using datal,7
    l 5,d2
    
    # This will actually load
    # the contents of the
    # effective address calculated
    # by adding the offset d2 to
    # that in GPR 7 into GPR 5.
  2. The following example contains several source programs which together show the use of .dsect and .using pseudo-ops in implicit-based addressing.
    1. Source program foo_pm.s:

              .csect   foo_data[RW]
              .long   0xaa
              .short  10
              .short   20
              .globl   .foo_pm[PR]
              .csect   .foo_pm[PR]
              .extern  l1
              .using  TOC[TC0], 2
              l    7, T.foo_data
              b   l1
              br
              .toc
      T.foo_data:   .tc  foo_data[TC], foo_data[RW]
    2. Source program bar_pm.s:

              .csect   bar_data[RW]
              .long   0xbb
              .short  30
              .short   40
              .globl   .bar_pm[PR]
              .csect   .bar_pm[PR]
              .extern  l1
              .using TOC[TC0], 2
              l    7, T.bar_data
              b  l1
              br
              .toc
      T.bar_data:   .tc  bar_data[TC], bar_data[RW]
    3. Source program c1_s:

              .dsect   data1
      d1:     .long   0
      d2:     .short   0
      d3:     .short   0
              .globl   .c1[PR]
              .csect   .c1[PR]
              .globl   l1
      l1:     .using   data1, 7
              l   5, d1
              stu 5, t_data[TD](2)
              br                  # this br is necessary.
                                  # without it, prog hangs
              .toc
              .comm  t_data[TD],4
    4. Source for main program mm.c:

      extern  long  t_data;
      main()
      {
           int  sw;
           sw = 2;
           if ( sw == 2 ) {
             foo_pm();
             printf ( "when sw is 2, t_data is 0x%x\n", t_data );
           }
           sw = 1;
           if ( sw == 1 ) {
             bar_pm();
             printf ( "when sw is 1, t_data is 0x%x\n", t_data );
           }
      }
    5. Instructions for creating the executable file from the source:

      as -o foo_pm.o foo_pm.s
      as -o bar_pm.o bar_pm.s
      as -o c1.o c1.s
      cc -o mm mm.c foo_pm.o bar_pm.o c1.o
    6. The following is printed if mm is executed:

      when sw is 2, t_data is 0xaa
      when sw is 1, t_data is 0xbb

Related Information

Pseudo-ops Overview.

The .csect pseudo-op, .using pseudo-op.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]