bcgen_instructions.c 141 KB
Newer Older
1
#include "bcgen_instructions.h"
Erin van der Veen's avatar
Erin van der Veen committed
2

3 4 5 6
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

7 8 9
#include "abc_instructions.h"
#include "bcgen.h"
#include "util.h"
10

11
#define max_implemented_instruction_n CMAX-1
12

13 14
int is_32_bit=0;

15
struct program pgrm;
16
uint32_t last_d, last_jsr_with_d;
17

18
struct label_node *labels;
Camil Staps's avatar
Camil Staps committed
19
uint32_t label_id;
20 21
uint32_t global_label_count;
uint32_t global_label_string_count;
22
struct label *start_label=NULL;
23

24
uint32_t module_n;
25

26
uint32_t list_code = 0;
27

28 29
uint32_t allocated_code_size;
uint32_t allocated_data_size;
30
uint32_t allocated_strings_size;
31 32
uint32_t allocated_code_relocations_size;
uint32_t allocated_data_relocations_size;
33

34
#define N_ADD_ARG_LABELS 32
35
static uint32_t Fadd_arg_label_used[N_ADD_ARG_LABELS];
36
#ifndef LINK_CLEAN_RUNTIME
37
static int general_add_arg_label_used=0;
38
#endif
39

Camil Staps's avatar
Camil Staps committed
40
#ifndef LINK_CLEAN_RUNTIME
41 42 43 44 45 46 47 48 49
int16_t warned_unsupported_instructions[128]={-1};
int warned_unsupported_instructions_i=0;
void unsupported_instruction_warning(int16_t instruction) {
	for (int i=0; i<warned_unsupported_instructions_i; i++)
		if (warned_unsupported_instructions[i] == instruction)
			return;
	warned_unsupported_instructions[warned_unsupported_instructions_i++] = instruction;
	fprintf(stderr,"Warning: instruction %s is not supported by the interpreter\n",instruction_name(instruction));
}
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

char *used_ccalls[256]={NULL};
int used_ccalls_ptr=0;
void used_ccall_warning (char *c_function_name) {
	for (int i=0; i<used_ccalls_ptr; i++)
		if (!strcmp (used_ccalls[i],c_function_name))
			return;
	used_ccalls[used_ccalls_ptr]=safe_malloc (strlen (c_function_name)+1);
	strcpy (used_ccalls[used_ccalls_ptr],c_function_name);
	used_ccalls_ptr++;
}

void show_used_ccalls_warning (void) {
	if (used_ccalls_ptr==0)
		return;
	fprintf(stderr,"Warning: external C functions cannot be packaged into the bytecode: ");
66
	for (int i=0; i<used_ccalls_ptr-1; i++){
67
		fprintf (stderr,"%s; ",used_ccalls[i]);
68 69
		free (used_ccalls[i]);
	}
70
	fprintf (stderr,"%s\n",used_ccalls[used_ccalls_ptr-1]);
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
	free (used_ccalls[used_ccalls_ptr-1]);
}

int16_t requires_file_io[256]={-1};
int requires_file_io_ptr=0;
void requires_file_io_warning (int16_t instruction) {
	for (int i=0; i<requires_file_io_ptr; i++)
		if (requires_file_io[i]==instruction)
			return;
	requires_file_io[requires_file_io_ptr]=instruction;
	requires_file_io_ptr++;
}

void show_requires_file_io_warning (void) {
	if (requires_file_io_ptr==0)
		return;
	fprintf(stderr,"Warning: some instructions require file I/O: ");
	for (int i=0; i<requires_file_io_ptr-1; i++)
		fprintf (stderr,"%s; ",instruction_name (requires_file_io[i]));
	fprintf (stderr,"%s\n",instruction_name (requires_file_io[requires_file_io_ptr-1]));
91
}
Camil Staps's avatar
Camil Staps committed
92
#endif
93

94
struct program *initialize_code(void) {
95 96 97 98 99
	int i;
	for(i = 0; i < N_ADD_ARG_LABELS; ++i)
		Fadd_arg_label_used[i] = 0;

	labels = NULL;
Camil Staps's avatar
Camil Staps committed
100
	label_id = 0;
101 102
	global_label_count = 0;
	global_label_string_count = 0;
Camil Staps's avatar
Camil Staps committed
103

104 105
	module_n = 0;

106 107 108 109 110
	pgrm = (struct program) {
		0,
		0,
		0,
		0,
111
		0,
112
		0,
113
		0,
Camil Staps's avatar
Camil Staps committed
114
		(struct word*) safe_malloc(512 * sizeof(struct word)),
115
		(uint32_t*) safe_malloc(512 * sizeof(uint32_t)),
116
		(uint64_t*) safe_malloc(512 * sizeof(uint64_t)),
117 118 119 120
		(relocation*) safe_malloc(512 * sizeof(relocation)),
		(relocation*) safe_malloc(512 * sizeof(relocation)),
		};

121 122
	allocated_code_size = 512;
	allocated_data_size = 512;
123
	allocated_strings_size = 512;
124 125
	allocated_code_relocations_size = 512;
	allocated_data_relocations_size = 512;
126 127

	return &pgrm;
128 129
}

Camil Staps's avatar
Camil Staps committed
130
#ifndef LINK_CLEAN_RUNTIME
131 132
void code_next_module(void) {
	module_n++;
133 134 135

	last_d = 0;
	last_jsr_with_d = 0;
136
}
Camil Staps's avatar
Camil Staps committed
137
#endif
138 139 140

static void realloc_code(void) {
	allocated_code_size *= 2;
Camil Staps's avatar
Camil Staps committed
141
	pgrm.code = (struct word*) safe_realloc(pgrm.code, allocated_code_size * sizeof(struct word));
142 143
}

144 145
static void realloc_strings(void) {
	allocated_strings_size *= 2;
146
	pgrm.strings = (uint32_t*) safe_realloc(pgrm.strings, allocated_strings_size * sizeof(uint32_t));
147 148
}

149 150
static void realloc_data(void) {
	allocated_data_size *= 2;
151
	pgrm.data = (uint64_t*) safe_realloc(pgrm.data, allocated_data_size * sizeof(uint64_t));
152 153
}

154
void store_code_elem(uint8_t bytewidth, uint64_t value) {
155 156 157
	if (pgrm.code_size >= allocated_code_size)
		realloc_code();

158
	pgrm.code[pgrm.code_size++] = (struct word) {bytewidth, value};
159
	pgrm.code_byte_size+=bytewidth;
160 161 162 163 164 165 166 167 168
}

struct label *enter_label(char *label_name) {
	struct label_node **label_node_pp;

	label_node_pp = &labels;
	while (*label_node_pp!=NULL) {
		struct label_node *label_node_p;
		int r;
Camil Staps's avatar
Camil Staps committed
169

170 171 172 173 174 175
		label_node_p=*label_node_pp;
		r=strcmp(label_name,label_node_p->label_node_label_p->label_name);
		if (r==0) {
			if (label_node_p->label_node_label_p->label_module_n>=0 && label_node_p->label_node_label_p->label_module_n!=module_n) {
				if (label_node_p->label_node_label_p->label_offset<0) {
					label_node_p->label_node_label_p->label_module_n = -1;
Camil Staps's avatar
Camil Staps committed
176

177 178 179
					return label_node_p->label_node_label_p;
				} else {
					struct label *new_label_p;
Camil Staps's avatar
Camil Staps committed
180

181
					new_label_p = (struct label*) safe_malloc(sizeof(struct label));
182
					new_label_p->label_name=label_node_p->label_node_label_p->label_name;
Camil Staps's avatar
Camil Staps committed
183
					new_label_p->label_id=label_id++;
184 185
					new_label_p->label_module_n=module_n;
					new_label_p->label_offset=-1;
186
					new_label_p->label_specials=NULL;
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203

					label_node_p->label_node_label_p=new_label_p;
					return new_label_p;
				}
			}

			return label_node_p->label_node_label_p;
		}
		if (r<0)
			label_node_pp=&label_node_p->label_node_left;
		else
			label_node_pp=&label_node_p->label_node_right;
	}

	struct label_node *new_label_node_p;
	struct label *new_label_p;

204 205
	new_label_node_p = (struct label_node*) safe_malloc(sizeof(struct label_node));
	new_label_p = (struct label*) safe_malloc(sizeof(struct label));
206 207 208
	new_label_node_p->label_node_left = NULL;
	new_label_node_p->label_node_right = NULL;
	new_label_node_p->label_node_label_p = new_label_p;
209
	new_label_p->label_name = (char*) safe_malloc(strlen(label_name) + 1);
Camil Staps's avatar
Camil Staps committed
210
	new_label_p->label_id=label_id++;
211 212 213
	strcpy(new_label_p->label_name, label_name);
	new_label_p->label_module_n = module_n;
	new_label_p->label_offset = -1;
214
	new_label_p->label_specials=NULL;
Camil Staps's avatar
Camil Staps committed
215

216 217 218 219
	*label_node_pp = new_label_node_p;
	return new_label_p;
}

220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
void add_label_special_offset_to (struct label *label,int32_t flags,int32_t location)
{
	struct label_specials *specials=safe_malloc (sizeof (struct label_specials));
	specials->label_specials_flags=flags;
	specials->label_specials_offset=location - (label->label_offset & -2);
	specials->label_specials_next=label->label_specials;
	label->label_specials=specials;
}

int32_t find_label_special_offset (struct label *label,int32_t flags)
{
	struct label_specials *specials=label->label_specials;

	while (specials!=NULL){
		if (specials->label_specials_flags & flags)
			return specials->label_specials_offset;
		specials=specials->label_specials_next;
	}

	EPRINTF ("internal error: find_label_special_offset (%s,%d) not found\n",label->label_name,flags);
	exit (-1);
}

243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
#ifdef LINKER
struct label *find_label(char *label_name) {
	struct label_node *label_node_p=labels;

	while (label_node_p!=NULL) {
		int r=strcmp(label_name,label_node_p->label_node_label_p->label_name);
		if (r==0)
			return label_node_p->label_node_label_p;
		else if (r<0)
			label_node_p=label_node_p->label_node_left;
		else
			label_node_p=label_node_p->label_node_right;
	}

	return NULL;
}

260 261
static struct label_node **move_label_tree_to_list(
		struct label_node **dest, struct label_node *tree) {
262
	if (tree->label_node_left!=NULL)
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
		dest=move_label_tree_to_list(dest,tree->label_node_left);
	*dest++=tree;
	if (tree->label_node_right!=NULL)
		dest=move_label_tree_to_list(dest,tree->label_node_right);
	return dest;
}

static struct label_node **merge_label_tree_with_list(
		struct label_node **dest,struct label_node *tree,
		struct label_node **list,unsigned int *list_i,unsigned int list_size) {
	int i=*list_i;

	if (i>=list_size)
		return move_label_tree_to_list(dest,tree);

	int r=strcmp(list[i]->label_node_label_p->label_name,tree->label_node_label_p->label_name);
	if (r>0) { /* prune: left side does not need to consider label list */
		if (tree->label_node_left!=NULL)
			dest=move_label_tree_to_list(dest,tree->label_node_left);
	} else {
		if (tree->label_node_left!=NULL)
			dest=merge_label_tree_with_list(dest,tree->label_node_left,list,list_i,list_size);

		i=*list_i;
		while (i<list_size && (r=strcmp(list[i]->label_node_label_p->label_name,tree->label_node_label_p->label_name))<0)
			*dest++=list[i++];
		*list_i=i;

		if (r==0) {
			EPRINTF("internal error: %s redefined\n",tree->label_node_label_p->label_name);
			exit(-1);
		}
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
	}

	*dest++=tree;

	if (tree->label_node_right!=NULL)
		dest=merge_label_tree_with_list(dest,tree->label_node_right,list,list_i,list_size);

	return dest;
}

static struct label_node *update_label_node_pointers(
		struct label_node **sorted_list,int lft,int rgt) {
	if (rgt<lft)
		return NULL;

	if (rgt==lft) {
		sorted_list[lft]->label_node_left=NULL;
		sorted_list[lft]->label_node_right=NULL;
		return sorted_list[lft];
	}

	int middle=lft+(rgt-lft)/2;
	sorted_list[middle]->label_node_left =update_label_node_pointers(sorted_list,lft,middle-1);
	sorted_list[middle]->label_node_right=update_label_node_pointers(sorted_list,middle+1,rgt);
	return sorted_list[middle];
}

void merge_new_labels_and_rebalance(struct label_node **new_labels,unsigned int n_new_labels) {
	for (int i=0; i<n_new_labels; i++) {
		struct label *label=new_labels[i]->label_node_label_p;
		label->label_id=label_id++;
		make_label_global(label);
	}

	if (labels==NULL) {
		labels=update_label_node_pointers(new_labels,0,label_id-1);
		return;
	}

	struct label_node **temp_list=safe_malloc(label_id*sizeof(struct label_node*));
	unsigned int list_i=0;
	struct label_node **temp_list_end=merge_label_tree_with_list(temp_list,labels,new_labels,&list_i,n_new_labels);
	while (list_i<n_new_labels)
		*temp_list_end++=new_labels[list_i++];

	labels=update_label_node_pointers(temp_list,0,label_id-1);

	free(temp_list);
}
#endif

346 347 348 349 350 351 352 353 354
struct label *new_label_at_offset(uint32_t offset) {
	char name[16];
	snprintf(name, 16, "i%x", offset);
	name[15] = '\0';
	struct label *label = enter_label(name);
	label->label_offset = offset;
	return label;
}

Camil Staps's avatar
Camil Staps committed
355 356 357
int internal_label_id = 0;
struct label *new_internal_label(void) {
	char label_name[14];
358
	sprintf(label_name,"%%%x",internal_label_id++);
Camil Staps's avatar
Camil Staps committed
359 360 361 362
	struct label *label = enter_label(label_name);
	return label;
}

363
void make_label_global(struct label *label) {
364 365 366 367 368
	if (label->label_module_n != -1) {
		label->label_module_n = -1;
		global_label_count++;
		global_label_string_count+=strlen(label->label_name);
	}
369 370
}

371
void store_data_l(uint64_t v) {
372 373
	if (pgrm.data_size >= allocated_data_size)
		realloc_data();
374
	*(uint64_t*)&pgrm.data[pgrm.data_size++] = v;
375 376
}

377 378 379 380 381
struct relocation *add_code_relocation(struct label *label, uint32_t offset) {
	if (pgrm.code_reloc_size>=allocated_code_relocations_size) {
		allocated_code_relocations_size *= 2;
		pgrm.code_relocations = (relocation*) safe_realloc(pgrm.code_relocations, allocated_code_relocations_size * sizeof(relocation));
	}
382

383 384 385 386
	struct relocation *relocation_p;

	relocation_p=&pgrm.code_relocations[pgrm.code_reloc_size++];
	relocation_p->relocation_offset=offset;
387
	relocation_p->relocation_flags=0;
388 389 390 391
	relocation_p->relocation_label=label;

	return relocation_p;
}
Camil Staps's avatar
Camil Staps committed
392

393 394 395 396
struct relocation *add_data_relocation(struct label *label, uint32_t offset) {
	if (pgrm.data_reloc_size>=allocated_data_relocations_size) {
		allocated_data_relocations_size *= 2;
		pgrm.data_relocations = (relocation*) safe_realloc(pgrm.data_relocations, allocated_data_relocations_size * sizeof(relocation));
397 398
	}

399 400 401 402
	struct relocation *relocation_p;

	relocation_p=&pgrm.data_relocations[pgrm.data_reloc_size++];
	relocation_p->relocation_offset=offset;
403
	relocation_p->relocation_flags=0;
404 405 406 407 408
	relocation_p->relocation_label=label;

	return relocation_p;
}

Camil Staps's avatar
Camil Staps committed
409
#ifndef LINK_CLEAN_RUNTIME
410 411
void store_code_internal_label_value(struct label *label,uint32_t offset) {
	add_code_relocation(label, pgrm.code_size);
412
	store_code_elem(2, offset);
413 414
}

415
void store_code_label_value(char *label_name,int32_t offset) {
416
	struct label *label;
Camil Staps's avatar
Camil Staps committed
417

418 419
	label=enter_label(label_name);

420
	add_code_relocation(label, pgrm.code_size);
421

422
	store_code_elem(2, offset);
423 424
}

425 426 427 428 429 430 431 432
void store_code_label_value_with_flags (char *label_name,int32_t flags,int32_t offset)
{
	struct label *label=enter_label (label_name);
	struct relocation *relocation=add_code_relocation (label,pgrm.code_size);
	relocation->relocation_flags=flags;
	store_code_elem (2,offset);
}

433
static void store_data_label_value_of_label(struct label *label,uint32_t offset) {
434
	add_data_relocation(label, pgrm.data_size);
435 436 437
	store_data_l(offset);
}

438
void store_data_label_value(char *label_name,uint32_t offset) {
439 440 441 442 443 444
	store_data_label_value_of_label(enter_label (label_name),offset);
}

void add_data2_to_code(int i) {
	if (list_code)
		printf("%d\t.data2 %d\n",pgrm.code_size,i);
Camil Staps's avatar
Camil Staps committed
445

446
	store_code_elem(2, i);
447 448
}

449
void add_data8_to_code(int i) {
450
	if (list_code)
451
		printf("%d\t.data8 %d\n",pgrm.code_size,i);
Camil Staps's avatar
Camil Staps committed
452

Camil Staps's avatar
Camil Staps committed
453
	store_code_elem(8, i);
454 455
}

Camil Staps's avatar
Camil Staps committed
456
void add_instruction(int16_t i) {
457 458 459
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s\n",pgrm.code_size,instruction_name (i));

460
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
461 462 463 464
}

void add_code_and_data_offsets(void) {
	int i;
Camil Staps's avatar
Camil Staps committed
465
	size_t code_offset,data_offset;
Camil Staps's avatar
Camil Staps committed
466

Camil Staps's avatar
Camil Staps committed
467 468
	code_offset = (size_t) pgrm.code;
	data_offset = (size_t) pgrm.data;
469

470
	for(i=0; i<pgrm.code_reloc_size; ++i) {
471 472
		struct relocation *relocation_p;

Camil Staps's avatar
Camil Staps committed
473
		relocation_p=&pgrm.code_relocations[i];
474
		if ((relocation_p->relocation_label->label_offset & 1)==0)
Camil Staps's avatar
Camil Staps committed
475
			*(int32_t*)&pgrm.code[relocation_p->relocation_offset] += code_offset;
476
		else
Camil Staps's avatar
Camil Staps committed
477
			*(int32_t*)&pgrm.code[relocation_p->relocation_offset] += data_offset;
478 479
	}

480
	for(i=0; i<pgrm.data_reloc_size; ++i) {
481 482
		struct relocation *relocation_p;

Camil Staps's avatar
Camil Staps committed
483
		relocation_p=&pgrm.data_relocations[i];
484
		if ((relocation_p->relocation_label->label_offset & 1)==0)
Camil Staps's avatar
Camil Staps committed
485
			*(int32_t*)&pgrm.data[relocation_p->relocation_offset] += code_offset;
486
		else
Camil Staps's avatar
Camil Staps committed
487
			*(int32_t*)&pgrm.data[relocation_p->relocation_offset] += data_offset;
488 489 490
	}
}

Camil Staps's avatar
Camil Staps committed
491
void add_instruction_label(uint16_t i,char *label_name) {
492 493 494
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %s\n",pgrm.code_size,instruction_name (i),label_name);

495
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
496 497 498
	store_code_label_value(label_name,0);
}

499 500 501 502 503 504 505 506
void add_instruction_label_flags (uint16_t i,char *label_name,int32_t flags) {
	if (list_code || i>max_implemented_instruction_n)
		printf ("%d\t%s %s\n",pgrm.code_size,instruction_name (i),label_name);

	store_code_elem (BYTEWIDTH_INSTRUCTION,i);
	store_code_label_value_with_flags (label_name,flags,0);
}

Camil Staps's avatar
Camil Staps committed
507
void add_instruction_label_offset(uint16_t i,char *label_name,uint32_t offset) {
508 509 510
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %s%+d\n",pgrm.code_size,instruction_name (i),label_name,offset);

511
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
512 513 514
	store_code_label_value(label_name,offset);
}

Camil Staps's avatar
Camil Staps committed
515
void add_instruction_label_offset_label(int16_t i,char *label_name1,uint32_t offset,char *label_name2) {
516 517 518
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %s%+d %s\n",pgrm.code_size,instruction_name (i),label_name1,offset,label_name2);

519
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
520 521 522 523
	store_code_label_value(label_name1,offset);
	store_code_label_value(label_name2,0);
}

Camil Staps's avatar
Camil Staps committed
524
void add_instruction_label_offset_w(uint16_t i,char *label_name,uint32_t offset,int32_t n1) {
525 526 527
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %s%+d %d\n",pgrm.code_size,instruction_name (i),label_name,offset,(int)n1);

528
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
529
	store_code_label_value(label_name,offset);
530
	store_code_elem(2, n1);
531 532
}

Camil Staps's avatar
Camil Staps committed
533
void add_instruction_label_offset_w_label(uint16_t i,char *label_name1,uint32_t offset,int32_t n1,char *label_name2) {
534 535 536
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %s%+d %d %s\n",pgrm.code_size,instruction_name (i),label_name1,offset,(int)n1,label_name2);

537
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
538
	store_code_label_value(label_name1,offset);
539
	store_code_elem(2, n1);
540 541 542 543
	store_code_label_value(label_name2,0);
}

void add_instruction_label_offset_label_label_offset_label
Camil Staps's avatar
Camil Staps committed
544
	(int16_t i,char *label_name1,uint32_t offset1,char *label_name2,char *label_name3,uint32_t offset2,char *label_name4) {
545 546 547 548
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %s%+d %s %s%+d %s\n",pgrm.code_size,instruction_name (i),label_name1,offset1,label_name2,
																			label_name3,offset2,label_name4);

549
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
550 551 552 553 554 555
	store_code_label_value(label_name1,offset1);
	store_code_label_value(label_name2,0);
	store_code_label_value(label_name3,offset2);
	store_code_label_value(label_name4,0);
}

Camil Staps's avatar
Camil Staps committed
556
void add_instruction_label_w_w(int16_t i,char *label_name,int32_t n1,int32_t n2) {
557 558 559
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %s %d %d\n",pgrm.code_size,instruction_name (i),label_name,(int)n1,(int)n2);

560
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
561
	store_code_label_value(label_name,0);
562 563
	store_code_elem(2, n1);
	store_code_elem(2, n2);
564 565
}

Camil Staps's avatar
Camil Staps committed
566
void add_instruction_c(int16_t i,char n) {
567 568 569 570 571 572 573
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d\n",pgrm.code_size,instruction_name (i),(int)n);

	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(1, n);
}

574 575 576 577 578 579 580 581 582
void add_instruction_c_label(int16_t i,char n,char *label_name) {
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %s\n",pgrm.code_size,instruction_name (i),(int)n,label_name);

	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(1, n);
	store_code_label_value(label_name,0);
}

Camil Staps's avatar
Camil Staps committed
583
void add_instruction_w(int16_t i,int32_t n) {
584 585 586
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d\n",pgrm.code_size,instruction_name (i),(int)n);

587 588 589 590
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(2, n);
}

591
void add_instruction_w_i(int16_t i,int32_t n1,int64_t n2) {
592
	if (list_code || i>max_implemented_instruction_n)
593
		printf("%d\t%s %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2);
594

595
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
596
	store_code_elem(2, n1);
Camil Staps's avatar
Camil Staps committed
597
	store_code_elem(8, n2);
598 599
}

Camil Staps's avatar
Camil Staps committed
600
void add_instruction_w_label(int16_t i,int32_t n,char *label_name) {
601 602 603
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %s\n",pgrm.code_size,instruction_name (i),(int)n,label_name);

604 605 606 607 608
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(2, n);
	store_code_label_value(label_name,0);
}

Camil Staps's avatar
Camil Staps committed
609
void add_instruction_w_label_offset(int16_t i,int32_t n,char *label_name,uint32_t offset) {
610 611 612
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %s%+d\n",pgrm.code_size,instruction_name (i),(int)n,label_name,offset);

613
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
614
	store_code_elem(2, n);
615 616 617
	store_code_label_value(label_name,offset);
}

Camil Staps's avatar
Camil Staps committed
618
void add_instruction_w_label_offset_label(int16_t i,int32_t n,char *label_name1,uint32_t offset,char *label_name2) {
619 620 621
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %s%+d %s\n",pgrm.code_size,instruction_name (i),(int)n,label_name1,offset,label_name2);

622
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
623
	store_code_elem(2, n);
624 625 626 627
	store_code_label_value(label_name1,offset);
	store_code_label_value(label_name2,0);
}

Camil Staps's avatar
Camil Staps committed
628
void add_instruction_w_label_w(int16_t i,int32_t n1,char *label_name,int32_t n2) {
629 630 631
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %s %d\n",pgrm.code_size,instruction_name (i),(int)n1,label_name,(int)n2);

632
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
633
	store_code_elem(2, n1);
634
	store_code_label_value(label_name,0);
635
	store_code_elem(2, n2);
636 637 638
}

void add_instruction_w_label_offset_label_label_offset_label
Camil Staps's avatar
Camil Staps committed
639
	(int16_t i,int32_t n1,char *label_name1,uint32_t offset1,char *label_name2,char *label_name3,uint32_t offset2,char *label_name4) {
640 641 642 643
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %s%+d %s %s%+d %s\n",pgrm.code_size,instruction_name (i),n1,label_name1,offset1,label_name2,
																				  label_name3,offset2,label_name4);

644
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
645
	store_code_elem(2, n1);
646 647 648 649 650 651
	store_code_label_value(label_name1,offset1);
	store_code_label_value(label_name2,0);
	store_code_label_value(label_name3,offset2);
	store_code_label_value(label_name4,0);
}

Camil Staps's avatar
Camil Staps committed
652
void add_instruction_w_label_offset_w(int16_t i,int32_t n1,char *label_name,uint32_t offset,int32_t n2) {
653 654 655
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %s+%d %d\n",pgrm.code_size,instruction_name (i),(int)n1,label_name,offset,(int)n2);

656
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
657
	store_code_elem(2, n1);
658
	store_code_label_value(label_name,offset);
659
	store_code_elem(2, n2);
660 661
}

Camil Staps's avatar
Camil Staps committed
662
void add_instruction_w_label_offset_w_w(int16_t i,int32_t n1,char *label_name,uint32_t offset,int32_t n2,int32_t n3) {
663 664 665
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %s+%d %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,label_name,offset,(int)n2,(int)n3);

666
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
667
	store_code_elem(2, n1);
668
	store_code_label_value(label_name,offset);
669 670
	store_code_elem(2, n2);
	store_code_elem(2, n3);
671 672
}

Camil Staps's avatar
Camil Staps committed
673
void add_instruction_w_label_offset_w_w_w(int16_t i,int32_t n1,char *label_name,uint32_t offset,int32_t n2,int32_t n3,int32_t n4) {
674 675 676
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %s+%d %d %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,label_name,offset,(int)n2,(int)n3,(int)n4);

677
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
678
	store_code_elem(2, n1);
679
	store_code_label_value(label_name,offset);
680 681 682
	store_code_elem(2, n2);
	store_code_elem(2, n3);
	store_code_elem(2, n4);
683 684
}

Camil Staps's avatar
Camil Staps committed
685
void add_instruction_w_c(int16_t i,int32_t n1,char n2) {
686 687 688 689 690 691 692 693
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2);

	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(2, n1);
	store_code_elem(1, n2);
}

Camil Staps's avatar
Camil Staps committed
694
void add_instruction_w_w(int16_t i,int32_t n1,int32_t n2) {
695 696
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2);
Camil Staps's avatar
Camil Staps committed
697

698
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
699 700
	store_code_elem(2, n1);
	store_code_elem(2, n2);
701 702
}

703
void add_instruction_i_w(int16_t i,int64_t n1,int32_t n2) {
704 705
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2);
Camil Staps's avatar
Camil Staps committed
706

707 708 709 710 711
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(8, n1);
	store_code_elem(2, n2);
}

712 713 714 715 716 717 718 719 720
void add_instruction_i_label(int16_t i,int64_t n,char *label_name) {
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %s\n",pgrm.code_size,instruction_name (i),(int)n,label_name);

	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(8, n);
	store_code_label_value(label_name,0);
}

Camil Staps's avatar
Camil Staps committed
721
void add_instruction_w_c_label(int16_t i,int32_t n1,char n2,char *label_name) {
722 723 724 725 726 727 728 729 730
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name);

	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(2, n1);
	store_code_elem(1, n2);
	store_code_label_value(label_name,0);
}

Camil Staps's avatar
Camil Staps committed
731
void add_instruction_w_w_label(int16_t i,int32_t n1,int32_t n2,char *label_name) {
732 733
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name);
734 735 736 737

	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(2, n1);
	store_code_elem(2, n2);
738
	store_code_label_value(label_name,0);
739 740
}

741
void add_instruction_w_i_label(int16_t i,int32_t n1,int64_t n2,char *label_name) {
742 743 744
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name);

745
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
746
	store_code_elem(2, n1);
Camil Staps's avatar
Camil Staps committed
747
	store_code_elem(8, n2);
748 749 750
	store_code_label_value(label_name,0);
}

Camil Staps's avatar
Camil Staps committed
751
void add_instruction_w_w_label_offset(int32_t i,int32_t n1,int32_t n2,char *label_name,uint32_t offset) {
752 753 754
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s%+d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name,offset);

755
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
756 757
	store_code_elem(2, n1);
	store_code_elem(2, n2);
758 759 760
	store_code_label_value(label_name,offset);
}

Camil Staps's avatar
Camil Staps committed
761
void add_instruction_w_w_label_w(int16_t i,int32_t n1,int32_t n2,char *label_name,int32_t n3) {
762 763 764
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name,(int)n3);

765
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
766 767
	store_code_elem(2, n1);
	store_code_elem(2, n2);
768
	store_code_label_value(label_name,0);
769
	store_code_elem(2, n3);
770 771
}

Camil Staps's avatar
Camil Staps committed
772
void add_instruction_w_c_label_c_label(int16_t i,int32_t n1,char n2,char *label_name1,char n3,char *label_name2) {
773 774 775 776 777 778 779 780 781 782 783
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s %d %s\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name1,(int)n3,label_name2);

	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(2, n1);
	store_code_elem(1, n2);
	store_code_label_value(label_name1,0);
	store_code_elem(1, n3);
	store_code_label_value(label_name2,0);
}

Camil Staps's avatar
Camil Staps committed
784
void add_instruction_w_w_label_w_label(int16_t i,int32_t n1,int32_t n2,char *label_name1,int32_t n3,char *label_name2) {
785 786 787
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s %d %s\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name1,(int)n3,label_name2);

788
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
789 790
	store_code_elem(2, n1);
	store_code_elem(2, n2);
791
	store_code_label_value(label_name1,0);
792
	store_code_elem(2, n3);
793 794 795
	store_code_label_value(label_name2,0);
}

796
void add_instruction_w_i_label_i_label(int16_t i,int32_t n1,int64_t n2,char *label_name1,int64_t n3,char *label_name2) {
797 798 799 800 801 802 803 804 805 806 807
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s %d %s\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name1,(int)n3,label_name2);

	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(2, n1);
	store_code_elem(8, n2);
	store_code_label_value(label_name1,0);
	store_code_elem(8, n3);
	store_code_label_value(label_name2,0);
}

Camil Staps's avatar
Camil Staps committed
808
void add_instruction_w_w_label_offset_w(int16_t i,int32_t n1,int32_t n2,char *label_name,uint32_t offset,int32_t n3) {
809 810 811
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s+%d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name,offset,(int)n3);

812
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
813 814
	store_code_elem(2, n1);
	store_code_elem(2, n2);
815
	store_code_label_value(label_name,offset);
816
	store_code_elem(2, n3);
817 818
}

Camil Staps's avatar
Camil Staps committed
819
void add_instruction_w_w_label_w_w(int16_t i,int32_t n1,int32_t n2,char *label_name,int32_t n3,int32_t n4) {
820 821 822
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name,(int)n3,(int)n4);

823
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
824 825
	store_code_elem(2, n1);
	store_code_elem(2, n2);
826
	store_code_label_value(label_name,0);
827 828
	store_code_elem(2, n3);
	store_code_elem(2, n4);
829 830
}

Camil Staps's avatar
Camil Staps committed
831
void add_instruction_w_w_label_offset_w_w(int16_t i,int32_t n1,int32_t n2,char *label_name,uint32_t offset,int32_t n3,int32_t n4) {
832 833 834
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s+%d %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name,offset,(int)n3,(int)n4);

835
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
836 837
	store_code_elem(2, n1);
	store_code_elem(2, n2);
838
	store_code_label_value(label_name,offset);
839 840
	store_code_elem(2, n3);
	store_code_elem(2, n4);
841 842
}

Camil Staps's avatar
Camil Staps committed
843
void add_instruction_w_w_w(int16_t i,int32_t n1,int32_t n2,int32_t n3) {
844 845 846
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,(int)n3);

847
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
848 849 850
	store_code_elem(2, n1);
	store_code_elem(2, n2);
	store_code_elem(2, n3);
851 852
}

Camil Staps's avatar
Camil Staps committed
853
void add_instruction_w_w_w_label(int16_t i,int32_t n1,int32_t n2,int32_t n3,char *label_name) {
854 855 856
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %d %s\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,(int)n3,label_name);

857
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
858 859 860
	store_code_elem(2, n1);
	store_code_elem(2, n2);
	store_code_elem(2, n3);
861 862 863
	store_code_label_value(label_name,0);
}

Camil Staps's avatar
Camil Staps committed
864
void add_instruction_w_w_w_label_offset(int16_t i,int32_t n1,int32_t n2,int32_t n3,char *label_name,uint32_t offset) {
865 866 867
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %d %s+%d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,(int)n3,label_name,offset);

868
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
869 870 871
	store_code_elem(2, n1);
	store_code_elem(2, n2);
	store_code_elem(2, n3);
872 873 874
	store_code_label_value(label_name,offset);
}

Camil Staps's avatar
Camil Staps committed
875
void add_instruction_w_w_w_label_w(int16_t i,int32_t n1,int32_t n2,int32_t n3,char *label_name,int32_t n4) {
876 877 878
	if (list_code || i>max_implemented_instruction_n)
		printf("\t%s %d %d %d %s %d\n",instruction_name (i),(int)n1,(int)n2,(int)n3,label_name,(int)n4);

879
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
880 881 882
	store_code_elem(2, n1);
	store_code_elem(2, n2);
	store_code_elem(2, n3);
883
	store_code_label_value(label_name,0);
884
	store_code_elem(2, n4);
885 886
}

Camil Staps's avatar
Camil Staps committed
887
void add_instruction_w_w_w_label_offset_w(int16_t i,int32_t n1,int32_t n2,int32_t n3,char *label_name,uint32_t offset,int32_t n4) {
888 889 890
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %d %s+%d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,(int)n3,label_name,offset,(int)n4);

891
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
892 893 894
	store_code_elem(2, n1);
	store_code_elem(2, n2);
	store_code_elem(2, n3);
895
	store_code_label_value(label_name,offset);
896
	store_code_elem(2, n4);
897 898
}

Camil Staps's avatar
Camil Staps committed
899
void add_instruction_w_w_w_label_w_w(int16_t i,int32_t n1,int32_t n2,int32_t n3,char *label_name,int32_t n4,int32_t n5) {
900 901 902
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %d %s %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,(int)n3,label_name,(int)n4,(int)n5);

903
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
904 905 906
	store_code_elem(2, n1);
	store_code_elem(2, n2);
	store_code_elem(2, n3);
907
	store_code_label_value(label_name,0);
908 909
	store_code_elem(2, n4);
	store_code_elem(2, n5);
910 911
}

Camil Staps's avatar
Camil Staps committed
912
void add_instruction_w_w_w_label_offset_w_w(int16_t i,int32_t n1,int32_t n2,int32_t n3,char *label_name,uint32_t offset,int32_t n4,int32_t n5) {
913 914 915
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %d %s+%d %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,(int)n3,label_name,offset,(int)n4,(int)n5);

916
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
917 918 919
	store_code_elem(2, n1);
	store_code_elem(2, n2);
	store_code_elem(2, n3);
920
	store_code_label_value(label_name,offset);
921 922
	store_code_elem(2, n4);
	store_code_elem(2, n5);
923 924
}

Camil Staps's avatar
Camil Staps committed
925
void add_instruction_w_w_w_w(int16_t i,int32_t n1,int32_t n2,int32_t n3,int32_t n4) {
926 927 928
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,(int)n3,(int)n4);

929
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
930 931 932 933
	store_code_elem(2, n1);
	store_code_elem(2, n2);
	store_code_elem(2, n3);
	store_code_elem(2, n4);
934 935
}

Camil Staps's avatar
Camil Staps committed
936
void add_instruction_w_w_w_w_w(int16_t i,int32_t n1,int32_t n2,int32_t n3,int32_t n4,int32_t n5) {
937 938 939
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %d %d %d\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,(int)n3,(int)n4,(int)n5);

940
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
941 942 943 944 945
	store_code_elem(2, n1);
	store_code_elem(2, n2);
	store_code_elem(2, n3);
	store_code_elem(2, n4);
	store_code_elem(2, n5);
946 947
}

948
void add_instruction_i(int16_t i,int64_t n) {
949
	if (list_code || i>max_implemented_instruction_n)
950
		printf("%d\t%s %d\n",pgrm.code_size,instruction_name (i),(int)n);
951

952
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
Camil Staps's avatar
Camil Staps committed
953
	store_code_elem(8, n);
954 955
}

Camil Staps's avatar
Camil Staps committed
956
void add_instruction_r(int16_t i,double r) {
957 958 959 960
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %f\n",pgrm.code_size,instruction_name (i),r);

	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
961 962 963 964 965 966
	if (is_32_bit){
		store_code_elem (4,((uint32_t*)&r)[0]);
		store_code_elem (4,((uint32_t*)&r)[1]);
	} else {
		store_code_elem (8,*(uint64_t*)&r);
	}
967 968
}

969 970 971 972 973 974
void add_instruction_w_r(int16_t i,int32_t n,double r) {
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %f\n",pgrm.code_size,instruction_name (i),r);

	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_elem(2, n);
975 976 977 978 979 980
	if (is_32_bit){
		store_code_elem (4,((uint32_t*)&r)[0]);
		store_code_elem (4,((uint32_t*)&r)[1]);
	} else {
		store_code_elem (8,*(uint64_t*)&r);
	}
981 982
}

Camil Staps's avatar
Camil Staps committed
983
void add_instruction_internal_label(int16_t i,struct label *label) {
984 985 986
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d\n",pgrm.code_size,instruction_name (i),label->label_offset);

987
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
988 989 990
	store_code_internal_label_value(label,0);
}

991 992 993 994 995 996 997 998 999
void add_instruction_internal_label_internal_label(int16_t i,struct label *label1,struct label *label2) {
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d\n",pgrm.code_size,instruction_name (i),label1->label_offset,label2->label_offset);

	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
	store_code_internal_label_value(label1,0);
	store_code_internal_label_value(label2,0);
}

Camil Staps's avatar
Camil Staps committed
1000
void add_instruction_w_internal_label_label(int16_t i,int32_t n1,struct label *label,char *label_name) {
1001 1002 1003
	if (list_code || i>max_implemented_instruction_n)
		printf("%d\t%s %d %d %s\n",pgrm.code_size,instruction_name (i),n1,label->label_offset,label_name);

1004
	store_code_elem(BYTEWIDTH_INSTRUCTION, i);
1005
	store_code_elem(2, n1);
1006 1007 1008 1009
	store_code_internal_label_value(label,0);
	store_code_label_value(label_name,0);
}

1010 1011 1012 1013 1014
struct word *add_add_arg_labels(void) {
	int i;

	for(i=0; i<N_ADD_ARG_LABELS; ++i)
		if (Fadd_arg_label_used[i]) {
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025
			if (i>0) {
				/* Three instructions above add_arg is the code used for fast
				 * applies of constructors. build_node returns; notB is not used. */
				if (i==1) {
					add_instruction(Cbuild_node2_rtn);
					add_instruction(CnotB);
				} else {
					add_instruction_w(Cbuild_node_rtn,i-1);
				}
				add_instruction(CnotB);
			}
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049
			char label_name[11];
			sprintf(label_name,"_add_arg%d",i);
			struct label *label = enter_label(label_name);
			if (label->label_module_n != -1) {
				make_label_global(label);
				label->label_offset = pgrm.code_size<<2;
			}
			add_instruction(Cadd_arg0+i);
		}

	if (general_add_arg_label_used) {
		fprintf<