Getting Started with M1750 Ada: Ada 95 Compilation System for Spacecraft Microprocessors | ||
---|---|---|
Prev | Chapter 1. Basic Techniques | Next |
If you want to see the generated code, then use the compiler 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 XGC Ada Users Guide, for more information on assembler options.
Here is an example where we generate a machine code listing.
Example 1-6. Generating a Machine Code Listing
$ m1750-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 0048 .word 72 7 0002 0065 .word 101 8 0004 006C .word 108 9 0006 006C .word 108 10 0008 006F .word 111 11 000a 0020 .word 32 12 000c 0057 .word 87 13 000e 006F .word 111 14 0010 0072 .word 114 15 0012 006C .word 108 16 0014 0064 .word 100 17 .LC1: 18 0016 0001 .word 1 19 0018 000B .word 11 20 .text 21 .global _ada_hello 22 _ada_hello: 23 0000 9FEE pshm r14,r14 24 0002 81EF lr r14,r15 25 0004 81BF lr r11,r15 26 0006 4AB9 8000 xorm r11,0x8000 27 000a F0B0 0000 c r11,_stack_limit 28 000e 7B02 bge .+4 29 0010 7708 bex 8 30 0012 8500 0000 lim r0,.LC0 31 0016 8510 000B lim r1,.LC1 32 001a 7EF0 0000 sjs r15,ada__text_io__put_line__2 33 001e 81FE lr r15,r14 34 0020 8FEE popm r14,r14 35 0022 7FF0 urs r15 ...
You could also use the object code dump utility m1750-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 an example using the object code dump utility.
Example 1-7. Output from Object Code Dump Program
$ m1750-coff-objdump -d hello.o hello.o: file format coff-m1750 Disassembly of section .text: 00000000 <_ada_hello>: 0: 9f ee pshm r14,r14 2: 81 ef lr r14,r15 4: 81 bf lr r11,r15 6: 4a b9 80 00 xorm r11,32768 a: f0 b0 00 00 c r11,0 <_ada_hello> e: 7b 02 bge 2 10: 77 08 bex 8 12: 85 00 00 00 lim r0,0 16: 85 10 00 0b lim r1,11 1a: 7e f0 00 00 sjs r15,0 <_ada_hello> 1e: 81 fe lr r15,r14 20: 8f ee popm r14,r14 22: 7f f0 urs r15
You can see how big your program is using the size command. Note that the sizes are in 8-bit bytes and not 16-bit words.
Example 1-8. Using the Size Program
$ m1750-coff-size hello.o text data bss dec hex filename 62 0 0 62 3e hello.o $ m1750-coff-size hello text data bss dec hex filename 9134 744 870 10748 29fc hello
To get more detail you can use the object code dump program, and ask for headers. Once again the sizes are in bytes. The addresses are byte addresses.
Example 1-9. Object Code Section Headers
$ m1750-coff-objdump -h hello hello: file format coff-m1750 Sections: Idx Name Size VMA LMA File off Algn 0 .init 00000036 00000000 00000000 00001000 2**1 CONTENTS, ALLOC, LOAD, CODE 1 .ivec 00000040 00000040 00000040 00001040 2**1 CONTENTS, ALLOC, LOAD, READONLY 2 .text 000021c2 00000100 00000100 00001100 2**1 CONTENTS, ALLOC, LOAD, CODE 3 .rdata 00000176 000022c2 000022c2 000032c2 2**1 CONTENTS, ALLOC, LOAD, READONLY 4 .data 000002e8 00010000 00002438 00004000 2**1 CONTENTS, ALLOC, LOAD, DATA 5 .bss 00000366 000102f0 000102f0 00000000 2**1 ALLOC 6 .stab 00004e60 00000000 00000000 000042e8 2**1 CONTENTS, DEBUGGING, NEVER_LOAD 7 .stabstr 00005f3c 00000000 00000000 00009148 2**0 CONTENTS, DEBUGGING, NEVER_LOAD