Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Lab Session-IV CSIT-120 Fall 2000 Precedence Rules Machine Language Programming The “Micro” Machine The “Micro” Simulator The “Micro” Translator (Thanks.

Similar presentations


Presentation on theme: "1 Lab Session-IV CSIT-120 Fall 2000 Precedence Rules Machine Language Programming The “Micro” Machine The “Micro” Simulator The “Micro” Translator (Thanks."— Presentation transcript:

1

2 1 Lab Session-IV CSIT-120 Fall 2000 Precedence Rules Machine Language Programming The “Micro” Machine The “Micro” Simulator The “Micro” Translator (Thanks to Genti) Experiment 4.1 and Lab Exercise 4-B Experiment 4.2 Lab 4 Continued

3 2 Mixing Arithmetic Operations When we try to perform several arithmetic operations in one expression, the expression becomes quite complex For example, consider the following Q = (A+B*C)(A+B/C) Q = ((A+B)*C)((A+B)/C)??? Q = (A+(B*C))(A+(B/C))???

4 3 Precedence Rules In order to resolve complex expressions without any ambiguity, a set of precedence rules is defined ( )Parenthesis have top priority In arithmetic operations, * and / take precedence over + and - = has lowest priority

5 4 Machine Language Programming All programs written in C++, Java or any other user-level language are translated to the machine language after compilation Look at an example that shows how a C++ program line will be converted to the machine language of “Micro”, an example machine

6 5 C++ Program My_var = this_data+next_data Compilation and Linking 0001010100111111//Load R5 from Memory 0001010000111110//Load R4 from Memory 0110011001010100//Add R4,R5 & store result in R6 0011011000111101//Store R6 into Memory The Compilation of Programs

7 6 Machine Language Programs A compiled and linked program is a series of machine language instructions and data Each processor has its own set of machine language instructions Can programs compiled for Pentium II run on Alpha workstation?

8 7 The “Micro” Machine The Micro Machine has >256 Memory cells, each cell can hold 1 byte >Memory addresses range 00-FF (two digits) >16 General Purpose Registers >Register addresses range 0-F (one digit) >Program Counter and Instruction Register >12 Machine Language Instructions (1-C)

9 8 The “Micro” Simulator The “Micro” Simulator is a C++ Program Download this program by visiting “The Micro” link in the labs webpage of the course Click on “micro” to download or cut & paste this program and save as a C++ file Double click on this file to run Visual C++ Compile and run the program

10 9 The Micro Simulator The full screen display shows the contents of the memory from cell 00 to cell FF It also shows contents of registers R0 through R15 PC and IR contents are visible too The machine has several single-letter commands (4-A): Experiment 4.1 (PC incr?)

11 10 Genti’s Translator It is obvious that writing hex code is cryptic and prone to errors. If anything goes wrong, it is difficult to trace the errors (or debug the code) To make it “human-friendly”, Our TA last semester Mr. Genti developed a translator for the assembly language of “micro”

12 11 Genti’s Translator This translator assumes the program is written using some suggested mnemonics Following is a list of instructions and their corresponding hex code and mnemonics

13 12 Genti’s Translator

14 13 Strategy for Programming “Micro” Develop your program using this list in a text file using wordpad or notepad Run Genti’s translator by using the link given in the course web pages Program asks for input file name and output file name It will leave the hex code in a text file Keep that file in view when you load the program into “micro” simulator

15 14 The Power to Simulate The Micro Simulator can run programs designed by you too Lab Exercise 4-B Design a program that adds values 1 through 5 together and leaves the result in register R9. These values should be loaded into the memory by hand. (4-C) Experiment 4.2

16 15 Lab-4 Continued The Micro Machine and its Simulator The JUMP instruction and its usage Experiment 4.4

17 16 Micro and its Simulator What is the memory size in Micro? How many instructions are there? How can we start executing a program in Micro? What is the difference between S and G commands? What does Genti’s Translator do?

18 17 JUMP Instruction JUMP instruction is provided to facilitate the implementation of loops and branches Its format is B RXY (JUMP RXY) It means “jump to location XY if R=R0 Unconditional jump if R0 compared to itself Experiment 4.4


Download ppt "1 Lab Session-IV CSIT-120 Fall 2000 Precedence Rules Machine Language Programming The “Micro” Machine The “Micro” Simulator The “Micro” Translator (Thanks."

Similar presentations


Ads by Google