• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help

 
Victoria Preston
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Victoria Preston
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is what I have so far...let me know if this makes any sense.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic