esc 101: fundamentals of computing · 2019. 3. 11. · move num1, r1 move num2, r2 add r1, r2 move...

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

Upload: others

Post on 30-Jan-2021

5 views

Category:

Documents


0 download

TRANSCRIPT

  • ESc 101: Fundamentals of Computing

    Lecture 2

    Jan 4, 2010

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

  • 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

  • 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

  • Execution

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

  • Execution

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

  • Execution

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

  • Execution

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

  • Execution

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

  • Execution

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

  • Execution

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

  • Execution

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

  • 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

  • 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

  • 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

    Review of Last LectureInterfacing with Computer