* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download COMS 261
Survey
Document related concepts
Reactive programming wikipedia , lookup
Library (computing) wikipedia , lookup
Falcon (programming language) wikipedia , lookup
Abstraction (computer science) wikipedia , lookup
Object-oriented programming wikipedia , lookup
Programming language wikipedia , lookup
Structured programming wikipedia , lookup
Go (programming language) wikipedia , lookup
History of compiler construction wikipedia , lookup
Cross compiler wikipedia , lookup
C Sharp (programming language) wikipedia , lookup
Transcript
COMS 261 Computer Science I Title: Computer Organization Date: September 2, 2005 Lecture Number: 3 1 Announcements • Office hours for today 9/2/05 – 1:30pm – 3:00pm • Read – Chapter 1, start chapter 2 2 Review • Computing Terminology – Computer systems – Measurements – Positional number systems 3 Outline • Computing Terminology – Decimal to binary conversion • Octal • Hexidecimal – Programming • High-Level language • Assembly language • Machine Language – Think – Edit – Compile - Test Cycle 4 Operating System • Windows®, UNIX®, Mac OS X® • Controls and manages the computing resources – Important services provided by an operating system • File system – Directories, folders, files Operating System – Commands that allow for manipulation of the file system • Sort, delete, copy – Ability to perform input and output on a variety of devices – Management of the running systems Decimal to Binary Conversion • Convert 1110 ?2 • Procedure – Find the highest power of the base (2) the number will divide • Find the highest power so that the base raised to that power is less than or equal to the given number 5 4 2 2 32 16 3 2 8 2 4 2 1 2 2 0 2 1 7 Decimal to Binary Conversion • 24 = 1610 is larger than 1110, while • 23 = 810 is less than or equal to 1110 – There is a 23 in the binary representation of the number 1110 – Subtract the base raised to the highest power from the number to convert 1110 810 310 1110 1* 2 ... 3 8 Decimal to Binary Conversion – Find the highest power of 2 the remainder will divide • 22 = 4 is larger than 310 – There is not a 22 in the binary representation of 1110 • 21 = 2 is less than or equal to 310 – There is a 21 in the binary representation of 1110 1110 1* 2 0 * 2 1* 2 ... 3 2 1 – Subtract the base raised to the highest power from the remainder 9 Decimal to Binary Conversion 310 210 110 1110 1* 2 0 * 2 1* 2 ... 3 2 1 – Find the highest power of the base (2) the remainder will divide • 20 = 1 is the same as 110 – There is a 20 in the binary representation of 1110 1110 1* 2 0 * 2 1* 2 1* 2 3 2 1 0 10 Decimal to Binary Conversion – Subtract the base raised to the highest power from the remainder • No remainder, and no more powers of 2, therefore 110 110 010 1110 10112 11 Other Representations • There are other representations of quantities – Octal: base 8 – Hexadecimal: base 16 • Conversions between the representations – Similar to binary to decimal and decimal to binary conversion, but with a different base 12 Two’s Complement • • • • Used by almost all computers Binary representation Includes negative numbers Contains one representation for the quantity 0 • Arithmetic operations – Simpler to perform – Result in a two’s complement number • No extra conversion must take place 13 Programming • Programs are specific sequences of instructions – Instructions are primitive operations • Move data from one place to another • Add two items together • Check a value for equivalence to zero •… 14 Programming – Instructions have a binary representation or encoding – Instruction set • The set of legal instructions for a particular machine – MIPS – Intel – AMD • Legal bit patterns recognized by the machine 15 Programming 10110010 10100110 01001110 11001010 • May mean (for the MIPS processor) – Add the contents of two registers – Put the result in a third register • May not be a part of the instruction set for the Intel processor – Illegal instruction 16 Programming • It is possible to write a program in binary instructions 10110010 10100110 01001110 11001010 11100011 10000100 01001010 11011001 10001001 11100101 11011000 10011011 . . . – The binary instruction set is also called machine language • Varies from processor to processor 17 Programming • Do software developers write programs in machine language? – NO • Tedious • Error prone, single bit out of place • Specific to only one machine – Said to be not portable • Difficult to maintain and change • Impossible for someone else to work on the program 18 Machine Language • Programs written using the binary instruction set are said to be written in machine language – The resulting list of instructions is called machine code, also called object code 19 Assembly Language • Assembly language – A language directly related to machine language – Each instruction has a unique symbol (mnemonic) associated with it – Assembly language programmers use the symbols that represent instructions instead of binary instructions – An assembler converts the symbols into machine language (instructions) 20 Assembly Language • Example assembly language program mnemonics push mov sub mov mov mov mov mov mov mov leave ret ebp ebp,esp esp,0x8 eax,0xcccccccc dword ptr [esp],eax dword ptr [esp+0x4],eax dword ptr [ebp-0x4],0x6 eax,dword ptr [ebp-0x4] dword ptr [ebp-0x8],eax eax,0x0 arguments near 21 Assembly Programming Editor Think Think Think Assembly Language Program Assembler Machine Language Program Different Input Test Cases Execute (run) Program 22 Programming • Machine language – Low-level programming – Binary language • Assembly language – Higher-level programming • Still pretty low-level – Mnemonics simplify programming 23 Programming • Assembly language (Cont.) – Simpler than machine language • Still tedious • Error prone • Not portable • Difficult to maintain assembly code program 24 HLL Programming • High-level languages – More English like – Powerful constructs – Simpler to write and maintain code – More portable 25 HLL Programming • High-level languages (Cont.) – Popular high-level languages •C • C++ • Java • Fortran • Perl • Smalltalk • Scheme •… 26 HLL Programming • Code reusability – Many operations are common to most programs • Printing to the console (screen) or a file • Mathematical routines • String processing • Etc, … 27 HLL Programming • Code reusability (Cont.) – Most useful to have common routines already compiled into machine language (object code) – Libraries are the object code for groups of related routines packaged into a single file 28 HLL Programming • Code reusability (Cont.) – Libraries and different object files must be combined forming a single executable file • Linking and the linker – Linking is the process of combining different files of object code into a single executable file – The linker is a program that performs the linking 29 HLL Programming C++/Fortran Language Program Editor Compiler Assembly Language Program Math Library Object Code Linker Assembler Think Think Think Machine Language Program Execute (run) Program 30 IDE’s • Integrated Development Environments – Provides one user interface for the development process • Editor, Compiler, Linker, Loader, Debugger, Viewer – We will be using the CodeWarrior IDE throughout this course 31