-
Notifications
You must be signed in to change notification settings - Fork 2
/
update need to split chain.java
245 lines (234 loc) · 9.96 KB
/
update need to split chain.java
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.io.*;
import java.util.*;
import java.util.Scanner;
import java.io.RandomAccessFile;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.io.UnsupportedEncodingException;
import java.nio.file.Path;
public class realdeal {
static int temp;
public static void main(String[] args) throws IOException {
String dataFile = "CK.chop";
byte[] bin;
StringBuilder sb = new StringBuilder();
try (BufferedReader input = openFile(dataFile)) {
String line;
String src2=new String();
while ((line = input.readLine()) != null) {
src2=line.replace(" ","");
bin=src2.getBytes();
System.out.println("imprimir el archivo\n"+src2);
System.out.println("impresion contenido en binary\n"+bin);
StringBuilder s3=new StringBuilder();
for(byte b:bin)
{
s3.append(String.format("%02X",b));
}
System.out.println("impresion del archivo en hex\n"+s3.toString());
System.out.println("tamanio de hex\n"+s3.length());
int totalpares=s3.length()/2;
System.out.println("pares totales:\n"+totalpares);
int count;
for(count=10;count<s3.length();count+=2)
{
//falta aqui diviir el S3 en pares para que entren al case
switch(temp){
case 0:
//write to file "HALT"
break;
case 1:
//write to file "PRTCR"
break;
case 2:
//write to file "PRTC"
break;
case 3:
//write to file "PRTI"
break;
case 4:
//write to file "PRTF"
break;
case 5:
//write to file "PRTD"
break;
case 6:
//write to file "PUSHC"
break;
case 7:
//write to file "PUSHI"
break;
case 8:
//write to file "PUSHF"
break;
case 9:
//write to file "PUSHD"
break;
case 10:
//write to file "PUSHS"
break;
case 11:
//write to file "PUSHAC"
break;
case 12:
//write to file "PUSHAI"
break;
case 13:
//write to file "PUSHAF"
break;
case 14:
//write to file "PUSHAD"
break;
case 15:
//write to file "PUSHAD"
break;
case 16:
//write to file "PUSHAS"
break;
case 17:
//write to file "PUSHKC"
break;
case 18:
//write to file "PUSHKI"
break;
case 19:
//write to file "PUSHKF"
break;
case 20:
//write to file "PUSHKD"
break;
case 21:
//write to file "PUSHKS"
break;
case 22:
//write to file "POPC"
break;
case 23:
//write to file "POPI"
break;
case 24:
//write to file "POPF"
break;
case 25:
//write to file "POPD"
break;
case 26:
//write to file "POPS"
break;
case 27:
//write to file "POPX"
break;
case 28:
//write to file "POPAI"
break;
case 29:
//write to file "POPAF"
break;
case 30:
//write to file "POPAD"
break;
case 31:
//write to file "POPAS"
break;
case 32:
//write to file "RDC"
break;
case 33:
//write to file "RDI"
break;
case 34:
//write to file "RDF"
break;
case 35:
//write to file "RDD"
break;
case 36:
//write to file "RDS"
break;
case 37:
//write to file "RDAC"
break;
case 38:
//write to file "RDAI"
break;
case 39:
//write to file "RDAF"
break;
case 40:
//write to file "RDAD"
break;
case 41:
//write to file "RDAS"
break;
case 42:
//write to file "JMP"
break;
case 43:
//write to file "JMPEQ"
break;
case 44:
//write to file "JMPNE"
break;
case 45:
//write to file "JMPGT"
break;
case 46:
//write to file "JMPGE"
break;
case 47:
//write to file "JMPLT"
break;
case 48:
//write to file "JMPLE"
break;
case 49:
//write to file "STX"
break;
case 50:
//write to file "STKX"
break;
case 51:
//write to file "INC"
break;
case 52:
//write to file "DEC"
break;
case 53:
//write to file "ADD"
break;
case 54:
//write to file "SUB"
break;
case 55:
//write to file "MUL"
break;
case 56:
//write to file "DIV"
break;
case 57:
//write to file "MOD"
break;
case 58:
//write to file "CMP"
break;
default:
break;
}
}
}
}
}
private static BufferedReader openFile(String fileName)
throws IOException {
// Don't forget to add buffering to have better performance!
return new BufferedReader(
new InputStreamReader(
new FileInputStream(fileName),
StandardCharsets.UTF_8));
}
}