0% found this document useful (0 votes)
110 views

COSC 1046 - Computer Science I: Hardware vs. Software

The document discusses the basic components of computers including hardware such as the CPU, RAM, and hard drives, as well as software categories like operating systems and applications, and how data and programs are stored in binary format using bits and bytes. Key hardware components, input/output devices, and how programs are executed are described at a high level. The relationship between hardware and software is explained, as well as how data is represented and stored in binary format in the computer.

Uploaded by

corey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views

COSC 1046 - Computer Science I: Hardware vs. Software

The document discusses the basic components of computers including hardware such as the CPU, RAM, and hard drives, as well as software categories like operating systems and applications, and how data and programs are stored in binary format using bits and bytes. Key hardware components, input/output devices, and how programs are executed are described at a high level. The relationship between hardware and software is explained, as well as how data is represented and stored in binary format in the computer.

Uploaded by

corey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

11-05-02

COSC 1046 - Computer Science I

Chapter 1: Introduction to Computers and Programming


Spring 2011

Hardware vs. Software


}  The physical components of a computer constitute the
hardware.
}  Hard drives
}  RAM Memory
}  Central Processing Unit
}  The programs that run on the hardware are called
software.
}  Microsoft Windows, UNIX, Linux, Mac OS X
}  Word, Photoshop, Firefox, etc…
}  Hardware without software is not useful .
}  Software can not be executed without hardware.

1
11-05-02

Key Hardware
}  Central Processing Unit:
}  Often referred to as the brain of a computer (poor analogy)
}  Controls the execution of the software – one or few
instructions at a time but at a very high rate.
}  Main Memory (RAM – Random Access Memory)
}  Entire software programs can not fit on the CPU.
}  Main memory is dynamic and fast (and volatile) storage for the
portion of the software not currently being executed.
}  Secondary Storage (Hard drives, USB keys, DVDs, etc.)
}  Long-term (i.e., non-volatile) storage for both software
programs and associated data.
}  Orders of magnitude larger and orders of magnitude slower
than main (RAM) memory.

Input and Output Devices


}  Input devices are used to provide data, information or
instructions to a program.
}  Keyboard, mouse, scanners, microphone, etc.

}  Output devices show results (intermediate or final)


produced by the execution of a program.
}  Screen, printer, speakers, CDs, DVDs, etc.

2
11-05-02

Categories of Software
}  Operating Systems
}  Act as an interface between the user and the hardware. Also
helps to control the orderly execution of multiple programs.
}  Microsoft Windows, UNIX, Linux, Mac OS X

}  Application Software


}  Programs that are not part of the operating system and work
on top of the operating system level.
}  Word, Photoshop, Firefox, etc…

Programs versus Data.


}  Programs contain instructions that tell the computer
(CPU, memory, peripherals) how to accomplish a certain
task.
}  Programs live on the hard drive until they are requested at
which point they are loaded into RAM and executed on the
CPU. Other hardware may also play a role during execution.
}  Programs are executable . Think MS Word.

}  Data is information that lives on the hard drive. It does


not contain any instructions.
}  Data may be required by a program in order to function but it
is not part of the instruction set.
}  Data is not executable . Think a Word Doc file.

3
11-05-02

Storing Data (and programs)


}  At the lowest level, all data and programs are stored (in
the CPU, in RAM and on secondary storage) as context-
sensitive sequences of 0s and 1s.

}  The smallest piece that a computer can access is a


single bit of information.
}  A bit is an electronic switch or a magnetic component that can
hold a value of either 1 or 0 only. Sometimes you will see this
referred to as on/off , true/false , etc.

Binary…
}  A single bit can store only two distinct
patterns: 0 or 1.
}  Two bits can be switched to form 4
distinct patterns: Binary Decimal
}  00, 01, 10 and 11 000 0
}  Three bits can produce 8 unique 001 1

patterns: 010 2
011 3
}  000, 001, 010, 011, 100, 101, 110, 111
100 4
}  We give these patterns meaning by 101 5
converting them to decimal values: 110 6
111 7

4
11-05-02

Binary Continued
}  In general, with each bit we add, we multiply the number
of patterns by 2.
}  1 bit = 2 patterns, 2 bits = 4 patterns, 3 bits = 8 patterns …
}  This can be formalize as : 2n where n is the number of bits
}  Since the first number of each binary sequence is 0 the
highest number or unique patterns that can be stored
with 2n bits is 2n – 1
}  1 bit has values 0 to 1 = (21 – 1)
}  2 bits has values 0 to 3 = (22 – 1)
}  3 bits has values 0 to 7 = (23 – I )
}  Question: What is the maximum decimal number that
can be represented by 8 bits? 10 bits? 16 bits?

Binary Numbers
}  The value stored in a binary number can be expressed as
the sum of 2p where p is the position of each digit.

}  What is the decimal value of :


}  00000001
}  10000000
}  10101010
}  11110000

5
11-05-02

Combining Bits
}  Working with individual bits is inefficient and can cause
confusion. As a result, bits are often grouped.
}  8 bits = 1 byte
}  With 1 byte we can store numbers from 0 to 255.
}  With 2 bytes, we can store numbers from 0 to 65535. (216-1)
}  NOTE: All of our examples have been positive numbers only.
If we want to store negative numbers we can, but we lose ½ of
our upper range.
}  Ex. 2 bytes can store 0 to 65535 or -32768 to +32767

Storing Characters
}  All data is stored and interpreted by the hardware as
binary sequences. Only context gives it value.
}  01000001 = 65 in decimal.
}  If we are not interested in processing numbers, we could
instead assign the above binary sequence to some other
context.
}  01000001 = 65 in decimal = letter A in ASCII
}  Characters are stored using the same binary sequences as
numbers – only the context differentiates them.
}  A-Z = 65 – 90
}  a-z = 97 – 122
}  0-9 (text numbers) = 48 – 59

6
11-05-02

ASCII Chart

Storing Decimal Precision Numbers


}  So far: all of our data has been integer values or context-
sensitive numbers such as ASCII characters.

}  Decimal numbers can also be computed and stored but


the mechanisms of this are not important at this point.
}  http://en.wikipedia.org/wiki/Fixed-point_arithmetic

7
11-05-02

Program Execution
}  When you request that a program execute (double-
click, command line, etc.):
}  The program is copied from the hard drive (secondary
storage) into main memory.
}  The CPU fetches the necessary instruction from RAM
}  The instruction is decoded to determine the operation
}  The instruction is executed
}  This process is repeated until
the execution of the program
concludes.

Writing Programs to be Executed


}  The processor understands only machine code . This is
considered the be the lowest level of instructions. It is
the only level that is understood by the processor and is
the most complicated form for humans to interpret.
}  We program using higher level languages that are easier
for us to understand but are not directly executable by
the processor
}  Trade off: Easy for us to understand – inefficient to translate
or compile so that the CPU can understand
}  In general – the lower the level of the language, the harder for
us to understand but the more efficient for execution.

8
11-05-02

Example
Python – High level
i=6 Assembly Language –
j=7 Low level
k=511
sum = i + j + k mov ax,I
add ax,j
add ax,k
mov sum,ax
Machine Code –
Lowest Level i dw 6
j dw 7
1010 0001 0000 0000 0000 0000 0000 k dw 511
0011 0000 0110 0000 0000 0000 0010 sum dw 0
0000 0011 0000 0110 0000 0000 0000
0100 1010 0011 0000 0000 0000 0110

Compilers Vs. Interpreters


}  How do programs written in high level languages become
executable by the processor?
}  Compile: A compiler translates high level language programs into a
machine code program.
}  The entire program is compiled before execution.
}  Compiling is required only once, may take a long time for large programs but
the final (stand-alone) machine level program is always executable.
}  A compiler is required for each different type of processor.
}  Interpret: An interpreter (separate from the program you have written)
interprets and translates each line or section of the program into
machine code to be executed on the CPU
}  The program is interpreted a small piece at a time.
}  A processor-specific interpreter is required each time the program is
executed.

9
11-05-02

Compilers vs. Interpreters


Stored on hard drive.
Compiler

C
C++
Assembly
Interpreter

Ruby
Python

What is important to know!?


}  Computers rely on both hardware and software to
complete tasks.
}  Computers read, store and interpret data in a binary
format.
}  Each type of computer has its own proprietary language .
}  Programmers use higher-level languages to write software
}  Software must be converted before the computer can
execute it
}  Some languages are compiled to binary format.
}  Time up front to create binary, faster execution, binaries not portable.
}  Other languages are interpreted on the fly.
}  Slower overall execution as instructions interpreted, interpreters
more portable.

10

You might also like