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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no 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 11:20:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!freenix!enst!enst.fr!not-for-mail From: sk Newsgroups: comp.lang.ada Subject: Re: if X in 1..35000 versus Boolean Date: Sat, 13 Jul 2002 13:17:57 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1026584403 60780 137.194.161.2 (13 Jul 2002 18:20:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sat, 13 Jul 2002 18:20:03 +0000 (UTC) Return-Path: X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19-4.3mdk i686) X-Accept-Language: en Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:27058 Date: 2002-07-13T13:17:57-05:00 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 -------------------------------------