| Getting Started with M68K Ada: Ada 95 Compilation System for the Motorola M68000 Family | ||
|---|---|---|
| Prev | Chapter 1. Basic Techniques | Next |
If you want to see the generated code, then use the option -Wa,-a. The first part (-Wa,) means pass the second part (-a) to the assembler. To get a listing that includes interleaved source code, use the options -g and -Wa,-ahld. See The M68K Ada Users Guide, for more information on assembler options.
Here is an example where we generate a machine code listing.
Example 1-7. Generating a Machine Code Listing
$ m68k-coff-gcc -c -O2 -Wa,-a hello.adb 1 .file "hello.adb" 2 gcc2_compiled.: 3 __gnu_compiled_ada: 4 .section .rdata,"r" 5 .LC0: 6 0000 4865 6C6C .ascii "Hello World" 6 6F20 576F 6 726C 64 7 000b 00 .even 8 .LC1: 9 000c 0000 0001 .long 1 10 0010 0000 000B .long 11 11 .text 12 .even 13 .globl _ada_hello 14 _ada_hello: 15 0000 4E56 0000 link.w %a6,#0 16 0004 BBCF cmp.l %sp,%a5 17 0006 6B02 bmi.b .+4 18 0008 4E45 trap #5 19 000a 203C 0000 move.l #.LC0,%d0 19 0024 20 0010 223C 0000 move.l #.LC1,%d1 20 0030 21 0016 2F01 move.l %d1,-(%sp) 22 0018 2F00 move.l %d0,-(%sp) 23 001a 4EB9 0000 jsr xgc__text_io__put_line$2 23 0000 24 0020 4E5E unlk %a6 25 0022 4E75 rts ...
You could also use the object code dump utility m68k-coff-objdump to disassemble the generated code. If you compiled using the debug option -g then the disassembled instructions will be annotated with symbolic references.
Here is example using the object code dump utility.
Example 1-8. Output from objdump
$ m68k-coff-objdump -d hello.o hello.o: file format coff-m68k Disassembly of section .text: 00000000 <_ada_hello>: 0: 4e56 0000 linkw %fp,#0 4: bbcf cmpal %sp,%a5 6: 6b02 bmis a <_ada_hello+0xa> 8: 4e45 trap #5 a: 203c 0000 0024 movel #36,%d0 10: 223c 0000 0030 movel #48,%d1 16: 2f01 movel %d1,-(%sp) 18: 2f00 movel %d0,-(%sp) 1a: 4eb9 0000 0000 jsr 0 <_ada_hello> 20: 4e5e unlk %fp 22: 4e75 rts ...
You can see how big your program is using the size command. The sizes are in bytes.
Example 1-9. Using the Size Command
$ m68k-coff-size hello.o
text data bss dec hex filename
56 0 0 56 38 hello.o
To get more detail you can use the object code dump program, and ask for headers.
Example 1-10. Using the Object Code Dump Program
$ m68k-coff-objdump -h hello.o
hello.o: file format coff-m68k
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000024 00000000 00000000 00000104 2**2
CONTENTS, ALLOC, LOAD, RELOC, CODE
1 .data 00000000 00000024 00000024 00000000 2**2
ALLOC, LOAD, DATA
2 .bss 00000000 00000024 00000024 00000000 2**2
ALLOC, NEVER_LOAD
3 .stab 0000015c 00000024 00000024 00000128 2**2
CONTENTS, RELOC, DEBUGGING
4 .stabstr 00000372 00000180 00000180 00000284 2**0
CONTENTS, DEBUGGING
5 .rdata 00000014 000004f2 000004f2 000005f6 2**2
CONTENTS, ALLOC, LOAD, READONLY
The simulator supports several options including the trace option (-t) and the statistics option (-s). Use the option --help for more information.
Example 1-11. Tracing Simulation
$ m68k-coff-run -t hello
<__cold_start>
-----------------------
-- Instruction trace --
-----------------------
------------+-------+----+-+-----+--------+----------------------
CPU time in pending ----psr----- disassembled
microseconds 7654321 ttsm i xnzvc pc instruction
------------+-------+----+-+-----+--------+----------------------
0.000 s 7 00000100: braw 0x104
<start>
0.160 s 7 00000104: movew #112,%sr
0.320 s 7 00000108: moveal #1310716,%sp
art0.S:777
0.480 s 7 0000010E: moveq #0,%d0
0.560 s 7 z 00000110: movec %d0,%cacr
0.720 s 7 z 00000114: movec %d0,%dfc
0.880 s 7 z 00000118: movec %d0,%dtt0
1.040 s 7 z 0000011C: movec %d0,%dtt1
1.200 s 7 z 00000120: movec %d0,%isp
1.360 s 7 z 00000124: movec %d0,%itt0
1.520 s 7 z 00000128: movec %d0,%itt1
1.680 s 7 z 0000012C: movec %d0,%mmusr
1.840 s 7 z 00000130: movec %d0,%msp
2.000 Stopped at PC = 0x00000130: interrupted