180 likes | 221 Views
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.
E N D
Introduction to Programming Hardware, Software, andNumber 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 Hardware
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 activitiesof 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.
CPU ArithmeticLogicUnit e.g. addition, subtraction, logical AND, OR, NOT executes machine language programs Control Unit Memory Central Processing Unit (CPU) Instruction (input) Result (output)
Main memory can be visualized as a column or row of cells. 0x000 A section of memory is called a byte. A byte is made up of 8 bits. 0x001 1 0 1 0 1 0 1 0 0x002 0x003 0x004 0x005 A section of two or four bytes is often called a word. 0x006 0x007 Memory
LDA #47 STA $570 DEX JSR $817 CPX #0 BNE #14 Translation program (Assembler) 000101000011001010000100010010010101010101010010 Assembly language program Machine language program (executable file) Low-Level Languages
000101000011001010000100010010010101010101010010 C/C++ Compiler Machine language program (object “.obj” file) 000101000011001010000100010010010101010101010010 000101000011001010000100010010010101010101010010 C/C++ Linker Precompiled Libraries (e.g. iostream) Machine language program (executable “.exe” file) Compiling a C/C++ Program #include <iostream> int main() { float x; cout << “ ... C/C++ program
The CPU’s control unit fetches, from main memory,the next instruction in the sequence of program instructions. Fetch The instruction is encoded in the form of a number. The control unit decodes the instruction and generates an electronic signal. Execute Decode The 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. Fetch-Decode-Execute Cycle • The CPU performs the fetch-decode-execute cycle to “run” program instructions
Source code (.java) Saves Java statements Is read by Byte code(.class) Java compiler Produces Is interpreted by Program Execution Java Virtual Machine Results in Java Program Development Text editor
000101000011001010000100010010010101010101010010 Java Compiler Java byte code (“.class” file) Compiling a Java Program public class ex01 { double x; int y; ... Java program
000101000011001010000100010010010101010101010010 Java Virtual Machine Precompiled libraries (i.e. byte code) Executing a Java Program 000101000011001010000100010010010101010101010010 Java byte code (“.class” file)
Numbering Systems • We count using our fingers.... • Base 10: • Computers count using binary digits or bits.... • Base 2: 006 000 001 003 004 005 002 007 008 009 011 012 013 010 00000110 00000111 00000000 00000001 00000010 00000011 00000100 00000101 00001000
unsigned byte ranges from 0 to 255 128 64 32 16 8 4 2 1 base 10 value 1 1 0 1 1 0 0 1 64 16 8 1 + + + + 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 = 217
two’s complement byte ranges from -128 to 127 Two’s Complement • Conversion from binary to decimal is identical, except the leftmost bit always has a negative weight base 10 value = -39 + + + +