| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#ifndef EMT_INCLUDED |
| 23 |
#define EMT_INCLUDED |
| 24 |
|
| 25 |
#ifndef STD_INCLUDED |
| 26 |
# include "std.h" |
| 27 |
#endif |
| 28 |
#ifndef ERR_INCLUDED |
| 29 |
# include "err.h" |
| 30 |
#endif |
| 31 |
#ifndef MCM_INCLUDED |
| 32 |
# include "mcm.h" |
| 33 |
#endif |
| 34 |
#ifndef OBJ_INCLUDED |
| 35 |
# include "obj.h" |
| 36 |
#endif |
| 37 |
#ifndef TOK_INCLUDED |
| 38 |
#include "tok.h" |
| 39 |
#endif |
| 40 |
|
| 41 |
|
| 42 |
struct emtldef |
| 43 |
{ |
| 44 |
ushort emtllnk; |
| 45 |
ushort emtlofs; |
| 46 |
uchar emtlflg; |
| 47 |
# define EMTLFSET 1 |
| 48 |
}; |
| 49 |
typedef struct emtldef emtldef; |
| 50 |
|
| 51 |
|
| 52 |
#define EMTLLNKEND ((ushort)~0) |
| 53 |
|
| 54 |
|
| 55 |
struct emtcxdef |
| 56 |
{ |
| 57 |
errcxdef *emtcxerr; |
| 58 |
mcmcxdef *emtcxmem; |
| 59 |
mcmon emtcxobj; |
| 60 |
ushort emtcxofs; |
| 61 |
uchar *emtcxptr; |
| 62 |
int emtcxlcnt; |
| 63 |
ushort emtcxlfre; |
| 64 |
emtldef emtcxlbl[1]; |
| 65 |
objnum emtcxfrob; |
| 66 |
}; |
| 67 |
typedef struct emtcxdef emtcxdef; |
| 68 |
|
| 69 |
|
| 70 |
struct emtledef |
| 71 |
{ |
| 72 |
uchar emtletyp; |
| 73 |
long emtleval; |
| 74 |
}; |
| 75 |
typedef struct emtledef emtledef; |
| 76 |
|
| 77 |
|
| 78 |
struct emtlidef |
| 79 |
{ |
| 80 |
int emtlicnt; |
| 81 |
emtledef emtliele[1]; |
| 82 |
}; |
| 83 |
typedef struct emtlidef emtlidef; |
| 84 |
|
| 85 |
|
| 86 |
void emtval(emtcxdef *ctx, struct tokdef *tok, uchar *base); |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
#define emtop(ctx,op) \ |
| 91 |
(emtres(ctx, (ushort)1), \ |
| 92 |
(void)(*((ctx)->emtcxptr + (ctx)->emtcxofs++) = (op))) |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
#define emtbyte(ctx,b) emtop(ctx,b) |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
#define emtmem(ctx,ptr,siz) \ |
| 101 |
(emtres(ctx, (ushort)(siz)),\ |
| 102 |
memcpy((ctx)->emtcxptr + (ctx)->emtcxofs,ptr,(size_t)(siz)),\ |
| 103 |
(void)((ctx)->emtcxofs += (siz))) |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
#define emtint2(ctx,i) \ |
| 108 |
(emtres(ctx, (ushort)2), oswp2((ctx)->emtcxptr + (ctx)->emtcxofs, i), \ |
| 109 |
(ctx)->emtcxofs+=2) |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
#define emtint2s(ctx,i) \ |
| 114 |
(emtres(ctx, (ushort)2), oswp2s((ctx)->emtcxptr + (ctx)->emtcxofs, i), \ |
| 115 |
(ctx)->emtcxofs+=2) |
| 116 |
|
| 117 |
|
| 118 |
#define emtint2at(ctx,i,ofs) \ |
| 119 |
(oswp2((ctx)->emtcxptr + (ofs), i)) |
| 120 |
|
| 121 |
|
| 122 |
#define emtint2sat(ctx,i,ofs) \ |
| 123 |
(oswp2s((ctx)->emtcxptr + (ofs), i)) |
| 124 |
|
| 125 |
|
| 126 |
#define emtint2from(ctx, ofs) \ |
| 127 |
(osrp2((ctx)->emtcxptr + (ofs))) |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
#define emtint4(ctx,l) \ |
| 132 |
(emtres(ctx, (ushort)4), oswp4s((ctx)->emtcxptr + (ctx)->emtcxofs, l), \ |
| 133 |
(ctx)->emtcxofs+=4) |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
void emtlini(emtcxdef *ctx); |
| 138 |
|
| 139 |
|
| 140 |
uint emtglbl(emtcxdef *ctx); |
| 141 |
|
| 142 |
|
| 143 |
uint emtgslbl(emtcxdef *ctx); |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
void emtslbl(emtcxdef *ctx, noreg uint *lab, int release); |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
void emtdlbl(emtcxdef *ctx, noreg uint *lab); |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
void emtclbl(emtcxdef *ctx, noreg uint *lab); |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
#define emtqset(ctx,lab) (((ctx)->emtcxlbl[lab].emtlflg & EMTLFSET) != 0) |
| 169 |
|
| 170 |
|
| 171 |
void emtjmp(emtcxdef *ctx, uchar op, uint lab); |
| 172 |
|
| 173 |
|
| 174 |
void emtres(emtcxdef *ctx, ushort bytes); |
| 175 |
|
| 176 |
|
| 177 |
void emtlst(emtcxdef *ctx, uint ofs, uchar *base); |
| 178 |
|
| 179 |
|
| 180 |
#define EMTINC 256 |
| 181 |
|
| 182 |
#endif |