Stubs (program stubs, procedure stubs, function stubs.)
- A stub is a the smallest possible fragment of a program which has just the essential statements that are necessary for it to able to be called, and to return to the calling location without creating an error.
Procedures
- aka modules, subprograms, program fragments, subroutines, functions)
call procedure by name
IRR Interrupt Request Routine
- recognise that an interrupt request has been received
- stop current execution
- push registers onto the stack
- execute the interrupt
- return to the last position before the IRR
- restore the situation to as it was before the interrupt by pulling the values for the registers off the stack
- resume program execution as if the interrupt had not occurred.
“Top Down” Development
During planning, work “top down”, that is,
- do the most general things first;
- fill in the most specific things last.
|
“Bottom up” development
This is what happens when you are writing the Pascal code, that is,
- do the most specific things first (fill in the details)
- then do the most general parts of the program last.
For example, you write the code for the procedures and functions before you write the code for the main program that calls the procedures or functions.
Pascal is said to be tightly structured or strongly structured, that is, the physical structure of a program always follows this order (as far as your course takes you!).
- program heading
- constant declarations
- type declarations
- variable declarations
- functions
- procedures
- main program
Procedures must be early in the program, so that the main program that calls them, knows where it is when it needs to call it.
|