-
Notifications
You must be signed in to change notification settings - Fork 5
/
print.c
60 lines (51 loc) · 1.07 KB
/
print.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
57
58
59
60
/*
* pirnt.c
*
* Created on: Nov 13, 2013
* Author: hxin
*/
#include "print.h"
#include <stdio.h>
void printbytevector(uint8_t *data, int length) {
int i;
for (i = 0; i < length; i++) {
int m;
for (m = 0; m < 8; m++) {
if (data[i] & (1ULL << m))
printf("1");
else
printf("0");
}
}
}
void printbytevector_twice(uint8_t *data, int length) {
int i;
for (i = 0; i < length; i++) {
int m;
for (m = 0; m < 8; m++) {
if (data[i] & (1ULL << m))
printf("11");
else
printf("00");
}
if (i % 8 == 7)
printf("\n");
}
}
void print128_bit(__m128i var) {
uint8_t *val = (uint8_t*) &var;
printbytevector(val, 16);
printf("\n");
}
void print128_bit_twice(__m128i var) {
uint8_t *val = (uint8_t*) &var;
printbytevector_twice(val, 16);
printf("\n");
}
void print128_hex(__m128i var) {
uint8_t *val = (uint8_t*) &var;
printf("Numerxcal: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7],
val[8], val[9], val[10], val[11], val[12], val[13], val[14],
val[15]);
}