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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,87b54dbabc658fa2 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.224.215.194 with SMTP id hf2mr31318082qab.0.1367010627754; Fri, 26 Apr 2013 14:10:27 -0700 (PDT) X-Received: by 10.50.178.210 with SMTP id da18mr616205igc.2.1367010627714; Fri, 26 Apr 2013 14:10:27 -0700 (PDT) Path: ef9ni23500qab.0!nntp.google.com!gp5no7331898qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 26 Apr 2013 14:10:27 -0700 (PDT) In-Reply-To: <9f4422b8-7103-4acb-a770-63561f055008@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.20.190.126; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 69.20.190.126 References: <931385b2-3520-4d7a-b56f-6d0d0b06d467@googlegroups.com> <508e7264-46c3-4c53-94e6-6bb427fb3908@googlegroups.com> <7bb4c21a-be68-433e-a517-484798a8a687@googlegroups.com> <9f4422b8-7103-4acb-a770-63561f055008@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: AVR Usart send number string with no 'Image From: Shark8 Injection-Date: Fri, 26 Apr 2013 21:10:27 +0000 Content-Type: text/plain; charset=ISO-8859-1 Date: 2013-04-26T14:10:27-07:00 List-Id: I rewrote it iteratively; I'm pretty sure an extended return doesn't require the second-stack so you should be fine. declare Subtype String_3 is String(1..3); use Interfaces; -- Because the secondary stack is disabled we cannot use either of -- (a) recursion, or (b) unconstrained return-types. Therefore we -- need to work both iteratively and with fixed-length strings. Function To_String( Input : Unsigned_8 ) Return String_3 is -- A temporary variable for manipulation, initialized to input. Working : Unsigned_8 := Input; begin -- Extended return, we do not have to initialize any characters -- because they will be in range '0'..'9' with leading zeros. Return Result : String_3 do -- We assign the digit it's proper value, based on its -- position within the string. For Digit in reverse Result'Range loop Result(Digit):= Character'Val( -- We add the mod 10 value of working -- to the value of '0' to get the proper -- digit-character. Natural(Working mod 10) + Character'Pos('0') ); -- We adjust our working-variable, by dividing it by 10. Working:= Working / 10; end loop; end return; End To_String; -- Testing variable. Temp : Natural := 4; begin -- Test while Temp < 256 loop Ada.Text_IO.Put_Line( To_String( Unsigned_8(Temp) ) ); Temp:= Temp *2; -- I want to end w/ 255, not 128. Temp:= (if temp = 256 then 255 else temp); end loop; end;