Post Reply 
HP 41 - branching to local label and return stack - FINAL RESULTS AND PROGRAMS
05-23-2019, 02:24 AM
Post: #30
RE: HP 41 - branching to local label and return stack
Hello Artur,

I have investigated the return stack for both RAM and HePaX RAM and it should works for both.

(05-22-2019 02:00 AM)Artur - Brasil Wrote:  I forgot to comment something strange about NovRAM:
I just saved the program SR (it has the others: LR and Sb) to NovRAM.
So, I deleted the SR from main memory.
Well, when I typed: XEQ ALPHA LR ALPHA, the calculator show XEQ IND A !!!
I just did the same thing and it works on my side.

Do the following:
  • GTO .. // to go to end of memory
  • PRGM // to enter program mode
  • XEQ "LR" // the command should be transformed into XROM "LR", if not then LR is not in HePaX RAM or you have a copy in main RAM
  • <- // to delete the above line
  • PRGM // to exit program mode

(05-22-2019 02:00 AM)Artur - Brasil Wrote:  I'll have to keep programs in main memory?
nop

(05-22-2019 02:00 AM)Artur - Brasil Wrote:  Diego says we can call a program stored in NovRAM without problems.
yep

I have done the following test procedure:
  1. loaded LR/SR routines in main RAM from the barcode sheet
  2. copied the program into HePaX RAM with HSAVEP
  3. deleted the program from main RAM with CLP
  4. entered a test program into main RAM that goes into 9 level deep sub-routines
  5. run the program in main RAM
    • XEQ "RS9" // it shows 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and stop
    • press R/S // it shows 8, 7, 6, 5, 4, 3, 2, 1, 0 and stop
    • press R/S // it shows 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and stop
    • press R/S // it shows 8, 7, 6, 5, 4, 3, 2, 1, 0 and stop
    • ...
  6. copied the program into HePaX RAM with HSAVEP
  7. deleted the program from main RAM with CLP
  8. run the program in HePaX RAM and I have the same results as above

Test program:
Code:
01 LBL "RS9"
02 SF 05
03 1
04 SIGN
05 CLX
06 LBL 00
07 FC?C 05     // skip next line the first time only
08 RTN         // stop
09 VIEW X      // shows 0
10 XEQ 01      // push return address (line 11)
11 GTO 00
12 LBL 01
13 LASTX
14 +
15 VIEW X      // shows 1
16 XEQ 02      // push return address (line 17)
17 LASTX
18 -
19 VIEW X      // shows 0
20 RTN         // pop return address (line 11)
21 LBL 02
22 LASTX
23 +
24 VIEW X      // shows 2
25 XEQ 03      // push return address (line 26)
26 LASTX
27 -
28 VIEW X      // shows 1
29 RTN         // pop return address (line 17)
30 LBL 03
31 LASTX
32 +
33 VIEW X      // shows 3
34 XEQ 04      // push return address (line 35)
35 LASTX
36 -
37 VIEW X      // shows 2
38 RTN         // pop return address (line 26)
39 LBL 04
40 LASTX
41 +
42 VIEW X      // shows 4
43 XEQ 05      // push return address (line 44)
44 LASTX
45 -
46 VIEW X      // shows 3
47 RTN         // pop return address (line 35)
48 LBL 05
49 LASTX
50 1
51 XROM "LR"   // save return stack into data registers 1 & 2 (lines 11, 17, 26, 35 & 44)
52 +
53 VIEW X      // shows 5
54 XEQ 06      // push return address (line 55) and looses first return address (line 11)
55 LASTX
56 1
57 XROM "SR"   // restore return stack from data registers 1 & 2 (lines 11, 17, 26, 35 & 44)
58 -
59 VIEW X      // shows 4
60 RTN         // pop return address (line 44)
61 LBL 06
62 LASTX
63 +
64 VIEW X      // shows 6
65 XEQ 07      // push return address (line 66) and looses second return address (line 17)
66 LASTX
67 -
68 VIEW X      // shows 5
69 RTN         // pop return address (line 55)
70 LBL 07
71 LASTX
72 +
73 VIEW X      // shows 7
74 XEQ 08      // push return address (line 75) and looses third return address (line 26)
75 LASTX
76 -
77 VIEW X      // shows 6
78 RTN         // pop return address (line 66)
79 LBL 08
80 LASTX
81 +
82 VIEW X      // shows 8
83 XEQ 09      // push return address (line 84) and looses fourth return address (line 35)
84 LASTX
85 -
86 VIEW X      // shows 7
87 RTN         // pop return address (line 75)
88 LBL 09
89 LASTX
90 +
91 VIEW X      // shows 9
92 STOP        // stop program, press R/S to unwind the stack
93 LASTX
94 -
95 VIEW X      // shows 8
96 END         // pop return address (line 84)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 41 - branching to local label and return stack - Sylvain Cote - 05-23-2019 02:24 AM



User(s) browsing this thread: 1 Guest(s)