Home > HP > Calculator > HP 15c Manual

HP 15c Manual

    Download as PDF Print this page Share this page

    Have a look at the manual HP 15c 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+.

    							 Section 6: Programming Basics 71 
     
    The program to calculate this information uses these formulas and data: 
    base area = r2. 
    volume = base area × height = r2h. 
    surface area = 2 base areas + side area = 2r2 + 2rh. 
     
    Radius, r Height, h Base Area Volume Surface Area 
    2.5cm 8.0 cm ? ? ? 
    4.0 10.5 ? ? ? 
    4.5 4.0 ? ? ? 
    TOTALS   ? ? ? 
    Method: 
    1. Enter an r value into the calculator and save it for other calculations. 
    Calculate  the  base  area  (r2),  store  it  for  later  use,  and  add  the  base 
    area to a register which will hold the sum of all base areas. 
    2. Enter h and  calculate  the  volume  (r2h). Add  it  to  a  register  to  hold 
    the sum of all volumes. 
    3. Recall r.  Divide  the  volume  by r and  multiply  by  2  to  yield  the  side 
    area.  Recall  the  base  area,  multiply  by  2,  and  add  to  the  side  area  to 
    yield the surface areas. Sum the surface areas in a register. 
    Do not enter  the  actual data  while  writing  the  program – just provide  for 
    their  entry.  These  values  will  vary  and  so  will  be  entered  before  and/or 
    during each program run. 
    Key  in  the  following  program  to  solve  the  above  problem.  The  display 
    shows  line  numbers  and  keycodes  (the  row  and  column  location  of  a  key), 
    which will be explained under Further Information. 
    Keystrokes Display  
    | ¥ 000- Sets calculator to Program 
    mode (PRGM displayed). 
    ´ CLEAR M 000- Clears program memory. Starts 
    at line 000.  
    						
    							72 Section 6: Programming Basics 
     
     
    Keystrokes Display   
    ´bA 001-42,21,11  Assigns this program the label 
    ―A‖. 
    O 0 002-   44  0  Stores the contents of X-register 
    into R0. r must be in the X-
    register before running the 
    program. 
    |x 003-   43 11  Squares the contents of the X-
    register (which will be r). 
    |$ 004-   43 26   
    * 005-      20  r2, the BASE AREA of a can. 
    O 4 006-   44  4  Stores the BASE AREA in R4. 
    O + 1 007-44,40, 1  Keeps a sum of all BASE 
    AREAS in R1. 
    ¦ 008-      31  Stops to display BASE AREA 
    and allow entry of the h value. 
    * 009-      20  Multiplies h by the BASE 
    AREA, giving VOLUME. 
    ´ © 010-   42 31  Pauses briefly to display 
    VOLUME. 
    O + 2 011-44,40, 2  Keeps a sum of all can 
    VOLUMES in R2. 
    l 0 012-   45  0  Recalls r. 
    ÷ 013-      10  Divides VOLUME by r. 
    2 014-       2   
    * 015-      20  2 rh, the SIDE AREA of a can. 
    l 4 016-   45  4  Recalls the BASE AREA of the 
    can. 
    2 017-       2  Multiplies base area by two (for 
    top and bottom). * 018-      20  
    						
    							 Section 6: Programming Basics 73 
     
     
    Keystrokes Display  
    + 019–      40 SIDE AREA + BASE AREA 
    = SURFACE AREA. 
    O + 3 020–44,40, 3 Keeps a sum of all SURFACE 
    AREAS in R3. 
    | n 021–   43 32 Ends the program and returns 
    program memory to line 000. 
    Now, lets run the program: 
    Keystrokes Display  
    | ¥  Sets calculator to Run mode. 
    (PRGM cleared.) 
    ´ CLEAR Q  Clears all storage registers. The 
    display does not change. 
    2.5 2.5 Enter r of the first can. 
    ´ A  
    (or: G A) 
    19.6350 Starts program A. BASE AREA 
    of first can. 
    (running flashes during 
    execution.) 
    8 8 Enter h of first can. Then restart 
    program. 
    ¦ 157.0796 VOLUME of first can. 
     164.9336 SURFACE AREA of first can. 
    4 4 Enter r of the second can. 
    ¦ 50.2655 BASE AREA of second can. 
    10.5 10.5 Enter h of second can. 
    ¦ 527.7876 VOLUME of second can. 
     364.4247 SURFACE AREA of 
    second can. 
    4.5 4.5 Enter r of the third can. 
    ¦ 63.6173 BASE AREA of third can.  
    						
    							74 Section 6: Programming Basics 
     
     
    Keystrokes Display  
    4 4 Enter h of third can. 
    ¦ 254.4690 VOLUME of third can. 
     240.3318 SURFACE AREA of third can. 
    l 1 133.5177 Sum of BASE AREAS. 
    l 2 939.3362 Sum of VOLUMES. 
    l 3 769.6902 Sum of SURFACE AREAS. 
    The  preceding  program  illustrates  the  basic  techniques  of  programming.  It 
    also  shows  how  data  can  be  manipulated  in  Program  and  Run  modes  by 
    entering,  storing,  and  recalling  data  (input  and  output)  using v, 
    O, l, storage register arithmetic, and programmed stops. 
    Further Information 
    Program Instructions 
    Each  digit,  decimal  point,  and  function  key  is considered  an instruction 
    and is  stored  in  one line of  program  memory.  An  instruction  may  include 
    prefixes  (such  as ´, O, t and b) and  still  occupy  only  one 
    line. Most instructions require one byte of program memory; however, some 
    require  two.  For  a  complete  list  of  two-byte  instructions,  refer  to 
    Appendix C. 
    Instruction Coding 
    Each  key  on  the  HP-15C  keyboard – except for  the  digit  keys  0  through  
    9 – is  identified  in  Program  mode  by  a  two-digit  ―keycode‖  that 
    corresponds to the keys position on the keyboard. 
    Instruction Code  
    O + 1 006-44,40, 1 Sixth program line. 
    ´ e V XXX-42, 5,25 e is just ―5‖.=
    The  first  digit  of= a  keycode  refers= to= the  row  (1= to= 4  from= top  to= bottom),=
    and  the  second= digit  refers= to= the  column= (1,  OI=9,= 0  from= left= to= right). 
    Exception: the keycode for a digit key is simply that digit.= 
    						
    							 Section 6: Programming Basics 75 
     
    Keycode 25: second row, fifth key. 
    Memory Configuration 
    Understanding  memory  configuration  is  not  essential  to  your  use  of  the 
    HP-15C.  It  is  essential,  however,  for  obtaining  maximum  efficiency  in 
    memory and programming use. The more you program, the more useful this 
    knowledge  will  be.  Memory  configuration  and  allocation  is  thoroughly 
    explained in appendix C, Memory Allocation. 
    Should you ever get an Error 10, you have run up against limitations of the 
    HP-15C  memory.  If  you  learn  how  to  reallocate  memory,  you  can  greatly 
    increase your ability to store information in the HP-15C. 
    The  HP-15C  memory  consists  of  67  registers  (R0 to  R65 and  the  Index 
    register) divided between data  storage  and programming/advanced  function 
    capability. The initial configuration is: 
     46  registers  for  both  programming  and  the  advanced  functions 
    (_, f, the  imaginary stack, and > functions). At seven 
    bytes  of  memory  per  register,  this  is  worth  322  program  bytes  if  no 
    memory is dedicated to advanced functions. 
     21  registers  for  data  storage  (R0 to  R9,  R.0 to  R.9,  and  the  Index 
    register). 
       
    						
    							76 Section 6: Programming Basics 
     
     
    Memory  is  reallocated  by  telling  the  calculator  which  data  storage  register 
    shall be the highest data register; all other registers are left for programming 
    and advanced functions. 
    Keystrokes Display  
    60 ´ m %* 60.0000 R60 and below allocated to data 
    storage; five (R61 to R65) remain 
    for programming. 
                                                               * The optional omission of the ´ keystroke after another prefix key is explained on page 78, Abbreviated Key Sequences. 
    Initial Memory Configuration 
     
       
    						
    							 Section 6: Programming Basics 77 
     
     
    Keystrokes Display  
    1 ´ m % 1.0000 R1 and R0 allocated for data 
    storage; R2 to R65 available for 
    programming and advanced 
    functions. 
    19 ´ m% 19.0000 Original allocation: R19 (R.9) and 
    below for data storage; R20, to 
    R65 for programming and 
    advanced functions.* 
    lm% 19.0000 Displays the current highest data 
    register. 
    The m and W (memory  status) functions  are  described  in  detail  in 
    appendix C. 
    Keep  in  mind  that  an  error  message  will  result (given  the  above  memory 
    configuration) if 
    1. You  try  to  address  a  register  higher  than  R19 (R.9),  which  initially  is 
    the highest register allocated to data storage (Error 3). 
    2. You have  322 occupied program bytes and try to load more  program 
    lines (Error 4). 
    3. You  try  to  run  an  advanced  function  with  insufficient  available 
    memory (Error 10). 
    Program Boundaries 
    End. Not every program needs to end with a n or ¦ instruction. If 
    you  are  at  the  end  of  occupied  program  memory,  there  is  an automatic 
    n instruction,  so  you  do  not  need  to  enter  one.  This  can  save  you  one 
    line  of  memory.  On  the  other  hand,  a  program  can  ―end‖  by  simply 
    transferring execution to another routine using t (section 7). 
    Labels. Labels  in  a  program  (or  subroutine)  are  markers  telling  the 
    calculator where to begin execution. Following an ´ label or G label 
    instruction, the calculator will search downward in program memory for the 
                                                               * For memory allocation and indirect addressing, registers R.0 through R.9 are referred to as R10 through R19.  
    						
    							78 Section 6: Programming Basics 
     
    corresponding  label.  If  need  be,  the  search  will  wrap  around  at  the  end  of 
    program  memory  and  continue  at  line  000.  When  it  encounters  an 
    appropriate label, the search stops and execution begins. 
    If  a  label  is  encountered  as  part  of  a  running  program,  it  has  no  effect,  that 
    is,  execution  simply  continues.  Therefore,  you  can  label  a  subordinate 
    routine within a program (more on subroutines in section 9). 
    Since the calculator searches in only one direction from its present position, 
    it  is  possible  (though  not  advisable)  to  use  duplicate  program  labels. 
    Execution will begin at the first appropriately labeled line encountered. 
     
    If  an ´ A entry  starts  the  search 
    for ―A‖ here,=
    it= then= proceeds= downward= through 
    memory,  wraps  around= to= line= 000,=
    and stops  at  label  ―A‖.  Execution  then 
    starts= and  continues  (ignoring  any 
    other labels) until a halt instructionK=
    000- 
    (stop) 
    ´bA 
     
    ´b3 
     
    ¦ 
    end of memory 
    Unexpected Program Stops 
    Pressing  Any  Key. Pressing  any  key  will  halt  program  execution. It  will 
    not halt  in  the  middle  of  an  operation.  This  instruction  will  be  completed 
    before the program stops. 
    Error  Stops. Program execution is immediately  halted  when the  calculator 
    attempts an improper operation that results in an Error display. 
    To  see  the  line  number  and  keycode  of  the  error-causing  instruction  (the 
    line  at  which  the  program  stopped), press  any  one  key  to  remove  the Error 
    message, then switch to Program mode. 
    If the display is flashing when a program stops, an overflow condition exists 
    (page 61). Press − =, or |  9 to stop the blinking. 
    Abbreviated Key Sequences 
    In  certain  cases,  an ´ prefix  you  might  expect  to  include  in  a  key 
    sequence  is  not  needed.  The  rule  for  using  an abbreviated  key  sequence is: 
    the ´ prefix  key  is  unnecessary  after  any  other  prefix  key.  (Page  19 
    contains a list of prefix keys.)  
    						
    							 Section 6: Programming Basics 79 
     
    For  example, ´b´A becomes ´bA, ´m´% 
    becomes ´m%,  and O´# becomes O#. 
    The removal of the ´ is not ambiguous because the ´-shifted function 
    is the only logical one in these cases. The keycodes for such instructions do 
    not include the extraneous ´ even if you do key it in. 
    User Mode 
    User  mode  is  a  convenience  to  save  keystrokes  when  addressing  (calling 
    up) programs for execution. Pressing ´U will exchange the  primary 
    functions  and ´-shifted  functions  of  the A through E keys  only.  In 
    User mode (USER annunciator displayed): 
     
    ´ shift  
    Primary 
     A B C D E 
    ¤  @ y ∕ 
    | shift x2 LN LOG 
    
    Press | U again to deactivate User mode. 
    Polynomial Expressions and Horners Method 
    Some expressions, such as polynomials, use the same variable several times 
    for their solution. For example, the expression 
    f(x) = Ax4 + Bx3 + Cx2 + Dx + E 
    uses  the  variable x four  different  times.  A  program  to  solve  such  an 
    equation  could  repeatedly  recall  a  stored  copy  of x from  a  storage  register. 
    A  shorter  programming  method,  however,  would  be  to  use  a  stack  which 
    has  been  filled  with  the  constant  (refer  to  Loading  the  Stack  with  a 
    Constant, page 41). 
    Horners Method is a useful means of rearranging polynomial expressions to 
    cut  calculation  steps  and  calculation  time.  It  is  especially  expedient  in 
    _ and f, two rather long-running functions that use subroutines. 
    This method involves rewriting a polynomial expression in a nested fashion 
    to eliminate exponents greater than 1: 
    Ax4 + Bx3 + Cx2 + Dx + E 
    (Ax3 + Bx2 + Cx + D)x + E 
    ((Ax2 + Bx + C)x + D)x + E 
    (((Ax + B)x + C)x + D)x + E  
    						
    							80 Section 6: Programming Basics 
     
    Example: Write  a  program  for 5x4 + 2x3 as (((5x + 2)x)x)x, then  evaluate 
    for x = 7 
    Keystrokes Display  
    | ¥ 000- Assumes position in memory 
    is line 000. If it is not, clear 
    program memory. 
    ´ b B 001-42,21,12  
    5 002-       5  
    * 003-      20 5x. 
    2 004-       2  
    + 005-      40 5x + 2. 
    * 006-      20 (5x + 2)x. 
    * 007-      20 (5x + 2)x2. 
    * 008-      20 (5x + 2)x3. 
    | n 009-   43 32  
    | ¥  Returns to Run mode, Prior 
    result remains in display. 
    7 v v 
    v 
      
    7.0000 Loads the stack (X-, Y-, Z-, 
    and T-registers) with 7. 
    ´ B 12,691.0000  
    Nonprogrammable Functions 
    When  the  calculator  is  in  Program  mode,  almost  every  function  on  the 
    keyboard  can  be  recorded  as an  instruction  in  program  memory.  The 
    following functions cannot be stored as instructions in program memory. 
     
    ´ CLEAR u | ‚ Â 
    ´ CLEAR M | W − 
    ´ % | ¥ =/. 
    ´ U t “ nnn =/­  
    						
    All HP manuals Comments (0)