Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science I CSCI-1100-01 Summer 2009 David E. Goldschmidt, Ph.D.

Similar presentations


Presentation on theme: "Computer Science I CSCI-1100-01 Summer 2009 David E. Goldschmidt, Ph.D."— Presentation transcript:

1 Computer Science I CSCI-1100-01 Summer 2009 David E. Goldschmidt, Ph.D. goldschd@strose.edu

2 Hardware

3 Central Processing Unit (CPU) Arithmetic Logic Unit Control Unit CPU Instruction (input)Result (output) e.g. addition, subtraction, logical AND, OR, NOT executes machine language programs

4 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. 0x000 0x001 0x003 0x002 0x004 0x005 0x006 0x007 A byte is made up of 8 bits. 10101010

5 Low-Level Languages 00010100 00110010 10000100 01001001 01010101 01010010 Machine language program (executable file) LDA #47 STA $570 DEX JSR $817 CPX #0 BNE #14 Assembly language program Translation program (Assembler)

6 Compiling a C/C++ Program #include int main() { float x; cout << “... C/C++ program C/C++ Compiler 00010100 00110010 10000100 01001001 01010101 01010010 Machine language program (object “.obj” file) 00010100 00110010 10000100 01001001 01010101 01010010 Precompiled Libraries (e.g. iostream) C/C++ Linker 00010100 00110010 10000100 01001001 01010101 01010010 Machine language program (executable “.exe” file)

7 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. Execute 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. The CPU performs the fetch-decode- execute cycle to “run” program instructions

8 Numbering Systems We count using our fingers.... Base 10: Computers count using binary digits or bits.... Base 2: 000001002003004005006007008009010011012013 000000000000000100000010000000110000010000000101000001100000011100001000

9 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 1248163264128 base 10 value 16 + 8 + 1 + = 217 64 + unsigned byte ranges from 0 to 255

10 Two’s Complement Conversion from binary to decimal is identical, except the leftmost bit always has a negative weight -1286432168421 11011001 -128641681 base 10 value +++ = -39 + two’s complement byte ranges from -128 to 127

11 Base Conversion (again) Convert from base 10 to base 2: Find the largest power of 2 that’s less than or equal to the number you’re trying to convert Subtract it from base 10 number and repeat... For example: 217 -128 89 - 64 25 - 16 9 - 8 1 1286432168421 11011001

12 Algorithms What is an algorithm? A solution to a problem A recipe A step-by-step set of English instructions that describes how inputs are processed to produce expected outputs Write an algorithm to change a light bulb Write an algorithm to get driving directions from Albany to Cape Cod

13 Algorithms Write an algorithm to sum integers 1 to 100 Write an algorithm to convert an unsigned byte (e.g. 11011001) from base 2 to base 10 Write an algorithm to convert a signed two’s complement byte (e.g. 11011001) from base 2 to base 10


Download ppt "Computer Science I CSCI-1100-01 Summer 2009 David E. Goldschmidt, Ph.D."

Similar presentations


Ads by Google