| 1 |
/***************************************************************************** |
| 2 |
* Free42 -- an HP-42S calculator simulator |
| 3 |
* Copyright (C) 2004-2026 Thomas Okken |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License, version 2, |
| 7 |
* as published by the Free Software Foundation. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program; if not, see http://www.gnu.org/licenses/. |
| 16 |
*****************************************************************************/ |
| 17 |
|
| 18 |
#ifndef CORE_STO_RCL_H |
| 19 |
#define CORE_STO_RCL_H 1 |
| 20 |
|
| 21 |
|
| 22 |
#include "free42.h" |
| 23 |
#include "core_phloat.h" |
| 24 |
#include "core_globals.h" |
| 25 |
|
| 26 |
|
| 27 |
/************************************************/ |
| 28 |
/* Signatures for functions mapped by map_unary */ |
| 29 |
/************************************************/ |
| 30 |
|
| 31 |
typedef int (*mappable_r)(phloat x, phloat *z); |
| 32 |
typedef int (*mappable_c)(phloat xre, phloat xim, phloat *zre, phloat *zim); |
| 33 |
|
| 34 |
|
| 35 |
/*************************************************/ |
| 36 |
/* Signatures for functions mapped by map_binary */ |
| 37 |
/*************************************************/ |
| 38 |
|
| 39 |
typedef int (*mappable_rr)(phloat x, phloat y, phloat *z); |
| 40 |
typedef int (*mappable_rc)(phloat x, phloat yre, phloat yim, |
| 41 |
phloat *zre, phloat *zim); |
| 42 |
typedef int (*mappable_cr)(phloat xre, phloat xim, phloat y, |
| 43 |
phloat *zre, phloat *zim); |
| 44 |
typedef int (*mappable_cc)(phloat xre, phloat xim, phloat yre, phloat yim, |
| 45 |
phloat *zre, phloat *zim); |
| 46 |
|
| 47 |
|
| 48 |
/****************************************************************/ |
| 49 |
/* Generic arithmetic operators, for use in the implementations */ |
| 50 |
/* of +, -, *, /, STO+, STO-, etc... */ |
| 51 |
/****************************************************************/ |
| 52 |
|
| 53 |
int assert_numeric(const vartype *v); |
| 54 |
int generic_div(const vartype *x, const vartype *y, |
| 55 |
int (*completion)(int, vartype *)); |
| 56 |
int generic_mul(const vartype *x, const vartype *y, |
| 57 |
int (*completion)(int, vartype *)); |
| 58 |
int generic_sub(const vartype *x, const vartype *y, vartype **res); |
| 59 |
int generic_add(const vartype *x, const vartype *y, vartype **res); |
| 60 |
int generic_rcl(arg_struct *arg, vartype **dst); |
| 61 |
int generic_sto(arg_struct *arg, char operation); |
| 62 |
|
| 63 |
|
| 64 |
/**********************************************/ |
| 65 |
/* Mappers to apply unary or binary operators */ |
| 66 |
/* to arbitrary parameter types */ |
| 67 |
/**********************************************/ |
| 68 |
|
| 69 |
int map_unary(const vartype *src, vartype **dst, mappable_r, mappable_c mc); |
| 70 |
int map_binary(const vartype *src1, const vartype *src2, vartype **dst, |
| 71 |
mappable_rr mrr, mappable_rc mrc, mappable_cr mcr, mappable_cc mcc); |
| 72 |
|
| 73 |
#endif |