Home » Personal collection » Acorn DFS disks » dfs_box03_disk13_bcpl_calc.scp » EXCLHDR
EXCLHDR
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Personal collection » Acorn DFS disks » dfs_box03_disk13_bcpl_calc.scp |
Filename: | EXCLHDR |
Read OK: | ✔ |
File size: | 0AB5 bytes |
Load address: | FF2DF6 |
Exec address: | 20007 |
File contents
// Floating/fixed point calculator header file. // The calculation procedures used are // copyright Richards Computer Products Ltd. (C) 1983 // Written by C Jobson 19/04/83 MANIFEST $( // T.xxx are codes to categorise input keystrokes T.MINUS = 0 // - T.EQUALS = 1 // = (or RETURN) T.OP = 2 // + (or ;), * (or :), / T.CLEAR = 3 // DELETE T.NUMCH = 4 // 0-9, E (or e) and . T.MONOP = 5 // function with one operand (e.g. sin) T.NUMOP = 6 // function giving a number (e.g pi) // S.xxx are 'states' of the calculator - it expects input in four // stages i.e. number, operator, number, equals (e.g. 123 + 456 =) S.NUM1 = 0 // first number expected S.OP = 1 // operator expected S.NUM2 = 2 // second number expected S.EQUALS = 3 // equals expected // C.xxx are characters to set text colours in mode 7 C.WHITE = 135; C.GREEN = 130; C.MAGENTA = 133 C.YELLOW = 131; C.CYAN = 134 NUMWIDTH = 17 // width of field to display number in FIRSTFN = #X90 // value returned by function key 0 UG = FIRSTFREEGLOBAL // to ease typing $) GLOBAL $( // Data items V1:UG; V2:UG+1 // two numbers being processed OP:UG+2 // current operator (as ASCII '+', '-', '*' or '/') CH:UG+3 // current keystroke CHTYPE:UG+4 // type of current keystroke (T.xxx manifests) STATE:UG+5 // current state (S.xxx manifests) MAXFN:UG+6 // value returned by highest function key in use RES.LEV:UG+7 // restart point - LONGJUMP here after clear etc. RES.LAB:UG+8 FNSET:UG+9 // distinguishes alternative uses of function keys // (initially 0) FUNCOP:UG+10 // address of procedure to perform function // corresponding to last function key pressed FNSETMAX:UG+11 // largest permissible value of FNSET // Common procedures CURSOR:UG+20 // position cursor RESET:UG+21 // reset after clear etc. PERFORM.OP:UG+22 // do +, -, * or / NUMPOS:UG+23 // position cursor for displaying a number GETNUM:UG+24 // read in a number GETCH:UG+25 // get next valid keystroke COPYL1L2:UG+26 // display second line of double-height number FLASHNUM:UG+27 // flash displayed number WRITENUM:UG+28 // display double-height number // Procedures which change for floating/fixed DISPNUM:UG+30 // display a number DISPHDNG:UG+31 // display heading // Procedures to handle use of function keys DISPFNS:UG+40 // display use of function keys INTERPFN:UG+41 // interpret function keys $)
00000000 2f 2f 20 46 6c 6f 61 74 69 6e 67 2f 66 69 78 65 |// Floating/fixe| 00000010 64 20 70 6f 69 6e 74 20 63 61 6c 63 75 6c 61 74 |d point calculat| 00000020 6f 72 20 68 65 61 64 65 72 20 66 69 6c 65 2e 0d |or header file..| 00000030 0a 2f 2f 20 54 68 65 20 63 61 6c 63 75 6c 61 74 |.// The calculat| 00000040 69 6f 6e 20 70 72 6f 63 65 64 75 72 65 73 20 75 |ion procedures u| 00000050 73 65 64 20 61 72 65 0d 0a 2f 2f 20 63 6f 70 79 |sed are..// copy| 00000060 72 69 67 68 74 20 52 69 63 68 61 72 64 73 20 43 |right Richards C| 00000070 6f 6d 70 75 74 65 72 20 50 72 6f 64 75 63 74 73 |omputer Products| 00000080 20 4c 74 64 2e 20 28 43 29 20 31 39 38 33 0d 0a | Ltd. (C) 1983..| 00000090 2f 2f 20 57 72 69 74 74 65 6e 20 62 79 20 43 20 |// Written by C | 000000a0 4a 6f 62 73 6f 6e 20 20 31 39 2f 30 34 2f 38 33 |Jobson 19/04/83| 000000b0 0d 0a 0d 0a 4d 41 4e 49 46 45 53 54 20 24 28 0d |....MANIFEST $(.| 000000c0 0a 20 20 20 2f 2f 20 54 2e 78 78 78 20 61 72 65 |. // T.xxx are| 000000d0 20 63 6f 64 65 73 20 74 6f 20 63 61 74 65 67 6f | codes to catego| 000000e0 72 69 73 65 20 69 6e 70 75 74 20 6b 65 79 73 74 |rise input keyst| 000000f0 72 6f 6b 65 73 0d 0a 0d 0a 20 20 20 54 2e 4d 49 |rokes.... T.MI| 00000100 4e 55 53 20 3d 20 30 20 20 20 20 2f 2f 20 2d 0d |NUS = 0 // -.| 00000110 0a 20 20 20 54 2e 45 51 55 41 4c 53 20 3d 20 31 |. T.EQUALS = 1| 00000120 20 20 20 2f 2f 20 3d 20 28 6f 72 20 52 45 54 55 | // = (or RETU| 00000130 52 4e 29 0d 0a 20 20 20 54 2e 4f 50 20 3d 20 32 |RN).. T.OP = 2| 00000140 20 20 20 20 20 20 20 2f 2f 20 2b 20 28 6f 72 20 | // + (or | 00000150 3b 29 2c 20 2a 20 28 6f 72 20 3a 29 2c 20 2f 0d |;), * (or :), /.| 00000160 0a 20 20 20 54 2e 43 4c 45 41 52 20 3d 20 33 20 |. T.CLEAR = 3 | 00000170 20 20 20 2f 2f 20 44 45 4c 45 54 45 0d 0a 20 20 | // DELETE.. | 00000180 20 54 2e 4e 55 4d 43 48 20 3d 20 34 20 20 20 20 | T.NUMCH = 4 | 00000190 2f 2f 20 30 2d 39 2c 20 45 20 28 6f 72 20 65 29 |// 0-9, E (or e)| 000001a0 20 61 6e 64 20 2e 0d 0a 20 20 20 54 2e 4d 4f 4e | and ... T.MON| 000001b0 4f 50 20 3d 20 35 20 20 20 20 2f 2f 20 66 75 6e |OP = 5 // fun| 000001c0 63 74 69 6f 6e 20 77 69 74 68 20 6f 6e 65 20 6f |ction with one o| 000001d0 70 65 72 61 6e 64 20 28 65 2e 67 2e 20 73 69 6e |perand (e.g. sin| 000001e0 29 0d 0a 20 20 20 54 2e 4e 55 4d 4f 50 20 3d 20 |).. T.NUMOP = | 000001f0 36 20 20 20 20 2f 2f 20 66 75 6e 63 74 69 6f 6e |6 // function| 00000200 20 67 69 76 69 6e 67 20 61 20 6e 75 6d 62 65 72 | giving a number| 00000210 20 28 65 2e 67 20 70 69 29 0d 0a 0d 0a 20 20 20 | (e.g pi).... | 00000220 2f 2f 20 53 2e 78 78 78 20 61 72 65 20 27 73 74 |// S.xxx are 'st| 00000230 61 74 65 73 27 20 6f 66 20 74 68 65 20 63 61 6c |ates' of the cal| 00000240 63 75 6c 61 74 6f 72 20 2d 20 69 74 20 65 78 70 |culator - it exp| 00000250 65 63 74 73 20 69 6e 70 75 74 20 69 6e 20 66 6f |ects input in fo| 00000260 75 72 0d 0a 20 20 20 2f 2f 20 73 74 61 67 65 73 |ur.. // stages| 00000270 20 69 2e 65 2e 20 6e 75 6d 62 65 72 2c 20 6f 70 | i.e. number, op| 00000280 65 72 61 74 6f 72 2c 20 6e 75 6d 62 65 72 2c 20 |erator, number, | 00000290 65 71 75 61 6c 73 20 28 65 2e 67 2e 20 31 32 33 |equals (e.g. 123| 000002a0 20 2b 20 34 35 36 20 3d 29 0d 0a 0d 0a 20 20 20 | + 456 =).... | 000002b0 53 2e 4e 55 4d 31 20 3d 20 30 20 20 20 20 20 2f |S.NUM1 = 0 /| 000002c0 2f 20 66 69 72 73 74 20 6e 75 6d 62 65 72 20 65 |/ first number e| 000002d0 78 70 65 63 74 65 64 0d 0a 20 20 20 53 2e 4f 50 |xpected.. S.OP| 000002e0 20 3d 20 31 20 20 20 20 20 20 20 2f 2f 20 6f 70 | = 1 // op| 000002f0 65 72 61 74 6f 72 20 65 78 70 65 63 74 65 64 0d |erator expected.| 00000300 0a 20 20 20 53 2e 4e 55 4d 32 20 3d 20 32 20 20 |. S.NUM2 = 2 | 00000310 20 20 20 2f 2f 20 73 65 63 6f 6e 64 20 6e 75 6d | // second num| 00000320 62 65 72 20 65 78 70 65 63 74 65 64 0d 0a 20 20 |ber expected.. | 00000330 20 53 2e 45 51 55 41 4c 53 20 3d 20 33 20 20 20 | S.EQUALS = 3 | 00000340 2f 2f 20 65 71 75 61 6c 73 20 65 78 70 65 63 74 |// equals expect| 00000350 65 64 0d 0a 0d 0a 20 20 20 2f 2f 20 43 2e 78 78 |ed.... // C.xx| 00000360 78 20 61 72 65 20 63 68 61 72 61 63 74 65 72 73 |x are characters| 00000370 20 74 6f 20 73 65 74 20 74 65 78 74 20 63 6f 6c | to set text col| 00000380 6f 75 72 73 20 69 6e 20 6d 6f 64 65 20 37 0d 0a |ours in mode 7..| 00000390 0d 0a 20 20 20 43 2e 57 48 49 54 45 20 3d 20 31 |.. C.WHITE = 1| 000003a0 33 35 3b 20 43 2e 47 52 45 45 4e 20 3d 20 31 33 |35; C.GREEN = 13| 000003b0 30 3b 20 43 2e 4d 41 47 45 4e 54 41 20 3d 20 31 |0; C.MAGENTA = 1| 000003c0 33 33 0d 0a 20 20 20 43 2e 59 45 4c 4c 4f 57 20 |33.. C.YELLOW | 000003d0 3d 20 31 33 31 3b 20 43 2e 43 59 41 4e 20 3d 20 |= 131; C.CYAN = | 000003e0 31 33 34 0d 0a 0d 0a 20 20 20 4e 55 4d 57 49 44 |134.... NUMWID| 000003f0 54 48 20 3d 20 31 37 20 20 20 20 20 20 20 20 20 |TH = 17 | 00000400 20 20 2f 2f 20 77 69 64 74 68 20 6f 66 20 66 69 | // width of fi| 00000410 65 6c 64 20 74 6f 20 64 69 73 70 6c 61 79 20 6e |eld to display n| 00000420 75 6d 62 65 72 20 69 6e 0d 0a 20 20 20 46 49 52 |umber in.. FIR| 00000430 53 54 46 4e 20 3d 20 23 58 39 30 20 20 20 20 20 |STFN = #X90 | 00000440 20 20 20 20 20 2f 2f 20 76 61 6c 75 65 20 72 65 | // value re| 00000450 74 75 72 6e 65 64 20 62 79 20 66 75 6e 63 74 69 |turned by functi| 00000460 6f 6e 20 6b 65 79 20 30 0d 0a 20 20 20 55 47 20 |on key 0.. UG | 00000470 3d 20 46 49 52 53 54 46 52 45 45 47 4c 4f 42 41 |= FIRSTFREEGLOBA| 00000480 4c 20 20 20 20 2f 2f 20 74 6f 20 65 61 73 65 20 |L // to ease | 00000490 74 79 70 69 6e 67 0d 0a 20 20 20 20 20 20 20 20 |typing.. | 000004a0 20 24 29 0d 0a 0d 0a 47 4c 4f 42 41 4c 20 24 28 | $)....GLOBAL $(| 000004b0 0d 0a 20 20 20 2f 2f 20 44 61 74 61 20 69 74 65 |.. // Data ite| 000004c0 6d 73 0d 0a 0d 0a 20 20 20 56 31 3a 55 47 3b 20 |ms.... V1:UG; | 000004d0 56 32 3a 55 47 2b 31 20 2f 2f 20 74 77 6f 20 6e |V2:UG+1 // two n| 000004e0 75 6d 62 65 72 73 20 62 65 69 6e 67 20 70 72 6f |umbers being pro| 000004f0 63 65 73 73 65 64 0d 0a 20 20 20 4f 50 3a 55 47 |cessed.. OP:UG| 00000500 2b 32 20 20 20 20 20 20 20 20 2f 2f 20 63 75 72 |+2 // cur| 00000510 72 65 6e 74 20 6f 70 65 72 61 74 6f 72 20 28 61 |rent operator (a| 00000520 73 20 41 53 43 49 49 20 27 2b 27 2c 20 27 2d 27 |s ASCII '+', '-'| 00000530 2c 20 27 2a 27 20 6f 72 20 27 2f 27 29 0d 0a 20 |, '*' or '/').. | 00000540 20 20 43 48 3a 55 47 2b 33 20 20 20 20 20 20 20 | CH:UG+3 | 00000550 20 2f 2f 20 63 75 72 72 65 6e 74 20 6b 65 79 73 | // current keys| 00000560 74 72 6f 6b 65 0d 0a 20 20 20 43 48 54 59 50 45 |troke.. CHTYPE| 00000570 3a 55 47 2b 34 20 20 20 20 2f 2f 20 74 79 70 65 |:UG+4 // type| 00000580 20 6f 66 20 63 75 72 72 65 6e 74 20 6b 65 79 73 | of current keys| 00000590 74 72 6f 6b 65 20 28 54 2e 78 78 78 20 6d 61 6e |troke (T.xxx man| 000005a0 69 66 65 73 74 73 29 0d 0a 20 20 20 53 54 41 54 |ifests).. STAT| 000005b0 45 3a 55 47 2b 35 20 20 20 20 20 2f 2f 20 63 75 |E:UG+5 // cu| 000005c0 72 72 65 6e 74 20 73 74 61 74 65 20 28 53 2e 78 |rrent state (S.x| 000005d0 78 78 20 6d 61 6e 69 66 65 73 74 73 29 0d 0a 20 |xx manifests).. | 000005e0 20 20 4d 41 58 46 4e 3a 55 47 2b 36 20 20 20 20 | MAXFN:UG+6 | 000005f0 20 2f 2f 20 76 61 6c 75 65 20 72 65 74 75 72 6e | // value return| 00000600 65 64 20 62 79 20 68 69 67 68 65 73 74 20 66 75 |ed by highest fu| 00000610 6e 63 74 69 6f 6e 20 6b 65 79 20 69 6e 20 75 73 |nction key in us| 00000620 65 0d 0a 20 20 20 52 45 53 2e 4c 45 56 3a 55 47 |e.. RES.LEV:UG| 00000630 2b 37 20 20 20 2f 2f 20 72 65 73 74 61 72 74 20 |+7 // restart | 00000640 70 6f 69 6e 74 20 2d 20 4c 4f 4e 47 4a 55 4d 50 |point - LONGJUMP| 00000650 20 68 65 72 65 20 61 66 74 65 72 20 63 6c 65 61 | here after clea| 00000660 72 20 65 74 63 2e 0d 0a 20 20 20 52 45 53 2e 4c |r etc... RES.L| 00000670 41 42 3a 55 47 2b 38 0d 0a 20 20 20 46 4e 53 45 |AB:UG+8.. FNSE| 00000680 54 3a 55 47 2b 39 20 20 20 20 20 2f 2f 20 64 69 |T:UG+9 // di| 00000690 73 74 69 6e 67 75 69 73 68 65 73 20 61 6c 74 65 |stinguishes alte| 000006a0 72 6e 61 74 69 76 65 20 75 73 65 73 20 6f 66 20 |rnative uses of | 000006b0 66 75 6e 63 74 69 6f 6e 20 6b 65 79 73 0d 0a 20 |function keys.. | 000006c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000006d0 20 2f 2f 20 28 69 6e 69 74 69 61 6c 6c 79 20 30 | // (initially 0| 000006e0 29 0d 0a 20 20 20 46 55 4e 43 4f 50 3a 55 47 2b |).. FUNCOP:UG+| 000006f0 31 30 20 20 20 2f 2f 20 61 64 64 72 65 73 73 20 |10 // address | 00000700 6f 66 20 70 72 6f 63 65 64 75 72 65 20 74 6f 20 |of procedure to | 00000710 70 65 72 66 6f 72 6d 20 66 75 6e 63 74 69 6f 6e |perform function| 00000720 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |.. | 00000730 20 20 20 20 2f 2f 20 63 6f 72 72 65 73 70 6f 6e | // correspon| 00000740 64 69 6e 67 20 74 6f 20 6c 61 73 74 20 66 75 6e |ding to last fun| 00000750 63 74 69 6f 6e 20 6b 65 79 20 70 72 65 73 73 65 |ction key presse| 00000760 64 0d 0a 20 20 20 46 4e 53 45 54 4d 41 58 3a 55 |d.. FNSETMAX:U| 00000770 47 2b 31 31 20 2f 2f 20 6c 61 72 67 65 73 74 20 |G+11 // largest | 00000780 70 65 72 6d 69 73 73 69 62 6c 65 20 76 61 6c 75 |permissible valu| 00000790 65 20 6f 66 20 46 4e 53 45 54 0d 0a 0d 0a 20 20 |e of FNSET.... | 000007a0 20 2f 2f 20 43 6f 6d 6d 6f 6e 20 70 72 6f 63 65 | // Common proce| 000007b0 64 75 72 65 73 0d 0a 0d 0a 20 20 20 43 55 52 53 |dures.... CURS| 000007c0 4f 52 3a 55 47 2b 32 30 20 20 20 20 20 20 2f 2f |OR:UG+20 //| 000007d0 20 70 6f 73 69 74 69 6f 6e 20 63 75 72 73 6f 72 | position cursor| 000007e0 0d 0a 20 20 20 52 45 53 45 54 3a 55 47 2b 32 31 |.. RESET:UG+21| 000007f0 20 20 20 20 20 20 20 2f 2f 20 72 65 73 65 74 20 | // reset | 00000800 61 66 74 65 72 20 63 6c 65 61 72 20 65 74 63 2e |after clear etc.| 00000810 0d 0a 20 20 20 50 45 52 46 4f 52 4d 2e 4f 50 3a |.. PERFORM.OP:| 00000820 55 47 2b 32 32 20 20 2f 2f 20 64 6f 20 2b 2c 20 |UG+22 // do +, | 00000830 2d 2c 20 2a 20 6f 72 20 2f 0d 0a 20 20 20 4e 55 |-, * or /.. NU| 00000840 4d 50 4f 53 3a 55 47 2b 32 33 20 20 20 20 20 20 |MPOS:UG+23 | 00000850 2f 2f 20 70 6f 73 69 74 69 6f 6e 20 63 75 72 73 |// position curs| 00000860 6f 72 20 66 6f 72 20 64 69 73 70 6c 61 79 69 6e |or for displayin| 00000870 67 20 61 20 6e 75 6d 62 65 72 0d 0a 20 20 20 47 |g a number.. G| 00000880 45 54 4e 55 4d 3a 55 47 2b 32 34 20 20 20 20 20 |ETNUM:UG+24 | 00000890 20 2f 2f 20 72 65 61 64 20 69 6e 20 61 20 6e 75 | // read in a nu| 000008a0 6d 62 65 72 0d 0a 20 20 20 47 45 54 43 48 3a 55 |mber.. GETCH:U| 000008b0 47 2b 32 35 20 20 20 20 20 20 20 2f 2f 20 67 65 |G+25 // ge| 000008c0 74 20 6e 65 78 74 20 76 61 6c 69 64 20 6b 65 79 |t next valid key| 000008d0 73 74 72 6f 6b 65 0d 0a 20 20 20 43 4f 50 59 4c |stroke.. COPYL| 000008e0 31 4c 32 3a 55 47 2b 32 36 20 20 20 20 2f 2f 20 |1L2:UG+26 // | 000008f0 64 69 73 70 6c 61 79 20 73 65 63 6f 6e 64 20 6c |display second l| 00000900 69 6e 65 20 6f 66 20 64 6f 75 62 6c 65 2d 68 65 |ine of double-he| 00000910 69 67 68 74 20 6e 75 6d 62 65 72 0d 0a 20 20 20 |ight number.. | 00000920 46 4c 41 53 48 4e 55 4d 3a 55 47 2b 32 37 20 20 |FLASHNUM:UG+27 | 00000930 20 20 2f 2f 20 66 6c 61 73 68 20 64 69 73 70 6c | // flash displ| 00000940 61 79 65 64 20 6e 75 6d 62 65 72 0d 0a 20 20 20 |ayed number.. | 00000950 57 52 49 54 45 4e 55 4d 3a 55 47 2b 32 38 20 20 |WRITENUM:UG+28 | 00000960 20 20 2f 2f 20 64 69 73 70 6c 61 79 20 64 6f 75 | // display dou| 00000970 62 6c 65 2d 68 65 69 67 68 74 20 6e 75 6d 62 65 |ble-height numbe| 00000980 72 0d 0a 0d 0a 20 20 20 2f 2f 20 50 72 6f 63 65 |r.... // Proce| 00000990 64 75 72 65 73 20 77 68 69 63 68 20 63 68 61 6e |dures which chan| 000009a0 67 65 20 66 6f 72 20 66 6c 6f 61 74 69 6e 67 2f |ge for floating/| 000009b0 66 69 78 65 64 0d 0a 0d 0a 20 20 20 44 49 53 50 |fixed.... DISP| 000009c0 4e 55 4d 3a 55 47 2b 33 30 20 20 20 20 20 2f 2f |NUM:UG+30 //| 000009d0 20 64 69 73 70 6c 61 79 20 61 20 6e 75 6d 62 65 | display a numbe| 000009e0 72 0d 0a 20 20 20 44 49 53 50 48 44 4e 47 3a 55 |r.. DISPHDNG:U| 000009f0 47 2b 33 31 20 20 20 20 2f 2f 20 64 69 73 70 6c |G+31 // displ| 00000a00 61 79 20 68 65 61 64 69 6e 67 0d 0a 0d 0a 20 20 |ay heading.... | 00000a10 20 2f 2f 20 50 72 6f 63 65 64 75 72 65 73 20 74 | // Procedures t| 00000a20 6f 20 68 61 6e 64 6c 65 20 75 73 65 20 6f 66 20 |o handle use of | 00000a30 66 75 6e 63 74 69 6f 6e 20 6b 65 79 73 0d 0a 0d |function keys...| 00000a40 0a 20 20 20 44 49 53 50 46 4e 53 3a 55 47 2b 34 |. DISPFNS:UG+4| 00000a50 30 20 20 20 20 20 2f 2f 20 64 69 73 70 6c 61 79 |0 // display| 00000a60 20 75 73 65 20 6f 66 20 66 75 6e 63 74 69 6f 6e | use of function| 00000a70 20 6b 65 79 73 0d 0a 20 20 20 49 4e 54 45 52 50 | keys.. INTERP| 00000a80 46 4e 3a 55 47 2b 34 31 20 20 20 20 2f 2f 20 69 |FN:UG+41 // i| 00000a90 6e 74 65 72 70 72 65 74 20 66 75 6e 63 74 69 6f |nterpret functio| 00000aa0 6e 20 6b 65 79 73 0d 0a 20 20 20 20 20 20 20 24 |n keys.. $| 00000ab0 29 0d 0a 0d 0a |)....| 00000ab5