introduction to programming
DESCRIPTION
Introduction to Programming. Hardware, Software, and Number Systems. David Goldschmidt, Ph.D. Computer Science The College of Saint Rose. wireless router. hard drive. system unit. power supply. motherboard (with CPU). video card. processor cooling fan. sound card. memory cards. - PowerPoint PPT PresentationTRANSCRIPT
Introduction to Programming
David Goldschmidt, Ph.D.Computer Science
The College of Saint Rose
Hardware, Software, andNumber Systems
Hardwarewireless router
system unit
power supply
motherboard (with CPU)
video card
memory cards
processor cooling fan
sound card
hard drive
Cool Hardware Tablet PCs combine laptop and PDA
features
Cool Hardware Docking stations…
Operating Systems System Software
Computer programs that directlycontrol the operations of thecomputer and its devices
Operating System Coordinates and orchestrates all activities
of the hardware devices in a computer Provides a Graphical User Interface (GUI )
forusers to interact with the computer
Operating Systems Microsoft Windows
Windows 2000, Windows XP,Windows XP Tablet PC,Windows Vista, Windows 7
Macintosh Mac OS v9.1, Mac OS X
Others UNIX, Linux, etc.
Hardware (a Closer Look)
Central Processing Unit (CPU)
ArithmeticLogicUnit
ControlUnit
CPU
Instruction (input) Result (output)
e.g. addition, subtraction, logical AND, OR, NOT
executes machine
language programs
Memory
Memory
A section of memory is called a byte.
A section of two or four bytes is often called a word.
Main memory can be visualized as a column or row of cells.
0x0000x001
0x0030x002
0x0040x0050x0060x007
A byte is made up of 8 bits.10101010
Low-Level Languages
000101000011001010000100010010010101010101010010
Machine language program(executable file)
LDA #47STA $570DEXJSR $817CPX #0BNE #14
Assembly language program
Translationprogram
(Assembler)
Compiling a C/C++ Program#include <iostream>
int main(){ float x; cout << “ ...
C/C++ program
C/C++Compiler
000101000011001010000100010010010101010101010010
Machine language program(object “.obj” file)
000101000011001010000100010010010101010101010010
Precompiled Libraries(e.g. iostream)
C/C++Linker
000101000011001010000100010010010101010101010010
Machine language program(executable “.exe” file)
Fetch-Decode-Execute Cycle
Fetch
The CPU’s control unit fetches, from main memory,the next instruction in the sequence of program instructions.
Decode
The instruction is encoded in the form of a number. The control unit decodes the instruction and generates an electronic signal.
ExecuteThe signal is routed to the appropriate component of the computer (such as the ALU, a disk drive, or some other device). The signal causes the component to perform an operation.
The CPU performs the fetch-decode-execute cycle to “run” program instructions
Java Program Development
Text editor Source code(.java)
Saves Java statements
Java compiler
Is read by
Byte code(.class)
Produces
JavaVirtual
Machine
Is interpreted by
ProgramExecution
Results in
Compiling a Java Program
public class ex01{ double x; int y;
...
Java program
JavaCompiler
000101000011001010000100010010010101010101010010
Java byte code(“.class” file)
Executing a Java Program
000101000011001010000100010010010101010101010010
Java byte code(“.class” file)
000101000011001010000100010010010101010101010010
Precompiled libraries(i.e. byte code)
JavaVirtual
Machine
Numbering Systems
We count using our fingers.... Base 10:
Computers count using binary digits or bits.... Base 2:
000001002003004005006007008009010011012013
000000000000000100000010000000110000010000000101000001100000011100001000
Base Conversion
A byte is a grouping of 8 bits
Convert an unsigned binary number (11011001) to decimal (base 10):
What about negative integers?
128
10011011
1248163264128base 10
value
16+ 8+ 1+ = 21764+
unsigned byte ranges
from 0 to 255
Two’s Complement
Conversion from binary to decimal is identical, except the leftmost bit always has a negative weight-128 64 32 16 8 4 2 1
1 1 0 1 1 0 0 1
-128 64 16 8 1
base 10
value
+ + + = -39+
two’s complement byteranges from -128 to 127