Chapter 5 Instruction Specifications

RTI

Syntax of SB n, RTS, INT n and RTI

1] A subroutine can be programmed between a normal scan and interrupt scan, between two interrupt scans, or after the final interrupt scan.

Program head

SB 1

Normal scanRTS Subroutine 1

END

Interrupt

Subroutine area

 

SB 2

Subroutine 2

INT 1

 

RTS

scan

RTI

 

SB 10

Subroutine 10

 

Subroutine area

 

 

 

Interrupt

INT 2

 

RTS

 

 

SB 11

Subroutine 11

scan

RTI

 

 

Subroutine area

 

RTS

 

 

 

SB 12

Subroutine 12

 

Program end

 

 

 

 

RTS

 

2] Program the subroutine start (SB n) and subroutine end (RTS) instructions without specifying startup conditions.

Startup

SB n

 

 

condition

 

 

 

 

 

Program

 

Startup

 

 

• The RTS startup condition error

RTS

 

will occur during operation pre-

condition

 

 

 

 

processing.

3] Program the interrupt scan start (INT n) and scan complete (RTI) instructions without specifying startup conditions.

Startup

INT n

condition

Program

5] It is also possible to program a subroutine with multiple entry points and one exit.

 

 

 

 

 

 

 

 

SB 1

SB 1

SB 2

SB 3

JMP 1

SB 2

JMP 1

 

 

JMP 1

 

 

JMP 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SB 3

 

 

 

LBL 1

 

 

 

 

 

 

RTS

 

 

 

 

 

 

 

 

 

 

 

 

LBL 1

 

 

 

 

 

 

 

 

RTS

6] It is also possible to program a interrupt scan with many entry points and one exit.

INT 0

INT 1

INT 2

INT 0

JMP 1

 

 

JMP 1

JMP 1

 

 

INT 2

 

 

 

 

 

 

 

 

JMP 1

 

 

 

 

 

 

 

 

INT 1

 

LBL 1

 

 

 

 

 

RTI

 

LBL 1

 

 

 

 

RTI

7] Nesting of subroutines is allowed up to 5 levels.

1st level 2nd level 3rd level 4th level 5th level

SB 1

 

SB 20

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SB 30

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CAL 30

 

 

 

SB 40

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SB 50

CAL 20

 

 

 

 

 

CAL 40

 

CAL 50

 

 

 

 

 

 

 

 

RTS

 

 

 

 

 

 

RTS

 

RTS

 

RTS

 

RTS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Startup

condition RT1

4] The same subroutine can be called from a normal scan, interrupt scan or subroutine.

Program head

CAL 1

Normal scan

CAL 1

 

 

END

 

SB 2

Subroutine 2 CAL 1

 

RTS

Subroutine 1

SB 1

 

 

RTS

 

 

INI 0

Interrupt scan

CAL 1

 

 

RTI

Program head

END

SB 20

RTS

SB 1

RTS

INT 0

RTI

SB 40

RTS

SB 30

RTS

SB 50

RTS

(1)As shown to the left, the subroutine program order and nesting order have no relationship.

5-114

Page 164
Image 164
Hitachi NJI-350B manual Syntax of SB n, RTS, INT n and RTI, Nesting of subroutines is allowed up to 5 levels, 114