cop3502: introduction to computer science yashas shankar program translation

20
COP3502: Introduction to Computer Science Yashas Shankar Program Translation

Upload: bertram-stevens

Post on 17-Jan-2018

222 views

Category:

Documents


0 download

DESCRIPTION

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

TRANSCRIPT

Page 1: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

COP3502: Introduction to Computer Science

Yashas Shankar

Program Translation

Page 2: 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

Page 3: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

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

Page 4: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

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.

Page 5: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

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

Page 6: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

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

Page 7: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

Program translation Today lecture

Binary representation & machine language

Page 8: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

Binary representation & machine language Human language

“hello my name is yashas” Machine language

“0001 1000 1111 1100 ………………0101” Machine language has only 0 and 1

Page 9: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

How machine language work?Human: add one and twoMachine:

Code for ADD 1 2

129 1 2

1000 0001 0000 0001 0000 0010

Page 10: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

Binary representation Machine only understands 0 and 1 We need to convert numbers that we understand

to what machines understand (and vise versa)

0 00001 00012 00103 00114 01005 01016 01107 0111

8 10009 100110 101011 101112 110013 110114 111015 1111

Page 11: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

How to adds two numbers in binary representation?

00010001 +0010

00100010 +0100

0 00001 00012 00103 00114 01005 01016 01107 0111

00000010 +0010

00110010 +0101

00110011 +0110

01010011 +1000

8 10009 100110 101011 101112 110013 110114 111015 1111

What can you notice here?

16 10000

Page 12: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

Binary representation – power of two bits

0 00001 00012 00104 01008 1000

16 1000032 10000064 100000

0128 100000

00

0 0000 0000

1 0000 0001

2 0000 0010

4 0000 0100

8 0000 1000

16 0001 0000

32 0010 0000

64 0100 0000

128 1000 0000

Page 13: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

Binary representation – power of two bits

0 0000 0000

1 0000 0001

2 0000 0010

4 0000 0100

8 0000 1000

16 0001 0000

32 0010 0000

64 0100 0000

128 1000 0000

00100010 +0100

01000100 +1000

0100001000 +10000

1100 0000 = 1000 0000 + 0100 000 = 128 + 64 = 192

Page 14: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

How to convert binary number to decimal number?

10110011

1 0 1 1 0 0 1 1128 64 32 16 8 4 2 1128 32 16 2 1 = 179

= 128 + 32 + 16 + 2 + 1 =179

Page 15: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

How to convert decimal number to binary number?198 = ?198 = 128 + 70 = 128 + 64 + 6

= 128 + 64 + 4 + 2 = 11000110

128 64 32 16 8 4 2 11 1 0 0 0 1 1 0

Page 16: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

Hexadecimal representation

Decimal Binary Hex0 0000 01 0001 12 0010 23 0011 34 0100 45 0101 56 0110 67 0111 7

Decimal

Binary Hex

8 1000 89 1001 910 1010 A11 1011 B12 1100 C13 1101 D14 1110 E15 1111 F

Page 17: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

How to convert binary to hexadecimal (and vise versa)?0001 0010 1111 1100 = 12FC101111 = 0010 1111 = 2F10 0011 1100 = 0010 0011 1100 = 23C1001 1101 11 = 0010 0111 0111 = 277

2F = 0010 11116CA3 = 0110 1100 1010 0011

Page 18: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

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

Page 19: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

Coverting Hex to Decimal and vise versta Hex to Dec: HexBinaryDecimal Dec to Hex: DecBinary Hex

Page 20: COP3502: Introduction to Computer Science Yashas Shankar Program Translation

What you need to know (well) How to convert binary to decimal How to convert decimal to binary How to convert binary to hexadecimal How to convert hexadecimal to binary How to add numbers in binary form