From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,71c41b6f4d72158c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-13 13:02:18 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news.stealth.net!news.stealth.net!204.127.161.2.MISMATCH!wn2feed!worldnet.att.net!204.127.198.204!attbi_feed4!attbi_feed3!attbi.com!sccrnsc03.POSTED!not-for-mail From: "Jeffrey Creem" Newsgroups: comp.lang.ada References: Subject: Re: if X in 1..35000 versus Boolean X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: NNTP-Posting-Host: 66.31.5.146 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc03 1026590537 66.31.5.146 (Sat, 13 Jul 2002 20:02:17 GMT) NNTP-Posting-Date: Sat, 13 Jul 2002 20:02:17 GMT Organization: AT&T Broadband Date: Sat, 13 Jul 2002 20:02:17 GMT Xref: archiver1.google.com comp.lang.ada:27063 Date: 2002-07-13T20:02:17+00:00 List-Id: Note that for anthing bigger than a trival program, it is often easier to use objdump so you can see the source code intermixed in the assembly code (perhaps this can be done in one step with gcc as well but I tend to use the approach below since it follows the ada xxx.ads, a.das xxx paradigm I got used to with VADS many years back now). For example (with the previous sample code): gcc -c -O3 -g xxx.adb C:\Documents and Settings\jcreem\Desktop>objdump --disassemble --source xxx.o xxx.o: file format pe-i386 Disassembly of section .text: 00000000 <__ada_xxx>: 0: 55 pushl %ebp begin Loop_Name : for i in 1 .. 1000 loop 1: b8 e7 03 00 00 movl $0x3e7,%eax 6: 89 e5 movl %esp,%ebp 8: 48 decl %eax 9: 79 fd jns 8 <__ada_xxx+8> b: 89 ec movl %ebp,%esp d: 5d popl %ebp e: c3 ret f: 90 nop (If you want that boring program to be even easier to understand, omit the frame pointer and then there are no "surprise" instructions there (suprise for a non assembly person) C:\Documents and Settings\jcreem\Desktop>gcc -c -O3 -g -fomit-frame-pointer xxx. adb C:\Documents and Settings\jcreem\Desktop>objdump --disassemble --source xxx.o xxx.o: file format pe-i386 Disassembly of section .text: 00000000 <__ada_xxx>: begin Loop_Name : for i in 1 .. 1000 loop 0: b8 e7 03 00 00 movl $0x3e7,%eax 5: 90 nop 6: 48 decl %eax 7: 79 fd jns 6 <__ada_xxx+6> 9: c3 ret a: 89 f6 movl %esi,%esi "sk" wrote in message news:mailman.1026584402.3884.comp.lang.ada@ada.eu.org... > > Hi, > > > I know only basics of Assembler, so this would be pointless in my case. > > Pointless ? > > --------------------------------------------------- > procedure xxx is > begin > Loop_Name : for i in 1 .. 1000 loop > null; > end loop Loop_Name; > end xxx; > > --------------------------------------------------- > gcc -S -c xxx.adb (Linux, Gnat 3.13p) > > --------------------------------------------------- > .file "xxx.adb" > .version "01.01" > gcc2_compiled.: > .text > .align 4 > .globl _ada_xxx > .type _ada_xxx,@function > _ada_xxx: -- Set up > pushl %ebp > movl %esp,%ebp <-- Set base to stack > subl $4,%esp <-- Decrement stack 4 bytes for loop > variable > movl $1,-4(%ebp) <-- Set loop variable to 1 > .L2: > cmpl $1000,-4(%ebp) <-- Is the loop variable = 1000 ? > jle .L5 <-- No, variable is less than 1000, jump > to .L5 > jmp .L3 <-- Yes, jump to .L3 > .align 4 > .L5: > jmp .L4 <-- Jump to .L4 > .align 4 > jmp .L3 > .align 4 > .L6: > .L4: > incl -4(%ebp) <-- Increment the loop counter > jmp .L2 <-- Go to beginning of loop > .align 4 > .L3: > jmp .L1 <-- Ok, finished > .align 4 > .L1: -- Clean up > movl %ebp,%esp > popl %ebp > ret > .Lfe1: > .size _ada_xxx,.Lfe1-_ada_xxx > .ident "GCC: (GNU) 2.8.1" > > --------------------------------------------------- > Play with the Ada code by changing the "x in 1 .. 1000" to > "x in 5 .. 57" for example, and look at the resultant > assembly listing. > > -- > ------------------------------------- > -- Merge vertically for real address > ------------------------------------- > s n p @ t . o > k i e k c c m > -------------------------------------