Many students find it difficult understanding the concept of Object Oriented Programming OOP - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Many students find it difficult understanding the concept of Object Oriented Programming OOP

Description:

Many students find it difficult understanding the concept of Object ... Abstraction is a wonderful thing! * Hiding * Device changes, client does not notice ... – PowerPoint PPT presentation

Number of Views:137
Avg rating:3.0/5.0
Slides: 13
Provided by: amol9
Category:

less

Transcript and Presenter's Notes

Title: Many students find it difficult understanding the concept of Object Oriented Programming OOP


1
(No Transcript)
2
  • Many students find it difficult understanding
    the concept of Object Oriented Programming (OOP)
  • Lack of exciting labs leads to a loss of
    interest
  • Created with partial support from the National
    Science Foundations Division of Undergraduate
    Education through CCD grant DUE 97-52626 and ILI
    grant DUE 98-50983.
  • MIPPET has 4 switches, 4 LED's, a High Current
    Output, an A/D converter and two communication
    ports

3
(No Transcript)
4
  • Object Class provides a high level coding
    structure for the user

Mippet (int port) //
Precondition Mippet must be connected to
parallel port at //
address "port" (can be 0x378, 0x278 or 0x3BC)
// Postcondition Mippet is initialized to
all items off // (status
port bits 0-3 low, 4-7 high) void
ReadSwitches (bool switch0, bool switch1,
bool switch2, bool switch3)
// Precondition None //
Postcondition Sets the switch parameters to 0 or
1 depending on //
whether the switch is pressed or not at the
instant // the function
call is made (0 not pressed, //
1 pressed) // Returns None
5
  • MIPPET connects to the parallel port of a
    computer
  • All inputs and outputs are through pins on the
    parallel port
  • To use a port, we need to know its base address
    and the semantics of its usage provided by the
    data sheet

6
  • MS C/C provides two functions to write/read
    from the port inp outp
  • e.g. The parallel port has a base address of
    0x378.
  • To read the Status Port (located at the
    base
  • address1)
  • int x
  • x inp(0x379)
  • To set or clear a bit, need to create a mask

7
(No Transcript)
8
(No Transcript)
9
  • Say we want to set Logical Output 3 high.
  • We know that Logical Output 3 is connected to
    pin 4, which is bit 2 on the status port
  • Since we want to modify bit 2, our mask will be
    0000 0100 0x04
  • But we cannot just write 0x04 (0000 0100) to
    the port as this will clear all other bits.

10
  • Must read in the existing value of the data
    port
  • e.g. x inp(0x378)
  • We take this value and OR it with our mask
    (0x04)
  • ORing this mask with the value read from the
    status port sets bit 2 and keeps all other values
    unchanged.
  • e.g. x 1100010 1100110
  • OR 0000100 0000100
  • -----------
    -----------
  • 1100110 1100110

11
  • Talking to devices is basically a matter of
    reading/writing to ports
  • Abstraction is a wonderful thing!
  • Hiding
  • Device changes, client does not notice

12
QUESTIONS?
Write a Comment
User Comments (0)
About PowerShow.com