Subroutines, What are subroutines, Using normal subroutines – Omron HOME SECURITY SYSTEM - MOTION SENSOR FQM1-MMA21 User Manual

Page 287: 264 programming appendix a

Advertising
background image

264

Programming

Appendix A

Subroutines

What Are Subroutines?

A subroutine is a program written between the SBN(092) and RET(093) instructions in a special subroutine
area. A subroutine is called from the main program using the SBS(091), MCRO(099), or JSB(982) instruction.

Subroutines can be used in the following three ways with the FQM1.

Using Normal Subroutines

A normal subroutine is written between the SBN(092) and RET(093) instructions and called using the
SBS(091) instruction.

1.

Write the program to be executed between SBN(092) and RET(093).

2.

Set the subroutine number for the operand of SBN(092).

3.

Call the subroutine using SBS(091)

Type of subroutine

Description

Calling instruction

Normal subroutines

Normal subroutines are executed without passing parameters.

SBS(091)

Subroutines for
which parameters
are passed

• Parameters can be passed to the subroutine.
• The results of processing in the subroutine can be returned to the

main program.

MCRO(099)

• Flags can be used to access the input condition to the subroutine

while the subroutine is being executed.

• It’s possible to check to see if a subroutine has been executed in the

past.

• Parameters can be passed to and from the subroutine using storage

registers.

JSB(982)

SBN

100

RET

SBS

100

SBN

10

RET

Set the subroutine
number to call. Here,
the subroutine number
is 100.

Main program
(section 1)

Subroutine
(section 2)

Set the the subroutine
number. Here, the
subroutine number is
100.

Subroutine
(section 3)

Set the the subroutine
number. Here, the
subroutine number is
10.

Processing

Processing

Advertising