esc 101: fundamentals of computing 2 - notes.pdf · esc 101: fundamentals of computing lecture 2...

14
ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 () ESc 101 Jan 4, 2010 1 / 16

Upload: others

Post on 26-Jun-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

ESc 101: Fundamentals of Computing

Lecture 2

Jan 4, 2010

Lecture 2 () ESc 101 Jan 4, 2010 1 / 16

Page 2: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Revisiting the Addition Program

We start by revisiting the addition program in all three languages.

We also revisit the execution of the machine language program toemphasize the way computation happens inside a computer.

Lecture 2 () ESc 101 Jan 4, 2010 3 / 16

Page 3: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

A Small Program

0000010010011001000001001001101000000110110010000000010011010001

- read memory location 001- read memory location 010- add two numbers read- store the result in memory location 001

Lecture 2 () ESc 101 Jan 4, 2010 4 / 16

Page 4: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Execution

Lecture 2 () ESc 101 Jan 4, 2010 5 / 16

Page 5: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Execution

Lecture 2 () ESc 101 Jan 4, 2010 6 / 16

Page 6: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Execution

Lecture 2 () ESc 101 Jan 4, 2010 7 / 16

Page 7: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Execution

Lecture 2 () ESc 101 Jan 4, 2010 8 / 16

Page 8: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Execution

Lecture 2 () ESc 101 Jan 4, 2010 9 / 16

Page 9: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Execution

Lecture 2 () ESc 101 Jan 4, 2010 10 / 16

Page 10: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Execution

Lecture 2 () ESc 101 Jan 4, 2010 11 / 16

Page 11: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Execution

Lecture 2 () ESc 101 Jan 4, 2010 12 / 16

Page 12: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Example Program in Assembly Language

0000010010011001000001001001101000000110110010000000010011010001

MOVE NUM1, R1MOVE NUM2, R2ADD R1, R2MOVE R1, NUM1

Move contents of memory location NUM1 to CPU register R1Move contents of memory location NUM2 to CPU register R2Add contents of R1 and R2 and store the result in R1Move the contents of R1 to memory location NUM1

Lecture 2 () ESc 101 Jan 4, 2010 13 / 16

Page 13: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Adding Two Numbers in C

main(){

int num1;int num2;

scanf("%d", &num1);scanf("%d", &num2);

num1 = num1 + num2;

printf("%d", num1);}

Lecture 2 () ESc 101 Jan 4, 2010 14 / 16

Page 14: ESc 101: Fundamentals of Computing 2 - Notes.pdf · ESc 101: Fundamentals of Computing Lecture 2 Jan 4, 2010 Lecture 2 ESc 101 Jan 4, 2010 1 / 16. ... We also revisit the execution

Important Concepts

Logging in: give your credentials to the login program

Directory Structure: Data and programs are organized in files on HardDisk.

Creating, removing, parsing directories: Done by the shell program;use commands ls, cd, mkdir, rmdir etc.

Creating and removing files: Use commands vi, emacs, rm etc.

Compiling C program: use gcc.

Lecture 2 () ESc 101 Jan 4, 2010 16 / 16