Contents|Index|Previous|Next

MS-DOS/Windows 3.1 Operating System

The following documentation discusses the procedures for using the main utilities for the MS-DOS/Windows 3.1 operating systems.

1. Create source code

Create the following sample source code and save it as ‘hello.c’. Use this program to verify correct installation.

#include <stdio.h>
int a, c;
void foo(int b)
{
c = a + b;
printf("%d + %d = %d\n", a, b, c);
}
int main()
{
int b;
a = 3;
b = 4;
printf("Hello, world!\n");
foo(b);
return 0;
}

2. Compile and link from source code

The stand-alone simulator can work with both ‘big-endian’ and ‘little-endian’ executables. The DDB evaluation board requires a ‘little-endian’ executable. For the following examples compile a ‘little-endian’ executable named ‘hello.xl’.

To compile and link this example enter:

C:\> gcc -g -EL hello.c -Tddb.ld -o hello.xl
C:\>

To compile a little-endian executable use the ‘-EL’ option to GCC. The option
‘-g’ generates debugging information, and ‘-o’ specifies the name of the executable to be produced. Other useful options include ‘-O’ for standard optimization, and ‘-O2’ for extensive optimization. When no optimization option is used GCC will not optimize.

To link an executable, the correct linker script must be specified with the
‘-T’ option. To link for the DDB (PMON) board, use ‘-Tddb.ld’. To link for a different PMON board’ use ‘-Tpmon.ld’.

3. Run the executable on the stand-alone simulator

To run this program on the stand-alone simulator, enter:

C:\> run hello.xl
hello world!
3 + 4 = 7
C:\>

The simulator executes the program, and returns when the program exits.

4. Run under the debugger

GDB can be used to debug executables either on hardware via serial or ethernet download or using the GNUPro MIPS simulator. Debugging on hardware does not support doing ethernet and serial downloads concurrently. It is recommended that ethernet downloads be done on a private network. Ethernet traffic on a typical LAN can cause problems downloading software to the card.

4a. Debug with serial download

To run this executable on the DDB board, under the GNU debugger GDB, enter:

    C:\> gdb hello.xl
    GDB is free software and you are welcome to distribute copies
    of it under certain conditions; type "show copying" to see the
    conditions. There is absolutely no warranty for GDB; type
    "show warranty" for details.
    GDB 4.16-nec-960902 (i386-go32 --target mips64vr4300-elf),
    Copyright 1996 Free Software Foundation, Inc.

    (gdb) target ddb com3
    Remote MIPS debugging using com3
    Current language: auto; currently asm

    (gdb) load
    .text   : 0xa0100000 .. 0xa01069c0
    .rodata : 0xa01069c0 .. 0xa0106df0
    .reginfo: 0xa0106df0 .. 0xa0106e08
    .data   : 0xa0107380 .. 0xa01079d0
    .lit8   : 0xa01079d0 .. 0xa0107a60
    .sdata  : 0xa0107a60 .. 0xa0107b00

    (gdb) break main
    Breakpoint 1 at 0xa01001b0: file hello.c, line 15.

    (gdb) run
    Starting program: C:\tmp\hello.xl
    Breakpoint 1, main () at hello.c:15
    15        a = 3;
    Current language: auto; currently c

    (gdb) print a
    $1 = 0

    (gdb) step
    16        b = 4;

    (gdb) print a
    $2 = 3

    (gdb) list
    11      int main()
    12      {
    13        int b;
    14
    15        a = 3;
    16        b = 4;
    17        printf("Hello, world!\n");
    18        foo(b);
    19        return 0;
    20      }

    (gdb) list foo
    1      #include <stdio.h>
    2
    3      int a, c;
    4
    5      void foo(int b)
    6      {
    7        c = a + b;
    8        printf("%d + %d = %d\n", a, b, c);
    9      }
    10

    (gdb) break 7
    Breakpoint 2 at 0xa0100144: file hello.c, line 7.

    (gdb) continue
    Continuing.
    Hello, world!
    Breakpoint 2, foo (b=4) at hello.c:7
    7        c = a + b;

    (gdb) step
    8        printf("%d + %d = %d\n", a, b, c);

    (gdb) print c
    $3 = 7

    (gdb) next
    3 + 4 = 7
    9       }

    (gdb) backtrace
    #0 foo (b=4) at hello.c:9
    #1 0xa01001e0 in main () at hello.c:18
    #2 0xa01058f8 in __do_main () at ../../../../../libgloss/mips/../do_main.c:12

    (gdb) quit

    C:\>

4b. Debug with ethernet download

To run this executable on the DDB board, under the GNU debugger GDB, using ethernet download enter:

    C:\> gdb hello.xl
    GDB is free software and you are welcome to distribute copies
    of it under certain conditions; type "show copying" to see the
    conditions. There is absolutely no warranty for GDB; type
    "show warranty" for details.
    GDB 4.16-nec-960902 i386-go32 --target mips64vr4300-elf),
    Copyright 1996 Free Software Foundation, Inc.

    (gdb) target ddb com3 192.168.1.1:C:/tmp/hello.tmp
    Remote MIPS debugging using /dev/ttya
    Current language: auto; currently asm

    (gdb) load
    .text   : 0xa0100000 .. 0xa01069c0
    .rodata : 0xa01069c0 .. 0xa0106df0
    .reginfo: 0xa0106df0 .. 0xa0106e08
    .data   : 0xa0107380 .. 0xa01079d0
    .lit8   : 0xa01079d0 .. 0xa0107a60
    .sdata  : 0xa0107a60 .. 0xa0107b00

    (gdb) break main
    Breakpoint 1 at 0xa01001b0: file hello.c, line 15.

    (gdb) run
    Starting program: C:\hello.xl
    Breakpoint 1, main () at hello.c:15
    15 a = 3;
    Current language: auto; currently c

    (gdb) print a
    $1 = 0

    (gdb) step
    16 b = 4;

    (gdb) print a
    $2 = 3

    (gdb) list
    11      int main()
    12      {
    13        int b;
    14
    15        a = 3;
    16        b = 4;
    17        printf("Hello, world!\n");
    18        foo(b);
    19        return 0;
    20      }

    (gdb) list foo
    1      #include <stdio.h>
    2
    3      int a, c;
    4
    5      void foo(int b)
    6      {
    7        c = a + b;
    8        printf("%d + %d = %d\n", a, b, c);
    9      }
    10

    (gdb) break 7
    Breakpoint 2 at 0xa0100144: file hello.c, line 7.

    (gdb) continue
    Continuing.
    Hello, world!
    Breakpoint 2, foo (b=4) at hello.c:7
    7 c = a + b;

    (gdb) step
    8 printf("%d + %d = %d\n", a, b, c);

    (gdb) print c
    $3 = 7

    (gdb) next
    3 + 4 = 7
    9       }

    (gdb) backtrace
    #0 foo (b=4) at hello.c:9
    #1 0xa01001e0 in main () at hello.c:18
    #2 0xa01058f8 in __do_main () at ../../../../../libgloss/mips/../do_main.c:12

    (gdb) quit

    C:\>

4c. Debug with the built-in simulator

To run this executable under the GNU debugger GDB, on the built-in simulator enter:

    C:\> gdb hello.xl
    GDB is free software and you are welcome to distribute copies
    of it under certain conditions; type "show copying" to see the
    conditions. There is absolutely no warranty for GDB; type
    "show warranty" for details.
    GDB 4.16-nec-960902 (i386-go32 --target mips64vr4300-elf),
    Copyright 1996 Free Software Foundation, Inc.

    (gdb) target sim
    Connected to the simulator.

    (gdb) load
    .text   : 0xa0100000 .. 0xa01069c0
    .rodata : 0xa01069c0 .. 0xa0106df0
    .reginfo: 0xa0106df0 .. 0xa0106e08
    .data   : 0xa0107380 .. 0xa01079d0
    .lit8   : 0xa01079d0 .. 0xa0107a60
    .sdata  : 0xa0107a60 .. 0xa0107b00

    (gdb) break main
    Breakpoint 1 at 0xa01001b0: file hello.c, line 15.

    (gdb) run
    Starting program: C:\hello.xl
    Breakpoint 1, main () at hello.c:15
    15          a = 3;
    Current language: auto; currently c

    (gdb) print a
    $1 = 0

    (gdb) step
    16          b = 4;

    (gdb) print a
    $2 = 3

    (gdb) list
    11          int main()
    12          {
    13            int b;
    14
    15            a = 3;
    16            b = 4;
    17            printf("Hello, world!\n");
    18            foo(b);
    19            return 0;
    20          }

    (gdb) list foo
    1         #include <stdio.h>
    2
    3         int a, c;
    4
    5         void foo(int b)
    6         {
    7           c = a + b;
    8           printf("%d + %d = %d\n", a, b, c);
    9         }
    10

    (gdb) break 7
    Breakpoint 2 at 0xa0100144: file hello.c, line 7.

    (gdb) continue
    Continuing.
    Hello, world!
    Breakpoint 2, foo (b=4) at hello.c:7
    7           c = a + b;

    (gdb) step
    8           printf("%d + %d = %d\n", a, b, c);

    (gdb) print c
    $3 = 7

    (gdb) next
    3 + 4 = 7
    9         }

    (gdb) backtrace
    #0 foo (b=4) at hello.c:9
    #1 0xa01001e0 in main () at hello.c:18
    #2 0xa01058f8 in __do_main () at ../../../../../libgloss/mips/../do_main.c:12

    (gdb) quit

    C:\>

5. Assembler listing from source code

The following command produces an assembler listing:

C:\> gcc -g -O2 -Wa,-alh,-L -c hello.c
C:\>

The assembler option ‘-alh’ requests a listing with high-level language and assembler language interspersed, ‘-L’ preserves local labels, while the compiler debugging option ‘-g’ gives the assembler the necessary debugging information. The ‘-O2’ option produces better looking code output.

The following example shows a partial excerpt of the output. In the following listing, the source lines are shown by ‘****’ .The ‘.stabn’ lines are part of symbolic debugging information, and you may ignore them.

    14:hello.c           ****
    15:hello.c           ****           a = 3;
    130                                       .stabn 68,0,15,$LM8
    131 0044 24020003                         li      $2,3     # 0x00000003
    132                         $LM9:
    16:hello.c           ****           b = 4;
    17:hello.c           ****           printf("Hello, world!\n");
    133                                       .stabn 68,0,17,$LM9
    134 0048 3C040000                         lui     $4,%hi($LC1) # high
    135                         $LM10:
    136                                       .stabn 68,0,15,$LM10
    137 004c AF820000                         sw      $2,a
    138                         $LM11:
    139                                       .stabn 68,0,17,$LM11
    140                                       .set    noreorder
    141                                       .set    nomacro
    142 0050 0C000000                         jal     printf
    143 0054 24840010                         addiu   $4,$4,%lo($LC1) # low
    144                                       .set    macro
    145                                       .set    reorder
    146