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

Slides:



Advertisements
Similar presentations
Goal: Write Programs in Assembly
Advertisements

ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
Lecture Roger Sutton 21: Revision 1.
Algorithms and Problem Solving
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Chapter 9. 2 Objectives You should be able to describe: Addresses and Pointers Array Names as Pointers Pointer Arithmetic Passing Addresses Common Programming.
Pointers Pointer - A pointer is a derived data type; that is it is a data type built from one of the standard types. Its value is any of the addresses.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Chapter 6. 2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single Value Pass by Reference Variable Scope.
CS 106 Introduction to Computer Science I 03 / 03 / 2008 Instructor: Michael Eckmann.
Even More C Programming Pointers. Names and Addresses every variable has a location in memory. This memory location is uniquely determined by a memory.
1. 2 FUNCTION INLINE FUNCTION DIFFERENCE BETWEEN FUNCTION AND INLINE FUNCTION CONCLUSION 3.
Introduction to C Programming
Pointers Applications
Macro & Function. Function consumes more time When a function is called, the copy of the arguments are passed to the parameters in the function. After.
Keystone Problems… Keystone Problems… next Set 19 © 2007 Herbert I. Gross.
11 Chapter 4 LOOPS AND FILES. 22 THE INCREMENT AND DECREMENT OPERATORS To increment a variable means to increase its value by one. To decrement a variable.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Welcome to CS 3260 Dennis A. Fairclough. Overview Course Canvas Web Site Course Materials Lab Assignments Homework Grading Exams Withdrawing from Class.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
Objective At the conclusion of this chapter you will be able to:
Von Neumann Machine Objectives: Explain Von Neumann architecture:  Memory –Organization –Decoding memory addresses, MAR & MDR  ALU and Control Unit –Executing.
Pointers: Basics. 2 What is a pointer? First of all, it is a variable, just like other variables you studied  So it has type, storage etc. Difference:
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Assembly Language CS 333 Sam Houston State University Dr. Tim McGuire.
Kirk Scott Computer Science The University of Alaska Anchorage 1.
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week 02  Reading: Textbook(4 th Ed.), Chapter 2 Textbook (6 th Ed.), Chapters.
Intermediate 2 Computing Unit 2 - Software Development.
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming –TextField Action Listeners, JEditorPane action listeners, HTML in a JEditorPane,
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Assembly Language CS 333 Sam Houston State University Dr. Tim McGuire.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
A FIRST BOOK OF C++ CHAPTER 8 ARRAYS AND POINTERS.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Mastering LMC Coding Part #1 Introduction to Low Level Languages Introduction to Little Man computer Simple examples (demos) with video tutorials included.
You learned how to declare pointer variables how to store the address of a variable into a pointer variable of the same type as the variable how to manipulate.
Data Structures & Algorithms CHAPTER 2 Arrays Ms. Manal Al-Asmari.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
SPACE COMPLEXITY & TIME COMPLEXITY 1. ALGORITHMS COMPLEXITY 2.
User-Written Functions
Chapter 2 - Introduction to C Programming
Functions CIS 40 – Introduction to Programming in Python
Chapter 2 - Introduction to C Programming
Unit# 9: Computer Program Development
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Programming in JavaScript
Computer Architecture and the Fetch-Execute Cycle
Chapter 2 - Introduction to C Programming
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Objectives You should be able to describe: Addresses and Pointers
Programming in JavaScript
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Chapter 2 - Introduction to C Programming
Review of Previous Lesson
Introduction to C Programming
Presentation transcript:

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

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

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

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

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

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

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

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

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 , on a CD, or any other suitable medium. 9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

The End 31