8

How do I code a C# program within visual studio that simulates MARIE?

 2 years ago
source link: https://www.codeproject.com/Questions/5317498/How-do-I-code-a-Csharp-program-within-visual-studi
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
I have a coding assignment that requires me to create a program in C#, within Visual Studio, that simulates MARIE. It needs to have global variables such as PC, MAR, MBR, AC, IR, etc. It needs to implement, fetch, decode and execute cycles. For instance, during the fetch cycle, the code needs to first place PC in MAR, then use MAR to access memory (array element) and grab the content and put it in IR and increment PC.

For example, let's say PC = 0, the code will place PC which is zero inside MAR, now MAR is zero, then the program will read memory[MAR] and save its content in IR register (variable) and increment PC which becomes 1. Next, you will check the first 4 bits of IR (in this example it is 0001, based on the 4 bits, the program needs to call Load function. Since Load command has an operant, the code also needs to put the remaining 12 bits of the IR inside MAR to be able to access the memory location MAR. Next, it grabs the content of memory[MAR] and converts it into integer (decimal value) and loads it into AC.

Some of these variables must be of type string, for instance the IR register and some of them such as PC is of type int. It also needs to implement functions to convert binary to decimal and a function to convert decimal to binary.

Here are some of the arrays that need to go into visual studio but I don't know what else needs to go with it:
Expand ▼   Copy Code
memory[0] = "0001000000010001"; // Load Addr

memory[1] = "0010000000010010"; // Store Next

memory[2] = "0001000000010011"; // Load Num

memory[3] = "0100000000010110"; //Subt One

memory[4] = "0010000000010101"; // Store Ctr

memory[5] = "0001000000010100"; //LOOP: Load Sum

memory[6] = "1011000000010010"; // AddI Next

memory[7] = "0010000000010100"; //Store Sum

memory[8] = "0001000000010010"; //Load Next

memory[9] = "0011000000010110"; //Add One

memory[10] = "0010000000010010"; //Store Next

memory[11] = "0001000000010101"; // Load Ctr

memory[12] = "0100000000010110"; //Subt One

memory[13] = "0010000000010101"; //Store Ctr

memory[14] = "1000000000000000"; // Skipcond

memory[15] = "1001000000000101"; //Jump

memory[16] = "0111000000000000"; // Halt

memory[17] = "0000000000010111"; //Addr

memory[18] = "0000000000000000"; // Next

memory[19] = "0000000000000101"; // Num

memory[20] = "0000000000000000"; //Sum

memory[21] = "0000000000000000"; // Ctr

memory[22] = "0000000000000001"; //One

memory[23] = "0000000000001010"; //Dec 10

memory[24] = "0000000000001111"; // Dec 15

memory[25] = "0000000000010100"; //Dec 20

memory[26] = "0000000000011001"; //Dec 25

memory[27] = "0000000000011110"; //Dec 30


What I have tried:

I've tried seeing if YouTube has any tutorials and so I don't know where to start and I've never coded anything like this before.
Comments
That reminds me of an assignment from my "History of Programming Languages" (or whatever) course back in college. But it looks like you have more bytes to work with, we had ten.
It's really pretty simple.
If we/others do your homework, you will learn nothing.

How do you code a program that simulates MARIE? - Reddithttps://www.reddit.com › AskProgramming › comments
2 days ago — Find the specs for how a MARIE CPU is supposed to work, implement a ... Going deeper, maybe you want to simulate each clock cycle, ...

How do I code a program in C# within Visual Studio that ...https://stackoverflow.com › questions › how-do-i-code-...
4 hours ago — I have a coding assignment due in 3 days that requires me to create a program in C#, within Visual Studio, that simulates MARIE.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK