The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Accessing Registers

Posted by Matt Gerrans on September 23, 2001 at 11:01 PM

that is stored in the PC register. But is there an easy way to access the same to get the information?

What are you talking about? The next bytecode to be executed by the JVM, or next machine code to be executed by the CPU? Java programs run in a virutal machine, so the next instruction in the PC register is the next instruction of the JVM to execute, not the Java program that it is running. And if I rembmer correctly, the JVM doesn't even use virtual registers, everything is stack-based. By the way, the CPU's next instruction is not in a register, rather there is a register, called IP, that *points* to where the next instruction is.

If you want to do low-level debugging of what is going on in the CPU, this can be done with any comercial C/C++ debugger (commercial compilers include one and you can get them stand-alone, like Turbo Debugger, which I think can be downloaded for free from Borland, these days). All you have to do is open java.exe in the debugger and start stepping through the code. It'll be a lot of steps, of course. Have fun!

Now, if what you are looking for is a byte-code level debugger, it may exist. If what to you mean by "next instruction" is the next line of Java code, then all you need is a standard debugger for Java, which is easy to find (Borland's JBuilder, etc.). If all you are looking for is an example of how bytecodes are executed, Mr. Venners has an example from his book which you can no doubt find elsewhere on, as well.


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us