Topics. Structured Computer Organization. Assembly language. IJVM instruction set. Mic-1 simulator programming

Similar documents
Topics. Block Diagram of Mic-1 Microarchitecture. Review Sheet. Microarchitecture IJVM ISA

The Microarchitecture Level

JAM 16: The Instruction Set & Sample Programs

Compiling Techniques

Topics. Computer Organization CS Exam 2 Review. Infix Notation. Reverse Polish Notation (RPN)

JVM. What This Topic is About. Course Overview. Recap: Interpretive Compilers. Abstract Machines. Abstract Machines. Class Files and Class File Format

2.2 THE MARIE Instruction Set Architecture

Compiler construction 2009

Topics. Computer Organization CS Mic-1 Microinstructions. Control Store (ROM) Programming Teams

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

1DT157 Digitalteknik och datorarkitekt. Digital technology and computer architecture, 5p

Recap: Printing Trees into Bytecodes

Chapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats

Chapter 5. A Closer Look at Instruction Set Architectures

Chapter 4. Micro-architecture Level PART I

Course Overview. PART I: overview material. PART II: inside a compiler. PART III: conclusion

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Printing this Slide Show

Principles of Computer Architecture. Chapter 5: Languages and the Machine

Compiler construction 2009

Chapter 5. A Closer Look at Instruction Set Architectures

Chapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats

Course Syllabus [1/2]

1992 Illinois JETS TEAMS Regional Computer Fundamentals Test

Topics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

CSC 4181 Handout : JVM

SOFTWARE ARCHITECTURE 7. JAVA VIRTUAL MACHINE

Code Generation Introduction

Computer Organization and Programming

CMSC430 Spring 2014 Midterm 2 Solutions

Final Exam. 12 December 2018, 120 minutes, 26 questions, 100 points

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Tutorial 3: Code Generation

CSE 431S Code Generation. Washington University Spring 2013

COMP3131/9102: Programming Languages and Compilers

The Java Virtual Machine. CSc 553. Principles of Compilation. 3 : The Java VM. Department of Computer Science University of Arizona

Implementing on Object-Oriented Language 2.14

SaM. 1. Introduction. 2. Stack Machine

Lecture 12 Summary. Goals

An Introduction to Multicodes. Ben Stephenson Department of Computer Science University of Western Ontario

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

Lecture 12 Summary. Main topics What use is this for? What next? Next Courses? Next topics? Teemu Kerola, Copyright 2010

Static Program Analysis

SOEN228, Winter Revision 1.2 Date: October 25,

CS & IT Conversions. Magnitude 10,000 1,

Exercise 7 Bytecode Verification self-study exercise sheet

ECE331: Hardware Organization and Design

Computer Principles and Components 1

231 Spring Final Exam Name:

Over-view. CSc Java programs. Java programs. Logging on, and logging o. Slides by Michael Weeks Copyright Unix basics. javac.

The MARIE Architecture

Lecture 4: Instruction Set Architecture

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

EC 413 Computer Organization

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000

Computer Organization and Assembly Language. Lab Session 01

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1

Representation of Information

CSCE 314 Programming Languages

EXAMINATIONS 2014 TRIMESTER 1 SWEN 430. Compiler Engineering. This examination will be marked out of 180 marks.

Notes: The Marie Simulator

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

data within a computer system are stored in one of 2 physical states (hence the use of binary digits)

A Tour of Language Implementation

Part VII : Code Generation

Code Generation. Frédéric Haziza Spring Department of Computer Systems Uppsala University

Review Questions. 1 The DRAM problem [5 points] Suggest a solution. 2 Big versus Little Endian Addressing [5 points]

1 Little Man Computer

EXAMINATIONS 2008 MID-YEAR COMP431 COMPILERS. Instructions: Read each question carefully before attempting it.

Modesto Junior College Course Outline of Record CMPSC 241

Computer Organization & Assembly Language Programming

Assembly Language LAB

CSc 453 Interpreters & Interpretation

Computer Architecture /

2010 Summer Answers [OS I]

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

CS577 Modern Language Processors. Spring 2018 Lecture Interpreters

Name: University of Michigan uniqname: (NOT your student ID number!)

COSC 6385 Computer Architecture. Instruction Set Architectures

Assembly Language Programming

Instruction Set Architecture

CSE/EE 322: Computer Architecture II Spring The JAM machine Series

JoeQ Framework CS243, Winter 20156


Lecture #6 Intro MIPS; Load & Store

Transfer of Control. Lecture 10 JMP. JMP Formats. Jump Loop Homework 3 Outputting prompts Reading single characters

Java byte code verification

Just In Time Compilation

Lecture 4: MIPS Instruction Set

Levels of Programming. Registers

CS Computer Architecture

MACHINE LEVEL REPRESENTATION OF DATA

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Java and C II. CSE 351 Spring Instructor: Ruth Anderson

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Introduction to Computers - Chapter 4

ORG ; TWO. Assembly Language Programming

1993 Illinois JETS TEAMS District Computer Fundamentals Test. 1. What is the decimal value of the sum of the two unsigned binary values: ?

Transcription:

Topics Assembly language IJVM instruction set Mic-1 simulator programming http://www.ontko.com/mic1/ Available in 2 nd floor PC lab S/W found in directory C:\mic1 1 Structured Computer Organization 2

Block Diagram of Microarchitecture (Mic-1) Datapath Part of CPU containing ALU, its inputs, and its outputs Purpose Implement the ISA level above it (macroarchitecture) Control Section Part of CPU containing the H/W necessary to direct the datapath 3 IJVM Instruction Set ISA level uses machine (binary) language Not very helpful to programmers! Interpretation Software-controlled datapath Require stored program with microinstructions How do we write machine language? 4

Assembly Language Uses symbolic names (mnemonics) and symbolic addresses (variables) for the machine language An assembler converts the assembly language into machine language Each statement produces exactly one machine instruction (1:1 mapping) 5 IJVM Instruction Set Subset of Java Virtual Machine (JVM) Only integer instructions 6

Why Use Assembly? Versus machine language Easier to remember mnemonics for instructions instead of corresponding machine language Easier to work with the symbolic addresses instead of numerical values of address Versus high-level language Access: has access to all features and instructions of the ISA Performance: Code produced can be much smaller (for low-memory devices) and faster (for speed-critical functions) 7 Assembly vs. High-Level Programming 5x effort for 3x speedup 10% of program responsible for 90% of execution time Tune critical 10% for improved performance We will use assembly for the Mic-1 simulator 8

Declaring Variables.main // all variables declared within.var and.end-var.var j i n.end-var // Main program goes here // Program execution is terminated with a HALT statement.end-main 9 BIPUSH value IJVM Assembly Mnemonics Pushes the value onto the stack Octal, decimal, hexadecimal, character (ASCII) ISTORE variable Pops a value from the stack and places it in the variable ILOAD variable Pushes the value in the variable onto the stack 10

BIPUSH value BIPUSH Value Formats Value is one byte Value is decimal by default BIPUSH 32 Leading 0 for octal number BIPUSH 032 Leading 0x for hexadecimal number BIPUSH 0x32 Leading for ASCII characters BIPUSH M 11 IJVM Assembly Mnemonics IADD Pops two values off the stack Adds them together Pushes the result onto the stack ISUB Pops two values off the stack Subtracts the first value popped from the second value popped off the stack Pushes the result onto the stack 12

ISUB in Detail First value popped from stack passes through ALU to H register (A input) Inverting A and adding 1 gives the 2 s complement Second value popped from stack is added to 2 s complement 13 Storing a Value into a Variable Use BIPUSH to push the value onto the stack and then use ISTORE to pop it off and place it in the variable. Use IN to get it from the keyboard and push it onto the stack and then use ISTORE to pop it off and place it in the variable. 14

// i = 3; j = 4; n = i + j; BIPUSH 3 ISTORE i BIPUSH 4 ISTORE j ILOAD i ILOAD j IADD ISTORE n HALT Simple Addition 15 // i = 3; j = 4; n = j - i; BIPUSH 3 ISTORE i BIPUSH 4 ISTORE j ILOAD j ILOAD i ISUB ISTORE n HALT Simple Subtraction 16

IJVM Assembly Mnemonics IINC variable value Adds the value to the variable and stores the result back in the variable DUP Copies the value on the top on the stack and pushes the same value onto the stack The value at the top of the stack and the value one below the top of the stack will be the same (duplicated). 17 Labels and Conditional Statements Label name: A reference to a place in the program L1: BIPUSH 8 IFEQ label name IFEQ L1 Pops a value off the stack if it is equal to zero than the program jumps to the label. GOTO label name GOTO L1 Unconditional jump to the label 18

Loops in Assembly Language BIPUSH 3 ISTORE i L1: ILOAD i IFEQ L2 IINC i -1 GOTO L1 L2: HALT High-level language: for (int i = 3; i = = 0; i--) 19 Other Conditional Statements IFLT label name Pop a value off the stack If the value is less than zero jump to the label IF_ICMPEQ label name Pop 2 values off the stack If they are equal jump to the label. 20

Exercise What does z contain? BIPUSH 4 ISTORE i BIPUSH 1 ISTORE z L1: ILOAD i IFLT L2 ILOAD z DUP IADD ISTORE z IINC i -1 GOTO L1 L2: HALT z = 32 (the loop executes 5x) 21