996
|
1 /*
|
|
2 * Copyright (c) 2005 Gregor Richards
|
|
3 *
|
|
4 * This file is part of egobfi.
|
|
5 *
|
|
6 * egobfi is free software; you can redistribute it and/or modify
|
|
7 * it under the terms of the GNU General Public License as published by
|
|
8 * the Free Software Foundation; either version 2 of the License, or
|
|
9 * (at your option) any later version.
|
|
10 *
|
|
11 * egobfi is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 * GNU General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU General Public License
|
|
17 * along with egobfi; if not, write to the Free Software
|
|
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 */
|
|
20
|
|
21 #define C2MHEAD() { \
|
|
22 memcpy((char *) (prog + pptr), \
|
|
23 "\x55" \
|
|
24 "\x89\xe5" \
|
|
25 "\xa1____", 8); \
|
|
26 memcpy((char *) (prog + pptr + 4), \
|
|
27 &mptri, 4); \
|
|
28 pptr += 8; \
|
|
29 }
|
|
30
|
|
31 #define C2MTAIL() { \
|
|
32 memcpy((char *) (prog + pptr), \
|
|
33 "\x5d\xc3", 2); \
|
|
34 pptr += 2; \
|
|
35 }
|
|
36
|
|
37 #define C2MADD(a) { \
|
|
38 *((char *) (prog + pptr)) = '\x80'; \
|
|
39 if ((a) >= 0) { \
|
|
40 *((char *) (prog + pptr + 1)) = '\x00'; \
|
|
41 *((char *) (prog + pptr + 2)) = (char) (a); \
|
|
42 } else { \
|
|
43 *((char *) (prog + pptr + 1)) = '\x28'; \
|
|
44 *((char *) (prog + pptr + 2)) = (char) ((a) * -1); \
|
|
45 } \
|
|
46 pptr += 3; \
|
|
47 }
|
|
48
|
|
49 #define C2MRHT(a) { \
|
|
50 if ((a) >= 0) { \
|
|
51 memcpy((char *) (prog + pptr), \
|
|
52 "\x83\xc0_" \
|
|
53 "\xa3____", 8); \
|
|
54 *((char *) (prog + pptr + 2)) = (char) (a); \
|
|
55 memcpy((char *) (prog + pptr + 4), &mptri, 4); \
|
|
56 } else { \
|
|
57 memcpy((char *) (prog + pptr), \
|
|
58 "\x83\xe8_" \
|
|
59 "\xa3____", 8); \
|
|
60 *((char *) (prog + pptr + 2)) = (char) ((a) * -1); \
|
|
61 memcpy((char *) (prog + pptr + 4), &mptri, 4); \
|
|
62 } \
|
|
63 pptr += 8; \
|
|
64 }
|
|
65
|
|
66 #define C2MLOS 9
|
|
67
|
|
68 #define C2MLO(rpptr) { \
|
|
69 int jlen; \
|
|
70 jlen = (int) (prog + pptr) - (int) (prog + rpptr) - 4; \
|
|
71 memcpy((char *) (prog + (rpptr)), \
|
|
72 "\x80\x38\x00" \
|
|
73 "\x0f\x84____", 9); \
|
|
74 memcpy((char *) (prog + (rpptr) + 5), &jlen, 4); \
|
|
75 }
|
|
76
|
|
77 #define C2MLC(sp) { \
|
|
78 int jlen; \
|
|
79 jlen = (int) (prog + sp) - (int) (prog + pptr) - 5; \
|
|
80 memcpy((char *) (prog + pptr), \
|
|
81 "\xe9____", 5); \
|
|
82 memcpy((char *) (prog + pptr + 1), &jlen, 4); \
|
|
83 pptr += 5; \
|
|
84 }
|
|
85
|
|
86 #define C2MCALL(a) { \
|
|
87 int cptr; \
|
|
88 cptr = (int) (a) - (int) (prog + pptr) - 5; \
|
|
89 memcpy((char *) (prog + pptr), \
|
|
90 "\xe8____" \
|
|
91 "\xa1____", 10); \
|
|
92 memcpy((char *) (prog + pptr + 1), &cptr, 4); \
|
|
93 memcpy((char *) (prog + pptr + 6), &mptri, 4); \
|
|
94 pptr += 10; \
|
|
95 }
|