[Oberon] System V5 - Oberon Strings Compiler Pattern

Hans Klaver hklaver at dds.nl
Fri Apr 15 00:29:54 CEST 2016


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



More information about the Oberon mailing list