-
-
Notifications
You must be signed in to change notification settings - Fork 193
Add intergalactic-transmission #1062
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
Conversation
|
||
#define WRONG_PARITY -1 | ||
|
||
int transmit_sequence(uint8_t *buffer, const uint8_t *message, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The focus of this exercise is on the encoding/decoding logic and not so much on figuring out function signatures. As a student I always find it annoying having to figure those out myself when i actually want to focus on the problem at hand, so I kept them here. Let me know if you think they should be removed.
As long as we can keep complexity in check, I'm in favor. |
|
||
#define BUFFER_SIZE 100 | ||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
#define WRONG_PARITY -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this already comes from intergalactic_transmission.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Removed.
uint8_t const payload = message[i] >> 1; | ||
uint8_t const parity = message[i] & 1; | ||
// check parity bit and return early if mismatch found | ||
if ((__builtin_popcount(payload) & 1) != parity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Alright, I will experiment a bit and create an issue so we can discuss (or maybe it'll be a PR already). |
Thanks! |
Reviewed this over at arm64-assembly and think it's a nice exercise, so I figured I'd add it here!
The test file is taken from the arm64 track with minor modifications. Over there we have generators for all test files. What would other
reviewersmaintainers think of introducing something like that here as well?