forked from moisutsu-playground/csjikken2-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_scan.c
156 lines (134 loc) · 3.74 KB
/
my_scan.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#define EXTIO_SCAN_ASCII (*(volatile unsigned int *)0x0310)
#define EXTIO_SCAN_REQ (*(volatile unsigned int *)0x030c)
#define EXTIO_SCAN_STROKE (*(volatile unsigned int *)0x0308)
#define SCAN_STRORING (unsigned int)0xffffffff
#define EXTIO_PRINT_STROKE (*(volatile unsigned int *) 0x0300)
#define EXTIO_PRINT_ASCII (*(volatile unsigned int *) 0x0304)
void my_print();
void my_scan();
main()
{
unsigned int string1[32];
unsigned int string2[32];
string1[0] = 'H';
string1[1] = 'E';
string1[2] = 'L';
string1[3] = 'L';
string1[4] = 'O';
string1[5] = '!';
string1[6] = '!';
string1[7] = '\n';
string1[8] = '\0';
my_print(string1);
while (1) {
string1[0] = 'S';
string1[1] = 'T';
string1[2] = 'R';
string1[3] = 'I';
string1[4] = 'N';
string1[5] = 'G';
string1[6] = '=';
string1[7] = '\0';
my_print(string1);
my_scan(string2);
string1[0] = 'E';
string1[1] = 'C';
string1[2] = 'H';
string1[3] = 'O';
string1[4] = ' ';
string1[5] = '\0';
my_print(string1);
my_print(string2);
string1[0] = '\n';
string1[1] = '\0';
my_print(string1);
}
}
void my_scan(str)
unsigned int *str;
{
EXTIO_SCAN_STROKE = (unsigned int)0x00000000;
EXTIO_SCAN_REQ = (unsigned int)0x00000001;
EXTIO_SCAN_STROKE = (unsigned int)0x00000001;
EXTIO_SCAN_STROKE = (unsigned int)0x00000000;
EXTIO_SCAN_STROKE = (unsigned int)0x00000001;
while (EXTIO_SCAN_ASCII == SCAN_STRORING) {
EXTIO_SCAN_STROKE = (unsigned int)0x00000000;
EXTIO_SCAN_STROKE = (unsigned int)0x00000001;
}
while ((*str = EXTIO_SCAN_ASCII) != (unsigned int)0x3e) { // 0x3e=RETURN
if ((*str >= 1) && (*str <= 26)) {
*str = 'A' + *str - 1;
} else if ((*str >= 48) && (*str <= 57)) {
*str = '0' + *str - 48;
} else {
if (*str == 0) {
*str = '@';
} else if (*str == 27) {
*str = '[';
} else if (*str == 29) {
*str = ']';
} else if ((*str >= 32) && (*str <= 47)) {
*str = ' ' + *str - 32;
} else if (*str == 58) {
*str = '?';
} else if (*str == 59) {
*str = '=';
} else if (*str == 60) {
*str = ';';
} else if (*str == 61) {
*str = ':';
} else if (*str == 62) {
*str = '\n';
} else {
*str = '@';
}
}
EXTIO_SCAN_STROKE = (unsigned int)0x00000000;
EXTIO_SCAN_STROKE = (unsigned int)0x00000001;
str++;
}
*str = '\0';
EXTIO_SCAN_STROKE = (unsigned int)0x00000000;
EXTIO_SCAN_REQ = (unsigned int)0x00000000;
EXTIO_SCAN_STROKE = (unsigned int)0x00000001;
EXTIO_SCAN_STROKE = (unsigned int)0x00000000;
}
void my_print(str)
unsigned int *str;
{
while (*str != '\0') {
EXTIO_PRINT_STROKE = (unsigned int)0x00000000;
if ((*str >= 'A') && (*str <= 'Z')) {
EXTIO_PRINT_ASCII = *str - 'A' + 1;
} else if ((*str >= 'a') && (*str <= 'z')) {
EXTIO_PRINT_ASCII = *str - 'a' + 1;
} else if ((*str >= '0') && (*str <= '9')) {
EXTIO_PRINT_ASCII = *str - '0' + 48;
} else {
if (*str == '@') {
EXTIO_PRINT_ASCII = (unsigned int)0;
} else if (*str == '[') {
EXTIO_PRINT_ASCII = (unsigned int)27;
} else if (*str == ']') {
EXTIO_PRINT_ASCII = (unsigned int)29;
} else if ((*str >= ' ') && (*str <= '/')) {
EXTIO_PRINT_ASCII = *str - ' ' + 32;
} else if (*str == '?') {
EXTIO_PRINT_ASCII = (unsigned int)58;
} else if (*str == '=') {
EXTIO_PRINT_ASCII = (unsigned int)59;
} else if (*str == ';') {
EXTIO_PRINT_ASCII = (unsigned int)60;
} else if (*str == ':') {
EXTIO_PRINT_ASCII = (unsigned int)61;
} else if (*str == '\n') {
EXTIO_PRINT_ASCII = (unsigned int)62;
} else {
EXTIO_PRINT_ASCII = (unsigned int)0x00000000;
}
}
EXTIO_PRINT_STROKE = (unsigned int)0x00000001;
str++;
}
}