comp.lang.ada
 help / color / mirror / Atom feed
From: codeallergy <romainbeckers@gmail.com>
Subject: Re: Ada and string literals
Date: Wed, 30 Jan 2013 14:54:01 -0800 (PST)
Date: 2013-01-30T14:54:01-08:00	[thread overview]
Message-ID: <ea8d08fe-fa00-491b-bf89-29dade053f62@googlegroups.com> (raw)
In-Reply-To: <4978d638-a04b-4561-85e9-cf6620265af2@googlegroups.com>

Thanks for answering.

i reversed the generated code. when u use a literal as a argument like this

    Put_Line("HELLO");
    Abc("HELLO");

the same string from the data section is shared. when you use constants from a package like this

    package Abc is
        str1 : aliased constant String : "LITERAL";
        str2 : aliased constant String : "LITERAL";
    end Abc;

strings are duplicated and put into the data section, aliased or not. when you use constant from a procedure header (dunno how u name that) like this

    procedure Abc
    is
        str1 : aliased constant String : "LITERAL";
    begin
        null;
    end Abc;

if the constant is aliased, the constant is not put into the data section but "hardcoded" and push on the stackframe like this:

    .text:00401FA2  mov dword ptr [ebp-104h], 1
    .text:00401FAC  mov dword ptr [ebp-100h], 7
    .text:00401FB6  mov dword ptr [ebp-0FCh], 4554494Ch ; 4C49544552414C = "LITERAL"
    .text:00401FC0  mov word ptr [ebp-0F8h], 4152h
    .text:00401FC9  mov byte ptr [ebp-0F6h], 4Ch

if not aliased the constant is put into the data section.

    - Rom B.



  parent reply	other threads:[~2013-01-30 22:54 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-30  0:44 Ada and string literals codeallergy
2013-01-30  7:08 ` Niklas Holsti
2013-01-30 11:50   ` Mart van de Wege
2013-01-30 13:52     ` Niklas Holsti
2013-01-30 16:09       ` Adam Beneschan
2013-02-01  0:54       ` Shark8
2013-02-01  9:03         ` Niklas Holsti
2013-02-01 14:58           ` Shark8
2013-01-30 16:52     ` codeallergy
2013-01-30 17:19       ` Adam Beneschan
2013-01-30 20:02       ` Simon Wright
2013-01-30 20:19         ` Georg Bauhaus
2013-01-30 22:06       ` Robert A Duff
2013-01-30 22:10         ` Jeffrey Carter
2013-01-31  2:23           ` Robert A Duff
2013-01-31 15:49             ` Adam Beneschan
2013-01-31 22:24               ` Robert A Duff
2013-02-01 21:16       ` gautier_niouzes
2013-02-02  1:55       ` Stephen Leake
2013-02-02 14:30         ` Robert A Duff
2013-01-31  9:20     ` ake.ragnar.dahlgren
2013-01-30 16:20   ` Robert A Duff
2013-02-01 13:20     ` Stephen Leake
2013-02-01 14:49       ` Robert A Duff
2013-02-01 17:23       ` Dmitry A. Kazakov
2013-02-01 20:22         ` Robert A Duff
2013-02-01 22:03           ` Dmitry A. Kazakov
2013-01-30 22:54 ` codeallergy [this message]
2013-02-01  0:50 ` Shark8
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox