Sunteți pe pagina 1din 6

ESc101: Fundamentals of Computing

2011-12-Monsoon Semester

Please switch off your mobile phones.

Announcements
List of all students with their sections is available at: http://www.cse.iitk.ac.in/users/dheeraj/esc101.txt A session on Linux
Sunday, 31st July, 11:00 AM Room Number 101, Computer Science Building

A tutorial in Hindi
Saturday, 30th July, 10:00 AM Room Number 102, Computer Science Building
Lec-03 Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon 1

Recap
What is an algorithm Describe algorithm in words Flow chart a pictorial representation of an algorithm

Lec-03

Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon

Another Algorithmic Problem

Given a binary number, print its equivalent decimal number.

Lec-03

Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon

Binary to Decimal Conversion


1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.
Lec-03

Read BinaryNumber PlaceValue = 1, DecimalNumber = 0 RightMostDigit = BinaryNumber MOD 10 If RightMostDigit > 1, Print Error, STOP. DigitValue = PlaceValue * RightMostDigit DecimalNumber = DecimalNumber + DigitValue PlaceValue = PlaceValue * 2 BinaryNumber = BinaryNumber / 10 (Integer Division) If BinaryNumber > 0, GoTo Step 3 Print DecimalNumber STOP.
Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon 4

Model of a Computer
From the perspective of programming, the main components are:
CPU: Central Processing Unit
ALU: Arithmetic and Logic Unit Control Unit

RAM: Random Access Memory

Additional devices of interest are:


Storage (e.g., Disks) Input (e.g., keyboard, mouse) Output (e.g., monitor, printer)
Lec-03 Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon 5

Memory
Bit: Having a value of 0 or 1 Byte: Having 8 bits Kilobyte (KB): 1024 bytes Megabyte (MB): 1024 KB Gigabyte (GB): 1024 MB Is generally byte addressable
32 bit addresses would mean a maximum memory of 4 GB.

Any byte can be read at any time random access Programs and Data are stored in memory.
Lec-03 Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon 6

ALU
Can execute arithmetic and logical operations
Add, Subtract, Multiply, Divide (for integers) Right shift, Left shift Comparison of two bytes or two numbers What operations needs to be done next on what inputs is controlled by the program

Lec-03

Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon

Control Unit
Responsible to bring the next instruction of the program. It then decodes the instruction and tells ALU what to execute next It is also responsible to bring in operands from memory to ALU. Similarly, it stores the results of the operation back to memory.

Lec-03

Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon

Binary Format
The basic memory unit in computer is a bit
Computer can only understand binary: 0 and 1. Computer can only operate on binary input and produce binary output. For example, if number 17 has to be stored in a byte, it will be stored as 00010001.

Lec-03

Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon

Any Questions?

Lec-03

Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon

10

S-ar putea să vă placă și