[Oberon] System V5 - Oberon Strings Compiler Pattern

Hans Klaver hklaver at dds.nl
Fri Apr 15 09:31:51 CEST 2016


Hi Jörg,

You wrote:

> (...)
> You will see that the two strings are NUL terminated and padded to 32 bit boundary.

That's OK. I understand.

But my point was that under the current Revised Oberon definition software writers should not expect strings to be NUL terminated.
And possibly that would come as a surprise to some, because before 2011 it used to be different. 

And there's still some work to be done before all existing Oberon code handles strings accordingly.

__
Hans


_________

> Hans
> 
> I was talking on the compiler implementation and not on the type compatibility rules.
> 
> You can test it yourself: Compile this and execute the command in the last line
> - - - 
> MODULE Test;
> CONST s1 = „abc“; s2 = „abcd“;
> END Test.
> ORP.Compile Test.Mod ~
> ORTool.DecObj Test.rsc
> - - - -
> 
> You will see that the two strings are NUL terminated and padded to 32 bit boundary.
> 
> br
> Jörg
> 
>> Am 15.04.2016 um 00:29 schrieb Hans Klaver <hklaver at dds.nl>:
>> 
>> Jörg wrote:
>> 
>>> Indeed, implementation of Oberon strings is different than Strings in Pascal. They are NUL terminated and padded to 32 bit boundary.
>> 
>> 
>> Starting with the 22.9.2011 version of the Oberon-07 Language Report strings in Oberon no longer are required to end with a null character. This is because from then on the notion of a character constant ceased to exist: things like "a" and 7AX now are considered single character strings, and a single character string can be assigned to variables of type CHAR. The only instance where the terminating 0X character is mandatory is when a string is assigned to an ARRAY n OF CHAR that is longer than the string.
>> 
>> See paragraphs 3. and 9.1.2 of the current report https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon07.Report.pdf
>> 
>> With this language change Wirth in one fell swoop resolved all problems and inconsistencies that had existed since Modula-2 in the definition and interaction of character constants, variables of type CHAR, strings and arrays of CHAR.
>> 
>> The remaining problem is that several current modules of Project Oberon contain procedures that are not yet made up to date with this language change. E.g. the procedures Files.WriteString and Texts.WriteString end in a TRAP when called with a string or character array that is not terminated with a 0X character.
>> 
>> --
>> Hans Klaver
>> 
>> 
>> 
>> 
>> Op 11 apr. 2016, om 21:37 heeft Jörg Straube het volgende geschreven:
>> 
>>> Indeed, implementation of Oberon strings is different than Strings in Pascal. They are NUL terminated and padded to 32 bit boundary.
>>> 
>>> Jörg
>>> 
>>>> Am 11.04.2016 um 20:29 schrieb Tomas Kral <thomas.kral at email.cz>:
>>>> 
>>>> Hi,
>>>> 
>>>> I am still reading PO.Applications, chapters on Compiler.
>>>> Looking at strings sample code pattern:
>>>> 
>>>> BEGIN
>>>> s0 := "ABCDEF"; 
>>>> ...
>>>> ADD R0 SB 0 @s0 
>>>> ADD R1 SB 64 @"ABCDEF" 
>>>> LDR R2 R1 0 
>>>> ADD R1 R1 4 
>>>> STR R2 R0 0 
>>>> ADD R0 R0 4 
>>>> ASR R2 R2 24 test for 0X 
>>>> BNE -6 
>>>> ...
>>>> 
>>>> My understanding is that strings are copied/assigned by 4 bytes (long
>>>> words) at a time in a loop that ends when 0X (NULL) is found. This may
>>>> also impose Strings of even lengths may have to be padded with 0X..0X on
>>>> long word boundary.
>>>> 
>>>> Correct?
>>>> 
>>>> This came as a surprise to me as I remember from University days about
>>>> Pascal/Modula strings, having a length byte in front.
>>>> 
>>>> Many thanks.
>>>> 
>>>> -- 
>>>> Tomas Kral <thomas.kral at email.cz>
>>>> 
>>>> --
>>>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
>>>> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>>> --
>>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
>>> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>> 
>> --
>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
>> https://lists.inf.ethz.ch/mailman/listinfo/oberon
> 
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20160415/8da0eec0/attachment.html>


More information about the Oberon mailing list