-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrep
executable file
·21 lines (20 loc) · 1.08 KB
/
rep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/sh
sed -r -i -e '
s/; [^\/].*/\/\/ \0/
s/lb \$([^,]*), login\(\$([^\)]*)\)/\1 = login[\2]\; \/\/ \0/g;
s/sb \$([^,]*), login\(\$([^\)]*)\)/login[\2] = \1\; \/\/ \0/g;
s/sw \$([^,]*), login\(\$([^\)]*)\)/*(int *)(login + \2) = \1\; \/\/ \0/g;
s/lw \$([^,]*), login\(\$([^\)]*)\)/\1 = *(int *)(login + \2)\; \/\/ \0/g;
s/daddi \$([^,]*), \$([^,]*), (.*)/\1 = \2 + \3\; \/\/ \0/g;
s/dsub \$([^,]*), \$([^,]*), \$(.*)/\1 = \2 - \3\; \/\/ \0/g;
s/sltu \$([^,]*), \$([^,]*), \$(.*)/\1 = \2 < \3\; \/\/ \0/g;
s/dsrl \$([^,]*), \$([^,]*), (.*)/\1 = \2 >> \3\; \/\/ \0/g;
s/dsll \$([^,]*), \$([^,]*), (.*)/\1 = \2 << \3\; \/\/ \0/g;
s/andi \$([^,]*), \$([^,]*), (.*)/\1 = \2 \& \3\; \/\/ \0/g;
s/beq \$([^,]*), \$([^,]*), (.*)/if (\1 == \2) goto \3\; \/\/ \0/g;
s/bne \$([^,]*), \$([^,]*), (.*)/if (\1 != \2) goto \3\; \/\/ \0/g;
s/bgez \$([^,]*), (.*)/if (\1 >= 0) goto \2\; \/\/ \0/g;
s/beqz \$([^,]*), (.*)/if (\1 == 0) goto \2\; \/\/ \0/g;
s/bnez \$([^,]*), (.*)/if (\1 != 0) goto \2\; \/\/ \0/g;
s/j (.*)/goto \1\; \/\/ \0/g;
' $1