File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "help" Watch "help" New topic
Author

help

Victoria Preston
Ranch Hand

Joined: Feb 03, 2006
Posts: 106
I am suppose to write classes for machine language code. I am suppose to take the description and wtire it in java. For instance a "LOAD RXY" is load the register R wtih the bit pattern found in the memory cell whose address is XY. I already have a class of registers and memory I just do not know how to start writting the code for a load.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Well, ultimately you're just going to do:


int data = memory.fetch(xy);
registers.load(R, data);

You'll have lots of little snips like this, one for each instruction. At some point, you're probably going to have to parse the instructions and figure out which one to call. A "switch" statement is one obvious way to do the latter.

But to get started, you might write a bunch of little instruction routines like the above, and try calling them from a test driver. You're definitely going to want some debug output routines to display the contents of memory and registers so that you can see if your instructions are doing the right thing.

Come to think of it, I guess I was helping you debug your "memory" class the other day, wasn't I?


[Jess in Action][AskingGoodQuestions]
Victoria Preston
Ranch Hand

Joined: Feb 03, 2006
Posts: 106
yep....I got that part done thanks to you. I will try what you suggested and get back to you....thanks
Victoria Preston
Ranch Hand

Joined: Feb 03, 2006
Posts: 106
this is what I have so far...let me know if this makes any sense.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help