Move ARM disassembler out of libacc and into the acc command-line tool.
diff --git a/include/acc/acc.h b/include/acc/acc.h
index af21a46..1182355 100644
--- a/include/acc/acc.h
+++ b/include/acc/acc.h
@@ -77,6 +77,12 @@
 void accGetPragmas(ACCscript* script, ACCsizei* actualStringCount,
                    ACCsizei maxStringCount, ACCchar** strings);
 
+/* Used to implement disassembly */
+
+void accGetProgramBinary(ACCscript* script,
+    ACCvoid** base,
+    ACCsizei* length);
+
 #ifdef __cplusplus
 };
 #endif
diff --git a/libacc/Android.mk b/libacc/Android.mk
index f77e2b3..2b4998e 100644
--- a/libacc/Android.mk
+++ b/libacc/Android.mk
@@ -7,10 +7,6 @@
 LOCAL_MODULE:= libacc
 LOCAL_SRC_FILES := acc.cpp
 
-ifeq ($(TARGET_ARCH),arm)
-LOCAL_SRC_FILES += disassem.cpp
-endif
-
 LOCAL_SHARED_LIBRARIES := libdl libcutils
 
 include $(BUILD_SHARED_LIBRARY)
@@ -24,10 +20,6 @@
 
 LOCAL_CFLAGS := -O0 -g
 
-ifeq ($(TARGET_ARCH),arm)
-LOCAL_SRC_FILES += disassem.cpp
-endif
-
 LOCAL_STATIC_LIBRARIES := libcutils
 LOCAL_LDLIBS := -ldl
 
diff --git a/libacc/acc.cpp b/libacc/acc.cpp
index b8ff29d..81d30ad 100644
--- a/libacc/acc.cpp
+++ b/libacc/acc.cpp
@@ -39,10 +39,6 @@
 #define PROVIDE_X64_CODEGEN
 #endif
 
-#ifdef PROVIDE_ARM_CODEGEN
-#include "disassem.h"
-#endif
-
 #if (defined(__VFP_FP__) && !defined(__SOFTFP__))
 #define ARM_USE_VFP
 #endif
@@ -55,7 +51,6 @@
 #define LOG_STACK(...) do {} while(0)
 // #define LOG_STACK(...) fprintf (stderr, __VA_ARGS__)
 
-#define ENABLE_ARM_DISASSEMBLY
 // #define PROVIDE_TRACE_CODEGEN
 
 // Uncomment to save input to a text file in DEBUG_DUMP_PATTERN
@@ -484,11 +479,6 @@
          */
         virtual void adjustStackAfterCall(Type* pDecl, int l, bool isIndirect) = 0;
 
-        /* Print a disassembly of the assembled code to out. Return
-         * non-zero if there is an error.
-         */
-        virtual int disassemble(FILE* out) = 0;
-
         /* Generate a symbol at the current PC. t is the head of a
          * linked list of addresses to patch.
          */
@@ -695,9 +685,9 @@
     public:
         ARMCodeGenerator() {
 #ifdef ARM_USE_VFP
-            LOGD("Using ARM VFP hardware floating point.");
+            // LOGD("Using ARM VFP hardware floating point.");
 #else
-            LOGD("Using ARM soft floating point.");
+            // LOGD("Using ARM soft floating point.");
 #endif
         }
 
@@ -1764,24 +1754,6 @@
 #endif
         }
 
-        virtual int disassemble(FILE* out) {
-#ifdef ENABLE_ARM_DISASSEMBLY
-            disasmOut = out;
-            disasm_interface_t  di;
-            di.di_readword = disassemble_readword;
-            di.di_printaddr = disassemble_printaddr;
-            di.di_printf = disassemble_printf;
-
-            int base = getBase();
-            int pc = getPC();
-            for(int i = base; i < pc; i += 4) {
-                fprintf(out, "%08x: %08x  ", i, *(int*) i);
-                ::disasm(&di, i, 0);
-            }
-#endif
-            return 0;
-        }
-
         /**
          * alignment (in bytes) for this type of data
          */
@@ -1833,27 +1805,6 @@
         }
 
     private:
-        static FILE* disasmOut;
-
-        static u_int
-        disassemble_readword(u_int address)
-        {
-            return(*((u_int *)address));
-        }
-
-        static void
-        disassemble_printaddr(u_int address)
-        {
-            fprintf(disasmOut, "0x%08x", address);
-        }
-
-        static void
-        disassemble_printf(const char *fmt, ...) {
-            va_list ap;
-            va_start(ap, fmt);
-            vfprintf(disasmOut, fmt, ap);
-            va_end(ap);
-        }
 
         static const int BRANCH_REL_ADDRESS_MASK = 0x00ffffff;
 
@@ -2783,10 +2734,6 @@
             return 5;
         }
 
-        virtual int disassemble(FILE* out) {
-            return 0;
-        }
-
         /* output a symbol and patch all calls to it */
         virtual void gsym(int t) {
             int n;
@@ -3114,10 +3061,6 @@
             return mpBase->jumpOffset();
         }
 
-        virtual int disassemble(FILE* out) {
-            return mpBase->disassemble(out);
-        }
-
         /* output a symbol and patch all calls to it */
         virtual void gsym(int t) {
             fprintf(stderr, "gsym(%d)\n", t);
@@ -5755,15 +5698,6 @@
         return true;
     }
 
-    int dump(FILE* out) {
-        fwrite(codeBuf.getBase(), 1, codeBuf.getSize(), out);
-        return 0;
-    }
-
-    int disassemble(FILE* out) {
-        return pGen->disassemble(out);
-    }
-
     /* Look through the symbol table to find a symbol.
      * If found, return its value.
      */
@@ -5796,10 +5730,14 @@
         }
     }
 
+    void getProgramBinary(ACCvoid** base, ACCsizei* length) {
+        *base = codeBuf.getBase();
+        *length = (ACCsizei) codeBuf.getSize();
+    }
+
     char* getErrorMessage() {
         return mErrorBuf.getUnwrapped();
     }
-
 };
 
 const char* Compiler::operatorChars =
@@ -5813,10 +5751,6 @@
             2, 2 /* ~ ! */
             };
 
-#ifdef PROVIDE_ARM_CODEGEN
-FILE* Compiler::ARMCodeGenerator::disasmOut;
-#endif
-
 #ifdef PROVIDE_X86_CODEGEN
 const int Compiler::X86CodeGenerator::operatorHelper[] = {
         0x1,     // ++
@@ -6014,8 +5948,9 @@
 }
 
 extern "C"
-void accDisassemble(ACCscript* script) {
-    script->compiler.disassemble(stderr);
+void accGetProgramBinary(ACCscript* script,
+    ACCvoid** base, ACCsizei* length) {
+    script->compiler.getProgramBinary(base, length);
 }
 
 
diff --git a/libacc/tests/Android.mk b/libacc/tests/Android.mk
index 77e48be..e9fbe03 100644
--- a/libacc/tests/Android.mk
+++ b/libacc/tests/Android.mk
@@ -21,7 +21,8 @@
 LOCAL_MODULE:= acc
 
 LOCAL_SRC_FILES:= \
-	main.cpp
+	main.cpp \
+    disassem.cpp
 
 LOCAL_SHARED_LIBRARIES := \
     libacc
diff --git a/libacc/armreg.h b/libacc/tests/armreg.h
similarity index 100%
rename from libacc/armreg.h
rename to libacc/tests/armreg.h
diff --git a/libacc/disassem.cpp b/libacc/tests/disassem.cpp
similarity index 100%
rename from libacc/disassem.cpp
rename to libacc/tests/disassem.cpp
diff --git a/libacc/disassem.h b/libacc/tests/disassem.h
similarity index 100%
rename from libacc/disassem.h
rename to libacc/tests/disassem.h
diff --git a/libacc/tests/main.cpp b/libacc/tests/main.cpp
index 5e9e816..311fec0 100644
--- a/libacc/tests/main.cpp
+++ b/libacc/tests/main.cpp
@@ -20,6 +20,14 @@
 #include <unistd.h>
 #endif
 
+#if defined(__arm__)
+#define PROVIDE_ARM_DISASSEMBLY
+#endif
+
+#ifdef PROVIDE_ARM_DISASSEMBLY
+#include "disassem.h"
+#endif
+
 #include <acc/acc.h>
 
 
@@ -29,15 +37,57 @@
     return mainFunc(argc, argv);
 }
 
-// Private API for development:
-
-extern "C"
-void accDisassemble(ACCscript* script);
-
 ACCvoid* symbolLookup(ACCvoid* pContext, const ACCchar* name) {
     return (ACCvoid*) dlsym(RTLD_DEFAULT, name);
 }
 
+#ifdef PROVIDE_ARM_DISASSEMBLY
+
+static FILE* disasmOut;
+
+static u_int
+disassemble_readword(u_int address)
+{
+    return(*((u_int *)address));
+}
+
+static void
+disassemble_printaddr(u_int address)
+{
+    fprintf(disasmOut, "0x%08x", address);
+}
+
+static void
+disassemble_printf(const char *fmt, ...) {
+    va_list ap;
+    va_start(ap, fmt);
+    vfprintf(disasmOut, fmt, ap);
+    va_end(ap);
+}
+
+static int disassemble(ACCscript* script, FILE* out) {
+    disasmOut = out;
+    disasm_interface_t  di;
+    di.di_readword = disassemble_readword;
+    di.di_printaddr = disassemble_printaddr;
+    di.di_printf = disassemble_printf;
+
+    ACCvoid* base;
+    ACCsizei length;
+
+    accGetProgramBinary(script, &base, &length);
+    unsigned long* pBase = (unsigned long*) base;
+    unsigned long* pEnd = (unsigned long*) (((unsigned char*) base) + length);
+
+    for(unsigned long* pInstruction = pBase; pInstruction < pEnd; pInstruction++) {
+        fprintf(out, "%08x: %08x  ", (int) pInstruction, *pInstruction);
+        ::disasm(&di, (uint) pInstruction, 0);
+    }
+    return 0;
+}
+
+#endif // PROVIDE_ARM_DISASSEMBLY
+
 int main(int argc, char** argv) {
     const char* inFile = NULL;
     bool printListing;
@@ -121,7 +171,9 @@
     }
 
     if (printListing) {
-        accDisassemble(script);
+#ifdef PROVIDE_ARM_DISASSEMBLY
+        disassemble(script, stderr);
+#endif
     }
 
     if (runResults) {