Post Reply 
Detect number entry on HP-35s?
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
W002  ABS
W003  IP
W004  STO B    // b = base register#
W005  0,9      // set fractional part to 0,9 so that ISG increments and always tests true
W006  STO C
W007  STO D    // start with entered base register
W008  +
W009  STO I    // i = memory index, start with b
W010  ISG C    // c = column index, start with 1
W011  ISG D    // d = 1,mmm. Since m is not yet known, assume m is very large (e.g. 900)
W012  SF 1     // set flag 1 to indicate that no empty entry occured yet   
W013  RCL D
W014  STO R    // row index
W015  EQN [IP(R),IP(C)]
W016  STO A
W017  CLSTK
W018  ALL
W019  INPUT A  // prompt A? [row,column]
W021  ABS      // check whether x is scalar or vector
W021  LASTx
W022  [1,0]
W023  x
W024  ABS
W025  x≠y?     // if x is a vector (i.e. no user input)
W026  GTO W038 // then determine #rows resp. #columns
W027  RCL I
W028  STO J
W029  ISG J
W030  STO(J)   // otherwise store a non-zero value in variable (i+1)
W031  RCL A    // recall input
W032  STO(I)   // and store in variable (i)
W033  ISG I    // increment register#
W034  ISG R    // increment row index
W035  GTO W015 // get next row
W036  ISG C    // increment column index
W037  GTO W013 // get next column
W038  FS? 1    // first occurence of R/S without entry?
W039  GTO W062 // then determine m = #rows
W040  SGN      // at this point x = ip(r)
W041  LASTx
W042  x>y?     // input cancelled before column was completed (row>1)?
W043  GTO W015 // then prompt again
W044  CLSTK    // otherwise matrix is complete
W045  RCL C
W046  IP
W047  STO N
W048  SGN
W049  STO- N   // determine n = #columns = c-1
W050  RCL M
W051  %
W052  RCL M
W053  RCLx N
W054  RCL+ B
W055  +
W056  x<>y     // y still has the 1 left from the % command
W057  -
W058  1E3
W059  ÷
W060  RCL+ B   // finished computing control number bbb.eeemm
W061  RTN      // quit
W062  STO M    // at this point x = ip(r)
W063  DSE M    // determine m = #rows = r-1
W064  GTO W066 // m>0? then continue
W065  GTO W015 // else no entry at all was made, prompt again
W066  CF 1     // reset "first empty input" flag
W067  RCL M
W068  1E3
W069  ÷
W070  STO D
W071  ISG D    // loop counter d = 1,mmm
W072  GTO W036 // get next column

This version even requires less memory than the previous ones. The 35s reports LN=243.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Detect number entry on HP-35s? - mbrethen - 02-25-2015, 03:37 AM
RE: Detect number entry on HP-35s? - d b - 02-26-2015, 06:31 AM
RE: Detect number entry on HP-35s? - Dieter - 03-08-2015 01:28 PM



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