SlideShare una empresa de Scribd logo
1 de 9
Descargar para leer sin conexión
hp calculators



HP 33S Writing a Simple Program




Programming the HP 33S

Practice example: the area of a circle

Tools for programming

Practice example: the sinc function

Using a program in another program
hp calculators

HP 33S Writing a Simple Program

Programming the HP 33S

Doing a simple calculation once on the HP 33S is easy. Doing the same calculation many times, or doing a complicated
calculation, takes longer. It can be better to store all the steps needed for the calculation in a program. A program is a
set of instructions, stored all together. Once it is written, it can be tested to see if it works correctly. Then it can be used
many times, without the need to press every key of the calculation each time.

A simple program is just a set of keystrokes stored so that they can be carried out with one key. The HP 33S provides
many commands to let programs do more, for example stop and ask for input, or show an intermediate result. This
training aid concentrates on simple programming; it also shows a few of the more advanced programming commands.

Practice example: the area of a circle

Given “r” the radius of a circle, the circle’s area “A” is calculated from the formula A = π r ². For example to calculate the
area of a circle with radius 3cm, the following keys are pressed.

In RPN mode:                  3=ºj¸

And in algebraic mode:        3=¸ºjÏ




                                                                                          Figure 1


Repeating the same 4 keys in RPN mode or 5 keys in algebraic mode for many circles is a lot of work. Here is how a
program would make it easier.

Example 1: Write a program in RPN mode to calculate the area of a circle, given its radius r.

Solution:        An RPN program and an algebraic program are shown below. The RPN program is shown first, called “A”
                 for “Area”.

                 In RPN mode, type the same keys for calculating the area as before, but mark the beginning of the
                 program with a label and the end of the program with a return.

                 First set program mode by typing ¹£ and then go to the top of program memory (called PRGM
                 TOP, see Figure 2), ready to begin a new program, by typing ¹rËË. Now the program can be
                 typed:

                 ¹ÓA=ºj¸ºÔ

                 The letter A is on the keyboard, below and to the right of the # key. Whenever Ó is typed, the
                 HP 33S uses the keys with the letters A – Z marked next to them to enter those letters.




hp calculators                                                -2-                          HP 33S Writing a Simple Program - Version 1.0
hp calculators

HP 33S Writing a Simple Program

                 The program will look as shown in Figures 2 through 4 below.




                                                                                          Figure 2




                                                                                          Figure 3




                                                                                          Figure 4


                 Each line of the program begins with the letter of the label, and then has a four-digit line number. The rest
                 of the program line is a function or a program instruction. The program instructions are LBL A and RTN, the
                 functions are x ², π and ×.

                 To use the program, it is necessary to move out of program mode, and to return to the beginning of the
                 program. Then a radius is typed and the ¥ key is pressed. The HP 33S executes (or runs) the
                 program.

                 To calculate the area of a circle with radius 5, make sure RPN mode is set, then press:

                 ¹£ºÔ5¥




                                                                                               Figure 5


Answer:          The area of a circle with radius 5 cm is just over 78.53 square cm.

                 To calculate the area of another circle with a different radius, it is enough to type the new radius and press
                 ¥ again. The program works like a new function, executed by means of the ¥ key instead of a key
                 with the name of one of the functions built into the HP 33S.

Example 2: Write a program in RPN mode to calculate the area of a circle, given its radius r.

Solution:        In algebraic mode, the program looks very similar, but with the calculation keys typed in algebraic order.
                 The HP 33S does not allow more than one program to have the same label, so the algebraic program
                 below is given the label B.

                 Go to the beginning of program memory by typing ¹rËË and set program mode by typing
                 ¹£. Then type the algebraic mode program:


hp calculators                                                 -3-                         HP 33S Writing a Simple Program - Version 1.0
hp calculators

HP 33S Writing a Simple Program

                     ¹ÓBºÚ=¸ºjϺÔ

                 To get B press the & key; it has a small B to its lower right. The program lines are as listed below.

                 B0001         LBL B
                 B0002         ALG
                 B0003         x²
                 B0004         ×
                 B0005         π
                 B0006         ENTER
                 B0007         RTN

                 If a program in algebraic mode performs a complete calculation then it is best to finish it with Ï so
                 that calculations made after the program will not be treated as part of the program’s calculation.

                 The second line is an instruction to set algebraic mode, to make sure program B is not used accidentally in
                 RPN mode. If the user always works in algebraic mode, or always remembers to switch to the right mode
                 before using a program then this program line is not needed, but it is always safer to use it. A similar line,
                 setting RPN mode, could have been used in program A for the same reason.

                 This program works just like the RPN version. To use it, first move out of program mode, and to go to the
                 beginning of the program. Then a radius is typed and the program is executed.

                 Therefore, to calculate the area of a circle with radius 5, press:

                 ¹£ºÔ5¥




                                                                                               Figure 6


Answer:          As in RPN mode, the area of a circle with radius 5 cm is calculated at just over 78.53 square cm.

                 To calculate the area of another circle with a different radius, it is enough to type the new radius and press
                 ¥ again. Like the RPN program, this program works similarly to a new function, executed by means of
                 the ¥ key instead of a key with the name of one of the functions built into the HP 33S.

Tools for programming

The HP 33S allows the user to create any or all of the labels from LBL A through LBL Z. The lines after a label all have
that label at the beginning of their line numbers. When a new label is typed, the HP 33S starts over again at line 1, with
the new label’s name at the beginning of each line. Figure 7 shows an example of this; if both program A and program B
were typed, then after the RTN in program B, the first line of program A is displayed on the calculator screen.




                                                                                          Figure 7

hp calculators                                                  -4-                        HP 33S Writing a Simple Program - Version 1.0
hp calculators

HP 33S Writing a Simple Program

Each label can be used only one time, and the HP 33S treats the lines from one label until the next label as a separate
program. It is also possible to have a program with no label, from the “PRGM TOP” until the first label.

To list the programs in the HP 33S, press the keys ¹u to get the “Memory” menu, and then 2 to get a display
of programs. If the algebraic version of the circle program has been entered then the calculator screen will look like
Figure 8. If only program A was typed, the screen will be as in Figure 9.




                                                                                       Figure 8


This means that the program with label B is the first program in memory, and that it is 21 bytes long. A byte is a piece of
calculator memory made up of 8 bits, and a bit is the smallest piece of memory, a single “0” or “1”. The HP 33S has
more than 31,000 bytes of memory available to hold programs and equations entered by the user. Given this much
memory, a long program could have up to 9,999 program lines, and that is why program line numbers are 4 digits long.
The up and down arrows at the right of the screen mean that there are more programs in the calculator – information
about each program in turn is displayed if the up or down arrow keys are pressed. If both the programs A and B have
been entered, press Ø to see information about program A.




                                                                                       Figure 9


Another tool to help in writing programs is the program checksum. To see the checksum for program A, press
ºÎ. While the Î key is held down, the calculator will show:




                                                                                       Figure 10


CK=DEFD means that the checksum for program A is the hexadecimal number DEFD. (The checksum for program B is
8A0B.) If the program was not typed correctly, then the checksum will be different. Press the key labeled Å at the
bottom left of the keyboard to cancel the display of information about programs.

The checksum has several purposes:

      •     If a program is correctly copied to the HP 33S from a web page or a book – the HP 33S manual has many
            useful example programs – then the checksum on the HP 33S will be the same as the checksum given with the
            program. If the checksum is not the same, a mistake was made and the program should be checked and
            corrected before it is used.

      •     If a user creates a new program on an HP 33S and then writes it down for future use, it is worth keeping a note
            of the checksum with the written program. That way, the program can be checked if it is typed into the HP 33S
            again later.



hp calculators                                               -5-                        HP 33S Writing a Simple Program - Version 1.0
hp calculators

HP 33S Writing a Simple Program

      •     If a user wants to offer a program to other users, the checksum should be given with the program, so the other
            users can check if they have entered the program correctly into their HP 33S.

The checksum can be very helpful, but it does not have to be used – for short programs such as the above it can be
enough to step through the program with the up and down arrow keys and correct any mistakes.

Mistakes can be either wrongly typed lines, or missing lines. To add a missing line, use the × and Ø keys until the
line before the missing line is at the bottom of the screen. Then type the missing line or lines. If a line is wrong, move it to
the lower line of the screen and use the ~ key to delete one or more lines, then type the correct line or lines.

Even after all typing errors have been corrected, a program can still be wrong if it was designed wrongly. The HP 33S
manual provides advice on program testing and describes more programming tools.

To go to a line in a program, to see it or to change it, use the GTO command, followed by a dot and then the program
name and the line number. For example to go to line 5 of program A type ¹rËA0005.

The LBL and the RTN help to identify each program. If a program is executed by the user pressing ¥ then the Ô
goes back to the top of program memory, where the program stops. If both program B and program A are in the HP 33S,
and program A is used, then the RTN at the end will go to label B at the top of program memory. Next time ¥ is
pressed, program B will begin, not program A. This means that only the program at the top of program memory will work
like a function key when ¥ is pressed. To execute program A if it is not at the top of memory, press tA.

Practice example: the sinc function

Example 3: As a third example, write a program to calculate the Sinc function Sinc(x) = Sin(x)÷x.

                 At first sight this looks little different from the previous program, but there is one difficulty – the program
                 needs to deal with the case of x = 0 when division by zero gives an error. The program needs to test for
                 x=0 and to handle that case specially. This example will show how tests are used in programs.

Solution:        Again write the program so it will use a number x that has been typed before the program begins. A
                 program like this will probably be used like an additional function on the calculator, so it should work both in
                 RPN mode and in algebraic mode, in the same way as functions built into the HP 33S. To do this, the
                 program will use a data register. Data registers are described in detail in a separate practice aid. The
                 program will also use a flag, flags are also described in a separate practice aid.

                 As before, first set program mode by typing ¹£ and then go to the top of program memory by
                 typing ¹rËË. Try storing the new program at the end of program memory. To do that, press the
                 up arrow key to go from the top of program memory to the last program instruction. If program A was typed
                 as above, the last instruction will be the RTN at its end. Give the new program the label “C”, using the last
                 letter of “Sinc” to name it. Type ¹ÓC. To type C, press ) after pressing Ó.




                                                                                            Figure 11




hp calculators                                                   -6-                          HP 33S Writing a Simple Program - Version 1.0
hp calculators

HP 33S Writing a Simple Program

                 Store the number in a data register, for this example use data register “A”, but any register could be used.
                 To type A, press # after pressing e. Then clear flag 0, which will be used later. To do this press
                 º· to show the flags menu, press 2 to clear a flag, and press 0 to specify that flag 0 is to be
                 cleared.




                                                                                              Figure 12


                 Now, if the number x is zero, set flag 0. This will let the program check later if x is zero, and will also display
                 a little zero at the top of the screen, to tell the user that sinc is being calculated for x equal to zero.

                 To make a decision like this in a program, it is necessary to use a test function, in this case the test is x=0?
                 Press º to get a menu of test functions. Then press 6 to get the x=0? test. If the test is true, flag
                 0 must be set. To do this press º· to show the flags menu, press 1 to set a flag, and press 0
                 to specify that flag 0 is to be set. This means that the program will test x to see if it is zero. If the test is true
                 and x is 0 then the next line will be carried out and flag 0 will be set. If x is not 0 then the test is not true and
                 the next step will be skipped, so flag 0 will be clear, because it was cleared at step C0003.

                 This is the way all tests work in HP 33S programs – do the next step if the test is true, or just do if true.




                                                                                              Figure 13


                 Now calculate the sine of x. If x is zero, then the sine will be zero; nothing will be changed. There is no
                 need for a test, just press k. After the sine has been calculated, the result can be divided by the original
                 number, at present stored in data register A, but first the number must be brought back from A, while the
                 sine is stored in A. To do this, exchange the sine with A. Press ºwA. Once again, press the #
                 key to enter the letter A. Figure 14 shows the program steps.




                                                                                              Figure 14


                 Now the sine can be divided by the original number, but this should only be done if the number is not zero.
                 The program must test x to see if it is not zero. Press º to get a menu of test functions. Then press
                 1 to get the x≠0? test. Then press e¯A to divide the original number into the sine in register A. If
                 the test is true and x is not 0 then the following line will be carried out and the division will be performed. If x
                 is 0 then the test is not true and the next step will be skipped. Again the program will follow the rule do if
                 true. If the original number was zero, then the division is not performed and there is no error caused by a
                 division by zero.




hp calculators                                                    -7-                           HP 33S Writing a Simple Program - Version 1.0
hp calculators

HP 33S Writing a Simple Program




                                                                                           Figure 15


                 The result is now ready but it is in A and has to be brought back, so another exchange with A is needed.
                 Press ºwA again, and the answer is ready, if the original number was not zero.




                                                                                           Figure 16


                 If the original number was zero then it has not been changed, and the result of all the above work is a zero.
                 However, the result might also be a zero if the calculations produced a number smaller than 10-499. The
                 HP 33S replaces numbers this small with zero. So the result should not be tested, instead flag 0 should be
                 tested, and if it is set then the original number was zero. In that case, it must be turned into a 1. First press
                 º·30. Then the 0 can be turned into a 1 using one of several functions that do this, for
                 example #.




                                                                                           Figure 17


                 To finish the program, press ºÔ, then leave program mode by typing ¹£.

                 The program can be tested with a few values of x. The definition of Sinc(x) as Sin(x)÷x. assumes that x is
                 in radians. (The program does not set radians mode, as a user might intentionally want to calculate
                 Sin(x)÷x in degrees or gradians.) Set radians mode if it is not set already, and calculate the sinc of 0.2.

                 Ý20Ë2tC




                                                                                           Figure 18


                 Confirm that the program works for 0. The program works both in RPN and algebraic modes, so try this in
                 RPN mode:

                 ¹ä0tC




                                                                                           Figure 19




hp calculators                                                  -8-                          HP 33S Writing a Simple Program - Version 1.0
hp calculators

HP 33S Writing a Simple Program

Answer:          The program works correctly in RPN and in algebraic modes, even for the special case where x is 0.
                 Furthermore, it works so that the original value of x can be recovered with the Í key.

                 The program is 42 bytes long and its checksum is D11C. At 13 steps, it is longer than the “area of a circle”
                 program, but not very long. Extra steps were needed to make it work for the special case, and to use a data
                 register for the calculation, so the program works both in RPN mode and in algebraic mode. This means
                 that the program can be used by other programs that need to calculate sinc.

Using a program in another program

Example 4: Use program C, written above, to calculate a sinc function value inside another program.

Solution:        This is very similar to writing a program which calculates a sine as part of a longer calculation. A program
                 which needs to calculate the sine of 1.3 radians might have the following lines in it:

                 D0001         LBL D
                 D0002         RAD
                 D0003         1.3
                 D0004         sin
                 D0005         … more program lines …

                 A program to use the sinc function, provided by program C, would look like this instead:

                 D0001         LBL D
                 D0002         RAD
                 D0003         1.3
                 D0004         XEQ C
                 D0005         … more program lines …

                 As this shows, if another program needs to calculate a sinc value, it can use program C like an HP 33S
                 function. First the number x is typed. Then, Instead of typing a function name, the user must call the sinc
                 program by typing XEQ C. When the calling program is run the sinc program will do its calculation. When
                 that reaches the RTN at its end, it will return to the program that called it, which will continue from the next
                 line. When a program is called from another program like this, it is called a subprogram or a subroutine.

                 If a program is used as a subroutine, called from another program, then the RTN at its end finishes the
                 subroutine and goes back to the program that called the subroutine. As was explained in the section on
                 tools for programming, if a program is not called up from another program, but is started by the user
                 pressing ¥, or t, then the Ô goes back to the top of program memory, where the program
                 stops.

                 Programs can do much more than has been described in this training aid. The reader should consult the
                 HP 33S manual and try some of the many example programs in it.




hp calculators                                                  -9-                          HP 33S Writing a Simple Program - Version 1.0

Más contenido relacionado

Destacado

Destacado (14)

Complex numbers & vectors hp35s overview
Complex numbers & vectors hp35s overviewComplex numbers & vectors hp35s overview
Complex numbers & vectors hp35s overview
 
Survey instruments
Survey instrumentsSurvey instruments
Survey instruments
 
Sokkia Set B training manual
Sokkia Set B  training manualSokkia Set B  training manual
Sokkia Set B training manual
 
Manual book total stasion sokkia set2
Manual book total stasion sokkia set2Manual book total stasion sokkia set2
Manual book total stasion sokkia set2
 
Metrologia 1
Metrologia 1Metrologia 1
Metrologia 1
 
Surveying and leveling-2
Surveying and leveling-2Surveying and leveling-2
Surveying and leveling-2
 
Curso topografia basica jun13_rocha
Curso topografia basica jun13_rochaCurso topografia basica jun13_rocha
Curso topografia basica jun13_rocha
 
Combiend curves of surveying
Combiend curves of surveyingCombiend curves of surveying
Combiend curves of surveying
 
Topic 4 curve lesson 2
Topic 4   curve lesson 2Topic 4   curve lesson 2
Topic 4 curve lesson 2
 
How to Set Up a Total Station
How to Set Up a Total StationHow to Set Up a Total Station
How to Set Up a Total Station
 
Part 5 simple curves updated
Part 5 simple curves updatedPart 5 simple curves updated
Part 5 simple curves updated
 
Topografia
TopografiaTopografia
Topografia
 
05 noções de desenho técnico
05   noções de desenho técnico05   noções de desenho técnico
05 noções de desenho técnico
 
Sokkia Total station setup and operation
Sokkia Total station setup and operationSokkia Total station setup and operation
Sokkia Total station setup and operation
 

Similar a Programming 33s simple

10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechz10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechzShahbaz Ahmad
 
Calculator 1
Calculator 1Calculator 1
Calculator 1livecode
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer scienceumardanjumamaiwada
 
Year 2 dsa c++ exercises on user defined functions
Year 2 dsa  c++ exercises on user defined functionsYear 2 dsa  c++ exercises on user defined functions
Year 2 dsa c++ exercises on user defined functionsErnesteNtezirizaza
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGJEENA SARA VIJU
 
Introduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic TutorialIntroduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic Tutorialnhomz
 
Microprocessor chapter 9 - assembly language programming
Microprocessor  chapter 9 - assembly language programmingMicroprocessor  chapter 9 - assembly language programming
Microprocessor chapter 9 - assembly language programmingWondeson Emeye
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Shipra Swati
 
Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.NandiniSidana
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2lemonmichelangelo
 
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed controlBca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed controlRai University
 

Similar a Programming 33s simple (20)

Programming Fundamental handouts
Programming Fundamental handoutsProgramming Fundamental handouts
Programming Fundamental handouts
 
10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechz10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechz
 
Calculator 1
Calculator 1Calculator 1
Calculator 1
 
Flowcharting and Algorithm
Flowcharting and Algorithm Flowcharting and Algorithm
Flowcharting and Algorithm
 
Pascal programming lecture notes
Pascal programming lecture notesPascal programming lecture notes
Pascal programming lecture notes
 
Qbasic
QbasicQbasic
Qbasic
 
lecture 5
 lecture 5 lecture 5
lecture 5
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
 
Year 2 dsa c++ exercises on user defined functions
Year 2 dsa  c++ exercises on user defined functionsYear 2 dsa  c++ exercises on user defined functions
Year 2 dsa c++ exercises on user defined functions
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Introduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic TutorialIntroduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic Tutorial
 
Qbasic tutorial
Qbasic tutorialQbasic tutorial
Qbasic tutorial
 
Microprocessor chapter 9 - assembly language programming
Microprocessor  chapter 9 - assembly language programmingMicroprocessor  chapter 9 - assembly language programming
Microprocessor chapter 9 - assembly language programming
 
Presentation flow diagrams exercises
Presentation  flow diagrams exercisesPresentation  flow diagrams exercises
Presentation flow diagrams exercises
 
ICP - Lecture 6
ICP - Lecture 6ICP - Lecture 6
ICP - Lecture 6
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6
 
Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
 
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed controlBca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
 

Más de Land Surveyors United Community

Más de Land Surveyors United Community (20)

Introduction to Land Surveying
Introduction to Land SurveyingIntroduction to Land Surveying
Introduction to Land Surveying
 
Sokkia set20 k
Sokkia set20 kSokkia set20 k
Sokkia set20 k
 
Sokkia sdr-8100 operations manual
Sokkia sdr-8100 operations manualSokkia sdr-8100 operations manual
Sokkia sdr-8100 operations manual
 
Compass surveying
Compass surveyingCompass surveying
Compass surveying
 
Land Surveying Resources Handbook
Land Surveying Resources HandbookLand Surveying Resources Handbook
Land Surveying Resources Handbook
 
Fundamentals hp33s exam-review
Fundamentals hp33s exam-reviewFundamentals hp33s exam-review
Fundamentals hp33s exam-review
 
Using the scientific calculator
Using the scientific calculatorUsing the scientific calculator
Using the scientific calculator
 
Using the hp35s Calculator
Using the hp35s CalculatorUsing the hp35s Calculator
Using the hp35s Calculator
 
Summing up 33_s
Summing up 33_sSumming up 33_s
Summing up 33_s
 
Hp33s calculator user_guide
Hp33s calculator user_guideHp33s calculator user_guide
Hp33s calculator user_guide
 
Programming Hp33s talk v3
Programming Hp33s talk v3Programming Hp33s talk v3
Programming Hp33s talk v3
 
Trimble R8 gnss r6-5800-364_userguide
Trimble R8 gnss r6-5800-364_userguideTrimble R8 gnss r6-5800-364_userguide
Trimble R8 gnss r6-5800-364_userguide
 
Nikon npl-302-instruction-manual-english
Nikon npl-302-instruction-manual-englishNikon npl-302-instruction-manual-english
Nikon npl-302-instruction-manual-english
 
Trimble 5700 manual
Trimble  5700  manualTrimble  5700  manual
Trimble 5700 manual
 
Sokkia set6 Total Station manual
Sokkia set6 Total Station manualSokkia set6 Total Station manual
Sokkia set6 Total Station manual
 
Sokkia set6f totalstation
Sokkia set6f totalstationSokkia set6f totalstation
Sokkia set6f totalstation
 
Sokkia spectrum-survey-field-manual
Sokkia spectrum-survey-field-manualSokkia spectrum-survey-field-manual
Sokkia spectrum-survey-field-manual
 
How and Where to find Land Surveying Jobs
How and Where to find Land Surveying JobsHow and Where to find Land Surveying Jobs
How and Where to find Land Surveying Jobs
 
History of-angles-measurements
History of-angles-measurementsHistory of-angles-measurements
History of-angles-measurements
 
Flyer kern 1998_aktuell
Flyer kern 1998_aktuellFlyer kern 1998_aktuell
Flyer kern 1998_aktuell
 

Último

Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCR
Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCRReal Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCR
Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCRdollysharma2066
 
Vip Udupi Call Girls 7001305949 WhatsApp Number 24x7 Best Services
Vip Udupi Call Girls 7001305949 WhatsApp Number 24x7 Best ServicesVip Udupi Call Girls 7001305949 WhatsApp Number 24x7 Best Services
Vip Udupi Call Girls 7001305949 WhatsApp Number 24x7 Best Servicesnajka9823
 
专业一比一美国加州州立大学东湾分校毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国加州州立大学东湾分校毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree专业一比一美国加州州立大学东湾分校毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国加州州立大学东湾分校毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degreeyuu sss
 
NO1 WorldWide kala jadu Love Marriage Black Magic Punjab Powerful Black Magic...
NO1 WorldWide kala jadu Love Marriage Black Magic Punjab Powerful Black Magic...NO1 WorldWide kala jadu Love Marriage Black Magic Punjab Powerful Black Magic...
NO1 WorldWide kala jadu Love Marriage Black Magic Punjab Powerful Black Magic...Amil baba
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsappssapnasaifi408
 
Call Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall AvailableCall Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall AvailableCall Girls in Delhi
 
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...srsj9000
 
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》o8wvnojp
 
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...Authentic No 1 Amil Baba In Pakistan
 
原版1:1复刻斯坦福大学毕业证Stanford毕业证留信学历认证
原版1:1复刻斯坦福大学毕业证Stanford毕业证留信学历认证原版1:1复刻斯坦福大学毕业证Stanford毕业证留信学历认证
原版1:1复刻斯坦福大学毕业证Stanford毕业证留信学历认证gwhohjj
 
Vip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts ServiceVip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts Serviceankitnayak356677
 
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...nagunakhan
 
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service GayaGaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service Gayasrsj9000
 
专业一比一美国旧金山艺术学院毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国旧金山艺术学院毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree专业一比一美国旧金山艺术学院毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国旧金山艺术学院毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degreeyuu sss
 
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfPresentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfchapmanellie27
 
existing product research b2 Sunderland Culture
existing product research b2 Sunderland Cultureexisting product research b2 Sunderland Culture
existing product research b2 Sunderland CultureChloeMeadows1
 
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一定制(UI学位证)爱达荷大学毕业证成绩单原版一比一
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一ss ss
 
Dubai Call Girls O525547819 Spring Break Fast Call Girls Dubai
Dubai Call Girls O525547819 Spring Break Fast Call Girls DubaiDubai Call Girls O525547819 Spring Break Fast Call Girls Dubai
Dubai Call Girls O525547819 Spring Break Fast Call Girls Dubaikojalkojal131
 

Último (20)

Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCR
Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCRReal Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCR
Real Sure (Call Girl) in I.G.I. Airport 8377087607 Hot Call Girls In Delhi NCR
 
young call girls in Gtb Nagar,🔝 9953056974 🔝 escort Service
young call girls in Gtb Nagar,🔝 9953056974 🔝 escort Serviceyoung call girls in Gtb Nagar,🔝 9953056974 🔝 escort Service
young call girls in Gtb Nagar,🔝 9953056974 🔝 escort Service
 
Vip Udupi Call Girls 7001305949 WhatsApp Number 24x7 Best Services
Vip Udupi Call Girls 7001305949 WhatsApp Number 24x7 Best ServicesVip Udupi Call Girls 7001305949 WhatsApp Number 24x7 Best Services
Vip Udupi Call Girls 7001305949 WhatsApp Number 24x7 Best Services
 
专业一比一美国加州州立大学东湾分校毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国加州州立大学东湾分校毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree专业一比一美国加州州立大学东湾分校毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国加州州立大学东湾分校毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
 
NO1 WorldWide kala jadu Love Marriage Black Magic Punjab Powerful Black Magic...
NO1 WorldWide kala jadu Love Marriage Black Magic Punjab Powerful Black Magic...NO1 WorldWide kala jadu Love Marriage Black Magic Punjab Powerful Black Magic...
NO1 WorldWide kala jadu Love Marriage Black Magic Punjab Powerful Black Magic...
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
 
Call Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall AvailableCall Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall Available
 
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
 
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》
《1:1仿制麦克马斯特大学毕业证|订制麦克马斯特大学文凭》
 
Low rate Call girls in Delhi Justdial | 9953330565
Low rate Call girls in Delhi Justdial | 9953330565Low rate Call girls in Delhi Justdial | 9953330565
Low rate Call girls in Delhi Justdial | 9953330565
 
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...
 
原版1:1复刻斯坦福大学毕业证Stanford毕业证留信学历认证
原版1:1复刻斯坦福大学毕业证Stanford毕业证留信学历认证原版1:1复刻斯坦福大学毕业证Stanford毕业证留信学历认证
原版1:1复刻斯坦福大学毕业证Stanford毕业证留信学历认证
 
Vip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts ServiceVip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts Service
 
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
 
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service GayaGaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
 
专业一比一美国旧金山艺术学院毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国旧金山艺术学院毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree专业一比一美国旧金山艺术学院毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国旧金山艺术学院毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
 
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfPresentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
 
existing product research b2 Sunderland Culture
existing product research b2 Sunderland Cultureexisting product research b2 Sunderland Culture
existing product research b2 Sunderland Culture
 
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一定制(UI学位证)爱达荷大学毕业证成绩单原版一比一
定制(UI学位证)爱达荷大学毕业证成绩单原版一比一
 
Dubai Call Girls O525547819 Spring Break Fast Call Girls Dubai
Dubai Call Girls O525547819 Spring Break Fast Call Girls DubaiDubai Call Girls O525547819 Spring Break Fast Call Girls Dubai
Dubai Call Girls O525547819 Spring Break Fast Call Girls Dubai
 

Programming 33s simple

  • 1. hp calculators HP 33S Writing a Simple Program Programming the HP 33S Practice example: the area of a circle Tools for programming Practice example: the sinc function Using a program in another program
  • 2. hp calculators HP 33S Writing a Simple Program Programming the HP 33S Doing a simple calculation once on the HP 33S is easy. Doing the same calculation many times, or doing a complicated calculation, takes longer. It can be better to store all the steps needed for the calculation in a program. A program is a set of instructions, stored all together. Once it is written, it can be tested to see if it works correctly. Then it can be used many times, without the need to press every key of the calculation each time. A simple program is just a set of keystrokes stored so that they can be carried out with one key. The HP 33S provides many commands to let programs do more, for example stop and ask for input, or show an intermediate result. This training aid concentrates on simple programming; it also shows a few of the more advanced programming commands. Practice example: the area of a circle Given “r” the radius of a circle, the circle’s area “A” is calculated from the formula A = π r ². For example to calculate the area of a circle with radius 3cm, the following keys are pressed. In RPN mode: 3=ºj¸ And in algebraic mode: 3=¸ºjÏ Figure 1 Repeating the same 4 keys in RPN mode or 5 keys in algebraic mode for many circles is a lot of work. Here is how a program would make it easier. Example 1: Write a program in RPN mode to calculate the area of a circle, given its radius r. Solution: An RPN program and an algebraic program are shown below. The RPN program is shown first, called “A” for “Area”. In RPN mode, type the same keys for calculating the area as before, but mark the beginning of the program with a label and the end of the program with a return. First set program mode by typing ¹£ and then go to the top of program memory (called PRGM TOP, see Figure 2), ready to begin a new program, by typing ¹rËË. Now the program can be typed: ¹ÓA=ºj¸ºÔ The letter A is on the keyboard, below and to the right of the # key. Whenever Ó is typed, the HP 33S uses the keys with the letters A – Z marked next to them to enter those letters. hp calculators -2- HP 33S Writing a Simple Program - Version 1.0
  • 3. hp calculators HP 33S Writing a Simple Program The program will look as shown in Figures 2 through 4 below. Figure 2 Figure 3 Figure 4 Each line of the program begins with the letter of the label, and then has a four-digit line number. The rest of the program line is a function or a program instruction. The program instructions are LBL A and RTN, the functions are x ², π and ×. To use the program, it is necessary to move out of program mode, and to return to the beginning of the program. Then a radius is typed and the ¥ key is pressed. The HP 33S executes (or runs) the program. To calculate the area of a circle with radius 5, make sure RPN mode is set, then press: ¹£ºÔ5¥ Figure 5 Answer: The area of a circle with radius 5 cm is just over 78.53 square cm. To calculate the area of another circle with a different radius, it is enough to type the new radius and press ¥ again. The program works like a new function, executed by means of the ¥ key instead of a key with the name of one of the functions built into the HP 33S. Example 2: Write a program in RPN mode to calculate the area of a circle, given its radius r. Solution: In algebraic mode, the program looks very similar, but with the calculation keys typed in algebraic order. The HP 33S does not allow more than one program to have the same label, so the algebraic program below is given the label B. Go to the beginning of program memory by typing ¹rËË and set program mode by typing ¹£. Then type the algebraic mode program: hp calculators -3- HP 33S Writing a Simple Program - Version 1.0
  • 4. hp calculators HP 33S Writing a Simple Program ¹ÓBºÚ=¸ºjÏºÔ To get B press the & key; it has a small B to its lower right. The program lines are as listed below. B0001 LBL B B0002 ALG B0003 x² B0004 × B0005 π B0006 ENTER B0007 RTN If a program in algebraic mode performs a complete calculation then it is best to finish it with Ï so that calculations made after the program will not be treated as part of the program’s calculation. The second line is an instruction to set algebraic mode, to make sure program B is not used accidentally in RPN mode. If the user always works in algebraic mode, or always remembers to switch to the right mode before using a program then this program line is not needed, but it is always safer to use it. A similar line, setting RPN mode, could have been used in program A for the same reason. This program works just like the RPN version. To use it, first move out of program mode, and to go to the beginning of the program. Then a radius is typed and the program is executed. Therefore, to calculate the area of a circle with radius 5, press: ¹£ºÔ5¥ Figure 6 Answer: As in RPN mode, the area of a circle with radius 5 cm is calculated at just over 78.53 square cm. To calculate the area of another circle with a different radius, it is enough to type the new radius and press ¥ again. Like the RPN program, this program works similarly to a new function, executed by means of the ¥ key instead of a key with the name of one of the functions built into the HP 33S. Tools for programming The HP 33S allows the user to create any or all of the labels from LBL A through LBL Z. The lines after a label all have that label at the beginning of their line numbers. When a new label is typed, the HP 33S starts over again at line 1, with the new label’s name at the beginning of each line. Figure 7 shows an example of this; if both program A and program B were typed, then after the RTN in program B, the first line of program A is displayed on the calculator screen. Figure 7 hp calculators -4- HP 33S Writing a Simple Program - Version 1.0
  • 5. hp calculators HP 33S Writing a Simple Program Each label can be used only one time, and the HP 33S treats the lines from one label until the next label as a separate program. It is also possible to have a program with no label, from the “PRGM TOP” until the first label. To list the programs in the HP 33S, press the keys ¹u to get the “Memory” menu, and then 2 to get a display of programs. If the algebraic version of the circle program has been entered then the calculator screen will look like Figure 8. If only program A was typed, the screen will be as in Figure 9. Figure 8 This means that the program with label B is the first program in memory, and that it is 21 bytes long. A byte is a piece of calculator memory made up of 8 bits, and a bit is the smallest piece of memory, a single “0” or “1”. The HP 33S has more than 31,000 bytes of memory available to hold programs and equations entered by the user. Given this much memory, a long program could have up to 9,999 program lines, and that is why program line numbers are 4 digits long. The up and down arrows at the right of the screen mean that there are more programs in the calculator – information about each program in turn is displayed if the up or down arrow keys are pressed. If both the programs A and B have been entered, press Ø to see information about program A. Figure 9 Another tool to help in writing programs is the program checksum. To see the checksum for program A, press ºÎ. While the Î key is held down, the calculator will show: Figure 10 CK=DEFD means that the checksum for program A is the hexadecimal number DEFD. (The checksum for program B is 8A0B.) If the program was not typed correctly, then the checksum will be different. Press the key labeled Å at the bottom left of the keyboard to cancel the display of information about programs. The checksum has several purposes: • If a program is correctly copied to the HP 33S from a web page or a book – the HP 33S manual has many useful example programs – then the checksum on the HP 33S will be the same as the checksum given with the program. If the checksum is not the same, a mistake was made and the program should be checked and corrected before it is used. • If a user creates a new program on an HP 33S and then writes it down for future use, it is worth keeping a note of the checksum with the written program. That way, the program can be checked if it is typed into the HP 33S again later. hp calculators -5- HP 33S Writing a Simple Program - Version 1.0
  • 6. hp calculators HP 33S Writing a Simple Program • If a user wants to offer a program to other users, the checksum should be given with the program, so the other users can check if they have entered the program correctly into their HP 33S. The checksum can be very helpful, but it does not have to be used – for short programs such as the above it can be enough to step through the program with the up and down arrow keys and correct any mistakes. Mistakes can be either wrongly typed lines, or missing lines. To add a missing line, use the × and Ø keys until the line before the missing line is at the bottom of the screen. Then type the missing line or lines. If a line is wrong, move it to the lower line of the screen and use the ~ key to delete one or more lines, then type the correct line or lines. Even after all typing errors have been corrected, a program can still be wrong if it was designed wrongly. The HP 33S manual provides advice on program testing and describes more programming tools. To go to a line in a program, to see it or to change it, use the GTO command, followed by a dot and then the program name and the line number. For example to go to line 5 of program A type ¹rËA0005. The LBL and the RTN help to identify each program. If a program is executed by the user pressing ¥ then the Ô goes back to the top of program memory, where the program stops. If both program B and program A are in the HP 33S, and program A is used, then the RTN at the end will go to label B at the top of program memory. Next time ¥ is pressed, program B will begin, not program A. This means that only the program at the top of program memory will work like a function key when ¥ is pressed. To execute program A if it is not at the top of memory, press tA. Practice example: the sinc function Example 3: As a third example, write a program to calculate the Sinc function Sinc(x) = Sin(x)÷x. At first sight this looks little different from the previous program, but there is one difficulty – the program needs to deal with the case of x = 0 when division by zero gives an error. The program needs to test for x=0 and to handle that case specially. This example will show how tests are used in programs. Solution: Again write the program so it will use a number x that has been typed before the program begins. A program like this will probably be used like an additional function on the calculator, so it should work both in RPN mode and in algebraic mode, in the same way as functions built into the HP 33S. To do this, the program will use a data register. Data registers are described in detail in a separate practice aid. The program will also use a flag, flags are also described in a separate practice aid. As before, first set program mode by typing ¹£ and then go to the top of program memory by typing ¹rËË. Try storing the new program at the end of program memory. To do that, press the up arrow key to go from the top of program memory to the last program instruction. If program A was typed as above, the last instruction will be the RTN at its end. Give the new program the label “C”, using the last letter of “Sinc” to name it. Type ¹ÓC. To type C, press ) after pressing Ó. Figure 11 hp calculators -6- HP 33S Writing a Simple Program - Version 1.0
  • 7. hp calculators HP 33S Writing a Simple Program Store the number in a data register, for this example use data register “A”, but any register could be used. To type A, press # after pressing e. Then clear flag 0, which will be used later. To do this press º· to show the flags menu, press 2 to clear a flag, and press 0 to specify that flag 0 is to be cleared. Figure 12 Now, if the number x is zero, set flag 0. This will let the program check later if x is zero, and will also display a little zero at the top of the screen, to tell the user that sinc is being calculated for x equal to zero. To make a decision like this in a program, it is necessary to use a test function, in this case the test is x=0? Press º to get a menu of test functions. Then press 6 to get the x=0? test. If the test is true, flag 0 must be set. To do this press º· to show the flags menu, press 1 to set a flag, and press 0 to specify that flag 0 is to be set. This means that the program will test x to see if it is zero. If the test is true and x is 0 then the next line will be carried out and flag 0 will be set. If x is not 0 then the test is not true and the next step will be skipped, so flag 0 will be clear, because it was cleared at step C0003. This is the way all tests work in HP 33S programs – do the next step if the test is true, or just do if true. Figure 13 Now calculate the sine of x. If x is zero, then the sine will be zero; nothing will be changed. There is no need for a test, just press k. After the sine has been calculated, the result can be divided by the original number, at present stored in data register A, but first the number must be brought back from A, while the sine is stored in A. To do this, exchange the sine with A. Press ºwA. Once again, press the # key to enter the letter A. Figure 14 shows the program steps. Figure 14 Now the sine can be divided by the original number, but this should only be done if the number is not zero. The program must test x to see if it is not zero. Press º to get a menu of test functions. Then press 1 to get the x≠0? test. Then press e¯A to divide the original number into the sine in register A. If the test is true and x is not 0 then the following line will be carried out and the division will be performed. If x is 0 then the test is not true and the next step will be skipped. Again the program will follow the rule do if true. If the original number was zero, then the division is not performed and there is no error caused by a division by zero. hp calculators -7- HP 33S Writing a Simple Program - Version 1.0
  • 8. hp calculators HP 33S Writing a Simple Program Figure 15 The result is now ready but it is in A and has to be brought back, so another exchange with A is needed. Press ºwA again, and the answer is ready, if the original number was not zero. Figure 16 If the original number was zero then it has not been changed, and the result of all the above work is a zero. However, the result might also be a zero if the calculations produced a number smaller than 10-499. The HP 33S replaces numbers this small with zero. So the result should not be tested, instead flag 0 should be tested, and if it is set then the original number was zero. In that case, it must be turned into a 1. First press º·30. Then the 0 can be turned into a 1 using one of several functions that do this, for example #. Figure 17 To finish the program, press ºÔ, then leave program mode by typing ¹£. The program can be tested with a few values of x. The definition of Sinc(x) as Sin(x)÷x. assumes that x is in radians. (The program does not set radians mode, as a user might intentionally want to calculate Sin(x)÷x in degrees or gradians.) Set radians mode if it is not set already, and calculate the sinc of 0.2. Ý20Ë2tC Figure 18 Confirm that the program works for 0. The program works both in RPN and algebraic modes, so try this in RPN mode: ¹ä0tC Figure 19 hp calculators -8- HP 33S Writing a Simple Program - Version 1.0
  • 9. hp calculators HP 33S Writing a Simple Program Answer: The program works correctly in RPN and in algebraic modes, even for the special case where x is 0. Furthermore, it works so that the original value of x can be recovered with the Í key. The program is 42 bytes long and its checksum is D11C. At 13 steps, it is longer than the “area of a circle” program, but not very long. Extra steps were needed to make it work for the special case, and to use a data register for the calculation, so the program works both in RPN mode and in algebraic mode. This means that the program can be used by other programs that need to calculate sinc. Using a program in another program Example 4: Use program C, written above, to calculate a sinc function value inside another program. Solution: This is very similar to writing a program which calculates a sine as part of a longer calculation. A program which needs to calculate the sine of 1.3 radians might have the following lines in it: D0001 LBL D D0002 RAD D0003 1.3 D0004 sin D0005 … more program lines … A program to use the sinc function, provided by program C, would look like this instead: D0001 LBL D D0002 RAD D0003 1.3 D0004 XEQ C D0005 … more program lines … As this shows, if another program needs to calculate a sinc value, it can use program C like an HP 33S function. First the number x is typed. Then, Instead of typing a function name, the user must call the sinc program by typing XEQ C. When the calling program is run the sinc program will do its calculation. When that reaches the RTN at its end, it will return to the program that called it, which will continue from the next line. When a program is called from another program like this, it is called a subprogram or a subroutine. If a program is used as a subroutine, called from another program, then the RTN at its end finishes the subroutine and goes back to the program that called the subroutine. As was explained in the section on tools for programming, if a program is not called up from another program, but is started by the user pressing ¥, or t, then the Ô goes back to the top of program memory, where the program stops. Programs can do much more than has been described in this training aid. The reader should consult the HP 33S manual and try some of the many example programs in it. hp calculators -9- HP 33S Writing a Simple Program - Version 1.0