R-20 Simulator
 Alle Dateien Funktionen Variablen Makrodefinitionen
core.h
gehe zur Dokumentation dieser Datei
1 //
2 // core.h
3 //
4 
5 #ifndef CORE_H
6 #define CORE_H
7 
8  // data representation
9 
10  // How to represent the 4 registers?
11  // Originally, there were 12 nibbles for BCD digits, 2 nibbles for
12  // BCD coded exponent and 1 nibble each for the signs.
13  //
14  // +- +- 1 , 2 3 4 5 6 7 8 9 0 1 2
15  //
16  // sign sign 10s 1s
17  // man exp \_________________ man _________________________/ \__exp__/
18  //
19  // | Byte 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
20  //
21  // New coding as of 2012-08-03:
22  //
23  // Each digit gets it dedicated byte to ease addition etc.
24  // Signs are stored in one byte: 0b .... ..me (mantissa, exponent)
25 
26 #define SIGNS 0
27 #define M 1
28 #define M_HIGH 1
29 #define M_ONES 10
30 #define E 11
31 #define E_TENS 11
32 #define E_ONES 12
33 #define NUMBER_SIZE 13
34 
35 #define NEG_M 0x01
36 #define NEG_E 0x02
37 
38 #define X 0 //
39 #define Y 1 // standard stack
40 #define Z 2 //
41 #define T 3 //
42 #define A 4 //
43 #define B 5 // safe area to do math w/o affecting X or Y
44 #define R 6 //
45 #define REG_NR 7
46 
47 extern char reg[REG_NR][NUMBER_SIZE];
48 extern char flags;
49 #define INFTY 0x01
50 
51 void copy_reg(char* dst, char* src);
52  int get_e(char* r);
53 void inc_e(char* r);
54 void shiftr1(char* r);
55 void shiftr(char* r, int n);
56 void plus(char* res, char* r1, char* r2);
57 void pop();
58 void push(char* r);
59 void enter();
60 void init_core();
61 
62 #endif // CORE_H