1987-11-20 11:12:07 +00:00
|
|
|
#include "decl.h"
|
|
|
|
#include <alloc.h>
|
1987-11-25 14:41:10 +00:00
|
|
|
|
|
|
|
/* This file contains some routines needed in "pars.g" to handle the action-
|
|
|
|
* grammarrule. The assembler-instructions are handeld in blocks rather than
|
|
|
|
* one at a time. So these routines provide saving and removing of assembler-
|
|
|
|
* instructions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
char **as_instructions; /* The buffer(?) where the instructions are saved */
|
|
|
|
|
|
|
|
int quantum = 0, /* Max. nr. of instructions in as_instructions[] */
|
|
|
|
nr_instr, /* Number of saved instructions */
|
|
|
|
first_action, /* Is this block of assembler-instr. the first after
|
1989-01-26 14:43:09 +00:00
|
|
|
* a '==>'?
|
1987-11-25 14:41:10 +00:00
|
|
|
*/
|
|
|
|
last_action; /* Is this block followed by a '.' ? */
|
|
|
|
|
1987-11-20 11:12:07 +00:00
|
|
|
|
|
|
|
init_as_block()
|
|
|
|
{
|
|
|
|
nr_instr = 0;
|
|
|
|
|
|
|
|
if ( quantum == 0) {
|
|
|
|
quantum = 16;
|
1988-10-20 12:55:02 +00:00
|
|
|
as_instructions = (char **)Malloc( quantum*sizeof( char *));
|
1987-11-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
save_as( instr)
|
|
|
|
char *instr;
|
1987-11-25 14:41:10 +00:00
|
|
|
|
|
|
|
/* Save a copy of 'instr'
|
|
|
|
*/
|
1987-11-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
if ( nr_instr == quantum) {
|
|
|
|
quantum *= 2;
|
1988-10-20 12:55:02 +00:00
|
|
|
as_instructions = (char **) Realloc( as_instructions,
|
1987-11-20 11:12:07 +00:00
|
|
|
quantum*sizeof( char *));
|
|
|
|
}
|
|
|
|
|
|
|
|
as_instructions[nr_instr++] = Salloc( instr, strlen( instr) + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
do_block_assemble()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
1987-11-25 14:41:10 +00:00
|
|
|
if ( nr_instr > 0) {
|
1987-11-20 11:12:07 +00:00
|
|
|
block_assemble( as_instructions, nr_instr,
|
|
|
|
first_action, last_action);
|
|
|
|
|
|
|
|
for ( i=0; i<nr_instr; i++)
|
|
|
|
free( as_instructions[i]);
|
|
|
|
}
|
|
|
|
}
|