Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Viewed less than a minute ago

1GXKko1jqR4lPnOY

C gcc 12.1.0

Created at 1 minute ago

Created by anonymous

Author

anonymous

1 minute ago

Language

C

Compiler

gcc 12.1.0

Options
Warnings
C11
no pedantic
セオライド・テクノロジー㈱株式会社フィックスターズ

Author

anonymous

1 minute ago

›
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>

#define INSTRUCTION_SIZE 4

unsigned char instruction[INSTRUCTION_SIZE] = {0x7F, 0xF0, 0x01, 0x13};

void print_first_instruction(unsigned char* instruction) {
unsigned char value = instruction[0];
unsigned char last_seven_bits = value & instruction[0];
char bit0 = 0x00;
printf("\nLast 7 bits in binary: ");
for (int i = 6; i >= 0; i--) {
bit0 |= (last_seven_bits >> i) & 0x01; // shift the bits and use bitwise OR to assign the bits to bit0
bit0 <<= 1; // shift bit0 to the left to make space for the next bit
printf("%d", (last_seven_bits >> i) & 0x01);
if(bit0 == 0x13){
printf("Add command");
}
}
}


int main(int argc, char *argv[]) {
print_first_instruction(instruction);
return 0;
}
$ gcc prog.c -Wall -Wextra -std=c11
prog.c: In function 'main':
prog.c:27:14: warning: unused parameter 'argc' [-Wunused-parameter]
   27 | int main(int argc, char *argv[]) {
      |          ~~~~^~~~
prog.c:27:26: warning: unused parameter 'argv' [-Wunused-parameter]
   27 | int main(int argc, char *argv[]) {
      |                    ~~~~~~^~~~~~
Last 7 bits in binary: 1111111
Exit Code:
0
セオライド・テクノロジー㈱株式会社フィックスターズ