Chapters 1-‐3 Review

Total Page:16

File Type:pdf, Size:1020Kb

Chapters 1-‐3 Review Chapters 1-3 Review C is a Procedural programming language (like Ada, BASIC, C++, C#, COBOL, Fortran, Java, Pascal, Perl, Python, Visual Basic). How long has C been around? Since late 1960s/early 1970s (1969-1972) Procedural This is a type of programming language that contains a series of computational steps to be carried out; procedures / routines / functions may be called at any point in the program, including by other functions or itself. Instruction Set This is the set of instructions that is defined on a processor. Different processors have different ones of these defined on them (within the circuitry of the processor). Program This is a collection of instructions that perform some purpose, solves a specific problem. Algorithm This refers to the approach or steps taken to solve the problem, to show the logic for the program. Compiler This is the process of analyzing & translating the program from the C program language to a form the computer can understand (machine language); creates an executable. Preprocessor The first sub-step when compiling where certain “administrative” things are taken care of before any compiling takes place (for example a #define, which we’ll talk about later). So, for now, think of this sub-step as “filling in the blanks” before compiling. (.i file) Assembler The second sub-step when compiling where the programming language instructions are broken down into assembly language instructions first (.s file) and then converts each assembly language instruction into binary code, or object code (.o file). Linker The last sub-step when compiling that links or adds to the object code any other code being included with the program (from the #includes or from the other program files that are all being compiled together) when then produces the executable program. Operating Systems Unix, Linux, Windows, MacOS are examples of these. These are the programs that control the entire operation of a computer system (such as I/O, system resources, execution of programs, etc). [Unix – developed at Bell Labs in 1969 in assembly language, re-written in C in 1972 (over 90% of it written in C; makes it much more easily ported to different systems with relatively small effort).] Steps to create a program: 1. Create a file (using vim/pico/nano/gedit) and code the program program_name.c 2. Compile (using gcc) gcc program_name.c a. Preprocessor i. Before any compiling takes place, the preprocessor takes care of a few “administrative” things, for example #define items ii. Can create .i file by doing the following: gcc –E program_name.c > ppf b. Assembler i. After it compiles, an assembly language version is created ii. The assembly statements are then translated into actual machine language instructions i.e. the assembler converts each assembly language statement into binary code (object code), producing a file that ends in .o program.o iii. Can create .s file by doing the following: gcc –S program_name.c iv. Can create .o file by doing the following: gcc –c program_name.c c. Linker i. After it compiles (with no errors), the linker links whatever else is needed all together so the program is ready to be run, e.g., if the program uses other programs that were previously processed by the compiler; also, anything from the library ii. Final linked file is the executable file, called a.out iii. Can capture all the above intermediate files by typing the following: gcc –save-temps program_name.c (will create .i, .s, & .o files) 3. Debug (fix erros) a. Syntax errors – language-specific omissions/errors, e.g., missing a semi-colon where one is required b. Semantic errors – logical erros, e.g. using a variable that hasn’t been declared yet 4. Repeat steps 2 & 3 until there are no errors and it works 5. To run your compiled program, just type ./a.out and your program called a.out will be loaded into your compter’s memory & execution will be initiated; when run, each statement of the program is sequentially executed in turn a. it might pause if it is waiting for input from the user or an event e.g. a mouse click b. results, or output, are displayed to the screen or written to a file. Machine instructions (Low-level) These are the (low-level) types of instructions that the computer (processor) understands. They are not human readable; are machine dependent - only worked on the machine that it was developed for (not portable). • The first computer programs, (1940s), were in terms of binary numbers (explain 1s & 0s). The set of binary numbers used in these programs corresponded directly to specific machine language instructions and locations in memory. • Instructions are simply a pattern of bits – different patterns correspond to different commands to the machine (CPU). • Example: 16-bit instruction from the 8086 microprocessor by Intel. (Show Intel’s processors here.) 0000001111010011 where the first 6 bits represent the opcode (the computer understands that 000000 means an ADD operation), the last 6 bits represent which registers the operands are in (3 bits for each register: 010 for Bx and 011 for Ax). • These days, instruction lengths are longer (e.g. 32 bits) and their lengths differ depending on the instruction. Assembly language (Low-level) These are also low-level types of instructions that, starting in the early 1950s, allowed the programmer to use a somewhat more English-like way of writing instructions by using abbreviations, or mnemonic codes, to refer to the bit-patterns. • A special program called an assembler translates the assembly language statements into the specific machine instructions of the computer system. • The programmer still had to learn the instruction set of the particular computer system because there is a one-to-one correspondence between the assembly language instructions and the specific machine instructions. • The resulting programs were not portable to other systems because they corresponded directly to the specific instruction set that the programmer was using. (i.e. machine dependent – only worked on the machine that it was developed for) Higher-level languages These languages, like C, use even more English-like statements than assembly language. • It was Grace Hopper’s idea that programs could be written in more English-like statements than Assembly and Machine language. (Look at the people posted in the Module.) • FORTRAN was one of the first (FORmula TRANslation), developed in 1954 by IBM in California, for scientific and engineering applications. • Programmers no longer had to concern themselves with the architecture of the particular computer system; the FORTRAN instructions (statements) were far removed from the instruction set of the particular machine. • A compiler is used to accomplish this. The compiler is a program that translates the statements from the higher-level language into a form that the computer understands (machine language instructions of the computer). • This meant that programs could be written in the language to be machine independent – i.e. the programs could be run on any machine that supported the language with few or no changes. • Grace Hopper created the first compiler; and it was from her work that the COBOL programming language was developed (1959). She is given credit for coining the phrase “debugging the computer” when an actual moth was found in the Mark II computer which stalled its operation. (Pgs. 11-20, Chapter 3 – Compiling and Running Your First Program) 101/Modules/Intro/FirstProgram/prog3_1.c /* this is the very first program in the book Program 3.1, on page 11 which is explained in detail in Chapter 3 */ #include <stdio.h> int main (void) { printf("\nProgramming is fun. \n"); return 0; } /* this is the very first program in the book with an added line of output and comments Program 3.1, on page 11 which is explained in detail in Chapter 3 */ // we need stdio.h because this is where printf is defined #include <stdio.h> // main() is the entry point where the program starts execution int main (void) { /* printf is used to print "Programming is fun." to the screen, followed by a new line denoted by \n */ printf("Programming is fun. \n"); /* same line with extra "new lines" note the difference when you run the program */ printf("\I’m going to love this class! \n\n"); // return 0 to the system to indicate successful execution return 0; } /* Program 3.4, on page 15 with an added line or two of code Displaying Variables */ // we need stdio.h because this is where printf is defined #include <stdio.h> // main() is the entry point where the program starts execution int main (void) { /* declaring a variable called "sum", which will hold the value of two numbers added together */ /* a variable needs to be declared somewhere before it is used; otherwise, it would cause a semantic error */ /* this variable is of type "int", which means it is an integer and not a decimal number */ int sum; sum = 50 + 25; /* printf is used to print 2 known values and 1 unkown value, "sum" */ printf ("\nThe sum of 50 and 25 is %i. \n\n", sum); sum = 483 + 379; printf ("The sum of 483 and 379 is %i. \n\n", sum); // return 0 to the system to indicate successful execution return 0; } .
Recommended publications
  • Xilinx XAPP545 Statistical Profiler for Embedded IBM Powerpc, Application Note
    Product Not Recommended for New Designs Application Note: Virtex-II Pro R Statistical Profiler for Embedded IBM PowerPC XAPP545 (v1.0) September 15, 2004 Author: Njuguna Njoroge Summary This application note describes how to generate statistical profiling information from the IBM PowerPC 405D, which is embedded in some Virtex-II Pro™ FPGAs. Specifically, the application note details how to convert trace output files generated from the Agilent Technologies Trace Port Analyzer into a gprof (GNU profiler) readable format. The gprof tool is capable of generating a histogram of a program's functions and a call-graph table of those functions. Introduction Profiling allows a programmer to assess where a program is spending most of its time and how frequently functions are being called. With this information, a programmer can gain insight as to what optimizations to make. In some cases, a programmer can identify bugs that would be otherwise undetectable. Using the RISCWatch application is a first step in profiling a program. Nonetheless, manually mulling through approximately 350 MB (or 8 million cycles) of trace data to discern the run-time profile of the program is a fruitless endeavor. In fact, the designers of RISCWatch realized this, so they standardized the trace output format to enable post processing of the trace. The regular format of the trace files allows scripts to parse through the trace and convert it to the gprof format. By converting the trace files into the gprof format, the widespread use of gprof in the profiling community
    [Show full text]
  • The Hexadecimal Number System and Memory Addressing
    C5537_App C_1107_03/16/2005 APPENDIX C The Hexadecimal Number System and Memory Addressing nderstanding the number system and the coding system that computers use to U store data and communicate with each other is fundamental to understanding how computers work. Early attempts to invent an electronic computing device met with disappointing results as long as inventors tried to use the decimal number sys- tem, with the digits 0–9. Then John Atanasoff proposed using a coding system that expressed everything in terms of different sequences of only two numerals: one repre- sented by the presence of a charge and one represented by the absence of a charge. The numbering system that can be supported by the expression of only two numerals is called base 2, or binary; it was invented by Ada Lovelace many years before, using the numerals 0 and 1. Under Atanasoff’s design, all numbers and other characters would be converted to this binary number system, and all storage, comparisons, and arithmetic would be done using it. Even today, this is one of the basic principles of computers. Every character or number entered into a computer is first converted into a series of 0s and 1s. Many coding schemes and techniques have been invented to manipulate these 0s and 1s, called bits for binary digits. The most widespread binary coding scheme for microcomputers, which is recog- nized as the microcomputer standard, is called ASCII (American Standard Code for Information Interchange). (Appendix B lists the binary code for the basic 127- character set.) In ASCII, each character is assigned an 8-bit code called a byte.
    [Show full text]
  • Tanium™ Client Deployment Guide
    Tanium™ Client Deployment Guide Version 6.0.314.XXXX February 05, 2018 The information in this document is subject to change without notice. Further, the information provided in this document is provided “as is” and is believed to be accurate, but is presented without any warranty of any kind, express or implied, except as provided in Tanium’s customer sales terms and conditions. Unless so otherwise provided, Tanium assumes no liability whatsoever, and in no event shall Tanium or its suppliers be liable for any indirect, special, consequential, or incidental damages, including without limitation, lost profits or loss or damage to data arising out of the use or inability to use this document, even if Tanium Inc. has been advised of the possibility of such damages. Any IP addresses used in this document are not intended to be actual addresses. Any examples, command display output, network topology diagrams, and other figures included in this document are shown for illustrative purposes only. Any use of actual IP addresses in illustrative content is unintentional and coincidental. Please visit https://docs.tanium.com for the most current Tanium product documentation. Tanium is a trademark of Tanium, Inc. in the U.S. and other countries. Third-party trademarks mentioned are the property of their respective owners. © 2018 Tanium Inc. All rights reserved. © 2018 Tanium Inc. All Rights Reserved Page 2 Table of contents Overview 8 What is the Tanium Client? 8 Registration 9 Client peering 9 File distribution 11 Prerequisites 14 Host system requirements 14 Admin account 15 Network connectivity and firewall 16 Host system security exceptions 16 Deployment options summary 18 Using the Tanium Client Deployment Tool 21 Methods 21 Before you begin 21 Install the Client Deployment Tool 23 Deploy the Tanium Client 25 Check for Tanium Client updates 32 Troubleshooting 33 Logs 34 Advanced settings 34 Deploying the Tanium Client to Windows endpoints 36 Step 1: Create the installer 36 Step 2: Execute the installer 37 © 2018 Tanium Inc.
    [Show full text]
  • An Efficient and Portable SIMD Algorithm for Charge/Current Deposition in Particle-In-Cell Codes✩
    Computer Physics Communications 210 (2017) 145–154 Contents lists available at ScienceDirect Computer Physics Communications journal homepage: www.elsevier.com/locate/cpc An efficient and portable SIMD algorithm for charge/current deposition in Particle-In-Cell codesI H. Vincenti a,b,∗, M. Lobet a, R. Lehe a, R. Sasanka c, J.-L. Vay a a Lawrence Berkeley National Laboratory, 1 Cyclotron Road, Berkeley, CA, USA b Lasers Interactions and Dynamics Laboratory (LIDyL), Commissariat À l'Energie Atomique, Gif-Sur-Yvette, France c Intel Corporation, OR, USA a r t i c l e i n f o a b s t r a c t Article history: In current computer architectures, data movement (from die to network) is by far the most energy Received 9 January 2016 consuming part of an algorithm (≈20 pJ=word on-die to ≈10,000 pJ/word on the network). To increase Received in revised form memory locality at the hardware level and reduce energy consumption related to data movement, 10 August 2016 future exascale computers tend to use many-core processors on each compute nodes that will have Accepted 19 August 2016 a reduced clock speed to allow for efficient cooling. To compensate for frequency decrease, machine Available online 19 September 2016 vendors are making use of long SIMD instruction registers that are able to process multiple data with one arithmetic operator in one clock cycle. SIMD register length is expected to double every four years. As Keywords: Particle-In-Cell method a consequence, Particle-In-Cell (PIC) codes will have to achieve good vectorization to fully take advantage OpenMP of these upcoming architectures.
    [Show full text]
  • Bits and Bytes
    BITS AND BYTES To understand how a computer works, you need to understand the BINARY SYSTEM. The binary system is a numbering system that uses only two digits—0 and 1. Although this may seem strange to humans, it fits the computer perfectly! A computer chip is made up of circuits. For each circuit, there are two possibilities: An electric current flows through the circuit (ON), or An electric current does not flow through the circuit (OFF) The number 1 represents an “on” circuit. The number 0 represents an “off” circuit. The two digits, 0 and 1, are called bits. The word bit comes from binary digit: Binary digit = bit Every time the computer “reads” an instruction, it translates that instruction into a series of bits (0’s and 1’s). In most computers every letter, number, and symbol is translated into eight bits, a combination of eight 0’s and 1’s. For example the letter A is translated into 01000001. The letter B is 01000010. Every single keystroke on the keyboard translates into a different combination of eight bits. A group of eight bits is called a byte. Therefore, a byte is a combination of eight 0’s and 1’s. Eight bits = 1 byte Capacity of computer memory, storage such as USB devices, DVD’s are measured in bytes. For example a Word file might be 35 KB while a picture taken by a digital camera might be 4.5 MG. Hard drives normally are measured in GB or TB: Kilobyte (KB) approximately 1,000 bytes MegaByte (MB) approximately 1,000,000 (million) bytes Gigabtye (GB) approximately 1,000,000,000 (billion) bytes Terabyte (TB) approximately 1,000,000,000,000 (trillion) bytes The binary code that computers use is called the ASCII (American Standard Code for Information Interchange) code.
    [Show full text]
  • Binary Bracelets
    10010011011000110 10010011011000110110000100010001000001000 1001001101100011011000010001000111000110110 00010 001 1000001000 100 10011 011 000110 110000 10001000 001000 11000010 010000 010001010001000001000 100100110 010 010 110110000100010001000001000 1001001101 1000 110110000100010001000001000 1001001101 10001101100001000100010000 010 01000 10010011011000110110 00010 001 1000001000 100 10011 011 000110 110000 10001000001000 11000010 010000 01000 010 010 11000110110 00010 001 1000001000 100 10011 011 000110 110000 1000 10000 01 000 11000 010 010000 010 010 010 010 010 0100010010011011000110 10010011011000110110000100010001000001000 10010011011000110110000100010001110001101 10 00010 001BINARY 1000001000 101000110110000100010001000001000 BRACELETS 10010011011000110110 00010 001 1000001000 100 10011 011 000110 110000 10001000001000 11000010 010000 01000 11000110110 00010 001 1000001000 100 10011 011 000110 110000 1000 10000 01 000 1110 1100011011000010001000100000 000110 110000 10001000001000 11000010 010000 01000 11000110110 00010 001 1000001000 100 10011 011 000110 110000 1000 10010011011000110110 00010 001 1000001000 100 10011 011 Binary Code We are often used to representing numbers using ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. This is called a base-10, or decimal system. Binary code, however, uses only zeros and ones in a sequence of eight spots. We often to refer to these binary, or base-2, digits as “bits.” Binary code is used to communicate information between computers, communication devices, and many more modern technologies. It’s useful to build into electronic devices because it is a simple system that requires something turn on or off (where 1 is the on state and 0 is the off state). This activity will allow you to embed your own name or nickname in this secret code on a bracelet. The binary code for capital letters is found on the back of this page.
    [Show full text]
  • Bapco® Eecomark V2 User Guide
    BAPCo® EEcoMark v2 User Guide BAPCo is a U.S. Registered Trademark of the Business Applications Performance Corporation. EEcoMark is a U.S. Registered Trademark of the Business Applications Performance Corporation. Copyright © 2012 Business Applications Performance Corporation. All other brand and product names are trademarks or registered trademarks of their respective holders Contents 1.0 General .................................................................................................................................................... 4 1.1 Terminology ........................................................................................................................................ 4 2.0 Setup ....................................................................................................................................................... 5 2.1 Minimum System Requirements ........................................................................................................ 5 2.2 Hardware Setup .................................................................................................................................. 5 2.3 Software Setup .................................................................................................................................... 6 3.0 Configuration .......................................................................................................................................... 7 3.1 Guidelines ..........................................................................................................................................
    [Show full text]
  • Perceptive – Installing Imagenow Client on a Workstation
    Perceptive – Installing ImageNow client on a workstation Installing the ImageNow client on a workstation PURPOSE – Any computer that is going to be used to scan or import documents into Avatar will need ImageNow installed. Monterey is hosted by Netsmart and requires that VPN Checkpoint be established prior to initiating ‘Launch POS Scan’ from within Avatar. 1. Installing the ImageNow Client • Open the ImageNow Client Build 6.7.0 (Patch Build 3543) > right click and select “run as Administrator” even if you use your $ account. Avatar – After hitting “launch POS” it should auto connect to the Sunflower screen but if it does not. Error msg = “Failed to load image now client”, it could be that it was installed incorrectly. If installed incorrectly, Uninstall program from control panel and then reinstall the ImageNow Client 6.7.0 (Patch Build 3543).exe • On the Welcome to the Installation Wizard dialog, click Next. • Enable the following icons to be installed: o ImageNow Client Files o Demo Help o Administrator Help o Support for Viewing Non-graphic Data o ImageNow Printer (this is not selected by default) Note: the picture below does not have the ImageNow Printer selected. • On the License Agreement window, scroll down to the bottom of the License Agreement and accept the terms of the License Agreement to activate the Next button. • All sub features will be installed on the local hard drive, click Next. • On the Default connection Profile window, enter the following information and then click Next. o Name: Monterey PROD o Server ID: montereyimagenow.netsmartcloud.com o Server Type: Test o Port Number: 6000 The default information entered above creates the connection profiles below: Monterey Perceptive - Installing ImageNow v3 0(Installing the ImageNow Client onto a workstation) 1 | Page Plexus Foundations Perceptive – Installing ImageNow client on a workstation • Select the Next twice, and then Install.
    [Show full text]
  • PG-FP5 Flash Memory Programmer User's Manual
    User’s Manual User’s PG-FP5 Flash Memory Programmer User’s Manual All information contained in these materials, including products and product specifications, represents information on the product at the time of publication and is subject to change by Renesas Electronics Corp. without notice. Please review the latest information published by Renesas Electronics Corp. through various means, including the Renesas Electronics Corp. website (http://www.renesas.com). www.renesas.com Rev. 5.00 Dec, 2011 Notice 1. All information included in this document is current as of the date this document is issued. Such information, however, is subject to change without any prior notice. Before purchasing or using any Renesas Electronics products listed herein, please confirm the latest product information with a Renesas Electronics sales office. Also, please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website. 2. Renesas Electronics does not assume any liability for infringement of patents, copyrights, or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights of Renesas Electronics or others. 3. You should not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or in part. 4. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples. You are fully responsible for the incorporation of these circuits, software, and information in the design of your equipment.
    [Show full text]
  • Framework Visualizing of 32-Bit System Updates Response to Use
    al and Com tic pu re ta o t e io h n T a f l o S l c a i Journal of Theoretical & Computational e n n r c u e o J ISSN: 2376-130X Science Short Communication Framework Visualizing of 32-Bit System Updates Response to use 64-Bit Apps Operations Implications Based on System Troubles and Apps Updates and Errors/Framework Visualizing of 32-Bit System Updates Issues with use 64-Bit Apps Updating and Operations Al Hashami Z*, CS Instructor, Oman-Muscat SHORT COMMUNICATION AIMS AND OBJECTIVES The development of the systems versions is dramatic based on The aims of this research is to identify the implications of the buses lanes, memory and registers. As known in the updating operating system especially if it 32-bit under use of 64- computing the general rule that if the RAM is under 4GB, don’t bit applications operations a trouble face the users in case of that need a 64-bit CPU but if the RAM more than 4GB it need. users use many 64-bit applications. It is Identification of 32-bit Some users find that a 32-bit is enough memory and good system updating troubles under operations and updating of 64- performance, in contrast to huge size applications that need bit applications. Also identify of updating implications of 64-bit more memory and fast processing should use faster processor. software that working under 32-bit system implications. Some applications used for processing images, videos and 3D Usual users face many troubles in case of updates of systems rendering utilities need faster CPU like 64-bit system.
    [Show full text]
  • Code a Keychain Craft Kit (Pk/24) GP3306 1.0
    Reorder Number GP3306 Code a Keychain Craft Kit (Pk/24) GP3306 1.0 Fun Learn some new vocabulary words! Facts! Project Ideas • Cross Curricular For more craft ideas... ASCII - “American Standard Code for Information Links • Activity Sheets Interchange” encoding of characters. See what Crafty Kate is up to! Binary - A way of representing information using A FREE resource: Visit www.ssww.com/crafty-kate. only 2 options. Read About It- Visit our Blog at ssww.com/blog. Bit - Short for “Binary Digit”. It is one digit’s location . in a binary number. 8 bits make 1 byte. Get Social- Join and follow our social communities! Code a Keychain Craft Kit (Pk/24) Code/Coding - Transformation from one PLEASE READ ALL INSTRUCTIONS BEFORE STARTING . interpretation to another. Decode - Convert a coded message into something familiar. YOUR KIT CONTAINS: Encode – To convert a familiar message into code. • White Beads The type of code used for converting characters is . known as American Standard Code for Information • Black Beads Interchange (ASCII). It is the most commonly used • Assorted Colored Beads encoding scheme for files that contain text. • Cord Resources: techopedia.com • Split Rings http://wiki.kidzsearch.com code.org YOU WILL NEED: • Scissors • Ruler MAKING IT EASY to SAVE MORE on your next order! • Paper plates (optional) EACH PERSON SHOULD HAVE: Call Toll-Free • A split ring $ OFF 1-800-243-9232 • A 15” length of cord Your Next Order of The beads will be shared only $ 00 Online: 10 39 or more. ssww.com among the group. Please mention Offer Code:M2467 Minimum order $39 excludes shipping and taxes.
    [Show full text]
  • Machine and Assembly Language Programming
    COURSE TITLE: FOUNDATIONS OF SEQUENTIAL PROGRAM CODE: CSC 206 TOPIC TWO Machine language, assembly language and assemblers, low/high level languages (Machine-level implementation of high-level language) Objectives By the end of this class, students should be able to: 1. describe computer/programming language 2. list and describe the three different types or levels of programming languages 3. list the advantages of programming languages 4. list the disadvantages of programming languages 5. list and describe the different examples of types or levels of programming languages DISCLAIMER The contents of this document are intended for leaning purposes at the undergraduate level. The materials are from different sources including the internet and the contributors do not in any way claim authorship or ownership of them. COMPUTER / PROGRAMMING LANGUAGES Computer or Programming Languages are sets of words, symbols and codes used to write programs. Different programming languages are available for writing different types of programs. Some languages are specially used for writing business programming, others are used for writing scientific program etc. There are three types or levels of computer programming: 1. Machine language 2. Low level Languages 3. High Level Languages Machine language Machine Language is the actual bits used to control the processor in the computer, usually viewed as a sequence of hexadecimal numbers (typically bytes). The processor reads these bits in from program memory, and the bits represent "instructions" as to what to do next. Thus machine language provides a way of entering instructions into a computer (whether through switches, punched tape, or a binary file). Machine Language instruction has two (2) parts.
    [Show full text]