root / lab2 / utils.c @ 2
History | View | Annotate | Download (707 Bytes)
1 | 1 | up20180614 | #include <lcom/lcf.h> |
---|---|---|---|
2 | |||
3 | #include <stdint.h> |
||
4 | |||
5 | int(util_get_LSB)(uint16_t val, uint8_t *lsb) {
|
||
6 | /* To be implemented by the students */
|
||
7 | 2 | up20180614 | //printf("%s is not yet implemented!\n", __func__);
|
8 | *lsb=val&0xFF;
|
||
9 | return 0; |
||
10 | 1 | up20180614 | } |
11 | |||
12 | int(util_get_MSB)(uint16_t val, uint8_t *msb) {
|
||
13 | /* To be implemented by the students */
|
||
14 | 2 | up20180614 | //printf("%s is not yet implemented!\n", __func__);
|
15 | *msb=(val&0xFF00)>>8; |
||
16 | 1 | up20180614 | |
17 | 2 | up20180614 | return 0; |
18 | 1 | up20180614 | } |
19 | |||
20 | int (util_sys_inb)(int port, uint8_t *value) { |
||
21 | /* To be implemented by the students */
|
||
22 | uint32_t b32; |
||
23 | sys_inb(port,&b32); |
||
24 | //printf("%x",b32);
|
||
25 | *value=b32&0xFF;
|
||
26 | //printf("%x\n",*value);
|
||
27 | |||
28 | |||
29 | //printf("%s is not yet implemented!\n", __func__);
|
||
30 | |||
31 | return 0; |
||
32 | } |
||
33 | |||
34 | /* a = 133
|
||
35 | b = a & 0x0F
|
||
36 | 1000 0101
|
||
37 | */ |