Go to the source code of this file.
Data Structures | |
struct | _sat_cpu |
The emulated Saturn CPU as a memory area in ARM domain. More... | |
struct | sat_list_struct |
An RPL List Object. More... | |
struct | _sat_stack_element |
A descriptor for an RPL stack element in Saturn notation. More... | |
struct | _sat_stack_data |
Data structure, that models a single stack element. More... | |
Defines | |
#define | SWAP4(x) (((x) << 4) | ((x) >> 4)) |
Swap low and high nibbles in a byte. | |
#define | ALIGN(x, a) (((unsigned)(x)+(a)-1) & (~((unsigned)(a)-1))) |
Align an address 'x' to a 'a' bit boundary. | |
#define | BOOL int |
Standard definition for BOOLEAN type. | |
#define | FALSE 0 |
The BOOLEAN constant FALSE . | |
#define | TRUE !FALSE |
The BOOLEAN constant TRUE . | |
#define | SAT_STACK_BIAS 1 |
How many stack levels are used by the launcher. | |
#define | SAT_DOINT 0x2614 |
Saturn data prologue: ZINT (Typical Exact Integer). | |
#define | SAT_DOCSTR 0x2a2c |
Saturn data prologue: STRING. | |
#define | SAT_DOREAL 0x2933 |
Saturn data prologue: REAL. | |
#define | SAT_DOEREL 0x2955 |
Saturn data prologue: EXTENDED REAL. | |
#define | SAT_DOHXS 0x2a4e |
Saturn data prologue: UINT (HEX STRING). | |
#define | SAT_DOBINT 0x2911 |
Saturn data prologue: BINT. | |
#define | SAT_DOCMP 0x2977 |
Saturn data prologue: COMPLEX. | |
#define | SAT_DOECMP 0x299D |
Saturn data prologue: EXTENDED COMPLEX. | |
#define | SAT_DOCHAR 0x29BF |
Saturn data prologue: CHAR. | |
#define | SAT_DOARRY 0x29e8 |
Saturn data prologue: ARRAY. | |
#define | SAT_DOLNKARRY 0x29e8 |
Saturn data prologue: LINKED ARRAY. | |
#define | SAT_DOIDNT 0x2e48 |
Saturn data prologue: ID (variable name). | |
#define | SAT_DOLAM 0x2e6D |
Saturn data prologue: LAM ID (variable name). | |
#define | SAT_DOROMP 0x2e92 |
Saturn data prologue: XLIB (ROM Pointer). | |
#define | SAT_DORRP 0x2a96 |
Saturn data prologue: RRP (Directory objects). | |
#define | SAT_DOSYMB 0x2AB8 |
Saturn data prologue: SYMBOLIC. | |
#define | SAT_DOLIST 0x2A74 |
Saturn data prologue: LIST. | |
#define | SAT_DOCOL 0x2D9D |
Saturn data prologue: SECONDARY (Programs). | |
#define | SAT_DOGROB 0x2B1E |
Saturn data prologue: GROB. | |
#define | SAT_SEMI 0x312b |
Saturn composite object terminator: SEMI. | |
#define | SAT_DOBAK 0x2B62 |
Saturn data prologue: BACKUP. | |
#define | SAT_DOCODE 0x2DCC |
Saturn data prologue: CODE. | |
#define | SAT_DOEXT 0x2ADA |
Saturn data prologue: UNIT OBJECT. | |
#define | SAT_DOFLASHP 0x26AC |
Saturn data prologue: FLASH PTR. | |
#define | SAT_DOLIB 0x2B40 |
Saturn data prologue: LIBRARY. | |
#define | SAT_DOMATRIX 0x2686 |
Saturn data prologue: SYMBOLIC ARRAY. | |
#define | SAT_DOTAG 0x2AFC |
Saturn data prologue: TAGGED OBJECT. | |
#define | SAT_DOAPLET 0x26D5 |
Saturn data prologue: DOAPLET. | |
#define | SAT_DOEXT0 0x2B88 |
Saturn data prologue: LIBDATA. | |
#define | SAT_DOACPTR 0x2BAA |
Saturn data prologue: ACPTR (internal object). | |
#define | SAT_DOEXT1 SAT_DOACPTR |
#define | SAT_DOEXT2 0x2BCC |
Saturn data prologue: EXT2. | |
#define | SAT_DOEXT3 0x2BEE |
Saturn data prologue: EXT3. | |
#define | SAT_DOEXT4 0x2C10 |
Saturn data prologue: EXT4. | |
#define | SAT_DOLNGREAL 0x263A |
Saturn data prologue: LNGREAL. | |
#define | SAT_DOLNGCOMP 0x2660 |
Saturn data prologue: LNGCOMP. | |
#define | REAL_0 0x2f937 |
#define | REAL_1 0x2f94c |
#define | REAL_2 0x2f961 |
#define | REAL_3 0x2f976 |
#define | REAL_4 0x2f98b |
#define | REAL_5 0x2f9a0 |
#define | REAL_6 0x2f9b5 |
#define | REAL_7 0x2f9ca |
#define | REAL_8 0x2f9df |
#define | REAL_9 0x2f9f4 |
#define | SAT_PROLOGUE_STRING SAT_DOCSTR |
#define | SAT_PROLOGUE_UINT SAT_DOHXS |
#define | SAT_DATA_TYPE_INT 28 |
HP calculator Data Type: INT. | |
#define | SAT_DATA_TYPE_LONG 10 |
HP calculator Data Type: LONG. | |
#define | SAT_DATA_TYPE_STRING 2 |
HP calculator Data Type: STRING. | |
#define | SAT_DATA_TYPE_REAL 0 |
HP calculator Data Type: REAL. | |
#define | SAT_DATA_TYPE_UNSUPPORTED -999 |
Marker for unsupported Data Type. | |
#define | sat_moveup(a, b, c) sat_memmove(a,b,c) |
C implementation of Saturn MOVEUP. | |
#define | sat_movedown(a, b, c) sat_memmove(a,b,c) |
C implementation of Saturn MOVEDOWN. | |
#define | sat_peek_sat_addr(sat_addr) sat_peek((sat_addr),5) |
Convenience macro for peeking Saturn addresses (5 nibbles). | |
#define | sat_peek_sat_byte(sat_addr) ((unsigned char) sat_peek((sat_addr),2)) |
Convenience macro for peeking one byte (2 nibbles). | |
#define | sat_poke_sat_byte(sat_addr, val) sat_poke((sat_addr), (unsigned) (val), 2) |
Convenience macro for poking a single byte (2 nibbles) to Saturn memory. | |
#define | sat_poke_sat_bytes(sat_addr, bytes, n) sat_poke_nibbles((sat_addr), (bytes), (2*(n))) |
Convenience macro for poking many bytes (2*n nibbles) to Saturn memory. | |
#define | sat_poke_sat_addr(sat_addr, val) sat_poke((sat_addr), (val), 5) |
Convenience macro for poking a Saturn address (5 nibbles) to Saturn memory. | |
#define | SAT_INTRPPTR 0x8076B |
Saturn CPU storage area: D0. | |
#define | SAT_DSKTOP 0x806F8 |
Saturn CPU storage area: D1. | |
#define | SAT_RSKTOP 0x806F3 |
Saturn CPU storage area: B. | |
#define | SAT_AVMEM 0x80E9B |
Saturn CPU storage area: D. | |
#define | SAT_TEMPTOP 0x806EE |
Saturn emu storage area: TEMPTOP. | |
#define | SAT_EDITLINE 0x806FD |
Saturn emu storage area: EDITLINE. | |
#define | SAT_ERROR 0x80EA5 |
Saturn error message number address: ERROR. | |
#define | SAT_TRUE 0x3a81 |
SysRPL flags: TRUE. | |
#define | SAT_FALSE 0x3ac0 |
SysRPL flags: FALSE. | |
#define | sat_stack_pop_string(s) sat_pop_str((s)) |
Alias name mapping for maintaining API consistency. | |
#define | sat_stack_pop_string_alloc sat_pop_str_alloc |
Alias name mapping for maintaining API consistency. | |
#define | sat_stack_pick_string(l, b) sat_pick_str((l),(b)) |
Alias name mapping for maintaining API consistency. | |
#define | sat_stack_pick_string_alloc(l) sat_pick_str_alloc((l)) |
Alias name mapping for maintaining API consistency. | |
#define | sat_stack_push_bool sat_pushtruefalse |
An alias for sat_pushtruefalse. | |
Typedefs | |
typedef unsigned long long | ULONGLONG |
typedef long long | LONGLONG |
typedef _sat_cpu | SAT_CPU |
The emulated Saturn CPU as a memory area in ARM domain. | |
typedef _sat_cpu * | SAT_PCPU |
The emulated Saturn CPU as a memory area in ARM domain. | |
typedef sat_list_struct * | SAT_LIST |
An RPL List Object. | |
typedef _sat_stack_element | SAT_STACK_ELEMENT |
A descriptor for an RPL stack element in Saturn notation. | |
typedef _sat_stack_element * | SAT_PSTACK_ELEMENT |
A descriptor for an RPL stack element in Saturn notation. | |
typedef _sat_stack_data | SAT_STACK_DATA |
Data structure, that models a single stack element. | |
typedef _sat_stack_data * | SAT_PSTACK_DATA |
Data structure, that models a single stack element. | |
Functions | |
void | sat_poke (int sat_addr, unsigned val, int nibbles) |
Poke up to 8 nibbles of data to Saturn domain. | |
void | sat_poke_nibbles (unsigned sat_addr, const char *data, int nibbles) |
Poke many nibbles to Saturn domain. | |
unsigned | sat_peek (int sat_addr, int nibbles) |
Peek up to 8 nibbles of data from Saturn domain. | |
void | sat_memmove (int satsrc, int satdest, int nibbles) |
C implementation of Saturn MOVEUP/MOVEDOWN. | |
int | sat_getfreetempob () |
Obtain maximum object size that can be created with sat_createtemp(). | |
int | sat_createtemp (int objsize) |
Create a temporary object in the Saturn Heap. | |
int | sat_shrinklastob (int objaddr, int newsize) |
Change the allocated size of the last object in tempob. | |
BOOL | sat_push_string (int type_prolog, int size_nibbles, const char *data) |
Push a string on the RPL stack. | |
unsigned int | sat_map_s2a (unsigned int sat_addr) |
Translate a Saturn memory address to ARM domain. | |
unsigned int | sat_map_a2s (unsigned int arm_addr) |
Translate an ARM memory address to Saturn domain. | |
void * | sat_peek_sat_bytes (void *target, unsigned sat_addr, int nbytes) |
Peek many nibbles from Saturn domain into ARM memory. | |
unsigned char * | sat_concatnib (unsigned char *dest, unsigned int destLen, unsigned char *source, unsigned int sourceLen) |
Combines 2 strings of binary Saturn data. | |
unsigned | sat_stack_init () |
DEPRECATED: Initialize RPL stack access This function MUST be called before any other high level stack API function. The returned value is NOT intended for any usage other then storing it! | |
void | sat_stack_exit (unsigned rpl_stack_bias) |
DEPRECATED: Finalize RPL stack access This function MUST be called before exiting the program Failing this may cause a calculator crash (TTRM with memory clear!) | |
int | sat_stack_depth () |
Get number of elements on the RPL stack (DEPTH). | |
int | sat_get_stack_element (int index, SAT_STACK_ELEMENT *element) |
Get a stack element (GET). | |
int | sat_stack_drop () |
Pop one element off the stack (DROP). | |
int | sat_stack_dropn (int n) |
Pop many elements off the stack (DROPN). | |
int | sat_stack_swap () |
Swap elements on level 1 and 2 (SWAP). | |
int | sat_stack_nip () |
Swap then drop (NIP). | |
int | sat_stack_push_string (const char *str) |
Push a string onto the RPL stack. | |
char * | sat_pop_str (char *buf) |
Pop a string from the RPL stack. | |
char * | sat_pick_str (int level, char *buf) |
Pick a string at level 'level' from the RPL stack. | |
char * | sat_pick_str_alloc (int level) |
Pick a string at level 'level' from the RPL stack with automatically allocated memory. | |
char * | sat_pop_str_alloc () |
Pop a string from the RPL stack with automatically allocated memory. | |
int | _sat_stack_push_int (int z, int radix, int binary) |
Push a string representation of an integer onto the stack The integer is converted to a string and then pushed via sat_stack_push_string(). | |
int | sat_stack_push_int (int z) |
Push a string representation (base=10) of an integer onto the stack The integer is converted to a string and then pushed via sat_stack_push_string(). | |
int | sat_stack_push_double (double d) |
Push a string representation of a double onto the stack The double value is converted to a string and then pushed via sat_stack_push_string(). | |
BOOL | sat_push_zint_llong (LONGLONG num) |
Push a LONGLONG onto the RPL stack as a ZINT Accepts a number of Type 'LONGLONG', and pushes it as an Exact Integer (ZINT). | |
BOOL | sat_push_zint_array (unsigned int digits, unsigned int negative, unsigned char *source) |
Helper function for pushing ZINTs onto the Stack Accepts an array of binary digits, and pushes then onto the stack egc {1,2,3,4,5,6,7,8,9} for 123456789. It also accepts a negative flag (if TRUE, number is treated as negative) and number of digits. | |
LONGLONG | sat_pop_zint_llong () |
Pop a ZINT off the RPL stack into a LONGLONG Pop a ZINT (exact integer) off the RPL stack into a LONGLONG (64 bit signed integer). | |
SAT_LIST | sat_list_create (unsigned int maxSize) |
Creates an RPL List Object Creates a List object of type SAT_LIST, used for holding multiple Saturn objects. | |
void | sat_list_destroy (SAT_LIST list) |
destroys an RPL List Object Frees the memory takes by a SAT_LIST | |
BOOL | sat_push_list (SAT_LIST list) |
Pushes an RPL List Object (of type SAT_LIST) onto the RPL Stack. | |
void | sat_list_add_real (SAT_LIST list, double num) |
adds a Double to an RPL List as a Real | |
void | sat_list_add_zint_array (SAT_LIST list, unsigned int digits, unsigned int negative, unsigned char *source) |
Helper function for adding ZINTs to an RP List Accepts an array of binary digits, and adds to a List eg {1,2,3,4,5,6,7,8,9} for 123456789. It also accepts a negative flag (if TRUE, number is treated as negative) and number of digits. | |
char * | sat_convert_zint_array (unsigned int digits, unsigned int negative, unsigned char *source, unsigned char *dest) |
Helper function for converting an array of digits to a Zint. Accepts an array of binary digits, and creates a binary Zint object eg {1,2,3,4,5,6,7,8,9} for 123456789. It also accepts a negative flag (if TRUE, number is treated as negative) and number of digits. | |
void | sat_list_add_zint (SAT_LIST list, LONGLONG num) |
adds a LONGLONG to an RPL List as a ZINT | |
unsigned char * | sat_convert_double_real (double number, unsigned char *realStr) |
Helper function that dakes in a double, and returns a binary Real Object. | |
int | sat_stack_levels_avail () |
Inquiry function that tells how many stack levels are available for pushing. | |
char * | _sat_decode_string (unsigned sat_addr) |
Decode a Saturn string object. | |
int | sat_decode_stack_element (SAT_STACK_DATA *data, SAT_STACK_ELEMENT *stack) |
Decode a stack element to a SAT_STACK_DATA type. | |
double | sat_pop_real () |
Pop a Real from the Stack, as a Double. The Real object is popped from the RPL stack, and transformed into a double. | |
void | sat_pushptr (int sataddr) |
Push a pointer in the stack. | |
BOOL | sat_push_bint (int bint) |
Push a bint on the RPL stack. | |
BOOL | sat_push_real (double number) |
Push a real on the RPL stack. | |
BOOL | sat_push_char (char byte) |
Push a char on the RPL stack. | |
BOOL | sat_push_comp (ULONGLONG real, ULONGLONG imag) |
Push a complex number on the RPL stack. | |
BOOL | sat_push_realarray (int rows, int columns, ULONGLONG *arry) |
Push a real array on the RPL stack. | |
LONGLONG | sat_BCD2LONGLONG (unsigned addr, int digits) |
double | sat_real2double (unsigned addr) |
ULONGLONG | sat_double2real (double n) |
int | sat_decode_real (unsigned address, double *val) |
int | sat_check_type (unsigned int level, unsigned int prologue) |
type checks a stack type | |
int | sat_stack_pop_stdargs (char ***argv) |
Build a standard C main (argc,**argv) tuple from the RPL stack. | |
int | _sat_stack_pop_stdargs (const char *arg0, char ***argv) |
Build a standard C main (argc,**argv) tuple from the RPL stack arg0 denotes an (optional) program name. If arg0 == NULL, _sat_stack_pop_stdargs() follows the semantics of it's default frontend sat_stack_pop_stdarg(). This function's purpose is mainly to ease the adaption of "standard" C programs, which provide a program name in argv[0]. | |
void | sat_errorsto (int errno) |
C version of the sysRPL ERRORSTO. Sets current error number. | |
void | sat_pushtruefalse (BOOL arg) |
Push saturn flag FALSE if arg is FALSE, TRUE otherwise. | |
Variables | |
SAT_CPU * | _saturn_cpu |
This library contains routines, that enable an applications programmer to access the RPL data on the calculator's stack and performing generalized data exchange with the Saturn emulator. The latter - "hacking" functions - consist mainly of a set of "peek" and "poke" functions for various data entities like "nibbles","bytes","words" and "strings" and address translation functions ARM <-> Saturn. There are just a few, easy to remember, high level API functions, which allow for complete control over the stack. The programmer does not need to know about Saturn internals.
#include <hpgcc49.h> int main() { // Initialize RPL stack unsigned rpl_stack_bias = sat_stack_init(); sat_stack_push_string("Hello, World!"); sat_stack_exit(rpl_stack_bias); //close it return 0; }
This program takes an integer (a'Zint' in HP terms) off the stack, doubles it, and pushes the result. This example has minimal error checking. Ideally you would use sat_stack_depth to detect if the stack is empty first, and check the type before usage.
#include <hpgcc49.h> int main() { // Initialize RPL stack unsigned rpl_stack_bias = sat_stack_init(); sat_push_zint_llong(sat_pop_zint_llong()*2); sat_stack_exit(rpl_stack_bias); //close it return 0; }
This program pops 2 ZINTs off the stack, adds them, and pushes the result. It is more complicated because it does error checking. IT checks that at least 2 items are on the stack, and that they are both of type ZINT
#include <hpgcc49.h> int main() { // Initialize stack access unsigned rpl_stack_bias = sat_stack_init(); if (sat_stack_depth()<2){ //check for enough items sat_stack_push_string("Error: Too Few Arguments!"); goto exit; } SAT_STACK_ELEMENT first; //examine the elements on stack SAT_STACK_ELEMENT second; //we don't pop them yet. sat_get_stack_element(1,&first); //look at first element from stack sat_get_stack_element(2,&second);//look at second element from stack //Now, check that both 'first' and 'second' are ZINTs //One way to do this is by checking the 'prologue'. It identifies //the type of the object. Use 'SAT_DOINT' to check for ZINTs if( (first.prologue!=SAT_DOINT)||(second.prologue!=SAT_DOINT)){ sat_stack_push_string("Error: Bad Argument Type!"); //bail out goto exit; } //now, pop the actual values off the stack LONGLONG first_val = sat_pop_zint_llong(); //first element value LONGLONG second_val = sat_pop_zint_llong(); //second element value sat_push_zint_llong(first_val+second_val); //push the addition exit: sat_stack_exit(rpl_stack_bias); return 0; }
The following program expects two exact integer values, converted to strings, on the stack. It performs some operations with them and pushes a result back. As a string as well. It treats the stack as parameters to a classic C program using 'argc' and 'argv' values.
#include <hpgcc49.h> // Template for RPL stack pop/push usage // Ingo Blank, 2004-11-24 int main() { // argument counter int argc = 0; // Initialize stack access unsigned rpl_stack_bias = sat_stack_init(); // Determine number of elements in the stack int level = sat_stack_depth(); // Dynamically dimension argument vector just as big as needed char *argv[level]; while (sat_stack_depth()) { SAT_STACK_ELEMENT e; SAT_STACK_DATA d; // Get element at level #1, i.e. stack-top sat_get_stack_element(1,&e); // decode it ... sat_decode_stack_element(&d,&e); // check validity and store in argument vector // Note that elements are stored in *reverse* order, since // the stack is a LIFO structure if (d.type == SAT_DATA_TYPE_STRING) // remove single quotes from algebraic objects (if present) argv[++argc,--level] = str_unquote(d.sval,'\''); else ; // unsupported data type, error message, bail out, ignore ... // pop one element off the stack and continue loop sat_stack_drop(); } // Now all RPL data is stored in the argv[] vector // your program here ... // Since the program does no screen output, skip init sequence //sys_intOff(); //sys_slowOn(); //clear_screen(); // Demo: take two arguments, convert them to integers and apply the 4 // basic arithmetic operations to them if (argc >= 2) { int x = atoi(argv[0]); int y = atoi(argv[1]); char buf[64]; // print the result formatted as an HP list object {,,,} sprintf(buf,"{%d %d %d %d}",x+y,x-y,x*y,y ? x/y : 0); // push the string back to the stack // the receiving (User)RPL pogram can convert it with STR-> to a // proper list object sat_stack_push_string(buf); } // Finalize stack access // NEVER forget that, or risk a device crash! sat_stack_exit(rpl_stack_bias); // Since the program does no screen output, skip exit sequence //sys_slowOff(); //sys_intOn(); return 0; }
Definition in file saturn.h.
#define ALIGN | ( | x, | |||
a | ) | (((unsigned)(x)+(a)-1) & (~((unsigned)(a)-1))) |
#define SAT_DATA_TYPE_LONG 10 |
#define SAT_DATA_TYPE_REAL 0 |
#define SAT_DATA_TYPE_STRING 2 |
#define SAT_DATA_TYPE_UNSUPPORTED -999 |
#define SAT_DOACPTR 0x2BAA |
#define SAT_DOCOL 0x2D9D |
#define SAT_DOECMP 0x299D |
#define SAT_DOEREL 0x2955 |
#define SAT_DOEXT 0x2ADA |
#define SAT_DOFLASHP 0x26AC |
#define SAT_DOHXS 0x2a4e |
#define SAT_DOIDNT 0x2e48 |
#define SAT_DOINT 0x2614 |
#define SAT_DOLAM 0x2e6D |
#define SAT_DOLNGCOMP 0x2660 |
#define SAT_DOLNGREAL 0x263A |
#define SAT_DOLNKARRY 0x29e8 |
#define SAT_DOMATRIX 0x2686 |
#define SAT_DOROMP 0x2e92 |
#define SAT_DORRP 0x2a96 |
#define SAT_DOTAG 0x2AFC |
#define SAT_EDITLINE 0x806FD |
#define SAT_ERROR 0x80EA5 |
#define sat_movedown | ( | a, | |||
b, | |||||
c | ) | sat_memmove(a,b,c) |
#define sat_moveup | ( | a, | |||
b, | |||||
c | ) | sat_memmove(a,b,c) |
#define sat_peek_sat_addr | ( | sat_addr | ) | sat_peek((sat_addr),5) |
#define sat_peek_sat_byte | ( | sat_addr | ) | ((unsigned char) sat_peek((sat_addr),2)) |
#define sat_poke_sat_addr | ( | sat_addr, | |||
val | ) | sat_poke((sat_addr), (val), 5) |
#define sat_poke_sat_byte | ( | sat_addr, | |||
val | ) | sat_poke((sat_addr), (unsigned) (val), 2) |
#define sat_poke_sat_bytes | ( | sat_addr, | |||
bytes, | |||||
n | ) | sat_poke_nibbles((sat_addr), (bytes), (2*(n))) |
#define SAT_SEMI 0x312b |
#define SAT_STACK_BIAS 1 |
#define sat_stack_pick_string | ( | l, | |||
b | ) | sat_pick_str((l),(b)) |
#define sat_stack_pick_string_alloc | ( | l | ) | sat_pick_str_alloc((l)) |
#define sat_stack_pop_string | ( | s | ) | sat_pop_str((s)) |
#define sat_stack_pop_string_alloc sat_pop_str_alloc |
#define sat_stack_push_bool sat_pushtruefalse |
#define SAT_TEMPTOP 0x806EE |
#define SWAP4 | ( | x | ) | (((x) << 4) | ((x) >> 4)) |
The emulated Saturn CPU as a memory area in ARM domain.
typedef struct _sat_cpu { unsigned int Read[257]; unsigned int Write[257]; unsigned char unknown_data[260]; unsigned int A; unsigned int Ah; unsigned int B; unsigned int Bh; unsigned int C; unsigned int Ch; unsigned int D; unsigned int Dh; unsigned int R0; unsigned int R0h; unsigned int R1; unsigned int R1h; unsigned int R2; unsigned int R2h; unsigned int R3; unsigned int R3h; unsigned int R4; unsigned int R4h; unsigned int D0; unsigned int D1; unsigned int P; unsigned int ST; unsigned int HST; unsigned int CARRY; unsigned int DECIMAL_MODE; } SAT_CPU, *SAT_PCPU;
typedef struct sat_list_struct * SAT_LIST |
An RPL List Object.
The emulated Saturn CPU as a memory area in ARM domain.
typedef struct _sat_cpu { unsigned int Read[257]; unsigned int Write[257]; unsigned char unknown_data[260]; unsigned int A; unsigned int Ah; unsigned int B; unsigned int Bh; unsigned int C; unsigned int Ch; unsigned int D; unsigned int Dh; unsigned int R0; unsigned int R0h; unsigned int R1; unsigned int R1h; unsigned int R2; unsigned int R2h; unsigned int R3; unsigned int R3h; unsigned int R4; unsigned int R4h; unsigned int D0; unsigned int D1; unsigned int P; unsigned int ST; unsigned int HST; unsigned int CARRY; unsigned int DECIMAL_MODE; } SAT_CPU, *SAT_PCPU;
typedef struct _sat_stack_data * SAT_PSTACK_DATA |
Data structure, that models a single stack element.
typedef struct _sat_stack_data { int type; union { int ival; double dval; LONGLONG lval; char *sval; }; } SAT_STACK_DATA, *SAT_PSTACK_DATA;
typedef struct _sat_stack_element * SAT_PSTACK_ELEMENT |
A descriptor for an RPL stack element in Saturn notation.
typedef struct _sat_stack_element { unsigned addr; unsigned prologue; } SAT_STACK_ELEMENT, *SAT_PSTACK_ELEMENT;
typedef struct _sat_stack_data SAT_STACK_DATA |
Data structure, that models a single stack element.
typedef struct _sat_stack_data { int type; union { int ival; double dval; LONGLONG lval; char *sval; }; } SAT_STACK_DATA, *SAT_PSTACK_DATA;
typedef struct _sat_stack_element SAT_STACK_ELEMENT |
A descriptor for an RPL stack element in Saturn notation.
typedef struct _sat_stack_element { unsigned addr; unsigned prologue; } SAT_STACK_ELEMENT, *SAT_PSTACK_ELEMENT;
char* _sat_decode_string | ( | unsigned | sat_addr | ) |
Decode a Saturn string object.
sat_addr | address of object in Saturn doamin |
int _sat_stack_pop_stdargs | ( | const char * | arg0, | |
char *** | argv | |||
) |
Build a standard C main (argc,**argv) tuple from the RPL stack arg0 denotes an (optional) program name. If arg0 == NULL, _sat_stack_pop_stdargs() follows the semantics of it's default frontend sat_stack_pop_stdarg(). This function's purpose is mainly to ease the adaption of "standard" C programs, which provide a program name in argv[0].
arg0 | Program name or NULL for none. | |
argv | Address of a char ** array, to hold the strings |
int _sat_stack_push_int | ( | int | z, | |
int | radix, | |||
int | binary | |||
) |
Push a string representation of an integer onto the stack The integer is converted to a string and then pushed via sat_stack_push_string().
z | an Integer | |
radix | The base | |
binary | 1=use "#zzz[o|d|h]" representation |
LONGLONG sat_BCD2LONGLONG | ( | unsigned | addr, | |
int | digits | |||
) |
int sat_check_type | ( | unsigned int | level, | |
unsigned int | prologue | |||
) |
type checks a stack type
level | The stack level to check | |
prologue | The type prologue being tested |
unsigned char* sat_concatnib | ( | unsigned char * | dest, | |
unsigned int | destLen, | |||
unsigned char * | source, | |||
unsigned int | sourceLen | |||
) |
Combines 2 strings of binary Saturn data.
This helper function acts like a strcat, but for binary Saturn data. Note: This function still needs more testing.
dest | Pointer to destination space | |
destLen | size of 'dest' in nibbles | |
source | Pointer to source data | |
destLen | size of 'source' in nibbles |
unsigned char* sat_convert_double_real | ( | double | number, | |
unsigned char * | realStr | |||
) |
Helper function that dakes in a double, and returns a binary Real Object.
number | the Number to transform into a Real | |
realStr | some storage space to put the binary representation (use at least 14 bytes) |
char* sat_convert_zint_array | ( | unsigned int | digits, | |
unsigned int | negative, | |||
unsigned char * | source, | |||
unsigned char * | dest | |||
) |
Helper function for converting an array of digits to a Zint. Accepts an array of binary digits, and creates a binary Zint object eg {1,2,3,4,5,6,7,8,9} for 123456789. It also accepts a negative flag (if TRUE, number is treated as negative) and number of digits.
digits | Number of digits in source | |
negative | Set to TRUE for negative numbers | |
source | the number as an array. Include binary values 0-9 ONLY. | |
dest | storage space for the encoded ZINT. |
int sat_createtemp | ( | int | objsize | ) |
Create a temporary object in the Saturn Heap.
C implementation of the HP49's ROM library routine
objsize | Size of object in nibbles |
NULL
on error int sat_decode_real | ( | unsigned | address, | |
double * | val | |||
) |
int sat_decode_stack_element | ( | SAT_STACK_DATA * | data, | |
SAT_STACK_ELEMENT * | stack | |||
) |
Decode a stack element to a SAT_STACK_DATA type.
data | Pointer to decoded structure | |
stack | Pointer to a raw stack element |
ULONGLONG sat_double2real | ( | double | n | ) |
void sat_errorsto | ( | int | errno | ) |
C version of the sysRPL ERRORSTO. Sets current error number.
errno | Calculator error message number. |
int sat_get_stack_element | ( | int | index, | |
SAT_STACK_ELEMENT * | element | |||
) |
Get a stack element (GET).
index | Stack Index [1..DEPTH] | |
element | Pointer to a SAT_STACK_ELEMENT structure |
int sat_getfreetempob | ( | ) |
Obtain maximum object size that can be created with sat_createtemp().
void sat_list_add_real | ( | SAT_LIST | list, | |
double | num | |||
) |
adds a Double to an RPL List as a Real
list | the List object | |
num | a number to add as a Real |
adds a LONGLONG to an RPL List as a ZINT
list | the List object | |
num | a 64 bit number to add as a ZINT |
void sat_list_add_zint_array | ( | SAT_LIST | list, | |
unsigned int | digits, | |||
unsigned int | negative, | |||
unsigned char * | source | |||
) |
Helper function for adding ZINTs to an RP List Accepts an array of binary digits, and adds to a List eg {1,2,3,4,5,6,7,8,9} for 123456789. It also accepts a negative flag (if TRUE, number is treated as negative) and number of digits.
list | the RPL List | |
digits | Number of digits in source | |
negative | Set to TRUE for negative numbers | |
source | the number as an array. Include binary values 0-9 ONLY. |
SAT_LIST sat_list_create | ( | unsigned int | maxSize | ) |
Creates an RPL List Object Creates a List object of type SAT_LIST, used for holding multiple Saturn objects.
maxSize | the size allocates for the List object, in Bytes |
void sat_list_destroy | ( | SAT_LIST | list | ) |
destroys an RPL List Object Frees the memory takes by a SAT_LIST
list | the list to free |
unsigned int sat_map_a2s | ( | unsigned int | arm_addr | ) |
Translate an ARM memory address to Saturn domain.
arm_addr | Memory address in ARM domain |
unsigned int sat_map_s2a | ( | unsigned int | sat_addr | ) |
Translate a Saturn memory address to ARM domain.
sat_addr | Memory address in Saturn domain |
void sat_memmove | ( | int | satsrc, | |
int | satdest, | |||
int | nibbles | |||
) |
C implementation of Saturn MOVEUP/MOVEDOWN.
This function moves a number of nibbles in Saturn domain. Automatically chooses direction to avoid overwriting.
satsrc | The source address in Saturn domain | |
satdest | The destination address in Saturn domain | |
nibbles | Number of nibbles to move |
unsigned sat_peek | ( | int | sat_addr, | |
int | nibbles | |||
) |
Peek up to 8 nibbles of data from Saturn domain.
This function reads up to 32 bit data in 4 bit chunks (nibbles) from Saturn memory.
sat_addr | The address in Saturn domain | |
nibbles | Number of nibbles to poke |
void* sat_peek_sat_bytes | ( | void * | target, | |
unsigned | sat_addr, | |||
int | nbytes | |||
) |
Peek many nibbles from Saturn domain into ARM memory.
This function copies 2*strlen(data) nibbles from Saturn to ARM memory.
target | Pointer to (allocated) memory in ARM domain | |
sat_addr | Source address in Saturn domain | |
nbytes | Number of bytes to copy |
char* sat_pick_str | ( | int | level, | |
char * | buf | |||
) |
Pick a string at level 'level' from the RPL stack.
level | Stack level to pick from | |
buf | Pointer to (big enough!) string buffer |
char* sat_pick_str_alloc | ( | int | level | ) |
Pick a string at level 'level' from the RPL stack with automatically allocated memory.
level | Stack level to pick from |
void sat_poke | ( | int | sat_addr, | |
unsigned | val, | |||
int | nibbles | |||
) |
Poke up to 8 nibbles of data to Saturn domain.
This function stores up to 32 bit data in 4 bit chunks (nibbles) to Saturn memory.
sat_addr | The address in Saturn domain | |
val | The datum itself | |
nibbles | Number of nibbles to poke |
void sat_poke_nibbles | ( | unsigned | sat_addr, | |
const char * | data, | |||
int | nibbles | |||
) |
Poke many nibbles to Saturn domain.
This function stores 2*strlen(data) nibbles to Saturn memory. It calls sat_poke() as it's "work-horse".
sat_addr | The address in Saturn domain | |
data | The data string | |
nibbles | Number of nibbles to poke |
double sat_pop_real | ( | ) |
Pop a Real from the Stack, as a Double. The Real object is popped from the RPL stack, and transformed into a double.
char* sat_pop_str | ( | char * | buf | ) |
Pop a string from the RPL stack.
str | Pointer to (big enough!) string buffer |
char* sat_pop_str_alloc | ( | ) |
Pop a string from the RPL stack with automatically allocated memory.
LONGLONG sat_pop_zint_llong | ( | ) |
Pop a ZINT off the RPL stack into a LONGLONG Pop a ZINT (exact integer) off the RPL stack into a LONGLONG (64 bit signed integer).
BOOL sat_push_bint | ( | int | bint | ) |
Push a bint on the RPL stack.
Pushes a sysRPL BINT object on the stack
bint | 20-bit unsigned number |
TRUE
on success BOOL sat_push_char | ( | char | byte | ) |
Push a char on the RPL stack.
Pushes a character on the stack
byte | 8-bit character |
TRUE
on success Push a complex number on the RPL stack.
Pushes a complex number on the stack
real | 64-bit BCD calculator real number | |
imag | 64-bit BCD calculator real number |
TRUE
on success Pushes an RPL List Object (of type SAT_LIST) onto the RPL Stack.
list | the List object to push. |
BOOL sat_push_real | ( | double | number | ) |
Push a real on the RPL stack.
Pushes a double, as a 'real' number on the RPL stack
number | A 'Double' floating point number. |
TRUE
on success Push a real array on the RPL stack.
Pushes an array of real numbers on the stack
rows | Number of rows in the matrix | |
columns | Number of columns in the matrix | |
arry | Pointer to an array of (rows*columns) 64-bit BCD calculator real numbers |
TRUE
on success BOOL sat_push_string | ( | int | type_prolog, | |
int | size_nibbles, | |||
const char * | data | |||
) |
Push a string on the RPL stack.
This function works with ZINT,HXS,CSTR,LIBDATA and CODE data types
type_prolog | The data type's prologue | |
size_nibbles | Number of nibbles to push | |
data | Pointer to data string |
TRUE
on success BOOL sat_push_zint_array | ( | unsigned int | digits, | |
unsigned int | negative, | |||
unsigned char * | source | |||
) |
Helper function for pushing ZINTs onto the Stack Accepts an array of binary digits, and pushes then onto the stack egc {1,2,3,4,5,6,7,8,9} for 123456789. It also accepts a negative flag (if TRUE, number is treated as negative) and number of digits.
digits | Number of digits in source | |
negative | Set to TRUE for negative numbers | |
source | the number as an array. Include binary values 0-9 ONLY. |
Push a LONGLONG onto the RPL stack as a ZINT Accepts a number of Type 'LONGLONG', and pushes it as an Exact Integer (ZINT).
num | the number to push as a ZINT (LONGLONG). |
void sat_pushptr | ( | int | sataddr | ) |
Push a pointer in the stack.
Pushes a data pointer to the stack and adjusts the available memory.
sataddr | Saturn address of the object |
void sat_pushtruefalse | ( | BOOL | arg | ) |
Push saturn flag FALSE if arg is FALSE, TRUE otherwise.
arg | Boolean True/False to push on the calculator stack |
double sat_real2double | ( | unsigned | addr | ) |
int sat_shrinklastob | ( | int | objaddr, | |
int | newsize | |||
) |
Change the allocated size of the last object in tempob.
C implementation of the HP49's ROM routines Shrink$ and Stretch$
objaddr | Address of the object's prolog | |
newsize | New size to allocate for the object |
int sat_stack_depth | ( | ) |
Get number of elements on the RPL stack (DEPTH).
int sat_stack_drop | ( | ) |
Pop one element off the stack (DROP).
int sat_stack_dropn | ( | int | n | ) |
Pop many elements off the stack (DROPN).
void sat_stack_exit | ( | unsigned | rpl_stack_bias | ) |
DEPRECATED: Finalize RPL stack access This function MUST be called before exiting the program Failing this may cause a calculator crash (TTRM with memory clear!)
unsigned sat_stack_init | ( | ) |
DEPRECATED: Initialize RPL stack access This function MUST be called before any other high level stack API function. The returned value is NOT intended for any usage other then storing it!
int sat_stack_levels_avail | ( | ) |
Inquiry function that tells how many stack levels are available for pushing.
int sat_stack_nip | ( | ) |
Swap then drop (NIP).
int sat_stack_pop_stdargs | ( | char *** | argv | ) |
Build a standard C main (argc,**argv) tuple from the RPL stack.
Contrary to the "standard" argv, this argv array holds exactly argc values, i.e. we have NO program name. Note also, that the arguments are stored in reverse order as they were push to the stack and that no null pointer is appended as the last element. (Remember the stack is a LIFO - Last In First Out - structure )
argv | Address of a char ** array, to hold the strings |
int sat_stack_push_double | ( | double | d | ) |
Push a string representation of a double onto the stack The double value is converted to a string and then pushed via sat_stack_push_string().
d | a double |
int sat_stack_push_int | ( | int | z | ) |
Push a string representation (base=10) of an integer onto the stack The integer is converted to a string and then pushed via sat_stack_push_string().
z | an Integer |
int sat_stack_push_string | ( | const char * | str | ) |
Push a string onto the RPL stack.
str | Pointer to (zero delimited) string |
int sat_stack_swap | ( | ) |
Swap elements on level 1 and 2 (SWAP).