Program Design Two - Microcomputer Structures - Lecture Slides, Slides of Microcomputers

The lecture slides of the Microcomputer Structures are very easy to understand and the main points are:Program Design Two, Initial Part, Top Down Design, Modular Design, Parameter Passing, Stack and Local Variables, Structured Programming, Receive, Modify and Store, Output

Typology: Slides

2012/2013

Uploaded on 05/08/2013

anandini
anandini 🇮🇳

4.7

(9)

119 documents

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Program Design (2)
9/20/6 Lecture 3 - Instruction Set - Al 1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Program Design Two - Microcomputer Structures - Lecture Slides and more Slides Microcomputers in PDF only on Docsity!

Program Design (2)

Lecture Overview

  • Have seen the initial part of
    • Top down design
    • Modular design
  • Now
    • Parameter Passing
    • Stack and Local Variables
    • Structured Programming

Parameter passing example

  • Subroutine PUT_CHAR displays a single character on the monitor.
  • Main program action
    • Push character on stack
    • Call subroutine BSR PUT_CHAR
    • PUT_CHAR knows the location, and as only 1 byte, the data might be passed in a data register
    • More formal method places the data on the stack
    • It can use 4(A7) or 6(A7) to access the character.

Parameter passing in Registers

  • Works when the quantity of data is small or the processor has many, many registers.
  • Passing arguments in registers is code that is position independent and reentrant.
  • Position independent as no absolute address location involved in data transfer
  • Reentrant as the registers would be saved before they are reused.

Pass by Reference

  • Subroutine to search a region of memory
    • Text in memory
    • Want to check for sequence of characters
  • Info needed by subroutine
    • Starting and ending address of text
    • Start and ending address of the string
    • Subroutine receives addresses when called
    • Information in call – what string to find
  • Note: Code is not reentrant and cannot be used by an interrupt routine

Code example

  • For using the stack to pass by reference.

Parameter Passing on the Stack

  • Can use the stack to transfer the actual data
  • Can be used to pass the addresses for pass-by- reference

Figures for this example

  • Fig 3.

Stack frame

  • Allocation space on the stack - LEA -200(SP),SP
  • To restore stack prior to return - LEA 200(SP),SP
  • Refer to Fig 3.6 of text.

Simplification

  • LINK and UNLINK
    • A instruction to specifically do this
    • MOVE.L D0-D7,/A3-A6, -SP
      • Save the specified registers on the stack
    • LINK A1, #-
      • Allocate 64 bytes (16 longwords) of on this stack frame
    • Start subroutine

Subroutine example

  • Calculate R=(P 2 + Q 2 )/(P 2 – Q 2 )

Link Example

  • The stack

Three fundamental components

  • These are the basic elements of all high level functional programming languages.
  • Sequence
    • Action A, then action B, then action C, etc.
  • A looping mechanism
    • Finite loop – a set number of iterations
    • Conditional loop – exit when condition occurs
  • A decision mechanism
    • If (condition) THEN action A ELSE action B

GO TO????????????????????

• All algorithms can be programmed using

structured programming techniques

without using a GO TO!!!