Home > HP > Calculator > HP 12c Owners Manual

HP 12c Owners Manual

    Download as PDF Print this page Share this page

    Have a look at the manual HP 12c Owners 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 9: Branching and Looping  111 
     
    File name: hp 12c_users guide_English_HDPMBF12E44  Page: 111 of 209   
    Printered Date: 2005/7/29    Dimension: 14.8 cm x 21 cm 
     
    Keystrokes Display   
     
    15,000.00  
    Ê 
    07-  45  1Line 07: :
    1. 
     
    20.00 20% tax rate has been recalled to 
    X-register, moving income to 
    Y-register. 
    Ê 
    08-    25Line 08: b
    . 
     
    3,000.00 20% of 15,000 = 3,000. 
    20000 
    20,000. Keys income equal to test value into 
    display and X-register.   
    Ê 
    01-  45  0Line 01: :
    0. 
     
    20,000.00 Test value has been recalled to 
    X-register, moving income to 
    Y-register. 
    Ê 
    02-    34Line 02: ~
    . 
     
    20,000.00 Income has been placed in 
    X-register and test value has been 
    placed in Y-register.   
    Ê 
    03-  43  34Line 03 go
    . 
     
    20,000.00  
    Ê 
    04- 43, 33   07Condition tested by o
     was true, 
    so program execution continued 
    with line 04: gi
    07. 
     
    20,000.00  
    Ê 
    07-  45  1Line 07: :
    1. 
     
    20.00 20% tax rate has been recalled to 
    X-register, moving income to 
    Y-register. 
    Ê 
    08-    25Line 08: b
    . 
     
    4,000.00 20% of 20,000 = 4,000. 
    25000 
    25,000. Keys income greater than test value 
    into display and X-register. 
    Ê 
    01-  45  0Line 01: :
    0. 
     
    20,000.00 Test value has been recalled to 
    X-register, moving income to 
    Y-register.  
    						
    							112  Section 9: Branching and Looping 
     
     
    File name: hp 12c_users guide_English_HDPMBF12E44  Page: 112 of 209   
    Printered Date: 2005/7/29    Dimension: 14.8 cm x 21 cm 
     
    Keystrokes Display   
    Ê 
    02-    34Line 02: ~
    . 
     
    25,000.00 Income has been placed in 
    X-register and test value has been 
    placed in Y-register. 
    Ê 
    03-  43  34Line 03: go
    . 
     
    25,000.00  
    Ê 
    05-  45  2Condition tested by o
     was false, 
    so program execution skipped the 
    next line and continued at line 05: 
    :
    2. 
     
    25.00 25% tax rate has been recalled to 
    X-register, moving income to 
    Y-register. 
    Ê 
    06- 43, 33   08Line 06: gi
    08. 
     
    25.00  
    Ê 
    08-    25Line 08: b
    . 
     
    6,250.00 25% of 25,000 = 6,250.  
    						
    							 
    113 
    File name: hp 12c_users guide_English_HDPMBF12E44  Page: 113 of 209   
    Printered Date: 2005/7/29    Dimension: 14.8 cm x 21 cm 
      Section 10 
    Program Editing 
    There are various reasons why you might want to modify a program you have 
    stored in Program memory: to correct a program that turns out to have errors; to 
    insert new instructions such as ?
     to store intermediate results or u
     to display 
    intermediate results; or to replace a u
     instruction by an t
     instruction. 
    Rather than clearing program memory and keying in the modified program, you 
    can modify the program already stored in the calculator. This is called program 
    editing. 
    Changing the Instruction in a Program Line 
    To change a single instruction in program memory: 
    1. Press fs to set the calculator to Program mode. 
    2. Use Ç, Ü, or i. to set the calculator to the program line preceding 
    the line containing the instruction to be changed. 
    3.  Key in the new instruction. 
    For example, to change the instruction stored in program line 05, press 
    gi.
    04, then key in the new instruction that is to be stored in program line 
    05. The instruction previously stored in line 05 will be replaced; it is not 
    automatically “bumped” into line 06. 
    Example:
     With the last program from the preceding section still stored in the 
    calculator, suppose you wanted to use register R
    2 for some other purpose, and so 
    you needed to replace the :
    2 instruction in program line 05 with, say, :
    6. 
    You could change the instruction in line 05 as follows: 
    Keystrokes Display   
    fs 
    00- Sets calculator to Program mode.   
    gi.04 
    04- 43, 33   07Sets calculator to program line 
    preceding that containing the instruction 
    to be changed. 
    :6 
    05-  45  6Keys new instruction into program line 
    05, replacing the :
    2 instruction 
    previously there. 
    Ê 
    06- 43, 33  08Shows that instruction in program line 
    06 has not been changed.  
    						
    							114  Section 10: Program Editing 
     
     
    File name: hp 12c_users guide_English_HDPMBF12E44  Page: 114 of 209   
    Printered Date: 2005/7/29    Dimension: 14.8 cm x 21 cm 
     
    Keystrokes Display   
    fs 
    6,250.00 Sets calculator back to Run mode. 
    (Display shown assumes results remain 
    from last example in precedin
    g section.) 
    :2?6 
    25.00 Copies tax rate from R2 into R6. 
    Adding Instructions at the End of a Program 
    To add one or more instructions at the end of the last program stored in program 
    memory: 
    1. Press fs to set the calculator to Program mode. 
    2. Press gi. followed by two digits that specify the last line you keyed 
    into program memory (that is, the highest numbered line, not necessarily the 
    line most recently keyed in). 
    3.  Key in the new instruction or instructions. 
    Note: To add one or more instructions at the end of a program that is not 
    the last program stored in program memory, use the procedure described 
    below under Adding Instructions Within a Program. 
    Example:
     With the last program from the preceding section stored in the 
    calculator, suppose you wanted to add a -
     instruction at the end in order to 
    calculate the net income after taxes. You could do so as follows: 
    Keystrokes Display   
    fs 
    00- Sets calculator to Program mode.   
    gi.08 
    08-    25Sets calculator to last line keyed into 
    program memory. 
    - 
    09-    30Keys new instruction into program 
    line 09. 
    fs 
    25.00 Sets calculator back to Run mode. 
    15000t 
    12,000.00 Net income after 20% tax is 
    subtracted from $15,000 income.  
    						
    							  Section 10: Program Editing  115 
     
    File name: hp 12c_users guide_English_HDPMBF12E44  Page: 115 of 209   
    Printered Date: 2005/7/29    Dimension: 14.8 cm x 21 cm 
     
    Adding Instructions Within a Program 
    If an instruction is to be added within a program, simply keying it in will replace 
    the instruction previously stored in that program line, as described above; the 
    contents of all higher-numbered program lines remain unchanged. 
    To add instructions within a program, you could simply key in the new instructions, 
    beginning at the proper program line, followed by the original instructions from 
    that program line through the end of the program. This method is described below 
    under Adding Instructions by Replacement. When instructions must be added in the 
    middle of a long program, however, using this method will require you to key in 
    numerous instructions — namely, the original instructions from the point at which 
    the new instructions are added through the end of program memory. Since keying 
    in these instructions may require a significant amount of time, in such situations you 
    may prefer to use the method described below under Adding Instructions by 
    Branching. 
    That method basically involves branching to the new instructions which are stored 
    at the end of program memory, then branching back to the program line 
    immediately following the line from which you branched out. Adding instructions 
    by branching is not so simple as adding instructions by replacement; however, it 
    generally will require fewer keystrokes whenever there are more than four program 
    lines between (and including) the first line to be executed after the new instruction(s) 
    and the last line you keyed into program memory. Furthermore, if program 
    memory includes branches to program lines following the point at which the new 
    instruction(s) are being added, adding instructions by branching will not require 
    that you change the line numbers specified in the i
     instructions, which may be 
    necessary when you add instructions by replacement. 
    Adding Instructions by Replacement 
    1. Press fs to set the calculator to Program mode. 
    2. Press gi. followed by two digits that specify the last program line to 
    be executed before the added instruction(s). This sets the calculator to the 
    proper program line for adding the new instruction(s) in the next step. 
    3.  Key in the new instruction or instructions. 
    4. Key in the original instruction or instructions, beginning with the first 
    instruction to be executed after the added instruction(s), and continuing 
    through the last instruction you keyed into program memory. 
    Note: If program memory includes branches to program lines following that 
    at which the first new instruction is being added, remember to change the 
    line number(s) specified in the i instruction(s) — as described above 
    under Changing the Instruction in a Program Line — to the actual new line 
    number(s).  
    						
    							116  Section 10: Program Editing 
     
     
    File name: hp 12c_users guide_English_HDPMBF12E44  Page: 116 of 209   
    Printered Date: 2005/7/29    Dimension: 14.8 cm x 21 cm 
     
    Example:
     Assuming you have added a - 
    instruction at the end of program 
    memory as in the preceding example, suppose you now wanted to insert an t
     
    instruction before the -
     instruction so that the program will display the amount of 
    the tax before displaying the net income after tax. Since there is only one 
    instruction (-
    ) following the point at which the new instruction is being added, it 
    is simplest to add the t
     instruction by replacement, as follows: 
    Keystrokes Display   
    fs 
    00- Sets calculator to Program mode.   
    gi.08 
    08-    25 Sets calculator to last program line 
    to be executed, which contains the 
    b
     instruction. 
    t 
    09-    31 Keys in new instruction. 
    - 
    10-    30 Keys in original instruction, which 
    was replaced by new instruction 
    added. 
    fs 
    12,000.00 Sets calculator back to Run mode. 
    15000t 
    3,000.00 Twenty percent tax on $15,000 
    income. 
    t 
    12,000.00 Net income after tax. 
    Adding Instructions by Branching 
    1. Press fs to set the calculator to Program mode. 
    2. Press gi. followed by two digits that specify the program line 
    immediately preceding the point at which the new instruction(s) are being 
    added — usually, the last program line to be executed before the added 
    instruction(s). This sets the calculator to the proper program line for inserting 
    a i instruction in the next step. This i instruction will replace whatever 
    instruction was already stored there, but that instruction will be keyed back 
    into program memory, to be executed just after the new instructions, in step 
    7. 
    3. Press gi followed by two digits that specify the second line after the last 
    line you keyed into program memory. (Branching to the second line rather 
    than to the first is necessary because the first line following the last program 
    in program memory must contain a i00 instruction. The i00 
    instruction ensures that program execution will branch to line 00 and halt 
    after the program is run.) For example, if the last line you keyed into 
    program memory was line 10, you would press gi12 at this step, 
    preserving the gi00 in line 11. 
    4. Press gi. followed by two digits that specify the last line you keyed 
    into program memory.  
    						
    							  Section 10: Program Editing  117 
     
    File name: hp 12c_users guide_English_HDPMBF12E44  Page: 117 of 209   
    Printered Date: 2005/7/29    Dimension: 14.8 cm x 21 cm 
     
    5. Press gi00. This automatically converts a data storage register into 
    seven additional lines of program memory (if there was not already a 
    i00 instruction remaining at the end of program memory), and it ensures 
    that program execution will branch to line 00 after the program is run. 
    6.  Key in the instruction(s) being added. 
    7.  Key in the instruction that originally immediately followed the point at which 
    the new instruction(s) are being added — that is, the first instruction to be 
    executed after the added instruction(s). (This instruction was replaced by the 
    i instruction keyed in at step 3.) 
    8. Press gi followed by two digits that specify the second line following 
    the point at which the new instruction(s) are being added. This i 
    instruction will cause program execution to branch back to the proper line 
    within the original program. 
    Example:
     Continuing with the preceding example, suppose incomes less than or 
    equal to $7,500 were not to be taxed. You could modify the program to check for 
    this condition and stop at line 00, displaying the original income keyed in, by 
    storing 7,500 in register R
    3 and adding the following instructions between lines 00 
    and 01: :
    3~gogi
    00. Since there are more than four instructions 
    between (and including) the first line to be executed after the added instructions 
    (line 01) and the last line you keyed into program memory (line 10), it will require 
    fewer keystrokes to add the new instructions by branching than to add them by 
    replacement. 
    Keystrokes Display   
    fs 
    00- Sets calculator to Program mode.   
    gi.00 
    00- Sets calculator to program line 
    immediately preceding point at 
    which new instructions are being 
    added. (In this particular example, 
    this step could have been skipped 
    since calculator was already set at 
    the proper program line.) 
    gi12 
    01- 43, 33   12 Branches to program line 12, the 
    second line after last line of 
    program. 
    gi.10 
    10-    30 Sets calculator to last line of 
    program so that i
    00 instruction 
    keyed in next will be stored in first 
    line following program. 
    gi00 
    11- 43, 33   00 Ensures that i
    00 instruction 
    follows program.  
    						
    							118  Section 10: Program Editing 
     
     
    File name: hp 12c_users guide_English_HDPMBF12E44  Page: 118 of 209   
    Printered Date: 2005/7/29    Dimension: 14.8 cm x 21 cm 
     
    Keystrokes Display   
    :3 
    12-  45  3 
    ~ 13-    34 
    go 14-  43  34 
    gi00 15- 43, 33   00 
    Added instructions. 
    :0 
    16-  45  0 Keys in instruction immediately 
    following point at which new 
    instructions are being added. (This 
    instruction was replaced in line 01 
    by i
    12 instruction.) 
    gi02 
    17- 43, 33   02 Branches back to second line (line 
    02) following point at which new 
    instructions are being added. 
    fs 
    12,000.00 Sets calculator back to Run mode. 
    7500?3 
    7,500.00 Stores test value in register R3. 
    6500t 
    6,500.00 Runs program for income less than 
    $7,500. Display shows original 
    income keyed in, indicating that tax 
    is zero. 
    15000t 
    3,000.00 Tax on $15,000 income. 
    t 
    12,000.00 Net income after tax. This shows 
    program still works for an income 
    greater than $7,500 and less than 
    $20,000. 
    The following illustration of the edited program shows how program execution 
    branches to the instructions added at the end of program memory, then branches 
    back.  
    						
    							  Section 10: Program Editing  119 
     
    File name: hp 12c_users guide_English_HDPMBF12E44  Page: 119 of 209   
    Printered Date: 2005/7/29    Dimension: 14.8 cm x 21 cm 
     
      
    						
    							 
    120 
    File name: hp 12c_users guide_English_HDPMBF12E44  Page: 120 of 209   
    Printered Date: 2005/7/29    Dimension: 14.8 cm x 21 cm 
      Section 11 
    Multiple Programs 
    You can store multiple programs in program memory, provided that you separate 
    them by instructions that will halt program execution after each program is run and 
    return to the beginning of the program if it is run again. You can run programs 
    after the first one stored in program memory by setting the calculator to the first 
    line of the program using i 
    before pressing t
    . 
    Storing Another Program 
    To store a program after another program is already stored in program memory: 
    1. Press fs to set the calculator to Program mode. Do not clear program 
    memory. 
    2. Press gi. followed by two digits that specify the number of the last 
    line you keyed into program memory. 
    Note: If this is the second program to be stored in program memory, you 
    will need to ensure that a i00 instruction separates it from the first 
    program by doing step 3. If there are already two or more programs stored 
    in program memory, skip step 3 and proceed with step 4. 
    3. Press gi00. This automatically converts a data storage register into 
    seven additional lines of program memory (if there was not already a 
    i00 instruction remaining at the end of program memory), and it ensures 
    that program execution will branch to line 00 after the first program is run. 
    4.  Key the program into program memory. If you are storing a program that 
    you originally had written to be stored at the beginning of program memory 
    and the program contains a i instruction, be sure to change the line 
    number specified in the instruction so that the program will branch to the 
    actual new line number. 
    Note: The next two steps are included so that program execution will halt 
    after this program is run and will return to the beginning of the program if it 
    is run again. If the program ends with a loop, you should skip steps 5 and 6 
    since the instructions in those steps would serve no purpose and never be 
    executed. 
    5. Press t. This halts program execution at the end of the program. 
    6. Press gi followed by two digit keys that specify the first line number of 
    your new program. This transfers program execution to the beginning of the 
    new program when the program is run again.  
    						
    All HP manuals Comments (0)

    Related Manuals for HP 12c Owners Manual