saturn.h

Go to the documentation of this file.
00001 //& <prolog>
00002 //& ****************************************************************************
00003 //&
00004 //& Written by Ingo Blank & Claudio Lapilli October 2004
00005 //& 
00006 //& Copyright (C) 2004 HP-GCC Development Team
00007 //&
00008 //& ****************************************************************************
00009 //&
00010 //&
00011 //& This file is part of HP-GCC.
00012 //&
00013 //& HP-GCC is free software; you can redistribute it and/or modify
00014 //& it under the terms of the GNU General Public License as published by
00015 //& the Free Software Foundation; either version 2, or (at your option)
00016 //& any later version.
00017 //& 
00018 //& HP-GCC is distributed in the hope that it will be useful,
00019 //& but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 //& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 //& GNU General Public License for more details.
00022 //& 
00023 //& You should have received a copy of the GNU General Public License
00024 //& along with HP-GCC; see the file COPYING. 
00025 //&
00026 //& As a special exception, you may use this file as part of a free software
00027 //& library without restriction.  Specifically, if other files instantiate
00028 //& templates or use macros or inline functions from this file, or you compile
00029 //& this file and link it with other files to produce an executable, this
00030 //& file does not by itself cause the resulting executable to be covered by
00031 //& the GNU General Public License.  This exception does not however
00032 //& invalidate any other reasons why the executable file might be covered by
00033 //& the GNU General Public License.
00034 //&
00035 //& ****************************************************************************
00036 
00037 //& </prolog>
00038 
00039 
00040 // $Header: /cvsroot/hpgcc/sources/hplib/saturn.h,v 1.20 2005/05/22 16:58:00 njz3 Exp $
00041 
00042 #ifndef __SATURN_H
00043 #define __SATURN_H
00044 
00045 
00046 #ifdef HP49
00047 #include "hp49.h"
00048 #endif
00049 
00050 
00051 // LONG TYPE DEFINITION, ADDED BY CLAUDIO 01/14/05
00052 #ifndef _LONGLONG_DEF
00053 typedef unsigned long long ULONGLONG;
00054 typedef long long LONGLONG;
00055 #define _LONGLONG_DEF
00056 #endif
00057 
00058 
00286 #define SWAP4(x) (((x) << 4) | ((x) >> 4))
00287 
00292 #define ALIGN(x,a) (((unsigned)(x)+(a)-1) & (~((unsigned)(a)-1)))
00293 
00298 #ifndef BOOL
00299 #define BOOL int
00300 #endif
00301 
00306 #ifndef FALSE
00307 #define FALSE 0
00308 #endif
00309 
00314 #ifndef TRUE
00315 #define TRUE !FALSE
00316 #endif
00317 
00318 
00319 
00366 typedef
00367 
00368 struct _sat_cpu {
00369     
00370     unsigned int     Read[257];
00371     unsigned int     Write[257];
00372     unsigned char     unknown_data[260];
00373     unsigned int    A;
00374     unsigned int    Ah;
00375     unsigned int    B;
00376     unsigned int    Bh;
00377     unsigned int    C;
00378     unsigned int    Ch;
00379     unsigned int    D;
00380     unsigned int    Dh;
00381     
00382     unsigned int    R0;
00383     unsigned int    R0h;
00384     unsigned int    R1;
00385     unsigned int    R1h;
00386     unsigned int    R2;
00387     unsigned int    R2h;
00388     unsigned int    R3;
00389     unsigned int    R3h;
00390     unsigned int    R4;
00391     unsigned int    R4h;
00392     
00393     unsigned int    D0;
00394     unsigned int    D1;
00395     unsigned int    P;
00396     unsigned int    ST;
00397     unsigned int    HST;
00398     unsigned int    CARRY;
00399     unsigned int    DECIMAL_MODE;
00400     
00401 } SAT_CPU, *SAT_PCPU;
00402 
00403 
00408 // < ibl ; 2005-10-26 >
00409 // made struct definition non-anonymous for C++ compliance
00410 
00411 typedef struct sat_list_struct { //an RPL List Object - Al, Feb '05
00412            unsigned int size;
00413            unsigned char * data;
00414         } *SAT_LIST;
00415 
00416 extern SAT_CPU *_saturn_cpu;
00417 
00418 // SATURN Stack
00419 
00424 #define SAT_STACK_BIAS 1 
00425 
00426 
00441 typedef struct _sat_stack_element
00442 {
00443     unsigned    addr;
00444     unsigned    prologue;
00445     
00446 } SAT_STACK_ELEMENT, *SAT_PSTACK_ELEMENT;
00447 
00448 
00449 // ALL PROLOGUE CONSTANTS RENAMED BY CLAUDIO
00450 // TO MATCH THE SYSRPL NAMES 01/08/05
00451 
00455 #define SAT_DOINT 0x2614
00456 
00459 #define SAT_DOCSTR        0x2a2c
00460 
00463 #define SAT_DOREAL        0x2933
00464 
00468 #define SAT_DOEREL        0x2955
00469  
00473 #define SAT_DOHXS        0x2a4e
00474 
00477 #define SAT_DOBINT        0x2911
00478 
00481 #define SAT_DOCMP        0x2977
00482 
00485 #define SAT_DOECMP        0x299D
00486 
00489 #define SAT_DOCHAR        0x29BF
00490 
00493 #define SAT_DOARRY        0x29e8
00494 
00497 #define SAT_DOLNKARRY        0x29e8
00498 
00501 #define SAT_DOIDNT        0x2e48
00502 
00505 #define SAT_DOLAM        0x2e6D
00506 
00509 #define SAT_DOROMP        0x2e92
00510 
00513 #define SAT_DORRP        0x2a96
00514 
00517 #define SAT_DOSYMB        0x2AB8
00518 
00521 #define SAT_DOLIST        0x2A74
00522 
00525 #define SAT_DOCOL        0x2D9D
00526 
00529 #define SAT_DOGROB        0x2B1E
00530 
00533 #define SAT_SEMI        0x312b
00534 
00537 #define SAT_DOBAK        0x2B62
00538 
00541 #define SAT_DOCODE        0x2DCC
00542 
00545 #define SAT_DOEXT        0x2ADA
00546 
00549 #define SAT_DOFLASHP    0x26AC
00550 
00553 #define SAT_DOLIB        0x2B40
00554 
00557 #define SAT_DOMATRIX    0x2686
00558 
00561 #define SAT_DOTAG        0x2AFC
00562 
00565 #define SAT_DOAPLET        0x26D5
00566 
00569 #define SAT_DOEXT0        0x2B88
00570 
00573 #define SAT_DOACPTR        0x2BAA
00574 #define SAT_DOEXT1      SAT_DOACPTR
00575 
00578 #define SAT_DOEXT2        0x2BCC
00579 
00582 #define SAT_DOEXT3        0x2BEE
00583 
00586 #define SAT_DOEXT4        0x2C10
00587 
00590 #define SAT_DOLNGREAL        0x263A
00591 
00594 #define SAT_DOLNGCOMP        0x2660
00595 
00596 
00597 // PREDEFINED REALS
00598 
00599 
00600 #define REAL_0        0x2f937
00601 #define REAL_1        0x2f94c
00602 #define REAL_2        0x2f961
00603 #define REAL_3        0x2f976
00604 #define REAL_4        0x2f98b
00605 #define REAL_5        0x2f9a0
00606 #define REAL_6        0x2f9b5
00607 #define REAL_7        0x2f9ca
00608 #define REAL_8        0x2f9df
00609 #define REAL_9        0x2f9f4
00610 
00611 
00612 
00613 // OBSOLETE CONSTANTS: KEPT FOR COMPATIBILITY ONLY
00614 // CHANGED BY CLAUDIO 01/08/05
00615 #define SAT_PROLOGUE_STRING SAT_DOCSTR
00616 #define SAT_PROLOGUE_UINT SAT_DOHXS
00617 
00622 #define SAT_DATA_TYPE_INT        28
00623 
00628 #define SAT_DATA_TYPE_LONG        10
00629 
00634 #define SAT_DATA_TYPE_STRING        2
00635 
00640 #define SAT_DATA_TYPE_REAL        0
00641 
00647 #define SAT_DATA_TYPE_UNSUPPORTED -999
00648 
00668 typedef struct _sat_stack_data
00669 {
00670     int    type;
00671     union {
00672         int        ival;
00673         double        dval;
00674         LONGLONG    lval;
00675         char        *sval;
00676     };
00677 } SAT_STACK_DATA, *SAT_PSTACK_DATA;
00678 
00679 
00680 // general SAT hacking functions
00681 
00691 void sat_poke(int sat_addr,unsigned val,int nibbles);
00692 
00704 void sat_poke_nibbles(unsigned sat_addr, const char *data, int nibbles);
00705 
00715 unsigned sat_peek(int sat_addr,int nibbles);
00716 
00728 void sat_memmove(int satsrc,int satdest,int nibbles);
00729 
00730 
00742 #define sat_moveup(a,b,c) sat_memmove(a,b,c)
00743 
00755 #define sat_movedown(a,b,c) sat_memmove(a,b,c)
00756 
00757 
00758 
00766 int sat_getfreetempob();
00767 
00768 
00769 
00780 int sat_createtemp(int objsize);
00781 
00782 
00783 
00794 int sat_shrinklastob(int objaddr,int newsize);
00795 
00796 
00797 
00798 
00799 
00800 
00813 BOOL sat_push_string(int type_prolog,int size_nibbles,const char *data);
00814 
00823 unsigned int sat_map_s2a(unsigned int sat_addr);
00824 
00834 unsigned int sat_map_a2s(unsigned int arm_addr);
00835 
00840 #define sat_peek_sat_addr(sat_addr) sat_peek((sat_addr),5)
00841 
00846 #define sat_peek_sat_byte(sat_addr) ((unsigned char) sat_peek((sat_addr),2))
00847 
00859 void *sat_peek_sat_bytes(void *target, unsigned sat_addr, int nbytes);
00860 
00861 
00875 unsigned char * sat_concatnib (unsigned char * dest, unsigned int destLen,  unsigned char* source, unsigned int sourceLen);
00876 
00877 
00878 
00883 #define sat_poke_sat_byte(sat_addr,val) sat_poke((sat_addr), (unsigned) (val), 2)
00884 
00889 #define sat_poke_sat_bytes(sat_addr, bytes, n) sat_poke_nibbles((sat_addr), (bytes), (2*(n)))
00890 
00895 #define sat_poke_sat_addr(sat_addr,val) sat_poke((sat_addr), (val), 5)
00896 
00897 // Saturn register save area
00898 
00903 #define SAT_INTRPPTR 0x8076B     /* D0 */
00904 
00909 #define SAT_DSKTOP   0x806F8    /* D1 */
00910 
00915 #define SAT_RSKTOP   0x806F3    /* B */
00916 
00921 #define SAT_AVMEM    0x80E9B    /* D */
00922 
00927 #define SAT_TEMPTOP  0x806EE
00928 
00933 #define SAT_EDITLINE  0x806FD
00934 
00939 #define SAT_ERROR 0x80EA5
00940 
00941 
00942 // OTHER USEFUL SATURN OBJECTS
00943 
00947 #define SAT_TRUE 0x3a81
00948 
00952 #define SAT_FALSE 0x3ac0
00953 
00954 
00955 
00956 
00957                               
00958 // RPL stack 
00959 
00973 unsigned sat_stack_init();
00974 
00982 void sat_stack_exit(unsigned rpl_stack_bias);
00983 
00989 int sat_stack_depth();
00990 
00998 int sat_get_stack_element(int index, SAT_STACK_ELEMENT *element);
00999 
01005 int sat_stack_drop();
01006 
01012 int sat_stack_dropn(int n);
01013 
01020 int sat_stack_swap();
01021 
01028 int sat_stack_nip();
01029 
01030 // push primitives
01031 
01038 int sat_stack_push_string(const char *str);
01039 
01046 //char *sat_stack_pop_string(char *str); // replaced by pick/pop paradigm functions
01047 
01048 char *sat_pop_str(char *buf);
01049 
01056 char *sat_pick_str(int level,char *buf);
01057 
01065 char *sat_pick_str_alloc(int level);
01066 
01073 char *sat_pop_str_alloc();
01074 
01075 
01080 #define sat_stack_pop_string(s) sat_pop_str((s))
01081 
01086 #define sat_stack_pop_string_alloc sat_pop_str_alloc
01087 
01092 #define sat_stack_pick_string(l,b) sat_pick_str((l),(b))
01093 
01098 #define sat_stack_pick_string_alloc(l) sat_pick_str_alloc((l))
01099 
01100 
01110 int _sat_stack_push_int(int z, int radix, int binary);
01111 
01119 int sat_stack_push_int(int z);
01120 
01128 int sat_stack_push_double(double d);
01129 
01138 BOOL sat_push_zint_llong(LONGLONG num);
01139 
01154 BOOL sat_push_zint_array (unsigned int digits, unsigned int negative, unsigned char * source);
01155 
01156 
01163 LONGLONG sat_pop_zint_llong();
01164 
01172 SAT_LIST sat_list_create(unsigned int maxSize);
01173 
01174 
01181 void sat_list_destroy(SAT_LIST list);
01182 
01189 BOOL sat_push_list(SAT_LIST list);
01190 
01191 
01198 void sat_list_add_real(SAT_LIST list, double num);
01199 
01213 void sat_list_add_zint_array(SAT_LIST list, unsigned int digits, unsigned int negative, unsigned char * source );
01214 
01228 char * sat_convert_zint_array (unsigned int digits, unsigned int negative, unsigned char * source, unsigned char * dest);
01229 
01230 
01238 void sat_list_add_zint(SAT_LIST list, LONGLONG num);
01239 
01240 
01248 unsigned char *  sat_convert_double_real(double number, unsigned char * realStr);
01249 
01250 
01257 int sat_stack_levels_avail();
01258 
01259 // Saturn data codec
01260 
01269 char *_sat_decode_string(unsigned sat_addr);
01270 
01279 int sat_decode_stack_element(SAT_STACK_DATA *data, SAT_STACK_ELEMENT *stack);
01280 
01281 
01288 double sat_pop_real();
01289 
01290 
01291 // LOW-LEVEL ROUTINES FOR DIRECT OBJECT ACCESS
01292 
01301 void sat_pushptr(int sataddr);
01302 
01303 
01304 
01305 
01318 BOOL sat_push_string(int type_prolog,int size_nibbles,const char *data);
01319 
01329 BOOL sat_push_bint(int bint);
01330 
01340 BOOL sat_push_real(double number);
01341 
01351 BOOL
01352 sat_push_char(char byte);
01353 
01364 BOOL
01365 sat_push_comp(ULONGLONG real,ULONGLONG imag);
01366 
01367 
01379 BOOL
01380 sat_push_realarray(int rows,int columns,ULONGLONG *arry);
01381 
01382 LONGLONG sat_BCD2LONGLONG (unsigned addr, int digits);
01383 double sat_real2double (unsigned addr);
01384 ULONGLONG sat_double2real(double n);
01385 int sat_decode_real (unsigned address, double *val);
01386 
01394 int sat_check_type(unsigned int level, unsigned int prologue);
01395 
01396 
01408 int sat_stack_pop_stdargs(char ***argv);
01409 
01423 int _sat_stack_pop_stdargs(const char *arg0, char ***argv);
01424 
01425 
01432 void sat_errorsto(int errno);
01433 
01440 void sat_pushtruefalse(BOOL arg);
01441 
01446 #define sat_stack_push_bool sat_pushtruefalse
01447 
01448 
01449 #endif // __SATURN_H

Generated on Fri Feb 16 16:43:16 2007 for HP-GCCLibrary by  doxygen 1.5.0