IPS(Interpreter for Process Structures) for mbed

Dependencies:   ConfigFile FATFileSystem mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BaseIPS.h Source File

BaseIPS.h

00001 // BaseIPS.h 2015/5/22
00002 #pragma once
00003 
00004 /* data types */
00005 typedef unsigned char u8;
00006 typedef unsigned short u16;
00007 typedef signed short s16;
00008 typedef unsigned long u32;
00009 typedef unsigned char byte;
00010 
00011 /* some variables of IPS also need to be accessed by the emulator; here are their addresses: */
00012 #define READYFLAG 0x42e
00013 #define LOADFLAG 0x43b
00014 #define UHR 0x418
00015 #define SU0 0x41e
00016 #define SU1 0x422
00017 #define SU2 0x426
00018 #define SU3 0x42a
00019 #define a_PE 0x42f
00020 #define a_PI 0x431
00021 #define a_P1 0x433
00022 #define a_P2 0x435
00023 #define a_P3 0x437
00024 #define a_NDptr 0x43e
00025 #define a_Os 0x43c
00026 
00027 #define TVE 1023
00028 
00029 class BaseIPS {
00030 public:
00031     BaseIPS();
00032     void emulator();
00033     void load_image(const u8* image, int size);
00034     void command(const char* s);
00035 
00036     void push_ps(u16 w);
00037     u16 pull_ps();
00038     virtual uint8_t mem_peek(uint16_t a) = 0;
00039     virtual void mem_poke(uint16_t a, uint8_t b) = 0;
00040 
00041     uint8_t peekB(u16 a) { return mem_peek(a); }
00042     void pokeB(uint16_t a, uint8_t b) { mem_poke(a, b); }
00043 
00044 protected:
00045     void poke(u16 a, u16 w);
00046     u16 peek(u16 a);
00047     virtual void do_io() = 0;
00048     virtual bool test_20ms() { return false; }
00049     virtual void* file_open(const char* filename, const char* mode = "rb") { return NULL; }
00050     virtual int file_getc(void* handle) { return -1; }
00051     virtual void file_putc(int c, void* handle) {}
00052     virtual bool file_close(void* handle) { return false; }
00053     virtual void trace(u32 cycle, u16 ppc, u16 hp, u16 cpc, u16 ps, u16 rs) {}
00054     virtual void usercode(uint16_t cpc) = 0;
00055     int input_ptr;
00056 
00057 private:
00058     u32 peek32(u16 a);
00059     u16 PPC, HP, PS, RS;
00060     u32 cycle;
00061     int depth;
00062     int redraw;
00063     int idle;
00064     void push_rs(u16 w);
00065     u16 pull_rs();
00066     void* inputfile;
00067     void do_20ms();
00068     void read_inputfile(void);
00069 
00070     void c_rumpelstilzchen(void); // 0
00071     void c_defex(void); // 1
00072     void c_consex(void); // 2
00073     void c_varex(void); // 3
00074     void c_retex(void); // 4
00075     void c_get(void); // 5
00076     void c_getB(void); // 6
00077     void c_put(void); // 7
00078     void c_putB(void); // 8
00079     void c_1bliteral(void); // 9
00080     void c_2bliteral(void); // 10
00081     void c_bronz(void); // 11
00082     void c_jump(void); // 12
00083     void c_weg(void); // 13
00084     void c_pweg(void); // 14
00085     void c_plus(void); // 15
00086     void c_minus(void); // 16
00087     void c_dup(void); // 17
00088     void c_pdup(void); // 18
00089     void c_vert(void); // 19
00090     void c_zwo(void); // 20
00091     void c_rdu(void); // 21
00092     void c_rdo(void); // 22
00093     void c_index(void); // 23
00094     void c_s_to_r(void); // 24
00095     void c_r_to_s(void); // 25
00096     void c_eqz(void); // 26
00097     void c_gz(void); // 27
00098     void c_lz(void); // 28
00099     void c_geu(void); // 29
00100     void c_f_vergl(void); // 30
00101     void c_nicht(void); // 31
00102     void c_und(void); // 32
00103     void c_oder(void); // 33
00104     void c_exo(void); // 34
00105     void c_bit(void); // 35
00106     void c_cbit(void); // 36
00107     void c_sbit(void); // 37
00108     void c_tbit(void); // 38
00109     void loop_sharedcode(int i);
00110     void c_jeex(void); // 39
00111     void c_loopex(void); // 40
00112     void c_plusloopex(void); // 41
00113     void c_fieldtrans(void); // 42
00114     void c_pmul(void); // 43
00115     void c_pdiv(void); // 44
00116     void c_tue(void); // 45
00117     void c_polyname(void); // 46
00118     void c_scode(void); // 47
00119     void c_cscan(void); // 48
00120     void c_chs(void); // 49
00121     void c_cyc2(void); // 50
00122     void c_close(void); // 51
00123     void c_open(void); // 52
00124     void c_oscli(void); // 53
00125     void c_load(void); // 54
00126     void c_save(void); // 55
00127     void c_setkbptr(void); // 56
00128     void c_getPS(void); // 57
00129     void c_setPS(void); // 58
00130     void c_rp_code(void); // 59
00131     void c_tr_code(void); // 60
00132     void c_swap3(void); // 61
00133     void c_defchar(void); // 62
00134     void c_pplus(void); // 63
00135     void c_pminus(void); // 64
00136 };
00137 
00138 
00139