Lines Matching refs:D
49 #define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) argument
87 dasm_State *D; in dasm_init() local
92 D = Dst_REF; in dasm_init()
93 D->psize = psz; in dasm_init()
94 D->lglabels = NULL; in dasm_init()
95 D->lgsize = 0; in dasm_init()
96 D->pclabels = NULL; in dasm_init()
97 D->pcsize = 0; in dasm_init()
98 D->globals = NULL; in dasm_init()
99 D->maxsection = maxsection; in dasm_init()
101 D->sections[i].buf = NULL; /* Need this for pass3. */ in dasm_init()
102 D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); in dasm_init()
103 D->sections[i].bsize = 0; in dasm_init()
104 D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ in dasm_init()
111 dasm_State *D = Dst_REF; in dasm_free() local
113 for (i = 0; i < D->maxsection; i++) in dasm_free()
114 if (D->sections[i].buf) in dasm_free()
115 DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); in dasm_free()
116 if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); in dasm_free()
117 if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); in dasm_free()
118 DASM_M_FREE(Dst, D, D->psize); in dasm_free()
124 dasm_State *D = Dst_REF; in dasm_setupglobal() local
125 D->globals = gl - 10; /* Negative bias to compensate for locals. */ in dasm_setupglobal()
126 DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); in dasm_setupglobal()
132 dasm_State *D = Dst_REF; in dasm_growpc() local
133 size_t osz = D->pcsize; in dasm_growpc()
134 DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); in dasm_growpc()
135 memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); in dasm_growpc()
141 dasm_State *D = Dst_REF; in dasm_setup() local
143 D->actionlist = (dasm_ActList)actionlist; in dasm_setup()
144 D->status = DASM_S_OK; in dasm_setup()
145 D->section = &D->sections[0]; in dasm_setup()
146 memset((void *)D->lglabels, 0, D->lgsize); in dasm_setup()
147 if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); in dasm_setup()
148 for (i = 0; i < D->maxsection; i++) { in dasm_setup()
149 D->sections[i].pos = DASM_SEC2POS(i); in dasm_setup()
150 D->sections[i].ofs = 0; in dasm_setup()
158 D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0)
160 do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \
161 D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0)
171 dasm_State *D = Dst_REF; in dasm_put() local
172 dasm_ActList p = D->actionlist + start; in dasm_put()
173 dasm_Section *sec = D->section; in dasm_put()
198 n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); in dasm_put()
199 D->section = &D->sections[n]; goto stop; in dasm_put()
204 n = (ins & 2047) - 10; pl = D->lglabels + n; in dasm_put()
211 pl = D->pclabels + n; CKPL(pc, PC); in dasm_put()
224 pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; in dasm_put()
226 pl = D->pclabels + n; CKPL(pc, PC); in dasm_put()
229 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; in dasm_put()
264 dasm_State *D = Dst_REF; in dasm_link() local
270 if (D->status != DASM_S_OK) return D->status; in dasm_link()
273 for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) in dasm_link()
274 if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; in dasm_link()
280 for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) { in dasm_link()
281 int n = D->lglabels[idx]; in dasm_link()
283 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } in dasm_link()
288 for (secnum = 0; secnum < D->maxsection; secnum++) { in dasm_link()
289 dasm_Section *sec = D->sections + secnum; in dasm_link()
295 dasm_ActList p = D->actionlist + b[pos++]; in dasm_link()
314 D->codesize = ofs; /* Total size of all code sections */ in dasm_link()
321 do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0)
329 dasm_State *D = Dst_REF; in dasm_encode() local
335 for (secnum = 0; secnum < D->maxsection; secnum++) { in dasm_encode()
336 dasm_Section *sec = D->sections + secnum; in dasm_encode()
341 dasm_ActList p = D->actionlist + *b++; in dasm_encode()
357 n = (int)((ptrdiff_t)D->globals[-n] - (ptrdiff_t)cp); in dasm_encode()
363 n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base); in dasm_encode()
371 ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); in dasm_encode()
387 if (base + D->codesize != (char *)cp) /* Check for phase errors. */ in dasm_encode()
396 dasm_State *D = Dst_REF; in dasm_getpclabel() local
397 if (pc*sizeof(int) < D->pcsize) { in dasm_getpclabel()
398 int pos = D->pclabels[pc]; in dasm_getpclabel()
399 if (pos < 0) return *DASM_POS2PTR(D, -pos); in dasm_getpclabel()
409 dasm_State *D = Dst_REF; in dasm_checkstep() local
410 if (D->status == DASM_S_OK) { in dasm_checkstep()
413 if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } in dasm_checkstep()
414 D->lglabels[i] = 0; in dasm_checkstep()
417 if (D->status == DASM_S_OK && secmatch >= 0 && in dasm_checkstep()
418 D->section != &D->sections[secmatch]) in dasm_checkstep()
419 D->status = DASM_S_MATCH_SEC|(D->section-D->sections); in dasm_checkstep()
420 return D->status; in dasm_checkstep()