2 * register - set or print a custom register value
4 * Copyright (C) 2007 Landon Curt Noll
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * @(#) $Revision: 30.1 $
21 * @(#) $Id: register.cal,v 30.1 2007/07/05 19:35:54 chongo Exp $
22 * @(#) $Source: /usr/local/src/bin/calc/custom/RCS/register.cal,v $
24 * Under source code control: 2007/07/05 11:11:11
25 * File existed as early as: 2007
27 * chongo <was here> /\oo/\ http://www.isthe.com/chongo/
28 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
32 * This file is part of the custom sample calc files.
34 * NOTE: You must use a calc that was compiled with ALLOW_CUSTOM= -DCUSTOM
35 * and run with a -C arg.
37 if (config("compile_custom") == 0) {
38 quit "calc compiled without -DCUSTOM";
39 } else if (config("allow_custom") == 0) {
40 quit "calc was run without the -D command line option";
46 local reg_max; /* number of registers */
52 return newerror("register only works on numeric values");
56 * determine register count
58 reg_max = custom("sysinfo", "REGNUM_MAX");
61 * determine the HALF length of a numeric value
64 return newerror("register number must be >= 0");
65 } else if (num > reg_max) {
66 return newerror("register number must be < REGNUM_MAX");
68 return custom("register", num);