HARSFEN0602ElmoHARmonicaSoftwareManual

PRELIMINARYDRAFT

7.7.39USRSUBJ – jump To User Subroutine

Purpose:

Call to user subroutine (push relevant function data to stack).

 

SEE 8.2

 

 

 

 

 

 

 

 

Algorithm:

 

 

 

 

 

 

 

 

BP

(SP)

 

(save base pointer)

 

 

SP

SP + 1

 

 

 

 

 

 

 

 

OP2

(SP)

 

(save return address)

 

 

SP

SP + 1

 

 

 

 

 

 

 

 

FuncIndex

(SP)

 

(save function index)

 

 

SP SP + 1

 

 

 

 

 

 

 

 

NArgIn (SP)

 

 

(save number of input arguments)

 

7.7.39.1.1.1.1.1

 

 

SP

 

SP + 1

 

 

NActArgOut

 

(SP)

(save number of actual output arguments)

 

SP

SP + 1

 

 

 

 

 

 

 

 

SP

BP

 

(update base pointer)

 

 

PC FuncAddr

 

(jump to user subroutine)

 

 

Attributes

 

 

 

 

 

 

 

 

Attribute

 

 

 

 

 

Value

Comment

 

 

 

 

 

 

 

 

 

 

Op code

 

 

 

 

 

May change in future

 

 

 

 

 

 

 

 

versions

 

Number of arguments

 

 

2

 

 

 

 

 

 

 

 

 

 

 

Argument type1

 

 

 

 

Unsigned short integer

Lower 8 bits :

 

 

 

 

 

 

 

 

 

Actual ouput arguments

 

 

 

 

 

 

 

 

 

Upper 8 bits :

 

 

 

 

 

 

 

 

 

Subroutine Index

 

Argument type1

 

 

 

 

Unsigned short integer

Return Address

 

Addressing mode1

 

 

 

Immediate2

 

 

Addressing mode1

 

 

 

Immediate2

 

 

Promotion

 

 

 

 

 

N.A.

 

 

Output type

 

 

 

 

 

N.A.

 

 

Imposes end of line

 

 

Yes

jump address is out of the

 

 

 

 

 

 

 

 

 

present executing line.

92

7.7.40USRSUBRT – Return from user subroutine

Purpose:

Return from user subroutine - restore stack to its state before function call, save output arguments in stack and jump to return address.

See 8.2

Algorithm:

7.7.40.1.1.1.1.1(SP-1) nActArgOut (number of actual output arguments)

(SP-2)

nArgIn (num of input arguments)

(SP-4)

RtAddr (return address)

SP

BP – 5 - nArgIn

(save output arguments from subroutine)

(SP-5)

BP (base pointer)

PC RtAddr

(return fromuser subroutine)

Page 94
Image 94
Elmo HARmonica, HARSFEN0602 software manual Usrsubj jump To User Subroutine, Usrsubrt Return from user subroutine, OP2