Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.

Similar presentations


Presentation on theme: "CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1."— Presentation transcript:

1 CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1

2 Brief Description of the Assignment The assignment is to rewrite the Osystem with modifications to the Machine to handle the scenario described after this initial listing of administrative details 2

3 The given MISC files are version 1 and have "V1" in their names. The naming convention will be to increment the version number in the file names for each of the assignments 3

4 You may have encountered MISC before. Do not use graphical versions of the MISC code. This assignment is a non-graphical assignment. Just use the V1 files given on the CS 320 page. 4

5 What You Have to Hand In These files: – MachineOSProgramV2.java – OsystemV2.java – MachineV2.java – MachineWordV2.java – MachineByteV2.java – MyTerminalIO.java – and sumtenV2.txt 5

6 Relatively minor changes will be needed in the MachineV2.java file The major part of the assignment consists of changes needed in OsystemV2.java 6

7 The following files are unchanged from their previous versions other than their names: – MachineOSProgramV2.java – MachineWordV2.java – MachineByteV2.java – MyTerminalIO.java – and sumtenV2.java 7

8 All you need to do is rename them and change the names of the classes declared in them, if any. This is a simple matter using search and replace in the editor 8

9 You need to give me all of the files needed to successfully compile and run your version of the solution on my computer You can hand these things by email, on a CD, or any other suitable medium. 9

10 Grading Grading will be based on black box testing Half credit for handing in something that looks like an honest attempt to write the code, but doesn’t work Full credit for a working copy that will correctly run sumtenV2.txt This will be evident if the dmc output shows that the program was loaded at a location other than address 0 in the machine and it has correctly calculated the sum of the first ten integers 10

11 Detailed Description of the Assignment The overall goal of the assignment is to make it possible to load a program and run a program at a memory offset other than 0 Having this ability is a step in the direction of having a simulation where it is possible to have more than one program loaded at a time Loading and running from an offset other than 0 entails a few details at a conceptual level, which are described below 11

12 Let it be specified that base addresses for loaded programs have to be multiples of 32 Remember that offset addressing is by word, not by byte Which offset will be used will not be determined by the user This will be determined by the Osystem. 12

13 The Osystem will have to check and adjust instructions in the machine language program before loading them Any machine language instructions that involve a memory variable will have to have the operand that refers to the variable’s offset incremented by whatever the load address was Likewise, any jump instructions will have to have the jump address operand incremented 13

14 Changes to the Code What follows are two relatively complete, although not exhaustively detailed outlines of changes that will have to be made in the code in order to support the scenario described above You do not have to follow these outlines exactly, but you do have to end up with code that will run the machine language program at an address other than 0 with changes only to the MachineV2 and OsystemV2 classes 14

15 Changes to MachineV2.java In the MachineV2 class it’s helpful to declare a public static final integer variable that tells how many lines in a machine language source program are set aside for memory variables In effect, the machine language specifications already use 8 for this value, so this can be coded into the simulation. 15

16 In the takeControl() method it’s necessary to take in an integer parameter that tells the load address of the program that is to take control of the machine This value is passed to the resetOffsets() method when it’s called in takeControl(). 16

17 In the resetOffsets() method the data offset register can be reset directly to the value of the parameter passed in The code offset register can be reset to the value of the parameter plus the value of the static final integer variable mentioned above. 17

18 With the exception of these changes to the machine involving the address of the loaded program, no other changes should be made to the way the machine works in order to solve this assignment. 18

19 Changes to OsystemV2.java In the OsystemV2 class it is helpful to declare a public static final integer variable that is assigned the same value as the variable in the MachineV2 class that tells how many lines in a machine language source program are set aside for memory variables. 19

20 It is also helpful to declare a private static integer variable that is assigned the offset to load a program to It is not necessary to code any flexibility into the system at this point In order to make sure you’re not going astray, make sure that the value you set the load offset to is 32, for example Do not set it to 0. Although your code might be correct, under black box testing a value of 0 would cause the output to appear to be in error 20

21 The most basic requirements of this assignment are that the machine code be loaded at an offset in memory, and that all memory references in the code be adjusted to reflect the offset location There would be several ways to accomplish this You could, for example, write a pre-processor for the source machine code 21

22 For the purposes of this assignment I recommend writing a static method to check each line of machine code and adjust any memory references in it right before loading This method can be called from the runProgramFile() method. Such a method for checking and adjusting lines of code would take the 4 bytes of a line of code and the load address as parameters 22

23 It would return a MachineWord containing the adjusted line of code It would check the parameter containing the first byte of every line to see what the instruction is For every move, add, or subtract instruction that had a memory variable as an operand, it would add the load offset to that operand The methods getIntFromByte() and copyIntToByte() can be used to update the contents of the byte. 23

24 The structure of the method would be reminiscent of the structure of the takeControl() method in the machine In other words, you can probably save yourself some typing by lifting the multiple if statements from that method to check for the various operators 24

25 Keep in mind that some of the arithmetic and move instructions don’t have memory operands, while for some the memory operand comes first, and for others the memory operand comes second Every jump instruction has a memory location as its first operand, and these should be adjusted in the same way After updating any bytes that need to be update, constructing and returning the word containing the updated bytes should be relatively straightforward. 25

26 In the runProgramFile() method it would be necessary to distinguish between lines of data and lines of code Inside the loop where the lines are read, an if statement can check to see whether the count of lines is still below the value of the static final variable telling how many lines are set aside for variables 26

27 If so, the word to load can be constructed without calling the method to do adjustments If not, the word to load is obtained from a call to the method explained above Wherever the word comes from, it is loaded as before, only with its offset being formed from adding its offset in the source file to the load offset of the program. 27

28 Finally, takeControl() is called as before, except that it is now passed a parameter, the variable containing the load offset chosen for the program for this particular test run. 28

29 It should be relatively easy to tell whether or not the updated Machine and Osystem work correctly You would do rpf on sumtenV2.txt Then you would do dmc 29

30 Inside the dmc file you would expect to see the same thing you saw in version 1 of the code, except that everything would be moved to a new memory offset, say 32 In particular, if the run was successful, you would expect to see not only the data segment and code segment of the source program in new locations in memory, but the result of the program run, the decimal value 55 shown in base 2, at offset 1 from the load address. 30

31 The End 31


Download ppt "CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1."

Similar presentations


Ads by Google