Chapter 7: Low-Level Programming Languages Chapter 7 Low-Level Programming Languages Page 66 In order to execute instructions on a CPU, those instructions.

Slides:



Advertisements
Similar presentations
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
Advertisements

Week 3. Assembly Language Programming  Difficult when starting assembly programming  Have to work at low level  Use processor instructions >Requires.
 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
Cpe 252: Computer Organization1 Lo’ai Tawalbeh Programming The Basic Computer Chapter 6:
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
2.3) Example of program execution 1. instruction  B25 8 Op-code B means to change the value of the program counter if the contents of the indicated register.
The Assembly Language Level
COE Computer Organization & Assembly Language
Cmput Lecture 8 Department of Computing Science University of Alberta ©Duane Szafron 2000 Revised 1/26/00 The Java Memory Model.
Chapter 3 Assembly Language: Part 1. Machine language program (in hex notation) from Chapter 2.
Low-Level Programming Languages
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
Chapter 7 Low-Level Programming Languages Nell Dale John Lewis.
Implementation of a Stored Program Computer
Introduction to Computers and Programming. Some definitions Algorithm: Algorithm: A procedure for solving a problem A procedure for solving a problem.
Assembly & Machine Languages
Lecture 18 Last Lecture Today’s Topic Instruction formats
The computer memory and the binary number system.
1 CS/COE0447 Computer Organization & Assembly Language Pre-Chapter 2.
CPS120: Introduction to Computer Science
The CPU The Central Presentation Unit Main Memory and Addresses Address bus and Address Space Data Bus Control Bus The Instructions set Mnemonics Opcodes.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Evolution of Programming Languages Generations of PLs.
GCSE Computing#BristolMet Session Objectives#11 MUST identify what program instructions consist of SHOULD describe how instructions are coded as bit patterns.
Implementation of a Stored Program Computer ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides2.ppt Modification date: Oct 16,
ITEC 352 Lecture 12 ISA(3). Review Buses Memory ALU Registers Process of compiling.
Computer Science 101 How the Assembler Works. Assembly Language Programming.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
4-1 Chapter 4 - The Instruction Set Architecture Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
Chapter 2 Data Manipulation Yonsei University 1 st Semester, 2015 Sanghyun Park.
Computer Operations A computer is a programmable electronic device that can store, retrieve, and process data Data and instructions to manipulate the data.
Important Concepts  Parts of the CPU  Arithmetic/Logic Unit  Control Unit  Registers  Program Counter  Instruction Register  Fetch/Decode/Execute.
Chapter 7 Low-Level Programming Languages (slides modified by Erin Chambers)
Chapter 7 Low-Level Programming Languages Nell Dale John Lewis.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
1.4 Representation of data in computer systems Instructions.
Chapter 7 Low-Level Programming Languages Nell Dale John Lewis.
Computer Organization 1 Instruction Fetch and Execute.
The Instruction Set Architecture. Hardware – Software boundary Java Program C Program Ada Program Compiler Instruction Set Architecture Microcode Hardware.
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
MIPS assembly syntax Home Assignment 3 Assigned. Deadline 2016 February 14, Sunday.
Department of Electronic & Electrical Engineering Lecture 2. PIC16F84A Architecture / Instructions Memory. Program/Data (Harvard) File Registers (Data).
27 October 2015 Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident.
CPIT Program Execution. Today, general-purpose computers use a set of instructions called a program to process data. A computer executes the.
First Foray into Programming (the hard way). A reminder from last lesson: A machine code instruction has two parts:  Op-code  Operand An instruction.
Programming Languages
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
Assembly Language Ms. V.Anitha AP/CSE SCT
Morgan Kaufmann Publishers
Chapter 3 Machine Language and Assembly Language.
Chapter 3 Machine Language and Assembly Language.
MIPS assembly syntax Comments
A Closer Look at Instruction Set Architectures
Microcomputer Programming
The Processor and Machine Language
CSCE Fall 2013 Prof. Jennifer L. Welch.
Computer Architecture
ECEG-3202 Computer Architecture and Organization
Computer Architecture and the Fetch-Execute Cycle
Sequencing, Selection, and Loops in Machine Language
MARIE: An Introduction to a Simple Computer
CSCE Fall 2012 Prof. Jennifer L. Welch.
Introduction to Microprocessor Programming
Chapter 6 Programming the basic computer
CS334: MIPS language _Mars simulator Lab 2_1
Instruction execution and ALU
Algoritmos y Programacion
Presentation transcript:

Chapter 7: Low-Level Programming Languages Chapter 7 Low-Level Programming Languages Page 66 In order to execute instructions on a CPU, those instructions must be in the particular binary format that was designed for that CPU. The set of instructions available for a particular CPU is known as its machine language. Sample Machine Instruction Format Op-Code Field (specifies the operation to be performed) Operand Field (gives further details pertinent to the operation)

Simplified Machine Language Chapter 7 Low-Level Programming Languages Page 67 Note that every instruction is sixteen bits (four hexadecimal digits) in length.

Sample Program Chapter 7 Low-Level Programming Languages Page CLoad register 0 with the integer 92 (hexadecimal 5C) 300EStore the contents of register 0 at main memory address 0E 205ALoad register 0 with the integer 90 (hexadecimal 5A) 300FStore the contents of register 0 at main memory address 0F 110ELoad register 1 with the bit pattern at main memory address 0E 120FLoad register 2 with the bit pattern at main memory address 0F 5012Add the contents of registers 1 & 2 and put the sum in register 0 300DStore the contents of register 0 at memory address 0D C000Halt execution In an advanced language, like C++, this program would be: void main() { int X, Y, Z; int X, Y, Z; X = 92; X = 92; Y = 90; Y = 90; Z = X + Y; Z = X + Y;}

Another Sample Program Chapter 7 Low-Level Programming Languages Page 69 How would we code this pseudocode with our machine language? Procedure negative (x) If x < 0 If x < 0 Then return 1 Then return 1 Else return 0 Else return 0 We’ll assume that the value of x has already been stored in main memory at address 5A, that the returned value (0 or 1) will be placed at address 5B, and that the program itself will be stored starting at address D0.

Chapter 7 Low-Level Programming Languages Page 70 Procedure negative (x) If x < 0 If x < 0 Then return 1 Then return 1 Else return 0 Else return 0 Let’s take advantage of the fact that if an 8- bit two’s- complement number is ANDed with , the result is if the number is positive, and if the number is negative.

Chapter 7 Low-Level Programming Languages Page 71 To make programming easier to handle, special languages (unique to the kinds of computers running them) have been developed. Machine Language Feature Corresponding Assembly Language Feature Hexadecimal Op-Codes Mnemonic Operators (“LOADVAR”, “JUMPEQ”, etc.) Data In Specific Main Memory Locations User-Defined Variable Names (“X”, “RESULT”) Instruction Addresses In Main Memory User-Defined Instruction Labels (“NEGATIVE”, “STOREIT”) Programs written in such an assembly language are executed by first passing through a special program (called an assembler) that translates the assembly language code into machine language. Assembly Language Example : LOADVAR R1,X LOADVAR R1,X LOADHEX R0,80 LOADHEX R0,80 AND R2,R0,R1 AND R2,R0,R1 JUMPEQ R0,R2,NEGATIVE JUMPEQ R0,R2,NEGATIVE LOADHEX R3,00 LOADHEX R3,00 JUMPEQ R0,R0,STOREIT JUMPEQ R0,R0,STOREIT NEGATIVE LOADHEX R3,01 STOREIT STORE R3, RESULT HALT HALT

Chapter 7 Low-Level Programming Languages Page 72 While assembly languages are easier to use than machine languages, they still share two big problems with machine languages. Assembly Language Problems 1. Assembly languages are still machine-dependent. A program written in one machine’s assembly language cannot be executed on a computer with a different instruction set and register configuration. 2. Assembly language programming is still too nitpicky. Programmers are forced to concentrate on the tiny details necessary to choreograph the computer’s activity, instead of focusing on the overall solution of the problem being tackled. overall solution of the problem being tackled.