Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- uint8_t mult(uint8_t a, uint8_t b) {
- uint8_t result =
- ((a << 0) & (0 - ((b & 0x01) >> 0))) +
- ((a << 1) & (0 - ((b & 0x02) >> 1))) +
- ((a << 2) & (0 - ((b & 0x04) >> 2))) +
- ((a << 3) & (0 - ((b & 0x08) >> 3))) +
- ((a << 4) & (0 - ((b & 0x10) >> 4))) +
- ((a << 5) & (0 - ((b & 0x20) >> 5))) +
- ((a << 6) & (0 - ((b & 0x40) >> 6))) +
- ((a << 7) & (0 - ((b & 0x80) >> 7)));
- return result;
- }
- void main(void) {
- printf("%u * %u = %u", 8, 7, mult(8, 7));
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement