Assembly Assignment 6 - Lottery
|
|
- Kory Payne
- 5 years ago
- Views:
Transcription
1 Assembly Assignment 6 - Lottery Valdemar Örn Erlingsson Pseudo-Code Again, I write in a language I know very well, C++. Writing real code lets me test all functionality before I start. #include <iostream> using namespace std; int getrandom(); void int line[5]; int getrandom() { int r = rand(); //Fetch a random number r = r % 40; // Make sure number is in range r = r+1; // Add one to make range return r; } void getline() { L0: line[0] = getrandom(); //Fetch a random number L1: line[1] = getrandom(); // Note how I roll out the comparison for this part. // Only 5 numbers, easier to handle like // this in assembly, then to use loops! if (line[1] == line[0]) goto L1; L2: line[2] = getrandom(); if (line[2] == line[0]) goto L2; if (line[2] == line[1]) goto L2;
2 L3: L4: line[3] = getrandom(); if (line[3] == line[0]) goto L3; if (line[3] == line[1]) goto L3; if (line[3] == line[2]) goto L3; line[4] = getrandom(); if (line[4] == line[0]) if (line[4] == line[1]) if (line[4] == line[2]) if (line[4] == line[3]) } // Print a line of numbers cout << "\n" << line[0] << "\t" << line[1]; cout << "\t" << line[2] << "\t" << line[3] << "\t" << line[4]; int main() { srand ( time(null) ); // Seed the random generator // Create and print five lines // Print the winning line and bonus number cout << "\n\nwinning numbers (Bonus number)"; int bonus; Bonus: bonus = getrandom(); if (bonus == line[0]) if (bonus == line[1]) if (bonus == line[2]) if (bonus == line[3]) if (bonus == line[4]) cout << "\t(" << bonus << ")\n"; } return 0;
3 Assembly code START ORG $1000 BRA MAIN LINE DS.W 5 * Storage for the numbers of every line SPACE DC.B ' ',0 TAB DC.B 9,0 LEFTBR DC.B '(',0 RIGHTBR DC.B ')',0 WINNER DC.B 'Tonights lottery numbers (Bonus number)',0 NOP MACRO LEA SPACE,A1 * Print blank line MOVE.B #13,D0 ENDM MACRO LEA TAB,A1 * Print tab character MOVE.B #14,D0 ENDM * Random number generator * NextPRN Ninc0 MOVEQ #$AF-$100,d1 MOVEQ #18,d2 MOVE.l d6,d0 ADD.l d0,d0 BCC.s Ninc1 * set EOR value * do this 19 times * get current * shift left 1 bit * branch if bit 32 not set Ninc1 EOR.b d1,d0 DBF d2,ninc0 * loop * do galois LFSR feedback MOVE.l d0,d6 MOVE.l d0,d1 RTS * save back to seed word * Save also to d1 for displaying NextPRN SWAP d1 * the top 16 bits are "a bit more random" * than the lower 16 bits... :) MOVE.w d1,d2 MOVE.l d2,d1 * get rid of upper 16 bits MOVEQ #40,d2 DIVU d2,d1 * divide by 40, remainder (modulus) in * upper 16 bits SWAP d1 * put remainder in lower 16 bits MOVE.w d1,d2 MOVE.l d2,d1 * get rid of upper 16 bits ADDI.L #1,d1 RTS * randum number stored in d1
4 L0 L1 LEA LINE,A6 * Load address of line into A6 * Use A4 as working pointer BEQ L1 L2 BEQ L2 BEQ L2 ADDQ #4,A5 L3 BEQ L3 BEQ L3 CMP (A5),D1 * Compare to (2) BEQ L3 ADDQ #6,A5 L4
5 CMP (A5),D1 * Compare to (2) CMP (A5),D1 * Compare to (3) ADDQ #8,A5 * Print the entire line MOVEQ #2,D2 RTS
6 MAIN seed MOVE.B #8,D0 MOVE d1,d6 * Fetch seconds from midnight for random LEA WINNER,A1 * Print "Tonights lottery numbers.." MOVE.B #13,D0 * Get the winning line BONUS CMP (A5),D1 * Compare to (2) CMP (A5),D1 * Compare to (3) CMP (A5),D1 * Compare to (4) ADDQ #8,A5 MOVE D1,D6 * Keep bonus number in D6 LEA LEFTBR,A1 * Print left bracket MOVE.B #14,D0 MOVE D6,D1 * Print the number MOVE.L #3,D0
7 LEA RIGHTBR,A1 * Print left bracket MOVE.B #13,D0 MOVE.B #9,D0 Halt Simulator END START Notes The code contains alot of repetitions. I do this rather than use loops at some points because it is easier to implement. Also, although code size is larger, execution is faster this way, so it's not all bad. The random number generator was found at I use Trap #8 as the first seed (returns time from midnight). This is decent, but it does not give *good* randomness. Although not specifially mentioned in the project, I have added a check to make sure each number only appears once in every line. This feature takes up almost half the program code, but the same code is repeated several times.
Multiplies the word length <ea> times the least significant word in Dn. The result is a long word.
MATHEMATICAL INSTRUCTIONS Multiply unsigned MULU ,dn Action Notes: Example: Multiplies the word length times the least significant word in Dn. The result is a long word. 1. The lowest word of
More informationINTRODUCTION TO BRANCHING. There are two forms of unconditional branching in the MC68000.
INTRODUCTION TO BRANCHING UNCONDITIONAL BRANCHING There are two forms of unconditional branching in the MC68000. BRA instruction BRA Program control passes directly to the instruction located at
More informationSubroutines. passing data
Subroutines passing data Mechanisms: pass by value pass by result pass by value result/ value return/ copy restore pass by reference pass by name pass by lazy evaluation Techniques: 1. in registers 2.
More informationC Calling Conventions
C Calling Conventions 1. parameters are passed on the run-time or system stack, SP (or A7) 2. parameters pushed on stack in right to left order of call A6 used as the stack frame pointer local variables
More informationEECE416 :Microcomputer Fundamentals and Design Instruction Sets and Groups
EECE416 :Microcomputer Fundamentals and Design 68000 Instruction Sets and Groups 1 Instruction Groups Data Transfer Groups Arithmetic Group Logical Group Shift and Rotate Group Bit Manipulation Group Binary
More informationModule 7: Address Registers & Array Processing
Module 7: Address Registers & Array Processing Special instructions for address registers CMPA, MOVEA, SUBA, ADDA LEA Understanding arrays Array applications 2006 munim@utm.my,athif@fke.utm.my,kamal@bip.utm.my
More informationstack frame where register An is used as the argument pointer.
STACK FRAMES The MC68000 provides two special instructions to allocate and deallocate a data structure called a frame in the stack to make subroutines easier to code. general structure of a frame: SP local
More information68000 Architecture. To review the the architecture of the microprocessor.
68000 Architecture Aims To review the the architecture of the 68000 microprocessor. Intended Learning Outcomes At the end of this module, students should be able to: Briefly explain the history of microprocessor
More informationAssembly Language. Operand Size. The internal registers. Computers operate on chunks of data composed of a particular number of bits.
1 2 Chapter 6 Assembly Language Operand Size 8 bits 16 bits Computers operate on chunks of data composed of a particular number of bits. The 68K has a 32-bit architecture and a 16-bit organization. Internal
More informationLab 2 Use Traps. Lab 2 Input and Output 2 nd Semester. Lab 2 English. Lab 2 Pseudocode
Lab 2 Input and Output Lab 2 Use Traps Write (i.e. design and implement) an assembly language program that will accept user input from the keyboard and echo this to the terminal screen. Input should terminate
More informationCPE/EE 421 Microcomputers
CPE/EE 421 Microcomputers Instructor: Dr Aleksandar Milenkovic Lecture Note S07 Outline Stack and Local Variables C Programs 68K Examples Performance *Material used is in part developed by Dr. D. Raskovic
More informationINTRODUCTION TO BRANCHING
INTRODUCTION TO BRANCHING UNCONDITIONAL BRANCHING There are two forms of unconditional branching in the MC68000. BRA instruction BRA Program control passes directly to the instruction located at
More informationLab Instructor : Jean Lai
Lab Instructor : Jean Lai Group related statements to perform a specific task. Structure the program (No duplicate codes!) Must be declared before used. Can be invoked (called) as any number of times.
More informationCPE/EE 421 Microcomputers
CPE/EE 421 Microcomputers Instructor: Dr Aleksandar Milenkovic Lecture Note S04 *Material used is in part developed by Dr. D. Raskovic and Dr. E. Jovanov CPE/EE 421/521 Microcomputers 1 The 68000 Family
More informationProgram Development. Chapter 5
Chapter 5 Program Development Expected Outcomes Distinguish between various codes in the programming language Explain the role of assembler and compiler Distinguish between different data types Use directive
More informationLast Time. Response time analysis Blocking terms Priority inversion. Other extensions. And solutions
Last Time Response time analysis Blocking terms Priority inversion And solutions Release jitter Other extensions Today Timing analysis Answers a question we commonly ask: At most long can this code take
More information68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1
68000 Instruction Set (2) 9/20/6 Lecture 3 - Instruction Set - Al 1 Lecture Overview The 68000 Instruction Set continued The understand and effectively use an architecture must understand the register
More informationAlex Milenkovich 1. CPE/EE 421 Microcomputers: Motorola 68000: Assembly Language and C. Outline
Outline CPE/EE 421 Microcomputers: Motorola 68: Assembly Language and C Instructor: Dr Aleksandar Milenkovic Lecture Notes ACIA Example: Pseudo-code + Assembly Passing parameters In registers Passing by
More informationTutorial 1 Microcomputer Fundamentals
Tutorial 1 Microcomputer Fundamentals Question 1 What do these acronyms mean? (a) CPU? (b) ROM? (c) EPROM? (d) RWM? (e) RAM? (f) I/O? What role does the CPU play in a computer system? Why is ROM an essential
More information1. bit manipulation instructions such as BTST, BCHG
1. bit manipulation instructions such as BTST, BCHG 9. (Exam #2, 1990) If ($53EFE)=$ 0A ($5FFFE)=$ 00 ($53EFF)=$ EE ($5FFFF)=$ 00 ($53F00)=$ FF ($60000)=$ 00 ($53F01)=$ 00 ($60001)=$ 00 ($53F02)=$ 12 ($60002)=$
More informationTutorial 12 Craps Game Application: Introducing Random Number Generation and Enumerations
Tutorial 12 Craps Game Application: Introducing Random Number Generation and Enumerations Outline 12.1 Test-Driving the Craps Game Application 12.2 Random Number Generation 12.3 Using an enum in the Craps
More informationCPE/EE 421 Microcomputers
CPE/EE 421 Microcomputers Instructor: Dr Aleksandar Milenkovic Lecture Note S06 *Material used is in part developed by Dr. D. Raskovic and Dr. E. Jovanov CPE/EE 421/521 Microcomputers 1 Course Administration
More information68000 Assembler by Paul McKee. User's Manual
Contents 68000 Assembler by Paul McKee User's Manual 1 Introduction 2 2 Source Code Format 2 2.1 Source Line Format............................... 2 2.1.1 Label Field............................... 2 2.1.2
More informationPhysics 116B Winter 2006: Problem Assignment 8
Physics 116B Winter 2006: Problem Assignment 8 Due Wednesday, March 15 1. You may use a calculator for the following: (a) Convert to decimal: $9F03. (b) Express in binary: $3CFA. (c) Convert to hexadecimal:
More informationBuilding on the foundation. Now that we know a little about cout cin math operators boolean operators making decisions using if statements
Chapter 5 Looping Building on the foundation Now that we know a little about cout cin math operators boolean operators making decisions using if statements Advantages of Computers Computers are really
More informationLast Time. Compiler requirements C preprocessor Volatile
Last Time Compiler requirements C preprocessor Volatile Today Coding and translation of interrupt handlers Coding inline assembly Compiler intrinsics Interrupts 30-second interrupt review: Interrupts are
More informationPART II: Cap. 6 - Linguaggio macchina M68000
192 CHAPTER 3 ARM, MOTOROLA, AND INTEL INSTRUCTION SETS 3.20 Rewrite the byte-sorting program in Figure 3.15b as a subroutine that sorts a list of 32-bit positive integers. The calling program should pass
More information13 Programming the & 8051
13 Programming the 68020 & 8051 The previous chapter described in general terms the typical instructions and addressing modes provided on microprocessors. In this chapter the facilities provided for two
More information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More information... Executing conditional instructions
1 2 Executing conditional instructions Our design to this point has been the SISD (single instruction single data) architecture This is fine if we wish to execute in a purely sequential mode We now wish
More informationSubroutine. Chapter 8
Chapter 8 Subroutine Expected Outcomes Describe and apply the stack for data storage Describe the process of subroutine in any programs Develop a subroutine and code Interpret subroutine process in the
More informationAlex Milenkovich 1. CPE/EE 421 Microcomputers: Motorola 68000: Architecture & Assembly Programming. Outline
Outline CPE/EE 421 Microcomputers: Motorola 68000: Architecture & Assembly Programming Instructor: Dr Aleksandar Milenkovic Lecture Notes Programmer s Model Assembly Language Directives Addressing Modes
More informationAddressing Modes. To review data transfer instructions and applying the more advanced addressing modes.
Addressing Modes Aims To review 68000 data transfer instructions and applying the more advanced addressing modes. Intended Learning Outcomes At the end of this module, students t should be able to Review
More informationA Quickie Introduction to the Windows Based 68K Assembler EASy68K
A Quickie Introduction to the Windows Based 68K Assembler EASy68K You now have a number of options to assemble your code for your microcontroller. One option, of course, is to assemble it by hand, using
More informationManual Instrumentation 2 Manual Instrumentation Process Throughout this document we will refer to the code in an unsupported language as the original
CodeTEST Tools Application Note Manual Instrumentation Manually insert test-point instructions, or tags, in source code to gather real time execution analysis using the Freescale CodeTEST Tools. Purpose
More informationToday s objective: introduction to really simple subroutines to simplify program structure for I/O
a 1 st look procedures and functions in high level languages are modeled on subroutines typically, assembly code is very modular with the main routine less than 100 lines long Today s objective: introduction
More informationSection 1--Computer architecture: organization of the cpu and memory, address and data bus, fetch-execute cycle
Here are some sample exams and questions that you can study for your first exam. These are actual problems that have been used on old exams. I have tried to eliminate all the problems of types which will
More informationLab Cover Page. Lab Date and Time: Teaching Assistant to whom you are submitting
Student Information First Name School of Computer Science Faculty of Engineering and Computer Science Last Name Student ID Number Lab Cover Page Please complete all fields: Course Name: Structure and Application
More informationMark Redekopp, All rights reserved. EE 357 Unit 4b. CF Assembly Basics
EE 357 Unit 4b CF Assembly Basics OPERATIONS AND INSTRUCTIONS Coldfire Instruction Classes Data Transfer Move data between processor & memory Move data between registers w/in processor Can specify.b,.w,.l
More informationFunctions in C++ Problem-Solving Procedure With Modular Design C ++ Function Definition: a single
Functions in C++ Problem-Solving Procedure With Modular Design: Program development steps: Analyze the problem Develop a solution Code the solution Test/Debug the program C ++ Function Definition: A module
More informationCharacter Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits
More informationSEE 3223 Microprocessors. 4: Addressing Modes. Muhammad Mun im Ahmad Zabidi
SEE 3223 Microprocessors 4: Addressing Modes Muhammad Mun im Ahmad Zabidi (munim@utm.my) Addressing Modes Aims To review 68000 data transfer instruchons and applying the more advanced addressing modes.
More informationLab 8 The Stack (LIFO) Structure
Lab 8 The Stack (LIFO) Structure Objective: The stack segment in memory is where the 80x86 maintains the stack. The stack stores important information about program including local variables, subroutine
More informationStudent # (In case pages get detached) The Edward S. Rogers Sr. Department of Electrical and Computer Engineering
ECE 243S - Computer Organization The Edward S. Rogers Sr. Department of Electrical and Computer Engineering Mid-term Examination, March 2005 Name Student # Please circle your lecture section for exam return
More informationMC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES
MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes o Review of Addressing Modes o Which branch instruction to use (signed vs unsigned) o Using X and Y registers
More informationWentworth Institute of Technology COMP201 Computer Science II Spring 2015 Derbinsky. C++ Kitchen Sink. Lecture 14.
Lecture 14 1 Exceptions Iterators Random numbers Casting Enumerations Pairs The Big Three Outline 2 Error Handling It is often easier to write a program by first assuming that nothing incorrect will happen
More informationLast Time. Low-level parts of the toolchain for embedded systems. Any weak link in the toolchain will hinder development
Last Time Low-level parts of the toolchain for embedded systems Ø Linkers Ø Programmers Ø Booting an embedded CPU Ø Debuggers Ø JTAG Any weak link in the toolchain will hinder development Today: Intro
More informationCPE300: Digital System Architecture and Design
CPE300: Digital System Architecture and Design Fall 2011 MW 17:30-18:45 CBC C316 RISC: The SPARC 09282011 http://www.egr.unlv.edu/~b1morris/cpe300/ 2 Outline Recap Finish Motorola MC68000 The SPARC Architecture
More informationLAB 1: MC68000 CPU PROGRAMMING DATA TRANSFER INSTRUCTIONS
LAB 1: MC68000 CPU PROGRAMMING DATA TRANSFER INSTRUCTIONS OBJECTIVES At the end of the laboratory works, you should be able to write simple assembly language programs for the MC68000 CPU using data transfer
More informationSubroutines. we jump to a new location in the code
Subroutines EE 57 Unit 7 Subroutines Stacks Subroutines (or functions) are portions of code that we can call from anywhere in our code, execute that t subroutine, and then A subroutine to calculate the
More informationProgramming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3
Programming - 1 Computer Science Department 011COMP-3 لغة البرمجة 1 011 عال- 3 لطالب كلية الحاسب اآللي ونظم المعلومات 1 1.1 Machine Language A computer programming language which has binary instructions
More informationPage 1. Lab. Something Cool. Quiz Results. Last Time. Embedded Compilers. Today: Intro to Embedded C
Something Cool Lab RFID is an exciting and growing technology This reader from Parallax is $40 and has a serial interface Lab 1 due next Tues Seemed to go pretty well on Tues? Questions? Quiz Results Last
More informationSomething Cool. RFID is an exciting and growing. This reader from Parallax is $40 and has a serial interface
Something Cool RFID is an exciting and growing technology This reader from Parallax is $40 and has a serial interface Lab Lab 1 due next Tues Seemed to go pretty well on Tues? Questions? Quiz Results Problem
More informationLab Reports. Program Description (separate page - ONLY IF REQUIRED)
Lab Reports Reports should be in neat, concise form and turned in on time. The best reports will cover all vital information in detail without excessive verbiage on unnecessary details. Your report will
More information2) Using the same instruction set for the TinyProc2, convert the following hex values to assembly language: x0f
CS2 Fall 28 Exam 2 Name: ) The Logisim TinyProc2 has four instructions, each using 8 bits. The instruction format is DR SR SR2 OpCode with OpCodes of for add, for subtract, and for multiply. Load Immediate
More informationMore Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4
More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4 Ziad Matni Dept. of Computer Science, UCSB Administrative CHANGED T.A. OFFICE/OPEN LAB HOURS! Thursday, 10 AM 12 PM
More informationLecture 23: Pointer Arithmetic
Lecture 23: Pointer Arithmetic Wai L. Khoo Department of Computer Science City College of New York November 29, 2011 Wai L. Khoo (CS@CCNY) Lecture 23 November 29, 2011 1 / 14 Pointer Arithmetic Pointer
More informationProgramming for Engineers Functions
Programming for Engineers Functions ICEN 200 Spring 2018 Prof. Dola Saha 1 Introduction Real world problems are larger, more complex Top down approach Modularize divide and control Easier to track smaller
More informationC++ Lecture 5 Arrays. CSci 588: Data Structures, Algorithms and Software Design.
C++ Lecture 5 Arrays CSci 588: Data Structures, Algorithms and Software Design http://www.cplusplus.com/doc/tutorial/arrays/ All material not from online sources copyright Travis Desell, 2013 Overview
More informationDescribing and Implementing Algorithms
Describing and Implementing Algorithms ECE2036 Lecture 1 ECE2036 Describing and Implementing Algorithms Spring 2016 1 / 19 What is an Algorithm? According to Wikipedia: An algorithm is a sequence of instructions,
More informationArray Elements as Function Parameters
Arrays Class 26 Array Elements as Function Parameters we have seen that array elements are simple variables they can be used anywhere a normal variable can unsigned values [] {10, 15, 20}; unsigned quotient;
More information(created by professor Marina Tanasyuk) FUNCTIONS
FUNCTIONS (created by professor Marina Tanasyuk) In C++, a function is a group of statements that is given a name, and which can be called from some point of the program. The most common syntax to define
More informationSol. Sol. a. void remove_items_less_than(int arr[], int size, int value) #include <iostream> #include <ctime> using namespace std;
r6.14 For the operations on partially filled arrays below, provide the header of a func tion. d. Remove all elements that are less than a given value. Sol a. void remove_items_less_than(int arr[], int
More informationChapter 10 - Notes Applications of Arrays
Chapter - Notes Applications of Arrays I. List Processing A. Definition: List - A set of values of the same data type. B. Lists and Arrays 1. A convenient way to store a list is in an array, probably a
More informationIntroduction to Programming
Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines
More informationNon-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words.
, ean, arithmetic s s on acters Comp Sci 1570 Introduction to C++ Outline s s on acters 1 2 3 4 s s on acters Outline s s on acters 1 2 3 4 s s on acters ASCII s s on acters ASCII s s on acters Type: acter
More informationChapter 3. Z80 Instructions & Assembly Language. Von Neumann Architecture. Memory. instructions. program. data
Von Neumann Architecture The von Neumann architecture is a computer design model that uses a processing unit and a separate storage to hold both instructions and data To run a machine, program and data
More information2B 52 AB CA 3E A1 +29 A B C. CS120 Fall 2018 Final Prep and super secret quiz 9
S2 Fall 28 Final Prep and super secret quiz 9 ) onvert 8-bit (2-digit) 2 s complement hex values: 4-29 inary: Hex: x29 2) onvert 8-bit 2 s complement hex to decimal: x3 inary: xe5 Decimal: 58 Note 3*6+
More informationXuan Guo. Lecture XIV: Review of Chapter 3 & 4. CSC 3210 Computer Organization and Programming Georgia State University. March 5, 2015.
CSC 3210 Computer Organization and Programming Georgia State University March 5, 2015 This lecture Plan for the lecture: Binary Hardware Device Converting from Decimal to other number system Converting
More informationThe terminal display function can be done using HexOut.
INTERRUPT TIMED CLOCK ABSTRACT: This laboratory will introduce the student to the generation of interrupts (using a programmable timer), the handling of an interrupt, and the priority of interrupts. This
More information9. Arrays. Compound Data Types: type name [elements]; int billy [5];
- 58 - Compound Data Types: 9. Arrays An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.
More information3. (5 points) Name the 5 components of a computer
Problem 1: (20 points) Short Answers (10 minutes) 1. (5 points): What is the result in register $t0 after these lines of MIPS assembly code are executed? add $t0, $zero, $zero ori $t0, $t0, 0xC3C3C3C3
More informationModule Contact: Dr Pierre Chardaire, CMP Copyright of the University of East Anglia Version 1
UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series UG Examination 2016-17 INTRODUCTORY PROGRAMMING CMP-0005A Time allowed: 2 hours Answer BOTH questions from Section A and ONE question
More informationChapter 5 C Functions
Chapter 5 C Functions Objectives of this chapter: To construct programs from small pieces called functions. Common math functions in math.h the C Standard Library. sin( ), cos( ), tan( ), atan( ), sqrt(
More informationCS 31 Discussion 1A, Week 4. Zengwen Yuan (zyuan [at] cs.ucla.edu) Humanities A65, Friday 10:00 11:50 a.m.
CS 31 Discussion 1A, Week 4 Zengwen Yuan (zyuan [at] cs.ucla.edu) Humanities A65, Friday 10:00 11:50 a.m. Today s focus Notes from the project 2 grading Function call predefined function define a function
More informationOverview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program
Overview - General Data Types - Categories of Words - The Three S s - Define Before Use - End of Statement - My First Program a description of data, defining a set of valid values and operations List of
More informationObjectivities. Experiment 1. Lab6 Array I. Description of the Problem. Problem-Solving Tips
Lab6 Array I Objectivities 1. Using rand to generate random numbers and using srand to seed the random-number generator. 2. Declaring, initializing and referencing arrays. 3. The follow-up questions and
More informationC++ For Science and Engineering Lecture 15
C++ For Science and Engineering Lecture 15 John Chrispell Tulane University Wednesday September 29, 2010 Function Review Recall the basics you already know about functions. Provide a function definition.
More informationElements of C in C++ data types if else statement for loops. random numbers rolling a die
Elements of C in C++ 1 Types and Control Statements data types if else statement for loops 2 Simulations random numbers rolling a die 3 Functions and Pointers defining a function call by value and call
More informationAgenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures
The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationMultiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationLab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1
Lab 2: Pointers 1. Goals Further understanding of pointer variables Passing parameters to functions by address (pointers) and by references Creating and using dynamic arrays Combing pointers, structures
More informationThis chapter introduces the notion of namespace. We also describe how to manage input and output with C++ commands via the terminal or files.
C++ PROGRAMMING LANGUAGE: NAMESPACE AND MANGEMENT OF INPUT/OUTPUT WITH C++. CAAM 519, CHAPTER 15 This chapter introduces the notion of namespace. We also describe how to manage input and output with C++
More informationMachine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine
Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction
More informationINSTRUCTION SET AND EXECUTION
SECTION 6 INSTRUCTION SET AND EXECUTION Fetch F1 F2 F3 F3e F4 F5 F6 Decode D1 D2 D3 D3e D4 D5 Execute E1 E2 E3 E3e E4 Instruction Cycle: 1 2 3 4 5 6 7 MOTOROLA INSTRUCTION SET AND EXECUTION 6-1 SECTION
More informationFreescale Semiconductor, I. Table 1: MCF5206 Power Consumption. 16MHZ 25MHz 33MHz UNITS mw. Notational Conventions
Order this document by MCF5206UMAD/AD Communications Consumer Systems and Advanced Group Consumer Technologies Group MCF5206 Addendum to MCF5206 User Manual April 13, 1998 This addendum to the initial
More informationSPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY
BACKGROUND 8086 CPU has 8 general purpose registers listed below: AX - the accumulator register (divided into AH / AL): 1. Generates shortest machine code 2. Arithmetic, logic and data transfer 3. One
More informationMultiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationCS 240 Data Structure Spring 2018 Exam I 03/01/2018
CS 240 Data Structure Spring 2018 Exam I 03/01/2018 This exam contains three section A) Code: (basic data type, pointer, ADT) a. Reading: Trace the code to predict the output of the code b. Filling: Fill
More informationThis simulated machine consists of four registers that will be represented in your software with four global variables.
CSCI 4717 Computer Architecture Project 1: Two-Stage Instuction Decoder Due: Monday, September 21, 26 at 11:59 PM What to submit: You will be submitting a text file containing two C functions, fetchnextinstruction()
More information4. Structure of a C++ program
4.1 Basic Structure 4. Structure of a C++ program The best way to learn a programming language is by writing programs. Typically, the first program beginners write is a program called "Hello World", which
More informationEE 3170 Microcontroller Applications
Q. 3.9 of HW3 EE 37 Microcontroller Applications (a) (c) (b) (d) Midterm Review: Miller Chapter -3 -The Stuff That Might Be On the Exam D67 (e) (g) (h) CEC23 (i) (f) (j) (k) (l) (m) EE37/CC/Lecture-Review
More informationLecture 6 Assembly Programming: Branch & Iteration
CPE 390: Microprocessor Systems Spring 2018 Lecture 6 Assembly Programming: Branch & Iteration Bryan Ackland Department of Electrical and Computer Engineering Stevens Institute of Technology Hoboken, NJ
More informationMultiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationChapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley
More informationChapter 2: Introduction to C++
Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++
More informationFunction Call Stack and Activation Records
71 Function Call Stack and Activation Records To understand how C performs function calls, we first need to consider a data structure (i.e., collection of related data items) known as a stack. Students
More information