[Dwarf-discuss] bit-string

2024-12-18 Thread Thomas David Rivers via Dwarf-discuss


PL/I has the concept of a "string", which can be a fixed-length
(possibly not known at compile time), or a fixed size with a 4-byte or 2-byte
runtime length prefix, or, depending on the consituents, a NULL (zero-byte)
terminated string.

For "character-like" strings, the constituents can be 1-byte, 2-byte,
4-byte strings, or UTF-8 values.  (e.g. strings of characters, or strings
of UTF-8 values, or strings of 4-byte unicode values.)

All of these seem to be straightforwardly handled by DWARF-5.

However, PL/I also has a "BIT string", which is a left-adjusted string
of bits, either of a fixed length (# of bits) or of a fixed size
with a either a 2-byte or 4-byte length prefix. Of course, there isn't
a NULL-terminated variant of this string, because a zero-bit is part of
the data.  The sizes may not be known at compile time.

I've gone thru the DWARF-5 standard a few times, but can't seem to
envision a straight-forward way to represent this.

Furthermore, an un-prefixed bit-string doesn't necessarily begin 
on a byte boundary, and, depending on the environment, needs to
be represented as a bit-offset which may be composed (even at runtime)
of (byte-location + bit-offset-in-byte).

Any suggestions on how to represent this in DWARF (5 or later) would
be appreciated!   Perhaps it's just something obvious I'm overlooking??

- Many Thanks! -
- Dave Rivers 

--
riv...@dignus.com 
-- 
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss


Re: [Dwarf-discuss] bit-string

2024-12-18 Thread Thomas David Rivers via Dwarf-discuss
David Blaikie wrote:
> 
> What sort of string-like behavior would one want on a bit-string? Seems
> like array would be the better fit to me...
> 

 It's a language that originates in the late 60s - so there are some,
 "different" ideas than more contemporary languages.

 You can ask for sub-strings of strings (character or bit), you can
 assign a string (shorter or of equal length) to a target string,
 you can also concatenate strings, and you can assign to portions 
 within a target bit string (or character string for that matter.)

 e.g.

test: proc;

 dcl b10 bit(10);
 dcl b20 bit(20) varying;
 dcl dest bit(30) varying4;  /* maximum possible result size */

   b10 = '1010'b;  /* assigns '101000' to b10 (passing on the right */
   /* with 0 bits because the length is fixed. */

   b20 = '10'b;/* assigns '10' to b20, moving a byte containing  */
   /* '10..' and setting the 2-byte length field */
   /* to 2, indicating the left-most 2 bits are used. */

   dest = b10 || b20;  /* assigns '10100010' to dest, setting it's */
   /* 4-byte length field to 12. */

   b10 = substr(dest,1,2);  /* extracts the first 2 bits from the bitfield */
  /* dest ('10') (2 bytes starting a position #1) and assigns  */
  /* it to b10, which is extended to 10 bits on-the-right  */
  /* because b10 is a fixed-length, resulting in '10'  */
  /* being assigned to b10 */

   substr(b10,6,1) = '1'b;  /* assigns a 1-bit value to b10, starting */
/* at bit #6 and going for 1 bit, resulting */
/* in '101001' being in b10 */

 end proc;

 So - it's a rather abstract idea of "strings of bits" similar to
 "strings of characters".  

 - Dave Rivers -

--
riv...@dignus.com

-- 
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss