1 package com.tapina.robe.swi;
2
3 import com.tapina.robe.runtime.Environment;
4
5 import java.lang.reflect.Method;
6
7 /***
8 * Floating point emulator SWIs.
9 * Currently there are no floating point instructions available.
10 */
11 public class FPEmulator extends SWIHandler {
12 private static FPEmulator ourInstance;
13
14 public synchronized static FPEmulator getInstance() {
15 if (ourInstance == null) {
16 ourInstance = new FPEmulator();
17 }
18 return ourInstance;
19 }
20
21 private FPEmulator() {
22 }
23
24 public static int getBase() {
25 return 0x40480;
26 }
27
28 private static final String[] methodNames = new String[]{
29 "Version", "", "", "", "", "", "", "",
30 "", "", "", "", "", "", "", "",
31 "", "", "", "", "", "", "", "",
32 "", "", "", "", "", "", "", "",
33 "", "", "", "", "", "", "", "",
34 "", "", "", "", "", "", "", "",
35 "", "", "", "", "", "", "", "",
36 "", "", "", "", "", "", "", ""
37 };
38
39 public static Method getMethod(Integer offset) throws NoSuchMethodException {
40 return getMethod(methodNames[offset.intValue()]);
41 }
42
43 private static final Method getMethod(String name) throws NoSuchMethodException {
44 return FPEmulator.class.getMethod(name, METHOD_PARAMETERS);
45 }
46
47 /***
48 * This SWI returns the version of the floating point emulator in use.
49 * @param env OUT: R0 = version of FPEmulator * 100
50 */
51 public final void Version(Environment env) {
52 env.getCpu().R[0] = version();
53 }
54
55 public final int version() {
56 return 400;
57 }
58
59 }