Summary for the Quiz - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Summary for the Quiz

Description:

CPU, Memory, Devices, Data Bus, Address Bus. Addresses and Enable ... void unit1 (int x) {x=1;}; int y; y=0; unit1(y); cout y endl; Call by reference ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 22
Provided by: scie241
Category:
Tags: quiz | summary | unit1

less

Transcript and Presenter's Notes

Title: Summary for the Quiz


1
Summary for the Quiz
  • Device Control
  • Architecture of PC
  • Interrupts in PC
  • Software Engineering
  • Data type, variables
  • Functions

2
Device Control
  • Architecture of PC
  • CPU, Memory, Devices, Data Bus, Address Bus
  • Addresses and Enable Devices
  • Interrupts in PC
  • Access Register Through Turbo C
  • Invoke Interrupts Through Turbo C

3
Architecture of PC
  • CPU, Memory, Devices, Data Bus, Address Bus
  • Connection between Them
  • Addresses and Enable Devices
  • Conversion among Decimal Numbers, Hexadecimal
    Numbers and Binary Numbers
  • Convert Addresses to Enable Devices for Hardware
    Devices

4
Interrupts of PC
  • Access Register Through Turbo C
  • Use Pseudo-Variables
  • Use SREGs
  • Invoke Interrupts Through Turbo C
  • description of interrupt in PC from handbooks
  • library functions from dos.h

5
Invoke Interrupts Through Turbo C
  • Description of interrupt in PC from handbooks
  • chapter 11 for keyboard and 12 for video
  • find out pre-condition and post-conditions of
    interrupts and their services
  • Library functions from dos.h
  • geninterrupt
  • int86

6
Software Engineering
  • Data type, variables
  • int, long, double, char, ascii code
  • pointer and array
  • struct //user defined data type
  • scope of variables (local vs global)
  • Functions
  • main
  • library functions
  • user defined functions
  • parameter list

7
int, long, double
  • Conversion between data types and Ascii code
  • What is the output of the following examples
  • int I I88888888 cout ltlt I ltltendl
  • int I I8888.8888 cout ltlt I ltlt endl
  • int I I9(88/9) cout ltlt I ltlt endl
  • int I I9(88/9.0) cout ltlt I ltlt endl
  • int I char x I97 xI cout ltlt xltlt endl

8
scope of variables (local vs global)
  • local variables of the same name
  • What is the output of the following program?
  • void change() int x xx-1
  • void main()
  • int x x4 change() cout ltlt x ltlt endl

9
Pointers
  • Definition of a pointer
  • int x
  • Address of pointer x
  • Value of pointer x
  • Object pointed to by pointer x
  • Assign values to a pointer
  • NULL
  • another pointer of the same type
  • address of another variable of the same type as
    the object pointed to by the pointer

10
array
  • Define an array int x100
  • size of array 100
  • name of the array a
  • element of array aI I0,1,, 99 //not 100

11
struct
  • Defined data type
  • struct new_data_type
  • int x //member variable 1
  • char y //member variable 2
  • double z //member variable 3
  • define a variable of this type
  • new_data_type w
  • access of member variables of struct
  • w.x1 w.ye w.z3.14
  • cout ltlt w.x ltlt w.y ltlt w.zltltendl

12
Functions
  • Main()
  • library functions
  • user defined functions
  • parameter lists

13
main ()
  • Each program has exactly one main()
  • Executed will start at the first line of main and
    finish at the end of main
  • Inside main(), other functions can be called to
    execute.

14
Library Functions
  • Include the necessary head file to call library
    functions
  • iostream.h for input/output
  • math.h for mathematical functions
  • dos.h for interrupt invoking functions

15
User Defined Functions
  • Prototype
  • return type, name, parameter list
  • preconditions and postconditions put down in
    comment
  • Definition
  • statements to be executed line by line
  • Call
  • invoke the function with adequate parameters

16
Parameter list
  • Call by value (default)
  • void unit1 (int x) x1
  • int y y0 unit1(y) cout ltlt yltlt endl
  • Call by reference
  • void unit2 (int x) x1
  • int y y0 unit2 (y) cout ltlt yltlt endl
  • Another way of comparison
  • printaddress1(int x) cout ltlt xltltendl
  • printaddress2(int x) cout ltltxltltendl
  • int y cout ltlt yltltendl
  • printaddress1(y) printaddress2(y)

17
Recursive Functions
  • a function call to itself inside the definition
    of a function. Such functions are called
    recursive.
  • An example
  • long int power(int n,int m)// the m-th power of
    n.
  • if (m0) return 1 // base case
  • return npower(n,m-1)

18
  • Another Example calculation of n!
  • long factorial(int n) //return n!
  • if (n0) return 1 //base case n0
  • return nfactorial(n-1) //n!n(n-1)!

19
Interrupt Function Intr()
  • structure REGPACK(unsigned r_ax,r_bx,r_cx,r_dx
    unsigned r_bp,r_si,r_di,r_ds,r_es,r_flags
  • void intr (int N, struct REGPACK Reg)
  • the same structure is used as input/output
  • r_ds_DS, r_es_ES should be set before invoke it
  • otherwise it will crash

20
An Example Using Intr()
readchar() char x REGPACK R /define
variables/ R.r_ax0x0000 /_AH0x0 service
0/ R.r_es_ES / preserve ES/
R.r_ds_DS / preserve DS/
intr(0x16,R) /keyboard interrupt 0x16 /
x0x00FFR.r_ax /xAL/ return x
21
Work on the Sample Quiz now
  • 1. Design a program which finds out the ASCII
    code of char f.
  • 2. What is the value of bitwise of 37 and 71?
  • 3. Draw the enable device for NMI (addresses
    0x70-0x7F)
  • 4. Prototype a function which returns the current
    video mode.
  • 5. Implement the above function by useing int86
    to invoke interrupt0x10 service 0x0F
Write a Comment
User Comments (0)
About PowerShow.com