Detect number entry on HP-35s?
|
02-28-2015, 09:53 PM
(This post was last modified: 03-01-2015 12:15 AM by mbrethen.)
Post: #21
|
|||
|
|||
RE: Detect number entry on HP-35s?
This doesn't achieve the goal I started with, but following Dieter's example:
Code: W001 LBL W Example: Code: 3 1 4 1 control number = 11.02203 the first register is R11 , the last one is R22 and there are 3 lines. Store this in A to identify matrix A. Could alternately enter the input in the stack instead (I'm not a fan of input queries): REGY [M,N] REGX R A proposed test for scalar: Code: W037 EQN (E*[1,0])*(E*[0,1]) If E=scalar the equation should always be 0; if E=vector (in terms of matrix position, i.e. never [0,0]) it should be a positive number <>0. |
|||
03-01-2015, 02:00 PM
Post: #22
|
|||
|
|||
RE: Detect number entry on HP-35s?
(02-28-2015 09:53 PM)mbrethen Wrote: This doesn't achieve the goal I started with I still do not understand what this goal is or was. Could you provide an example? (02-28-2015 09:53 PM)mbrethen Wrote: A proposed test for scalar: Fine. In the meantime I found a similar solution I was about to post. Dieter |
|||
03-01-2015, 04:13 PM
(This post was last modified: 03-01-2015 04:43 PM by Tugdual.)
Post: #23
|
|||
|
|||
RE: Detect number entry on HP-35s?
My understanding if the goal is that we want to enter an undefined number of values and at some point signal that the table is complete. The expectation is that when the user has entered the last value and is asked for the next one, he would simply press Enter and then a flag should indicate that nothing was entered which means -> end of data entry.
Is that correct? If that is the case, I would suggest KIS! Don't use INPUT, just a simple STOP and then GTO in the data entry loop. Then when data entry is complete, just have a second LBL B ready and expect the user to press XEC B when data entry is complete instead of entering a value and pressing R/S. So the scenario would be: Code: XEQ A You're done. Code sample: Code: A001 LBL A |
|||
03-01-2015, 07:48 PM
Post: #24
|
|||
|
|||
RE: Detect number entry on HP-35s?
(03-01-2015 04:13 PM)Tugdual Wrote: My understanding if the goal is that we want to enter an undefined number of values and at some point signal that the table is complete. The expectation is that when the user has entered the last value and is asked for the next one, he would simply press Enter and then a flag should indicate that nothing was entered which means -> end of data entry.Yes, all of the examples I've seen were limited to square matrices or vectors. Other than the user specifying a starting register and entering the element values, the program should do the rest. |
|||
03-01-2015, 08:59 PM
Post: #25
|
|||
|
|||
RE: Detect number entry on HP-35s?
(03-01-2015 07:48 PM)mbrethen Wrote: Yes, all of the examples I've seen were limited to square matrices or vectors. Other than the user specifying a starting register and entering the element values, the program should do the rest. OK, so the user enters, say, 12 values, and then simlpy presses R/S to indicate all elements have been entered (and stored). How does the program know if these 12 values define a 3x4 or 4x3 or 2x6 or 6x2 matrix? Please forgive me if I once again have to ask for an example. What does the user enter, which keys are pressed, and what is the program supposed to do with this input. Please give a complete example with every single key pressed. Dieter |
|||
03-02-2015, 02:26 AM
(This post was last modified: 03-02-2015 02:51 AM by mbrethen.)
Post: #26
|
|||
|
|||
RE: Detect number entry on HP-35s?
(03-01-2015 08:59 PM)Dieter Wrote: OK, so the user enters, say, 12 values, and then simlpy presses R/S to indicate all elements have been entered (and stored). How does the program know if these 12 values define a 3x4 or 4x3 or 2x6 or 6x2 matrix? The user puts the starting register on the stack. Executing the "matrix writer" program, it queries each element, column by column. When the user presses R/S the first time, that signals the end of first column and there are "m" rows. It then queries additional columns. When the user presses R/S a second time, that signals the end of the nth column and the program "learns" "m" rows and "n" columns. It finishes by placing a "control number" on the stack: bbb.eeerr where bbb = beginning register eee = end register rr = number of rows This control number will be used by other programs that operate on the matrix. Quote:Please forgive me if I once again have to ask for an example. What does the user enter, which keys are pressed, and what is the program supposed to do with this input. Please give a complete example with every single key pressed. In the example posted earlier: 11 XEQ "W" the HP-35 displays A? [1,1] 3 R/S A? [2,1] 5 R/S A? [3,1] 5 R/S A? [4,1] first column is stored R/S A? [1,2] now, the HP-35 knows the matrix has 3 rows (continues until) 1 R/S A? [2,4] 6 R/S A? [3,4] 8 R/S A? [1,5] all the elements are stored R/S REGX = 11.02203 first register is R11 , last is R22 and there are 3 rows. Sample code to query column: Code: W001 LBL W It's not complete, I need to add the logic to cycle through each column and then put the control number in the stack. |
|||
03-04-2015, 02:37 PM
(This post was last modified: 03-04-2015 02:39 PM by Dieter.)
Post: #27
|
|||
|
|||
RE: Detect number entry on HP-35s?
(03-02-2015 02:26 AM)mbrethen Wrote: The user puts the starting register on the stack. Executing the "matrix writer" program, it queries each element, column by column. When the user presses R/S the first time, that signals the end of first column and there are "m" rows. It then queries additional columns. When the user presses R/S a second time, that signals the end of the nth column and the program "learns" "m" rows and "n" columns. It finishes by placing a "control number" on the stack: bbb.eeerr OK, now I get what you want. The following code should be able to do this. Try it and see what you get. Code: W001 LBL W However, I think this method of entering a matrix is not a good idea. After the number of rows is known, the user has to enter complete columns. What happens if he doesn't? For instance, if there are m=3 rows but the user quits in column 5 after entering just one value? Are the following elements A[5,2] and A[5,3] assumed zero? Should the program throw an error? This would require some additional code after W043. That's why I would prefer the classic approach: simply have the user enter m and n. Dieter |
|||
03-06-2015, 04:27 PM
(This post was last modified: 03-09-2015 05:09 AM by mbrethen.)
Post: #28
|
|||
|
|||
RE: Detect number entry on HP-35s?
This performs most of the computations using just the stack. The A, I and T named variables are used for input, indirect register access and temporary storage, respectively. It is based on a program for the HP-41 by Jean-Marc Baillard. I have translated it for the HP-35s. In addition to the HP-41 Flag 22 issue, there were other parts of the code I had to work around: "sign" of zero results in 1 on the HP-41 (0 on the 35s) , ISG loop counter and STO arithmetic on the stack (e.g. STOx Y). As Dieter pointed out, the program isn't fail safe but I like the fact that it does all the bookkeeping for you.
Thanks to all who participated in this topic. Code: W001 LBL W Revision History 3/6/15 – Fixed an issue with the loop counter at line 42. 3/7/15 – Shortened the control # routine. 3/8/15 - Added line W025 so that absolute value isn't stored. |
|||
03-08-2015, 01:28 PM
(This post was last modified: 03-08-2015 01:43 PM by Dieter.)
Post: #29
|
|||
|
|||
RE: Detect number entry on HP-35s?
(03-06-2015 04:27 PM)mbrethen Wrote: This performs most of the computations using just the stack. The A, I and T named variables are used for input, indirect register access and temporary storage, respectively. It is based on a program for the HP-41 by Jean-Marc Baillard. I have translated it for the HP-35s. In addition to the HP-41 Flag 22 issue, there were other parts of the code I had to work around: More or less direkt translations of programs for other platforms are not always the best idea. On the HP41 saving registers makes sense, because every unused data register can be used to store the matrix and/or is available for additional program memory. That's why using the stack is a good idea. On the 35s however, the direct variables A–Z are always allocated and completely independent from program memory. They also do not store the matrix which resides in the indirect variables. BTW: you should change your step W023 to RCL A. Otherwise always the absolute value of the input is stored. (03-06-2015 04:27 PM)mbrethen Wrote: As Dieter pointed out, the program isn't fail safe but I like the fact that it does all the bookkeeping for you. The following code is an optimized version of my previous code. It also realizes if the user tries to cancel input before a complete row has been entered. It even detects if there is no input at all. Code: W001 LBL W This version even requires less memory than the previous ones. The 35s reports LN=243. Dieter |
|||
03-08-2015, 07:22 PM
(This post was last modified: 03-08-2015 11:03 PM by mbrethen.)
Post: #30
|
|||
|
|||
RE: Detect number entry on HP-35s?
(03-08-2015 01:28 PM)Dieter Wrote: More or less direkt translations of programs for other platforms are not always the best idea. I'm finding that out Quote:BTW: you should change your step W023 to RCL A. Otherwise always the absolute value of the input is stored. Noted. Quote:This version even requires less memory than the previous ones. The 35s reports LN=243. That's a 20% reduction from my translation; but the original HP-41 program was only 132 bytes! Does that suggest the HP-41 platform was more efficient? |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 13 Guest(s)