Skip to content

Support high-bit-zero numbering on bits types#112

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/support-high-bit-zero-numbering
Draft

Support high-bit-zero numbering on bits types#112
Copilot wants to merge 3 commits intomasterfrom
copilot/support-high-bit-zero-numbering

Conversation

Copy link

Copilot AI commented Dec 6, 2025

Many big-endian protocols (especially older RFCs like IP/TCP) number bits with bit 0 as the MSB. This adds a bit_numbering attribute to support that convention.

Changes

  • New bit_numbering attribute: Accepts "Lsb0" (default) or "Msb0" on bits types and as module default
  • C++ runtime: Added BitBlockMsb0 and OffsetBitBlockMsb0 classes that transform user offsets to physical offsets via physical = total_bits - user_offset - size
  • Code generator: Routes to BitBlockMsb0 when the referenced bits type has [bit_numbering: "Msb0"]
  • Documentation: Updated language reference with examples

Example

[$default byte_order: "BigEndian"]

bits IpFlags:
  [bit_numbering: "Msb0"]
  0 [+1]  Flag  reserved      # Bit 0 = MSB
  1 [+1]  Flag  dont_fragment
  2 [+1]  Flag  more_fragments
  3 [+13] UInt  fragment_offset

struct IpHeader:
  0 [+2]  IpFlags  flags_and_offset
    [byte_order: "BigEndian"]

This matches RFC 791's bit numbering convention directly.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.googleapis.com
    • Triggering command: /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 build //... (dns block)
    • Triggering command: /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 --version (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Support High-Bit-Zero Numbering on bits</issue_title>
<issue_description>This issue was copied from the upstream repository google/emboss.

Original issue: google#42
Original state: open, created at: 2022-04-20T03:17:02Z, updated at: 2024-12-18T23:14:43Z, by @reventlov


Original description

A number of big-endian protocols number bits with bit 0 as the highest-order/first-read bit. This seems to be particularly common in protocols that are expressed in terms of bitstreams.

Emboss should provide a way to allow bits to be addressed with bit 0 as the highest-order bit.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 6, 2025 03:44
…bits types

Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Copilot AI changed the title [WIP] Support high-bit-zero numbering on bits Support high-bit-zero numbering on bits types Dec 6, 2025
Copilot AI requested a review from AaronWebster December 6, 2025 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support High-Bit-Zero Numbering on bits

2 participants