HP 35s User Manual
Have a look at the manual HP 35s User Manual online for free. It’s possible to download the document as PDF or print. UserManuals.tech offer 1114 HP manuals and user’s guides for free. Share the user manual or guide on Facebook, Twitter or Google+.
hp calculators HP 35s Indirect register data packing program hp calculators - 3 - HP 35s Indirect register data packing program - Version 1.0 storage registers starting with 100 and working down. This can cause quite a shock when you’re not expecting it in a program or calculation. Each indirect register, like each direct register and each stack register, can hold a variety of objects, such as a real number, a complex number, or a 2-D or 3-D vector. Since these take varying amounts of memory to hold them, the HP 35s allocates 37 bytes per register for each location, whether the register needs that many bytes or not (see page 14-24 of the HP 35s user’s guide). This means that a group of indirect registers that are only going to hold a real number are only using 1/3 of the possible storage space per register. To reclaim some of this space that might otherwise be unused, it is possible to pack three real numbers into a 3-D vector and store the group into a single indirect register. This can save a tremendous amount of calculator memory. Storing 100 real numbers using indirect registers normally would use 3700 bytes. Packing them using the program in this learning module will only use 1/3 of that memory, which will then be available for other uses. This program originally appeared in Datafile, a publication of HPCC. HPCC is a voluntary, independent body run by and for users of handheld and portable computers and calculators. The club has been helping members for more than 20 years to get the most from their Hewlett Packard equipment and to further the exchange of information and ideas. You can find out more about HPCC at their website http://www.hpcc.org/ . The program listing. Program length is 338 bytes. Checksum C4F6. RDN is ) (Roll Down). All flag-related instructions (SF, CF, and FS?) are accessed through *+. The conditional tests (x=0?, x
hp calculators HP 35s Indirect register data packing program hp calculators - 4 - HP 35s Indirect register data packing program - Version 1.0 Usage Instructions: 1 ) Initialize the indirect registers to be used by providing the number of logical registers desired divided by 3 rounded up to the next highest integer. Then press XEQ Y070. For example, if you want 100 logical registers, give this routine 100 / 3, or 34 as an input. Note that you should probably keep at least 200-300 bytes free on the 35s. 2 ) To store a number, place the number to be stored in Y and the logical register location in X and press XEQ Y ENTER. Upon completion, the number just stored is in X. The original Z is now in Y and the original T is now in Z and T. LASTx is cleared. 3 ) To recall a number, place the logical register location to be recalled in X as a negative number and press XEQ Y ENTER. The recalled number is in X. The original contents of Y, Z, and T are undisturbed. LASTx contains the associated identity vector. Entering program lines. How to enter some of the program lines might not appear obvious at first. Here are the key presses to place them into the program. Line Y012: -*./)00123041 Line Y018: -*.4)00123041 Line Y024: -)001231 Line Y037: 57 Line Y043: 67 Line Y046: !73 Line Y051: -)016)0011 Line Y056: !73 Line Y064: -)0015!33*89*891: Line Y066: -)0015!39*83*891: Line Y068: -)0015!39*89*831: Line Y076: !7; Line by line analysis of the program. The description below explains what the program is doing in more detail. It may be of interest to see how the program operates. Lines What they do Lines Y002 through Y005: Reset flags. Lines Y006 andY007: Exits the program if an attempt is made to store into logical register zero, which is not supported. Lines Y008 and Y009 set flag zero if the logical register location is input as a negative, indicating a recall register input. Lines Y010 through Y013 store the indirect register number to be used into the I register. Lines Y014 through Y018: Determines the position in the 3-D vector where the value to be stored/recalled is found. Lines Y019 through Y029: Sets flag 1, 2, or 3, depending on the position within the 3-D vector for the value to be stored/recalled. Lines Y033 through Y036: Enters the appropriate identity vector. Line Y037: Extracts the proper value from the identity vector Lines Y038 and Y039: Exits the program if this is a recall entry. Line Y040 and Y041: Changes the sign of the extracted value and place it in stack register T. Line Y042: Calls a subroutine that creates an identity vector with the value of 1 in the vector replaced by the extracted value with its sign changed.
hp calculators HP 35s Indirect register data packing program hp calculators - 5 - HP 35s Indirect register data packing program - Version 1.0 Line Y043: Places in X the vector from the proper indirect register now with a zero in the location being replaced. Lines Y044 through Y048: These lines are stack manipulations to preserve the stack and store the previously extracted value into LASTx. Line Y049: Calls the subroutine that creates a vector with the proper position holding the value to be stored with the other locations holding a zero. Line Y050: Places this vector in T. At this point, register Z of the stack contains the original vector with a zero in the position where the value is to be stored, and register T of the stack contains a vector that has zeroes in the locations not being changed and the value being stored in the proper location within the vector. Line Y051: Adds these vectors in T and Z together and places the result in X. Line Y052: Stores this new vector back into the proper indirect register. Lines Y053 through Y057: Cleans up the stack so that the original value is in X, the original level Z is in Y, and the original level T is in Z and T. Lines Y058 through Y062: Cleans up the flags and exit the program. Lines Y063 through Y069: These lines are the subroutine called at lines Y042 and Y049. Lines Y070 through Y077: These lines are the initialization routine which stores vectors containing zeroes in the proper indirect registers. Usage Examples. This program can be used in manual run mode or from within a program. The table below shows several examples of how it might be used. Since the program preserves the stack, usage does not require much special consideration, other than LASTx, as noted above. Program usage is the same as run mode usage – the routine is simply called as a subroutine. Usage Examples Keystrokes 1 ) Set aside 50 indirect registers. 50 divided by 3 is 17, rounded up to the next highest integer. 17 9 2 ) Store the following numbers: 1.23456789 into logical register 10. 1.23456789 110
hp calculators HP 35s Indirect register data packing program hp calculators - 6 - HP 35s Indirect register data packing program - Version 1.0 Saving keystrokes. Storing a number manually into an indirect register requires six key presses (!$ !7) while this program only requires four key presses, not counting the location and value to be stored which would be the same in both instances. In the example below, 15 is stored into indirect register 10. Manually, this requires 10 key presses. Using this program only requires 8 key presses. Manually Using this program 10!$ 15 !7 15 1 10
hp calculators HP 35s Using HP 35s Flags What are flags? An example of using a flag to display a message General-purpose flags and special flags Using flags in programs
hp calculators HP 35s Using HP 35s Flags hp calculators - 2 - HP 35s Using HP 35s Flags - Version 1.0 What are flags? Ships use flags to signal special conditions. For example a ship might raise a flag as a distress signal, or to signal that an admiral is on board. Computers and calculators also use flags to signal special conditions. For example a flag could be used on the HP 35s to mark that financial calculations are being carried out in Canadian dollars, not in US dollars. Flags can be raised (or set) or else they can be lowered (or cleared). They provide the answers to simple yes/no questions. Wherever a question like this needs to be asked, especially in a program or in the display, a flag can be used. An Example of using a Flag to Display a Message An easy example of flag use is to display some simple message, for example a reminder. Example 1: A student who uses an HP 35s wants to display a reminder to complete Tuesday’s assignment. Solution: Set flag 1, which will show up in the display. First the user must press ! to display the flag operations menu. Figure 1 #Then the user must press $ to select the SF (Set Flag) operation. Figure 2 Now the user needs to press $ again to make the SF operation act on flag 1. Figure 3 Answer: Flag 1 is now set, and a small number 1 is displayed at the top of the calculator screen. The small “1” looks like an exclamation point and reminds the student that something important needs to be done. Alternatively flag 2 could be used, as a reminder of Tuesday’s assignment, as “two” sounds like “Tue”. Example 2: Once Tuesday’s assignment has been completed, the student no longer needs to display the 1. Solution: Clear flag 1, so it will no longer show up on the screen. Again the user must press ! to display the flag operations menu.
hp calculators HP 35s Using HP 35s Flags hp calculators - 3 - HP 35s Using HP 35s Flags - Version 1.0 Figure 4 #This time the user must press % to select the CF (Clear Flag) operation. Figure 5 The little 1 is still shown. Now the user needs to press $ to make the CF operation act on flag 1. Figure 6 Answer: Flag 1 is now clear, so the small number 1 is no longer at the top of the calculator screen. Example 3: Use the “Flag Set?” command to confirm that flag 1 is now clear. Solution: Use the same steps, but this time choose the third command in the flags menu, to ask if flag 1 is set. !&$# Figure 7 Answer: The display shows the message NO to tell the user that the answer to the question “is Flag 1 Set?” is “No”. Note: If the flag is set, the message YES is shown. The messages YES and NO replace the normal display of numbers on the HP 35s screen, and the message symbol is displayed. This does not mean that an error has been detected, instead it warns the user that a message is being shown, and must be cleared before normal operation can continue. To clear the message, press one of the two keys ( or ). ) is the “Clear” key, at the lower left of the keyboard; it is also used as the * key. The examples above show how flags can be set, cleared and tested by commands carried out on the keyboard. Flags are also very useful in programs, as is described below. General-purpose Flags and Special Flags HP 35s users can set, clear, and test 12 different flags. When the HP 35s is turned on first, all these flags are clear. Flags 0 through 4 are general-purpose flags, for use as signals and in programs. When one of these flags is set, its number is shown at the top of the HP 35s screen. The 0 looks like a degree sign and 1 like an exclamation point.
hp calculators HP 35s Using HP 35s Flags hp calculators - 4 - HP 35s Using HP 35s Flags - Version 1.0 Flags 5 through 11 are special-purpose flags, and their state is not shown at the top of the screen. Each flag has a special meaning when it is set. The user can set flag 5 to say that a program should stop if any calculation produces a result bigger than the largest number the HP 35s can handle. The number is replaced by the largest number the HP 35s can handle and the message OVERFLOW is displayed. If flag 5 is clear, the program continues to run, and OVERFLOW is displayed for a short time when the program finishes running. The calculator automatically sets flag 6 if an overflow occurs, or if a number in a non-decimal base is larger than the calculator can handle. This can be very useful in programs – a program can test flag 6 to see if a calculation has produced an overflow, and if so then the program can deal with the problem. Flag 6 should be cleared after it has been set, so that it can be used to test if another error occurs later. Flag 7 is set when fraction display mode is active. It becomes set when +, is first pressed, and it is cleared when +, is pressed again. It is also set when SF 7 is carried out on the keyboard or in a program. When flag 7 is cleared, fraction display is cancelled. This means that a program can set flag 7 to display a result as a fraction, and can later clear flag 7 so that further results can be displayed as usual. When flag 8 is set, fractions are displayed with the denominator equal to the number stored by the - command, but the fraction is simplified unless flag 9 is set too. For example, the number 0.5 is displayed as 5/10 if 10 is stored by the - command and flag 8 is set. If flag 9 is clear, the 5/10 is simplified to 1/2 but if flag 9 is set, it is not simplified. When flag 10 is clear (its normal state) any equation in a program is worked out and its result is put on the stack for use by the program. When flag 10 is clear an equation in a running program is displayed as a message and is not worked out. This means that an equation can be shown to the user, or that a message can be written as if it were an equation, and can then be displayed instead of being calculated; the message does not need to work as an equation, it could even say “HELLO, WORLD”. Flag 10 can be set before some equations, and cleared before others, so that a mixture of equations and messages can be used in a program. When flag 11 is set, a working program stops and asks for the value of each variable in an equation when it comes to an equation and flag 10 is clear. If the equation is used in integration (.) or in solving (/0), there is no prompt for the unknown variable, or the variable of integration. If flag 11 is clear, the value already stored in each variable, or 0 if no value has been stored, is used. Flags 5 through 11 can also be used in programs as if they were general-purpose flags, as long as this does not interfere with their special uses. For example flag 9 can be used freely so long as flag 8 is not set. Any program that uses these flags for general purposes should leave them cleared when it is completed. To use flags 10 and 11 with the flag commands, first press the decimal point key 1, then press 2 or $. Note: for details of equations, programs, fractions, solve and integrate, see the separate training aids on these topics. Using Flags in Programs The commands SF, CF and FS? can be very useful in programs. The examples below will show some of the ways in which flags can help in programs.
hp calculators HP 35s Using HP 35s Flags hp calculators - 5 - HP 35s Using HP 35s Flags - Version 1.0 Example 4: A long program has three parts. To let the user see how far it has gone, it can set flag 1 in the first part, flag 2 in the second part, and flag 3 in the third part. How is this done? Solution: At the beginning of the program, the user puts “SF 1” immediately after the first label. +3+45!$$ Figure 8 At the end of the first part of the program, the user clears flag 1 and sets flag 2. !%$!$%# Figure 9 At the end of the second part of the program, the user does the same, but clearing flag 2 and setting flag 3. Finally at the end of the program, the user clears flag 3. !%&!6# Figure 10 Answer: When the program runs, with the above steps in it, it will display flag 1 in the first part, flag 2 in the second part, and flag 3 in the third part. A long program will most likely have several labels in it, so the line numbers at the end might have a different letter in them, not A. Example 5: A program calculates a factorial and then uses it. To make sure the program warns the user if the factorial of a number larger than 253 is calculated, and the result overflows, the program sets flag 5. How is this done? Solution: “SF 5” is put in the program, just after the first label or just before the factorial is calculated. +3+47!$8+9# Figure 11 If an overflow occurs, the program will stop at line F003 and will show the message OVERFLOW.
hp calculators HP 35s Using HP 35s Flags hp calculators - 6 - HP 35s Using HP 35s Flags - Version 1.0 It is best to clear flag 5 at the end of the program, so the calculator will behave the usual way after the program is finished. Answer: This example shows how flag 5 can be useful in a program. Example 6: A program that uses temperatures must work with degrees Fahrenheit or degrees Celsius. Use flag 0 to make the program work with both temperature scales. Solution: The program is written so that it checks flag 0. If flag 0 is set, it converts from Fahrenheit to Celsius, if flag 0 is clear, it assumes the temperature is already in Celsius. In the program, these steps are typed: !&2+:# Figure 12 If flag 0 is set at step D016, then the answer to the test is YES, and step D017 is carried out. If flag 0 is clear then the answer to the test is NO and step D017 is skipped. The answer YES or NO is not displayed when a program is running. Instead, the rule “do the next step only if the answer is YES” is followed. To use the program, the user sets flag 0 if measurements are in degrees Fahrenheit. The little 0 is displayed at the top of the screen, to remind the user that flag 0 is set and that measurements in degrees Fahrenheit are expected. The zero looks like a degrees symbol, which is a useful reminder at times when the user is working with temperatures. The user must clear flag 0 if measurements are in degrees Celsius, and the zero will disappear. Answer: When the program is used with measurements in degrees Fahrenheit, the user must set flag 0. Step D017 of the program converts the measurement to degrees Celsius before the measurement is used. When the program is used with measurements in degrees Celsius, the user must clear flag 0. At step D016 the flag is not set, so step D017 is skipped, and the temperature is not converted to Celsius, as it already is in Celsius. These examples show just some of the ways in which flags can be used in programs. Some of the other training aids show other uses of flags on the HP 35s.