Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seek bits #482

Open
vhdirk opened this issue Sep 23, 2024 · 2 comments
Open

Seek bits #482

vhdirk opened this issue Sep 23, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@vhdirk
Copy link
Contributor

vhdirk commented Sep 23, 2024

Given the recent addition of seek_from_*, I was wondering if there are plans to add seek_bits_from_*, too.?

I have this weird protocol that looks somewhat like this:

struct Operation {
    header: Header, #2 bits

    #[deku(bits="6")]
    opCode: u8,
    
    operand: Operand # any number of bytes
}

As you would assume, opCode + operand could be just an enum. However, for some if not most operands, the header isn't so much a header but rather an integral part of the operand itself. I know, it's a weird format.

So, it'd be very cool if there was a way to define that the enum id location is input[2..8], and the operand is actually ( input[0..2], 6 unused bits, input[9...] )

Do you have any ideas on how this could be implemented?

@wcampbell0x2a
Copy link
Collaborator

I've solved that before by sending in an already read header into the operand, but it sounds like that's not really a solution since it's doesn't interpret the header the second time as just being two bits.

  1. We don't have bit_order support, yet. But that first u8 looks like Lsb Order . Add bit_order attribute #468. I've written other instructions set decoders that I had to do this for, wouldn't surprise me.
  2. I'd have to play around with the idea of seek_bits! I think it's possible as long as it's no bigger then the last read.

@vhdirk
Copy link
Contributor Author

vhdirk commented Sep 24, 2024

Ah, I indeed thought I had brought this up before, but it's been a while and I couldn't find it anymore :)
I'll search some more

@wcampbell0x2a wcampbell0x2a added the enhancement New feature or request label Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants