blob: 4a7b233baac9be92a8508efe6c6b7c9b8bf8ab75 (
plain)
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
|
package com.zylin.zpu.simulator.tools;
import java.io.FileInputStream;
import java.io.IOException;
public class MakeRam
{
public static void main(String[] args) throws IOException
{
new MakeRam().run(args[0]);
}
private void run(String string) throws IOException
{
FileInputStream file=new FileInputStream(string);
int i=0;
while (file.available()>4)
{
byte[] tmp=new byte[4];
file.read(tmp);
int word=0;
for (int j=0; j<4; j++)
{
word|=((int)(tmp[j])&0xff)<<((3-j)*8);
}
String str=Integer.toHexString(word);
while (str.length()<8)
{
str="0"+str;
}
System.out.println("" + i + " => x\"" + str + "\",");
i++;
}
}
}
|