OOPic Programming Fundamentals Compiled vs. Interpreted programs –Compiled program converts high level code into native machine language e.g., y=x+5; Machine.

Slides:



Advertisements
Similar presentations
Dynamic Memory Allocation in C.  What is Memory What is Memory  Memory Allocation in C Memory Allocation in C  Difference b\w static memory allocation.
Advertisements

CPU Review and Programming Models CT101 – Computing Systems.
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Characters and Strings.
The Assembly Language Level
The 8085 Microprocessor Architecture
Processor System Architecture
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
MotoHawk Training Model-Based Design of Embedded Systems.
Inline Assembly Section 1: Recitation 7. In the early days of computing, most programs were written in assembly code. –Unmanageable because No type checking,
The Analytical Engine Module 6 Program Translation.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ input/output and clock inputs Sequence of control signal combinations.
State Machines Used to Design Sequential Circuits.
Building An Interpreter After having done all of the analysis, it’s possible to run the program directly rather than compile it … and it may be worth it.
CIS 260 Computer Programming I in C Prof. Timothy Arndt.
C++ fundamentals.
CEG 320/520: Computer Organization and Assembly Language Programming1 CEG 320/520 Computer Organization and Assembly Language Programming.
Lecture 18 Last Lecture Today’s Topic Instruction formats
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
Micro-operations Are the functional, or atomic, operations of a processor. A single micro-operation generally involves a transfer between registers, transfer.
Higher Computing Computer Systems S. McCrossan 1 Higher Grade Computing Studies 2. Computer Structure Computer Structure The traditional diagram of a computer...
Tutorial 11 Using and Writing Visual Basic for Applications Code
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Computers Are Your Future Eleventh Edition Chapter 2: Inside the System Unit Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall1.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 2.
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
Interrupts By Ryan Morris. Overview ● I/O Paradigm ● Synchronization ● Polling ● Control and Status Registers ● Interrupt Driven I/O ● Importance of Interrupts.
OOPic (Object Oriented Pic) Dominick D’Aniello Jacques Bosman.
CSCI 211 Intro Computer Organization –Consists of gates for logic And Or Not –Processor –Memory –I/O interface.
Execution of an instruction
CS 111 – Sept. 15 Chapter 2 – Manipulating data by performing instructions “What is going on in the CPU?” Commitment: –Please read through section 2.3.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
Z80 Overview internal architecture and major elements of the Z80 CPU.
Electronic Analog Computer Dr. Amin Danial Asham by.
CSC141- Introduction to Computer programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture – 21 Thanks for Lecture Slides:
CS415 C++ Programming Takamitsu Kawai x4212 G11 CERC building WV Virtual Environments Lab West Virginia University.
1 The Instruction Set Architecture September 27 th, 2007 By: Corbin Johnson CS 146.
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
Principles of Programming - NI Chapter 10: Character & String : In this chapter, you’ll learn about; Fundamentals of Strings and Characters The difference.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
1 The user’s view  A user is a person employing the computer to do useful work  Examples of useful work include spreadsheets word processing developing.
23/07/2016CSE1303 Part B lecture notes 1 Introduction to computer systems Lecture B01 Lecture notes section B01.
1 Computer System Overview Chapter 1. 2 Operating System Exploits the hardware resources of one or more processors Provides a set of services to system.
Chapter 1: Introduction to Computers and Programming
Basic Computer Organization and Design
The 8085 Microprocessor Architecture
The 8085 Microprocessor Architecture
Pointers and Pointer-Based Strings
C Basics.
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
Introduction to C++ Programming
CSCE Fall 2013 Prof. Jennifer L. Welch.
The Von Neumann Model Basic components Instruction processing
Chapter 5: Computer Systems Organization
The 8085 Microprocessor Architecture
MARIE: An Introduction to a Simple Computer
CSCE Fall 2012 Prof. Jennifer L. Welch.
Overview Last lecture Digital hardware systems Today
CIS16 Application Development and Programming using Visual Basic.net
Pointers and Pointer-Based Strings
The C Language: Intro.
Computer Systems An Introducton.
Presentation transcript:

OOPic Programming Fundamentals Compiled vs. Interpreted programs –Compiled program converts high level code into native machine language e.g., y=x+5; Machine language runs on the target Done in levels Cross-compiler  code program on one machine (PC) generate machine code for another machine (microcontroller) Features –Fast –Interpreted program executes high level code on the machine that the interpreter is running on Each line of code is interpreted and run each time each time the program is run Fetch token from EEPROM  wait for fetch complete  decode token (objects that represent an action)  locate native code associated with token  execute native code  advance EEPROM address Features –Easier to write an interpreter than a compiler –Slow

Object Oriented Pic Object  conceptual approach allowing the programmer to interact with what appears to be a physical object –Grouping of code and data treated as a single unit Like pre-written code libraries –Examples: oFreq oButton oLCD Why objects? –More intutive, faster to learn to use –Functionality built into the objects, so coding becomes mostly just manipulating objects (rather than reading and writing to memory locations) –Like having prewritten code libraries Ex: PWM –“multitasking code” objects operate “continuously” rather than line-by-line –Can link objects together

Types (classes) of Objects Hardware –Represents or encapsulates a physically implemented piece of hardware: oDio1 oA2D10 Processing –Retrieves values from other objects, performs calculations, stores resulting value in another object oMath Variable –Stores a value and provides evaluation properties about that value oByte System –controls one of several system functions oOOPic

Creating Objects Need to create an instance of the particular class of object –oA2D10 light_level = new oA2D10; Identifier Names must begin with a letter Identifier Names cannot contain a period. Identifier Names must not exceed 32 characters. Identifier Names must be unique within the application. (Identifier names are case insensitive) The name of the Identifier is not stored in RAM and therefore can be any length (up to 32 characters) with out affecting the amount of RAM that gets allocated for the Identifier's instance –Not sensitive to case: Light_level = = liGHt_LeVEl –Creates an instance of an oA2D10 object (10 bit A/D) –Must be done at the beginning of the program –Allocates memory out of the free RAM to hold the instance of the Object, and is added to the Object list in the order defined If object operation is time critical, place next to each other –86 bytes of object memory available (96 total, but OOPic object takes 10 bytes) Don’t add object that you don’t need! They will take up memory and operating time Operating system steps through the object list and executes the defined properties of the object

Creating Objects, cont. Can create arrays of objects by specifying a index value when the object is declared –Example of array of 3 A2D10 objects oA2D10 light_level(3)= new oA2D10; –Access using index value: Z=light_level(1).value; Some class of some objects have variable size –Example oGate (provides logic gate functions) with two inputs oGate 2-input_OR = new oGate(2);//declare 2-input OR gate oGate objects can have up to 8 inputs

Object Properties Properties are things that allow you to customize the characteristics of an object and determine the value an object holds. Some of the common ones: –Result A value (number) the result of processing done by the object –Value A value (number) specifying the state, content or magnitude of an Object –Flag A value (number) that signals the beginning or end of an object process –String Allow the value to be represented as a string –Operate Turns the object on (enables it to respond to input changes) –It will hold the state of its last change until operate property set to 1 Syntax to set: –object_name.Property=expression; –Ex. oA2D10 light_level = new oA2D10; light_level.IOLine = 1; // Map A2D10 object to A/D line 1 light_level.Operate = cvTrue;// Enable A2D10 object Syntax to determine the state of an object: –Variable=object_name.Property;

Object Methods Methods are actions that objects can perform

Object Method Example oDio4 Nib1 = new oDio4; oDio4 Nib2 = new oDio4; Const num1 = 1;// Defines the constant “num1” equal to 1 Sub void Main (void) Nib1.IOGroup = 1;//IO lines 8-15 Nib1.Nibble = 0;//IO lines 8-11 (the lower 4 bits) Nib1.Direction = cvInput;// Digital inputs (cvInput = = 1) Nib2.IOGroup = 1;//IO lines 8-15 Nib2.Nibble = 1;//IO lines (the upper 4 bits) Nib2.Direction = 0;// Digital outputs (cvOutput = = 0) Nib2.Value = Nib1.Invert;//Nib1 bits are inverted and sent out Nib2 Nib2 = Nib1.LShift;//Nib1 bits are shifted left and sent out Nib2

Linking Objects Together Virtual Circuit is a way to link objects together so that the state of one object can signal or modify the state of another object, like two elements connected in an electronic circuit –Can have any number of objects in the circuit –Need at least one Processing object to accomplish the link Processing object retrieve their input values and store their output values in the properties of other Objects –Fast! –“Multitasking” functionality (output continues to update the objects connected as long as processing object’s operating bit is set

Linking Objects Together, cont. Link Method –Uses pointers to “point” to the appropriate property is located Flag pointer –Flags signal an object to begin or end processing »Ex. oDIO1’s Value property is a 1-bit flag –Any flag output from any object can be linked to any flag input of another object using a processing object such as: »oGate (2 + no. of inputs) bytes »oWire (3 bytes) »oFanout (2 + no. of outputs) bytes »oOneShot (3 bytes) »oFlipFlop (5 bytes) »oEvent (3 bytes) Object pointer –These link the default values between objects via a processing object –e.g., usually between hardware objects and processing objects »oMath (4 bytes) »oBus (3 bytes)

Linking Objects Together, cont. Link Method syntax: Processing_object_name.Input.Link(other_object_name) Processing_object_name.Output.Link(other_object_name)

Object Linking Example Problem: Acquire the light level from two photoresistors, PR1 and PR2. If the light level on PR1 is higher than that for PR2, output a ‘high’ on pin B7. If the light level for PR2 is higher than that for PR1, output a logic ‘low’ on pin B7. // Procedural Approach oA2D10 PR1 = new oA2D10;// 3 bytes oA2D10 PR2 = new oA2D10; // 3 bytes oDIO1 OUT1 = new oDIO1; // 1 byte  total = 7 bytes (79 left) Sub void Main (void) { PR1.IOLine = 1;// Map A2D10 object to A/D line 1 PR1.Operate = cvTrue;// Enable A2D10 object PR2.IOLine = 2;// Map A2D10 object to A/D line 2 PR2.Operate = cvTrue;// Enable A2D10 object While (1) { If (PR1.Value > PR2.Value) { OUT1 = 1; } else { OUT1 = 0; { } // Virtual Circuit Approach oA2D10 PR1 = new oA2D10; // 3 bytes oA2D10 PR2 = new oA2D10; // 3 bytes oDIO1 OUT1 = new oDIO1; // 1 byte oWire W = new oWire; // 3 bytes oCompare COMP = new oCompare; // 4 bytes  total = 14 bytes (72 left) Sub void Main (void) { PR1.IOLine = 1;// Map A2D10 object to A/D line 1 PR1.Operate = cvTrue;// Enable A2D10 object PR2.IOLine = 2;// Map A2D10 object to A/D line 2 PR2.Operate = cvTrue;// Enable A2D10 object COMP.Input.Link(PR1);// Link PR1 to Input of oCompare object COMP.Fuzziness = 10;// Set ‘deadband’ to 10 COMP.ReferenceIn1.Link(PR2); // Link PR2 value to ReferenceIn1 input of oCompare OUT1.Ioline=15;// Set OUT1 to line 15 – pin B7 OUT1.Direction=cvOutput;// Make OUT1 a digital output W.Input.Link(COMP.Above);// Link Above flag to input of oWire object W.Output.Link (OUT1);// Link output of oWire to oDIO1 object }

VC Graphical Layout PR1 oA2D10 I/O line 1, pin A0 PR2 oA2D10 I/O line 2, pin A1 Input ReferenceIn1 oCompare: COMP Fuzziness=10 Above Between Below oWire: W InputOutput OUT1 oDIO1 I/O line 1, pin A0

Procedures // Example of a procedure // from OOPic manual oDio1 A = New oDio1; Sub void main(void) { A.IOLine = 31; A.Direction = cvOutput; Blink(); } Sub void Blink(void) { A.Value = cvON; OOPic.Wait = 100; A.Value = cvOff; OOPic.Wait = 100; } // Example of a procedure passing an argument // from OOPic manual Dio1 A = New oDio1; Sub void main(void) { A.IOLine = 31; A.Direction = cvOutput; Blink(5); } Sub void Blink(Byte xTimes) { While (xTimes.Value > 0) { A.Value = cvON; OOPic.Wait = 100; A.Value = cvOff; OOPic.Wait = 100; xTimes = xTimes - 1; }

Functions Functions can return a value Function Byte GetMyVal(void) { If (SW.Value == cvPressed) { GetMyVal = A1.Value; } Else { GetMyVal = A2.Value; } Function ( ) { return [ ]; }

Events An event is defined as any change in state that is recognized by an Object. An Event Driven Program is a program where any change in state can cause a subprocedure to be executed even when the program flow was not expecting to do so. Therefore, the order in which your code executes depends on which events occur. In normal operation, when an oEvent Object's Operate property transitions from 0 to 1 the program flow is interrupted with a call to a Sub procedure specified by the oEvent Object's name. While the Sub procedure is executing the oEvent Object ignores the Operate property and waits for the program flow to return from the Sub procedure. When the program flow returns from the Sub procedure the oEvent Object resumes watching for the Operate property to transition from 0 to 1