COP3502: Introduction to Computer Science Yashas Shankar Program Translation.

Slides:



Advertisements
Similar presentations
Week 3. Assembly Language Programming  Difficult when starting assembly programming  Have to work at low level  Use processor instructions >Requires.
Advertisements

MOV Instruction MOV destination, source ; copy source to dest. MOV A,#55H ;load value 55H into reg. A MOV R0,A ;copy contents of A into R0 ;(now A=R0=55H)
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Information Processing
EET 2261 Unit 2 HCS12 Architecture
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
2.1 2 Number Systems Foundations of Computer Science  Cengage Learning.
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
1 Chapter-01 Introduction to Computers and C++ Programming.
1 Please switch off your mobile phones. 2 Prolog: The Initiation ET: Hey Alice! What is this on your desk? Alice: That’s a digital computer. ET: Digital.
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers citation and following credit line is included:
IT253: Computer Organization
CPU Internal memory I/O interface circuit System bus
Chapter 1: Digital Computers and Information Illustration at beginning of each Chapter Base 10 Binary Base 2 Octal Base 8 Hex bas
COP3502: Introduction to Computer Science Yashas Shankar.
Department of Mathematics Computer and Information Science1 CS112: Survey of Computer Science Chapter One Review: Introduction, Chapter Two: Number Systems.
CPIT 201 Introduction to Computing
Data Representation Bits, Bytes, Binary, Hexadecimal.
Computer Programming 12 Mr. Jean February 5 th, 2014.
1 CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich
Computer Science Introduction to the Number Base Unit Adapted from Slides by John Owen Computer Science Instructor, Rockport-Fulton High School, Rockport,
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
MODULE –I NUMBER SYSTEM Digital Design Amit Kumar Assistant Professor SCSE, Galgotias University, Greater Noida.
COP3502: Introduction to Computer Science Yashas Shankar Midterm review.
COP3502: Introduction to Computer Science Yashas Shankar Program Translation.
Computer Systems – Machine & Assembly code. Objectives Machine Code Assembly Language Op-code Operand Instruction Set.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Instruction Formats Competency: C5 Lecture no. 24.
Two’s Complement The language of machines, part II.
Starter Using the mini whiteboards record your answers: 1) Name 2 different Character Sets 2) Convert the Hex number 9E into denary 3) Convert the binary.
First Foray into Programming (the hard way). A reminder from last lesson: A machine code instruction has two parts:  Op-code  Operand An instruction.
CPIT 201 King AbdulAziz University Faculty of Computing & Information Technology Information Technology Department CH 2 Number Systems CPIT 201 Introduction.
EE345 Chapter 2 Lecture 3 April 4. Quiz every Wednesday 1 quiz = 1% extra credit five quizzes before midterm  5% for midterm. five quizzes before final.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
1 Chapter 1: Basic Concepts Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine 9/6/2003.
Lecturer: Santokh Singh
Binary and Hexadecimal
Assembly Language (CSW 353)
Digital Electronics INTRODUCTION ANALOG VS DIGITAL NUMBER SYSTEMS.
Integer Real Numbers Character Boolean Memory Address CPU Data Types
Introduction to Programming
Computer Science 210 Computer Organization
Data Representation Integers
Number Systems Lab session 1 Xuan Guo.
A Closer Look at Instruction Set Architectures
University of Gujrat Department of Computer Science
Chapter 1 Number Systems & Conversions
CDA 3100 Summer 2011.
Computer Science 210 Computer Organization
Computer Organization and ASSEMBLY LANGUAGE
Numbering System TODAY AND TOMORROW 11th Edition
CDA 3100 Spring 2010.
Computer Science A Level
Unit 18: Computational Thinking
ECEG-3202 Computer Architecture and Organization
COMS 161 Introduction to Computing
Number Representation
Computer Organization
ECEG-3202 Computer Architecture and Organization
CPS120: Introduction to Computer Science
Binary Addition (1 of 2) Two 1-bit values A B A + B 1
COMS 161 Introduction to Computing
Example 1: (expression evaluation)
COMS 361 Computer Organization
OBJECTIVES After reading this chapter, the reader should be able to :
Two’s Complement & Binary Arithmetic
Presentation transcript:

COP3502: Introduction to Computer Science Yashas Shankar Program Translation

Second part of this course  We will spend 4 classes on Program Translation (chapter 6 from your AE textbook) and 3 classes on Hardware (chapter 7 from your AE textbook)  You need to have the textbook  You won’t have to do programming on program.cs.fsu.edu (but you still have to write some assembly programs on papers)  We will spend 4 classes on Ethics  Textbook is optional, but you may need it to do extra credits  We will also spend some times reviewing programming during this period

Extra credit  There will be 4 extra credits  2 for homework  2 for quizzes  For each extra credit, write a 5-page summary of one chapter from your “ethics” textbook

Alternative extra credit for homework  Do the homework that you want to have your score increase  Put your homework on your webpage  Write a 2-page summary of one chapter in Ethics textbook and put it on your webpage  15 points will come from your homework and 10 points from the summary. Grading policy on homework part will be tougher. Your homework has to be 100% correct or you will get at least 5 points off.

Alternative extra credit for quiz  Design a 10-question quiz related to the subject in the quiz that you want to increase your score. Put a “correct” answer for each question.  Put your quiz & solution on your webpage  Your base score will be 8 points. If your quiz is good, you will get 9 or 10. If it is bad you will get 0-7 points

Extra credit submission  You have to state what each extra credit is for, e.g. for quiz#4, asg#12, etc.  Normal 5-page summary extra credits  Print out and hand them to me  Alternative extra credits  Put on your webpage (and notify me)  You can start submitting your extra credit when we start “ethics for computer science” part  You have to submit your extra credit before the final exam

Program translation  Today lecture  Binary representation & machine language

Binary representation & machine language  Human language  “hello my name is pitch”  Machine language  “ ………………0101”  Machine language has only 0 and 1

How machine language work? Human: add one and two Machine: Code for ADD

Binary representation  Machine only understand 0 and 1  We need to convert numbers that we understand to what machines understand (and vise versa)

How to adds two numbers in binary representation? What can you notice here?

Binary representation – power of two bits

Binary representation – power of two bits = = = 192

How to convert binary number to decimal number? = 179 = =179

How to convert decimal number to binary number? 198 = ? 198 = = = =

Hexadecimal representation DecimalBinaryHex DecimalBinaryHex A B C D E F

How to convert binary to hexadecimal (and vise versa)? = 12FC = = 2F = = 23C = = 277 2F = CA3 =

Hexadecimal representation  Computer doesn’t understand it  Save people a lot of writing  Easier for people to understand  0, 1, 2, …………, 9, A, B, C, D, E, F

Coverting Hex to Decimal and vise versta  Hex to Dec: Hex  Binary  Decimal  Dec to Hex: Dec  Binary  Hex

Negative numbers in binary representation 8-bit positive numbers = {0,1,…… 255} = {0,1,…., (2 8 – 1)} 32-bit positive numbers = {0,1,……..,(2 32 – 1)} 8-bit numbers = {-128, - 127, ….. 0, 1, ….127} 32-bit numbers = {-2 31, ……. 0, 1, …… ( )}

Negative numbers in binary representation 8-bit representation: always have 8 bits Positive number: start with 0 (left-most bit) Negative number: start with 1 (left-most bit) Example:

How to represent negative number?  Use 2-complement system  Start from positive number  Reverse all ones and zeros (the output is said to be in one- complement form)  Add one to the output to get 2-complement representation Example: what is -5? 5 = Reverse = Add 1 = = 2-complement form of =

How to subtract number?  Subtract = add negative number  Example: 19 – 5  Start from 5 and change to -5 by 2-complement method  Add 19 and -5 together  More detailed example: solve19 – 5 in binary representation  Add 19 and (-5) together  Step 1: change 19 to binary representation  Step 2: change -5 to 2-complement form  Step 3: add them together  Step 4: change the number back to decimal

Computation within CPU  This course  Accumulator based (in your textbook)  Stack based (I added it)  Example: C = A + B; Accumulator LoadA AddB StoreC Halt Stack PushA PushB Add PopC Halt

More on Accumulator  C=A+B LoadA AddB StoreC Halt  C=A+B Load128 Add129 Store130 Halt  C=A+B

More on Stack  C=A+B PushA PushB Add PopC Halt  C=A+B Push128 Push129 Add Pop130 Halt  C=A+B

More complex statement (Accumulator) Example1: E = A+(B*C) + D Accumulator LoadB MulC AddA AddD StoreE Example2: E = A+(B*C) + (D*F) Accumulator LoadB MulC AddA StoreTMP LoadD MulF AddTMP StoreE

More complex statement (stack) Example1: E = A+(B*C) + D E = ABC*+D+ Example2: E = A+(B*C) + (D*F) E = ABC*+DF*+ Stack representation PushA PushB PushC Mul Add PushD Add PopE PushA PushB PushC Mul Add PushD PushF Mul Add PopE

Stack representation  What do u need to know?  How to solve equations represented in stack representation  How to translate stack representation to normal representation and vise versa  Example: - what is the result of 234+*562-*+? Note: answer = 34 - what is 234+*562-*+ in normal representation? Note: answer = (2 * (3+4)) + (5 * (6-2)) - what is 2*3+4*5 in stack representation Note: answer = 23*45*+