Sunday, September 28, 2008

Question # 2

Research in the net usual applications done in assembly language. Describe these applications briefly and cite the efficiency and effectiveness of these applications.
Launch Java Applications from Assembly Language Programs

JavaNative Interface (JNI) is a mechanism that can be used toestablish communication between native language programs and theJava virtual machine. The documentation for JNI and the technicalliterature on JNI deal extensively with interactions between theJVM and C/C++ code. The Java SDK even provides a utility togenerate a header file to facilitate calling C/C++ programs fromJava code. However, there is hardly any mention of Java andassembly language code working together. In an earlier article I showed how assembly language programs can becalled from Java applications. Here I deal with the technique forinvoking Java programs from an ASM process through a demoapplication that calls a Java method from assembly language code.The Java method brings up a Swing JDialog to show thatit has, indeed, been launched.
Why Java with ASM?
JNI is essential to the implementation of Java, since the JVMneeds to interact with the native platform to implement some of itsfunctionality. Apart from that, however, use of Java classes canoften be an attractive supplement to applications written in otherlanguages, as Java offers a wide selection of APIs that makesimplementation of advanced functions very simple.Some time ago, I was associated with an application to collectreal-time data from a number of sources and save them in circularbuffers so that new data would overwrite old data once the buffergot filled up. If a designated trigger event was sensed through adigital input, a fixed number of data samples would be saved in thebuffers so that a snapshot of pre- and post-trigger data would beavailable. The original application was written in assemblylanguage. After the application was used for a few months, it wasfelt that it would be very useful to have the application mail thesnapshots to authorized supervisors whenever the trigger eventoccurred. Of course, it would have been possible to write thisextension in assembly, but the team felt that in that particularinstance it was easier to write that extension in Java and hook itup with the ASM program. As I had earlier worked with ASM-orientedJNI, I knew this could be done and, indeed, the project wasimplemented quickly and successfully.I am sure there are many legacy applications written in assemblylanguage that could benefit from such add-ons. However, it is notonly for old applications in need of renovation that JNI can proveuseful. Although it may seem unlikely to some of us, assemblylanguage is still used for writing selected portions of newprograms.

No comments: