-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patholdcode.cpp
95 lines (72 loc) · 1.71 KB
/
oldcode.cpp
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
static char charbuf[80];
static int GetTypeOf(ea_t ea)
{
flags_t flags = getFlags(ea);
if (!isData(flags)) return T_UNK;
if (isByte(flags)) return T_8BIT;
if (isWord(flags)) return T_16BIT;
if (isDwrd(flags)) return T_I32;
return T_UNK;
}
static bool DontNeedExplicitType(int datatype, int reftype, bool store)
{
if (datatype == reftype)
return true;
if (store) {
switch(datatype) {
case T_8BIT:
case T_I8:
case T_U8:
return reftype == T_I8 || reftype == T_U8;
case T_16BIT:
case T_I16:
case T_U16:
return reftype == T_I16 || reftype == T_U16;
default:
return false;
}
} else {
switch(datatype) {
case T_8BIT: return reftype == T_U8;
case T_16BIT:return reftype == T_U16;
default:
return false;
}
}
}
static const uint32 _typemask_size_masks[] = {
0xffffffff,
0xff,0xff,
0xffff,0xffff,
0xffffffff,
};
static char *PrintConstant(char *s, uint32 n, uint flags)
{
char *q;
char buf[40];
if (flags & PF_EA && (q = get_name(BADADDR, n, charbuf, sizeof(charbuf))) != NULL) {
// check if we don't need to write the type explicitly
if (flags & PF_TYPEMASK && DontNeedExplicitType( GetTypeOf(n),(flags & PF_TYPEMASK) - 1, !!(flags & PF_EA_STORE))) {
flags &= ~PF_TYPEMASK;
}
} else {
q = buf;
if (flags & PF_NEGCONST) {
uint32 tmp_n = (~n) & _typemask_size_masks[flags & PF_TYPEMASK];
if (CountBits(tmp_n) <= 2) {
*q++ = '~';
n = tmp_n;
}
}
if (n < 10) {
sprintf(q, "%d", n);
} else {
sprintf(q, "0x%X", n);
}
q = buf;
}
if (flags & PF_EA && flags & PF_TYPEMASK) { s = strcpy_e(s, TypeNames[(flags & PF_TYPEMASK) - 1]); }
s = strcpy_e(s, q);
if (flags & PF_EA && flags & PF_TYPEMASK ) { s = strcpy_e(s, ">"); }
return s;
}