-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Address.h
71 lines (61 loc) · 2.15 KB
/
Address.h
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
// Copyright Kabuki Starship� <kabukistarship.com>.
#pragma once
#ifndef SCRIPT2_ADDRESS
#define SCRIPT2_ADDRESS
#include <_Config.h>
#if SEAM >= SCRIPT2_DIC
namespace _ {
/* C++11 constexpr function for creating Script addresses headers with less
typing as well as ensuring there is only a single copy in ROM.
Template solves the problem of not being able using array constructors to
create data structures in ROM.
@code
Address<'A', 'B', 'C'> ()
@endcode
*/
template<const CHA... N>
LIB_MEMBER const CHA* Address() {
static const CHA path[sizeof...(N)] = {N...};
static const CHA term_char = 0;
return path;
}
/* Returns a pointer to static variable for writing the address { a, \0 } to.
*/
inline IUB PackAddress(IUA a) { return ((1 << 8) | a); }
/* Returns a pointer to static variable for writing the address
{ a, b, \0, \0 } to. */
inline IUC PackAddress(IUC a, IUC b) { return ((1 << 16) | a | (b << 8)); }
/* Returns a pointer to static variable for writing the address { a, b, c, \0 }
to. */
inline IUC PackAddress(IUC a, IUC b, IUC c) {
return ((1 << 24) | a | (b << 8) | (c << 16));
}
/* Returns a pointer to static variable for writing the address { a, b, c, d,
e, f, g, \0 } to. */
inline IUD PackAddress(IUD a, IUD b, IUD c, IUD d) {
IUD one = 1;
return (one << 32 | a | (b << 8) | (c << 16) | (d << 24));
}
/* Returns a pointer to static variable for writing the address { a, b, c, d,
e, f, g, \0 } to. */
inline IUD PackAddress(IUD a, IUD b, IUD c, IUD d, IUD e) {
IUD one = 1;
return (one << 40 | a | (b << 8) | (c << 16) | (d << 24) | (e << 32));
}
/* Returns a pointer to static variable for writing the address
{ a, b, c, d, e, f, g, \0 } to. */
inline IUD PackAddress(IUD a, IUD b, IUD c, IUD d, IUD e, IUD f) {
IUD one = 1;
return (one << 48 | a | (b << 8) | (c << 16) | (d << 24) | (e << 32) |
(f << 40));
}
/* Returns a pointer to static variable for writing the address
{ a, b, c, d, e, f, g, \0 } to. */
inline IUD PackAddress(IUD a, IUD b, IUD c, IUD d, IUD e, IUD f, IUD g) {
IUD one = 1;
return (one << 56 | a | (b << 8) | (c << 16) | (d << 24) | (e << 32) |
(f << 40) | (g << 48));
}
} //< namespace _
#endif
#endif