Section 9: Subroutines 103

MAIN PROGRAM

 

¥

 

´CLEAR M

(Not programmable.)

000-

 

001- ´b9

Start main program.

002- R

Radians mode.

003- O0

Stores x2 in R0.

004- ®

Brings x1 into X; x2 into Y.

005- O-0

(x2 - x1) in R0.

006- G.3

Transfer to subroutine ―.3‖ with x1.

 

Return from subroutine ―.3‖.

007-

- y1.

008- ®

Brings x2 into X-register.

009- G.3

Transfer to subroutine with x2.

 

Return from subroutine ―.3‖.

010- +

y2 - y1.

011- 0

Recalls (x2 – x1) from R0 and

 

calculates (y2 - y1)/(x2 - x1).

012- n

Program end (return to line 000).

SUBROUTINE

 

013- ´b.3

Start subroutine .3.

014- x

x2.

015- K

Recall x.

016- [

sin x.

017- -

x 2 – sin x, which equals y.

018- n

Return to origin in main program.

Calculate the slope for the following values of x1 and x2: 0.52, 1.25; -1, 1; 0.81, 0.98. Remember to use G9 (rather than ´9) when addressing a routine with a digit label.

Answers: 1.1507; -0.8415; 1.1652.