temp.c
2.09 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <stdio.h>
typedef signed char i8; /* signed */
typedef short int i16;
typedef long int i32;
typedef long long int i64;
typedef unsigned char u8; /* unsigned */
typedef unsigned short int u16;
typedef unsigned long int u32;
typedef unsigned long long int u64;
u16 vd[8], vs[8], vt[8], in_VCO,el;
main ()
{
int i;
vs[0] = 0x0001;
vs[1] = 0x000f;
vs[2] = 0x00ff;
vs[3] = 0x0fff;
vs[4] = 0x7fff;
vs[5] = 0xffff;
vs[6] = 0x7ff0;
vs[7] = 0xf000;
vt[0] = 0x0001;
vt[1] = 0x000f;
vt[2] = 0x00ff;
vt[3] = 0x0fff;
vt[4] = 0x7fff;
vt[5] = 0xffff;
vt[6] = 0x7ff0;
vt[7] = 0xf000;
in_VCO = 0x55;
for (i=0; i<16; i++) {
if (i != 1) {
el = (u16) i;
printf("---------------------------- %x \n",el);
Eval_vadd();
printf("\n\n");
}
}
}
Eval_vadd()
{
int i, carry,of,uf;
i16 si, ti;
i32 di,di_save;
for (i=0; i<8; i++) {
if (in_VCO & (0x01 << i))
carry = 1;
else
carry = 0;
si = (i16) vs[i];
if (el==0) /* vector */
ti = (i16) vt[i];
else if (el<4) /* Scaler Quarter 0,1 */
ti = (i16) vt[(i&0xe) + (el&0x1)];
else if (el<8) /* Scaler half 0,1,2,3 */
ti = (i16) vt[(i&0xc) + (el&0x3)];
else if (el<16) /* Scaler whole 0,1,2,3,4,5,6,7 */
ti = (i16) vt[(i&0x8) + (el&0x7)];
di = si - ti - carry;
of = uf = 0;
di_save = di;
if (di > 0x00007fff) {
of = 1;
di = 0x00007fff;
}
if (di < -32768) {
uf = 1;
di = -32768;
}
vd[i] = (u16) di;
printf("%x, %x,, %x, %x,,, %x, %x,,, %x, %x,,%x ",
i, carry, vs[i], vt[i], si, ti,di_save, di,vd[i]) ;
if (of) printf("... overflow\n");
else
if (uf) printf("... underflow\n");
else
printf("\n");
/*
Set128By16(&(mp->result), (u16) di, i);
rsp_VCO = UnFlag(rsp_VCO, (0x01 << i));
*/
}
}