-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzad1c.c
57 lines (42 loc) · 1.17 KB
/
zad1c.c
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
unsigned short int ReadStatusRegister();
unsigned short int ReadControlWord();
void SaveControlWord( int x);
//sprawdzenie flagi na poszczególnych indeksach
extern bool flag_check(unsigned short int status, int index){
printf("Flaga o indeksie %d od prawej strony strony wynosi: ",index);
int b = (status>>index)&1U;
if(b==1){
printf("%s","1\n");
return true;
}else{
printf("%s","0\n");
return false;
}
}
void print_binary(unsigned short int d){
int i;
for(i=15;i>=0;i--){
printf("%d",(d>>i)&1);
}
printf("\n");
}
int main(){
int a=12;
unsigned short int status, controlword;
status = ReadStatusRegister();
controlword= ReadControlWord();
printf("Binarna wartość rejestru sterującego koprocesora: \n");
print_binary(controlword);
printf("Binarna wartość rejestru statusowego: \n");
print_binary(status);
flag_check(status,3);
printf("Operacja zmiany określonych bitów w rejestrze sterującym: \n");
SaveControlWord(a);
controlword = ReadControlWord();
printf("Binarna wartość rejestru sterującego koprocesora po zmianie: \n");
print_binary(controlword);
return 0;
}