Update smallc.
This commit is contained in:
@@ -111,7 +111,7 @@ int __void__;
|
||||
/*
|
||||
* mv functions
|
||||
*/
|
||||
#define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
|
||||
#define mvwaddch(win,y,x,ch) (wmove(win,y,x) == ERR ? ERR : waddch(win,ch))
|
||||
#define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
|
||||
#define mvwaddstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
|
||||
#define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/*
|
||||
* Print all assembler info before any code is generated.
|
||||
*/
|
||||
header()
|
||||
void header()
|
||||
{
|
||||
output_string ("#\tSmall C for MIPS32\n");
|
||||
output_string ("#\tRetroBSD Project\n");
|
||||
@@ -41,12 +41,13 @@ header()
|
||||
//output_line ("global\tTmod");
|
||||
}
|
||||
|
||||
void
|
||||
newline()
|
||||
{
|
||||
output_byte ('\n');
|
||||
}
|
||||
|
||||
galign(t)
|
||||
int galign(t)
|
||||
int t;
|
||||
{
|
||||
int sign;
|
||||
@@ -63,7 +64,7 @@ galign(t)
|
||||
/*
|
||||
* Return size of an integer.
|
||||
*/
|
||||
intsize()
|
||||
int intsize()
|
||||
{
|
||||
return INTSIZE;
|
||||
}
|
||||
@@ -72,7 +73,7 @@ intsize()
|
||||
* Return offset of ls byte within word.
|
||||
* (ie: 8080 & pdp11 is 0, 6809 is 1, 360 is 3)
|
||||
*/
|
||||
byteoff()
|
||||
int byteoff()
|
||||
{
|
||||
return BYTEOFF;
|
||||
}
|
||||
@@ -103,14 +104,14 @@ void gen_comment() {
|
||||
/*
|
||||
* Print any assembler stuff needed after all code.
|
||||
*/
|
||||
trailer()
|
||||
void trailer()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Function prologue.
|
||||
*/
|
||||
fentry(int argtop)
|
||||
void fentry(int argtop)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -127,7 +128,7 @@ fentry(int argtop)
|
||||
/*
|
||||
* Text (code) segment.
|
||||
*/
|
||||
code_segment_gtext()
|
||||
void code_segment_gtext()
|
||||
{
|
||||
output_line (".text");
|
||||
}
|
||||
@@ -135,7 +136,7 @@ code_segment_gtext()
|
||||
/*
|
||||
* Data segment.
|
||||
*/
|
||||
data_segment_gdata()
|
||||
void data_segment_gdata()
|
||||
{
|
||||
output_line (".data");
|
||||
}
|
||||
@@ -143,8 +144,7 @@ data_segment_gdata()
|
||||
char *inclib() {
|
||||
#ifdef cpm
|
||||
return("B:");
|
||||
#endif
|
||||
#ifdef unix
|
||||
#else
|
||||
#ifdef INCDIR
|
||||
return(INCDIR);
|
||||
#else
|
||||
@@ -152,6 +152,7 @@ char *inclib() {
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Output the variable symbol at scptr as an extrn or a public.
|
||||
*/
|
||||
@@ -160,7 +161,7 @@ void ppubext (symbol_t *scptr)
|
||||
if( scptr->storage == STATIC )
|
||||
return;
|
||||
output_string ("\t.globl\t");
|
||||
output_string (scptr);
|
||||
output_string ((char*)scptr);
|
||||
newline();
|
||||
}
|
||||
|
||||
@@ -214,6 +215,7 @@ int gen_get_location(symbol_t *sym)
|
||||
output_number (sym->offset - stkp);
|
||||
newline();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -266,7 +268,7 @@ void gen_get_indirect(char typeobj, int reg)
|
||||
/*
|
||||
* Swap the primary and secondary registers.
|
||||
*/
|
||||
gen_swap()
|
||||
void gen_swap()
|
||||
{
|
||||
output_line ("move\t$at, $v0\n\tmove\t$v0, $v1\n\tmove\t$v1, $at");
|
||||
}
|
||||
@@ -275,12 +277,12 @@ gen_swap()
|
||||
* Print partial instruction to get an immediate value into
|
||||
* the primary register.
|
||||
*/
|
||||
gen_immediate_a()
|
||||
void gen_immediate_a()
|
||||
{
|
||||
output_string ("\tla\t$v0, ");
|
||||
}
|
||||
|
||||
gen_immediate_c()
|
||||
void gen_immediate_c()
|
||||
{
|
||||
output_string ("\tli\t$v0, ");
|
||||
}
|
||||
@@ -288,7 +290,7 @@ gen_immediate_c()
|
||||
/*
|
||||
* Push the primary register onto the stack.
|
||||
*/
|
||||
gen_push()
|
||||
void gen_push(int ignored)
|
||||
{
|
||||
output_line ("addiu\t$sp, -4");
|
||||
output_line ("sw\t$v0, 16($sp)");
|
||||
@@ -298,7 +300,7 @@ gen_push()
|
||||
/*
|
||||
* Pop the top of the stack into the secondary register.
|
||||
*/
|
||||
gen_pop()
|
||||
void gen_pop()
|
||||
{
|
||||
output_line ("lw\t$v1, 16($sp)");
|
||||
output_line ("addiu\t$sp, 4");
|
||||
@@ -308,7 +310,7 @@ gen_pop()
|
||||
/*
|
||||
* Swap the primary register and the top of the stack.
|
||||
*/
|
||||
gen_swap_stack()
|
||||
void gen_swap_stack()
|
||||
{
|
||||
output_line ("move\t$t1, $v0");
|
||||
output_line ("lw\t$v0, 16($sp)");
|
||||
@@ -318,7 +320,7 @@ gen_swap_stack()
|
||||
/*
|
||||
* Call the specified subroutine name.
|
||||
*/
|
||||
gen_call (char * sname)
|
||||
void gen_call (char * sname)
|
||||
{
|
||||
output_string ("\tjal\t");
|
||||
if (*sname == '^') {
|
||||
@@ -333,7 +335,7 @@ gen_call (char * sname)
|
||||
/*
|
||||
* Return from subroutine.
|
||||
*/
|
||||
gen_ret()
|
||||
void gen_ret()
|
||||
{
|
||||
output_line("lw\t$ra, 16($sp)");
|
||||
output_line("jr\t$ra");
|
||||
@@ -343,7 +345,7 @@ gen_ret()
|
||||
/*
|
||||
* Perform subroutine call to value on top of stack.
|
||||
*/
|
||||
callstk()
|
||||
void callstk()
|
||||
{
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
output_line("jr\t$t1");
|
||||
@@ -354,7 +356,7 @@ callstk()
|
||||
/*
|
||||
* Jump to specified internal label number.
|
||||
*/
|
||||
gen_jump (int label)
|
||||
void gen_jump (int label)
|
||||
{
|
||||
output_string ("\tj\t");
|
||||
print_label (label);
|
||||
@@ -365,7 +367,7 @@ gen_jump (int label)
|
||||
/*
|
||||
* Test the primary register and jump if false to label.
|
||||
*/
|
||||
gen_test_jump (int label, int ft)
|
||||
void gen_test_jump (int label, int ft)
|
||||
{
|
||||
if (ft)
|
||||
output_string("\tbne\t$v0, $zero, ");
|
||||
@@ -379,7 +381,7 @@ gen_test_jump (int label, int ft)
|
||||
/*
|
||||
* Print pseudo-op to define a byte.
|
||||
*/
|
||||
gen_def_byte()
|
||||
void gen_def_byte()
|
||||
{
|
||||
output_string ("\t.byte\t");
|
||||
}
|
||||
@@ -387,7 +389,7 @@ gen_def_byte()
|
||||
/*
|
||||
* Print pseudo-op to define storage.
|
||||
*/
|
||||
gen_def_storage()
|
||||
void gen_def_storage()
|
||||
{
|
||||
output_string ("\t.space\t");
|
||||
}
|
||||
@@ -395,7 +397,7 @@ gen_def_storage()
|
||||
/*
|
||||
* Print pseudo-op to define a word.
|
||||
*/
|
||||
gen_def_word()
|
||||
void gen_def_word()
|
||||
{
|
||||
output_string ("\t.word\t");
|
||||
}
|
||||
@@ -403,7 +405,7 @@ gen_def_word()
|
||||
/*
|
||||
* Generate alignment to a word boundary.
|
||||
*/
|
||||
gen_align_word()
|
||||
void gen_align_word()
|
||||
{
|
||||
output_string ("\t.align\t2\n");
|
||||
}
|
||||
@@ -411,7 +413,7 @@ gen_align_word()
|
||||
/*
|
||||
* Modify the stack pointer to the new value indicated.
|
||||
*/
|
||||
gen_modify_stack (int newstkp)
|
||||
int gen_modify_stack (int newstkp)
|
||||
{
|
||||
int k;
|
||||
|
||||
@@ -429,7 +431,7 @@ gen_modify_stack (int newstkp)
|
||||
/*
|
||||
* Multiply the primary register by INTSIZE.
|
||||
*/
|
||||
gen_multiply_by_two()
|
||||
void gen_multiply_by_two()
|
||||
{
|
||||
output_line ("sll\t$v0, 2");
|
||||
}
|
||||
@@ -437,7 +439,7 @@ gen_multiply_by_two()
|
||||
/*
|
||||
* Divide the primary register by INTSIZE.
|
||||
*/
|
||||
gen_divide_by_two()
|
||||
void gen_divide_by_two()
|
||||
{
|
||||
output_line ("sra\t$v0, 2");
|
||||
}
|
||||
@@ -445,7 +447,7 @@ gen_divide_by_two()
|
||||
/*
|
||||
* Case jump instruction.
|
||||
*/
|
||||
gen_jump_case()
|
||||
void gen_jump_case()
|
||||
{
|
||||
gen_call("^case");
|
||||
}
|
||||
@@ -454,7 +456,7 @@ gen_jump_case()
|
||||
* Add the primary and secondary registers.
|
||||
* If lval2 is int pointer and lval is int, scale lval.
|
||||
*/
|
||||
gen_add (int *lval, int *lval2)
|
||||
void gen_add (lvalue_t *lval, lvalue_t *lval2)
|
||||
{
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
output_line ("addiu\t$sp, 4");
|
||||
@@ -468,7 +470,7 @@ gen_add (int *lval, int *lval2)
|
||||
/*
|
||||
* Subtract the primary register from the secondary. // *** from TOS
|
||||
*/
|
||||
gen_sub()
|
||||
void gen_sub()
|
||||
{
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
output_line ("addiu\t$sp, 4");
|
||||
@@ -480,7 +482,7 @@ gen_sub()
|
||||
* Multiply the primary and secondary registers.
|
||||
* (result in primary)
|
||||
*/
|
||||
gen_mult()
|
||||
void gen_mult()
|
||||
{
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
output_line ("addiu\t$sp, 4");
|
||||
@@ -494,7 +496,7 @@ gen_mult()
|
||||
* Divide the secondary register by the primary.
|
||||
* (quotient in primary, remainder in secondary)
|
||||
*/
|
||||
gen_div()
|
||||
void gen_div()
|
||||
{
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
output_line ("addiu\t$sp, 4");
|
||||
@@ -505,7 +507,7 @@ gen_div()
|
||||
stkp = stkp + INTSIZE;
|
||||
}
|
||||
|
||||
gen_udiv()
|
||||
void gen_udiv()
|
||||
{
|
||||
output_line ("#FIXME genudiv");
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
@@ -522,7 +524,7 @@ gen_udiv()
|
||||
* divided by the primary register.
|
||||
* (remainder in primary, quotient in secondary)
|
||||
*/
|
||||
gen_mod()
|
||||
void gen_mod()
|
||||
{
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
output_line ("addiu\t$sp, 4");
|
||||
@@ -533,7 +535,7 @@ gen_mod()
|
||||
stkp = stkp + INTSIZE;
|
||||
}
|
||||
|
||||
gen_umod()
|
||||
void gen_umod()
|
||||
{
|
||||
output_line ("#FIXME genumod");
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
@@ -548,7 +550,7 @@ gen_umod()
|
||||
/*
|
||||
* Inclusive 'or' the primary and secondary registers.
|
||||
*/
|
||||
gen_or()
|
||||
void gen_or()
|
||||
{
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
output_line ("addiu\t$sp, 4");
|
||||
@@ -560,7 +562,7 @@ gen_or()
|
||||
/*
|
||||
* Exclusive 'or' the primary and secondary registers.
|
||||
*/
|
||||
gen_xor()
|
||||
void gen_xor()
|
||||
{
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
output_line ("addiu\t$sp, 4");
|
||||
@@ -573,7 +575,7 @@ gen_xor()
|
||||
/*
|
||||
* 'And' the primary and secondary registers.
|
||||
*/
|
||||
gen_and()
|
||||
void gen_and()
|
||||
{
|
||||
//output_line ("and.l\t(%sp)+,%d0");
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
@@ -587,7 +589,7 @@ gen_and()
|
||||
* times in the primary register.
|
||||
* (results in primary register)
|
||||
*/
|
||||
gen_arithm_shift_right()
|
||||
void gen_arithm_shift_right()
|
||||
{
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
output_line ("addiu\t$sp, 4");
|
||||
@@ -600,7 +602,7 @@ gen_arithm_shift_right()
|
||||
* times in the primary register.
|
||||
* (results in primary register)
|
||||
*/
|
||||
gen_arithm_shift_left()
|
||||
void gen_arithm_shift_left()
|
||||
{
|
||||
output_line ("lw\t$t1, 16($sp)");
|
||||
output_line ("addiu\t$sp, 4");
|
||||
@@ -611,7 +613,7 @@ gen_arithm_shift_left()
|
||||
/*
|
||||
* Two's complement of primary register.
|
||||
*/
|
||||
gen_twos_complement()
|
||||
void gen_twos_complement()
|
||||
{
|
||||
output_line ("sub\t$v0, $zero, $v0");
|
||||
}
|
||||
@@ -619,7 +621,7 @@ gen_twos_complement()
|
||||
/*
|
||||
* Logical complement of primary register.
|
||||
*/
|
||||
gen_logical_negation()
|
||||
void gen_logical_negation()
|
||||
{
|
||||
//gcall ("^lneg");
|
||||
output_line ("sltu\t$t1, $v0, $zero");
|
||||
@@ -631,7 +633,7 @@ gen_logical_negation()
|
||||
/*
|
||||
* One's complement of primary register.
|
||||
*/
|
||||
gen_complement()
|
||||
void gen_complement()
|
||||
{
|
||||
output_line ("addiu\t$t1, $zero, -1");
|
||||
output_line ("xor\t$v0, $t1");
|
||||
@@ -640,7 +642,7 @@ gen_complement()
|
||||
/*
|
||||
* Convert primary register into logical value.
|
||||
*/
|
||||
gen_convert_primary_reg_value_to_bool()
|
||||
void gen_convert_primary_reg_value_to_bool()
|
||||
{
|
||||
output_line ("sltu\t$t1, $v0, $zero");
|
||||
output_line ("sltu\t$t2, $zero, $v0");
|
||||
@@ -651,7 +653,7 @@ gen_convert_primary_reg_value_to_bool()
|
||||
/*
|
||||
* Increment the primary register by 1 if char, INTSIZE if int.
|
||||
*/
|
||||
gen_increment_primary_reg (lvalue_t *lval)
|
||||
void gen_increment_primary_reg (lvalue_t *lval)
|
||||
{
|
||||
if (lval->ptr_type & CINT)
|
||||
output_line("addiu\t$v0, 4");
|
||||
@@ -662,7 +664,7 @@ gen_increment_primary_reg (lvalue_t *lval)
|
||||
/*
|
||||
* Decrement the primary register by one if char, INTSIZE if int.
|
||||
*/
|
||||
gen_decrement_primary_reg (lvalue_t *lval)
|
||||
void gen_decrement_primary_reg (lvalue_t *lval)
|
||||
{
|
||||
if (lval->ptr_type & CINT)
|
||||
output_line("addiu\t$v0, -4");
|
||||
@@ -680,7 +682,7 @@ gen_decrement_primary_reg (lvalue_t *lval)
|
||||
/*
|
||||
* equal
|
||||
*/
|
||||
gen_equal()
|
||||
void gen_equal()
|
||||
{
|
||||
output_line("lw\t$t1, 16($sp)");
|
||||
output_line("sltu\t$t2, $v0, $t1");
|
||||
@@ -695,7 +697,7 @@ gen_equal()
|
||||
/*
|
||||
* not equal
|
||||
*/
|
||||
gen_not_equal()
|
||||
void gen_not_equal()
|
||||
{
|
||||
output_line("lw\t$t1, 16($sp)");
|
||||
output_line("sltu\t$t2, $v0, $t1");
|
||||
@@ -709,7 +711,7 @@ gen_not_equal()
|
||||
/*
|
||||
* less than (signed) - TOS < primary
|
||||
*/
|
||||
gen_less_than()
|
||||
void gen_less_than()
|
||||
{
|
||||
output_line("lw\t$t1, 16($sp)");
|
||||
output_line("addiu\t$sp, 4");
|
||||
@@ -721,7 +723,7 @@ gen_less_than()
|
||||
/*
|
||||
* less than or equal (signed) TOS <= primary
|
||||
*/
|
||||
gen_less_or_equal()
|
||||
void gen_less_or_equal()
|
||||
{
|
||||
output_line("lw\t$t1, 16($sp)");
|
||||
output_line("addiu\t$sp, 4");
|
||||
@@ -734,7 +736,7 @@ gen_less_or_equal()
|
||||
/*
|
||||
* greater than (signed) TOS > primary
|
||||
*/
|
||||
gen_greater_than()
|
||||
void gen_greater_than()
|
||||
{
|
||||
output_line("lw\t$t1, 16($sp)");
|
||||
output_line("addiu\t$sp, 4");
|
||||
@@ -747,7 +749,7 @@ gen_greater_than()
|
||||
/*
|
||||
* greater than or equal (signed) TOS >= primary
|
||||
*/
|
||||
gen_greater_or_equal()
|
||||
void gen_greater_or_equal()
|
||||
{
|
||||
output_line("lw\t$t1, 16($sp)");
|
||||
output_line("addiu\t$sp, 4");
|
||||
@@ -760,7 +762,7 @@ gen_greater_or_equal()
|
||||
/*
|
||||
* less than (unsigned)
|
||||
*/
|
||||
gen_unsigned_less_than()
|
||||
void gen_unsigned_less_than()
|
||||
{
|
||||
output_line("lw\t$t1, 16($sp)");
|
||||
output_line("addiu\t$sp, 4");
|
||||
@@ -772,7 +774,7 @@ gen_unsigned_less_than()
|
||||
/*
|
||||
* less than or equal (unsigned)
|
||||
*/
|
||||
gen_unsigned_less_or_equal()
|
||||
void gen_unsigned_less_or_equal()
|
||||
{
|
||||
output_line("lw\t$t1, 16($sp)");
|
||||
output_line("addiu\t$sp, 4");
|
||||
@@ -785,7 +787,7 @@ gen_unsigned_less_or_equal()
|
||||
/*
|
||||
* greater than (unsigned)
|
||||
*/
|
||||
gen_usigned_greater_than()
|
||||
void gen_usigned_greater_than()
|
||||
{
|
||||
output_line("lw\t$t1, 16($sp)");
|
||||
output_line("addiu\t$sp, 4");
|
||||
@@ -797,7 +799,7 @@ gen_usigned_greater_than()
|
||||
/*
|
||||
* greater than or equal (unsigned)
|
||||
*/
|
||||
gen_unsigned_greater_or_equal()
|
||||
void gen_unsigned_greater_or_equal()
|
||||
{
|
||||
output_line("lw\t$t1, 16($sp)");
|
||||
output_line("addiu\t$sp, 4");
|
||||
@@ -810,7 +812,7 @@ gen_unsigned_greater_or_equal()
|
||||
/*
|
||||
* Put first 4 arguments to registers a0-a3.
|
||||
*/
|
||||
gnargs (nargs)
|
||||
void gnargs (nargs)
|
||||
int nargs;
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -259,4 +259,129 @@ int get_item_at(char *symbol_name, int position);
|
||||
/**
|
||||
* push the primary register onto the stack
|
||||
*/
|
||||
//void gen_push();
|
||||
void gen_push(int reg);
|
||||
|
||||
void gen_comment(void);
|
||||
void output_string(char ptr[]);
|
||||
void newline(void);
|
||||
void print_tab(void);
|
||||
int output_byte(char c);
|
||||
int hier1(lvalue_t *lval);
|
||||
int hier1a(lvalue_t *lval);
|
||||
int hier1b(lvalue_t *lval);
|
||||
int hier1c(lvalue_t *lval);
|
||||
int hier2(lvalue_t *lval);
|
||||
int hier3(lvalue_t *lval);
|
||||
int hier4(lvalue_t *lval);
|
||||
int hier5(lvalue_t *lval);
|
||||
int hier6(lvalue_t *lval);
|
||||
int hier7(lvalue_t *lval);
|
||||
int hier8(lvalue_t *lval);
|
||||
int hier9(lvalue_t *lval);
|
||||
int hier10(lvalue_t *lval);
|
||||
int hier11(lvalue_t *lval);
|
||||
int rvalue(lvalue_t *lval, int reg);
|
||||
int match(char *lit);
|
||||
int amatch(char *lit, int len);
|
||||
void needlval(void);
|
||||
void store(lvalue_t *lval);
|
||||
int ch(void);
|
||||
int gch(void);
|
||||
int dbltest(lvalue_t *val1, lvalue_t *val2);
|
||||
void gen_multiply_by_two(void);
|
||||
void gen_sub(void);
|
||||
void result(lvalue_t *lval, lvalue_t *lval2);
|
||||
void gen_add(lvalue_t *lval, lvalue_t *lval2);
|
||||
void gen_mult(void);
|
||||
void gen_udiv(void);
|
||||
void gen_div(void);
|
||||
void gen_mod(void);
|
||||
void gen_umod(void);
|
||||
void gen_arithm_shift_right(void);
|
||||
void gen_arithm_shift_left(void);
|
||||
void gen_and(void);
|
||||
void gen_or(void);
|
||||
void gen_xor(void);
|
||||
void blanks(void);
|
||||
void gen_test_jump(int label, int ft);
|
||||
int getlabel(void);
|
||||
void gen_jump(int label);
|
||||
void print_label(int label);
|
||||
void output_label_terminator(void);
|
||||
void error(char ptr[]);
|
||||
int streq(char str1[], char str2[]);
|
||||
int sstreq( char *str1);
|
||||
void gen_convert_primary_reg_value_to_bool();
|
||||
int nch(void);
|
||||
int inbyte(void);
|
||||
void gen_equal(void);
|
||||
void gen_not_equal(void);
|
||||
void gen_less_or_equal(void);
|
||||
void gen_unsigned_less_or_equal(void);
|
||||
void gen_greater_or_equal(void);
|
||||
void gen_unsigned_greater_or_equal(void);
|
||||
void gen_less_than(void);
|
||||
void gen_unsigned_less_than(void);
|
||||
void gen_greater_than(void);
|
||||
void gen_usigned_greater_than(void);
|
||||
void gen_divide_by_two();
|
||||
void gen_increment_primary_reg(lvalue_t *lval);
|
||||
void gen_decrement_primary_reg (lvalue_t *lval);
|
||||
void gen_twos_complement(void);
|
||||
void gen_complement(void);
|
||||
void gen_logical_negation(void);
|
||||
void gen_immediate_a(void);
|
||||
void gen_immediate_c(void);
|
||||
int primary(lvalue_t *lval);
|
||||
void junk(void);
|
||||
void needbrack(char *str);
|
||||
void callfunction(char *ptr);
|
||||
int symname(char *sname);
|
||||
void kill(void);
|
||||
void multidef(char *symbol_name);
|
||||
int endst(void);
|
||||
int get_type(void);
|
||||
void need_semicolon(void);
|
||||
void fentry(int argtop);
|
||||
int statement(int func);
|
||||
int gen_modify_stack(int newstkp);
|
||||
void gen_ret(void);
|
||||
void illname(void);
|
||||
void output_label_prefix(void);
|
||||
void output_decimal(int number);
|
||||
void output_number(int num);
|
||||
void output_with_tab(char ptr[]);
|
||||
void gen_put_indirect(char typeobj);
|
||||
void expression(int comma);
|
||||
int astreq(char str1[], char str2[], int len);
|
||||
void readline(void);
|
||||
void header(void);
|
||||
void code_segment_gtext(void);
|
||||
void data_segment_gdata(void);
|
||||
void trailer(void);
|
||||
void newfunc(void);
|
||||
void declare_global(int type, int storage);
|
||||
void gen_def_byte(void);
|
||||
void gen_def_storage(void);
|
||||
void gen_def_word(void);
|
||||
void gen_align_word(void);
|
||||
int number(int val[]);
|
||||
int quoted_char(int *value);
|
||||
int quoted_string(int *position);
|
||||
int numeric(char c);
|
||||
int alphanumeric(char c);
|
||||
int alpha(char c);
|
||||
void gen_swap_stack(void);
|
||||
void gnargs(int nargs);
|
||||
void gen_call(char *sname);
|
||||
void callstk(void);
|
||||
void declare_local(int typ, int stclass);
|
||||
void doasm(void);
|
||||
void test(int label, int ft);
|
||||
void generate_label(int nlab);
|
||||
void addloop(loop_t *ptr);
|
||||
void delloop(void);
|
||||
void gen_jump_case(void);
|
||||
void addcase(int val);
|
||||
int galign(int t);
|
||||
void output_line(char ptr[]);
|
||||
|
||||
@@ -2,25 +2,14 @@
|
||||
/*% cc -O -c %
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "defs.h"
|
||||
#include "data.h"
|
||||
|
||||
error (ptr)
|
||||
char ptr[];
|
||||
void
|
||||
doerror(ptr)
|
||||
char *ptr;
|
||||
{
|
||||
FILE *tempfile;
|
||||
|
||||
tempfile = output;
|
||||
output = stdout;
|
||||
doerror(ptr);
|
||||
output = tempfile;
|
||||
doerror(ptr);
|
||||
errcnt++;
|
||||
}
|
||||
|
||||
doerror(ptr) char *ptr; {
|
||||
int k;
|
||||
gen_comment ();
|
||||
output_string (line);
|
||||
@@ -43,3 +32,16 @@ doerror(ptr) char *ptr; {
|
||||
newline ();
|
||||
}
|
||||
|
||||
void
|
||||
error(ptr)
|
||||
char ptr[];
|
||||
{
|
||||
FILE *tempfile;
|
||||
|
||||
tempfile = output;
|
||||
output = stdout;
|
||||
doerror(ptr);
|
||||
output = tempfile;
|
||||
doerror(ptr);
|
||||
errcnt++;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
/**
|
||||
* unsigned operand ?
|
||||
*/
|
||||
nosign(lvalue_t *is) {
|
||||
int nosign(lvalue_t *is) {
|
||||
symbol_t *ptr;
|
||||
|
||||
if((is->ptr_type) ||
|
||||
@@ -40,12 +40,12 @@ nosign(lvalue_t *is) {
|
||||
* @param comma
|
||||
* @return
|
||||
*/
|
||||
expression(int comma) {
|
||||
void expression(int comma) {
|
||||
lvalue_t lval;
|
||||
int k;
|
||||
|
||||
do {
|
||||
if (k = hier1 (&lval))
|
||||
if ((k = hier1 (&lval)))
|
||||
rvalue(&lval, k);
|
||||
if (!comma)
|
||||
return;
|
||||
@@ -57,7 +57,7 @@ expression(int comma) {
|
||||
* @param lval
|
||||
* @return
|
||||
*/
|
||||
hier1 (lvalue_t *lval) {
|
||||
int hier1 (lvalue_t *lval) {
|
||||
int k;
|
||||
lvalue_t lval2[1];
|
||||
char fc;
|
||||
@@ -70,7 +70,7 @@ hier1 (lvalue_t *lval) {
|
||||
}
|
||||
if (lval->indirect)
|
||||
gen_push(k);
|
||||
if (k = hier1 (lval2))
|
||||
if ((k = hier1 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
store (lval);
|
||||
return (0);
|
||||
@@ -94,7 +94,7 @@ hier1 (lvalue_t *lval) {
|
||||
gen_push(k);
|
||||
k = rvalue(lval, k);
|
||||
gen_push(k);
|
||||
if (k = hier1 (lval2))
|
||||
if ((k = hier1 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
switch (fc) {
|
||||
case '-': {
|
||||
@@ -144,7 +144,7 @@ hier1 (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier1a (lvalue_t *lval) {
|
||||
int hier1a (lvalue_t *lval) {
|
||||
int k, lab1, lab2;
|
||||
lvalue_t lval2[1];
|
||||
|
||||
@@ -157,7 +157,7 @@ hier1a (lvalue_t *lval) {
|
||||
for (;;)
|
||||
if (match ("?")) {
|
||||
gen_test_jump (lab1 = getlabel (), FALSE);
|
||||
if (k = hier1b (lval2))
|
||||
if ((k = hier1b (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
gen_jump (lab2 = getlabel ());
|
||||
print_label (lab1);
|
||||
@@ -168,7 +168,7 @@ hier1a (lvalue_t *lval) {
|
||||
error ("missing colon");
|
||||
return (0);
|
||||
}
|
||||
if (k = hier1b (lval2))
|
||||
if ((k = hier1b (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
print_label (lab2);
|
||||
output_label_terminator ();
|
||||
@@ -182,7 +182,7 @@ hier1a (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier1b (lvalue_t *lval) {
|
||||
int hier1b (lvalue_t *lval) {
|
||||
int k, lab;
|
||||
lvalue_t lval2[1];
|
||||
|
||||
@@ -195,7 +195,7 @@ hier1b (lvalue_t *lval) {
|
||||
for (;;)
|
||||
if (match ("||")) {
|
||||
gen_test_jump (lab = getlabel (), TRUE);
|
||||
if (k = hier1c (lval2))
|
||||
if ((k = hier1c (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
print_label (lab);
|
||||
output_label_terminator ();
|
||||
@@ -210,7 +210,7 @@ hier1b (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier1c (lvalue_t *lval) {
|
||||
int hier1c (lvalue_t *lval) {
|
||||
int k, lab;
|
||||
lvalue_t lval2[1];
|
||||
|
||||
@@ -223,7 +223,7 @@ hier1c (lvalue_t *lval) {
|
||||
for (;;)
|
||||
if (match ("&&")) {
|
||||
gen_test_jump (lab = getlabel (), FALSE);
|
||||
if (k = hier2 (lval2))
|
||||
if ((k = hier2 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
print_label (lab);
|
||||
output_label_terminator ();
|
||||
@@ -238,7 +238,7 @@ hier1c (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier2 (lvalue_t *lval) {
|
||||
int hier2 (lvalue_t *lval) {
|
||||
int k;
|
||||
lvalue_t lval2[1];
|
||||
|
||||
@@ -252,7 +252,7 @@ hier2 (lvalue_t *lval) {
|
||||
if ((ch() == '|') & (nch() != '|') & (nch() != '=')) {
|
||||
inbyte ();
|
||||
gen_push(k);
|
||||
if (k = hier3 (lval2))
|
||||
if ((k = hier3 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
gen_or ();
|
||||
blanks();
|
||||
@@ -266,7 +266,7 @@ hier2 (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier3 (lvalue_t *lval) {
|
||||
int hier3 (lvalue_t *lval) {
|
||||
int k;
|
||||
lvalue_t lval2[1];
|
||||
|
||||
@@ -280,7 +280,7 @@ hier3 (lvalue_t *lval) {
|
||||
if ((ch() == '^') & (nch() != '=')){
|
||||
inbyte ();
|
||||
gen_push(k);
|
||||
if (k = hier4 (lval2))
|
||||
if ((k = hier4 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
gen_xor ();
|
||||
blanks();
|
||||
@@ -294,7 +294,7 @@ hier3 (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier4 (lvalue_t *lval) {
|
||||
int hier4 (lvalue_t *lval) {
|
||||
int k;
|
||||
lvalue_t lval2[1];
|
||||
|
||||
@@ -308,7 +308,7 @@ hier4 (lvalue_t *lval) {
|
||||
if ((ch() == '&') & (nch() != '&') & (nch() != '=')) {
|
||||
inbyte ();
|
||||
gen_push(k);
|
||||
if (k = hier5 (lval2))
|
||||
if ((k = hier5 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
gen_and ();
|
||||
blanks();
|
||||
@@ -323,7 +323,7 @@ hier4 (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier5 (lvalue_t *lval) {
|
||||
int hier5 (lvalue_t *lval) {
|
||||
int k;
|
||||
lvalue_t lval2[1];
|
||||
|
||||
@@ -337,12 +337,12 @@ hier5 (lvalue_t *lval) {
|
||||
for (;;) {
|
||||
if (match ("==")) {
|
||||
gen_push(k);
|
||||
if (k = hier6 (lval2))
|
||||
if ((k = hier6 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
gen_equal ();
|
||||
} else if (match ("!=")) {
|
||||
gen_push(k);
|
||||
if (k = hier6 (lval2))
|
||||
if ((k = hier6 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
gen_not_equal ();
|
||||
} else
|
||||
@@ -356,7 +356,7 @@ hier5 (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier6 (lvalue_t *lval) {
|
||||
int hier6 (lvalue_t *lval) {
|
||||
int k;
|
||||
lvalue_t lval2[1];
|
||||
|
||||
@@ -374,7 +374,7 @@ hier6 (lvalue_t *lval) {
|
||||
for (;;) {
|
||||
if (match ("<=")) {
|
||||
gen_push(k);
|
||||
if (k = hier7 (lval2))
|
||||
if ((k = hier7 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
if (nosign(lval) || nosign(lval2)) {
|
||||
gen_unsigned_less_or_equal ();
|
||||
@@ -383,7 +383,7 @@ hier6 (lvalue_t *lval) {
|
||||
gen_less_or_equal ();
|
||||
} else if (match (">=")) {
|
||||
gen_push(k);
|
||||
if (k = hier7 (lval2))
|
||||
if ((k = hier7 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
if (nosign(lval) || nosign(lval2)) {
|
||||
gen_unsigned_greater_or_equal ();
|
||||
@@ -394,7 +394,7 @@ hier6 (lvalue_t *lval) {
|
||||
!sstreq ("<<")) {
|
||||
inbyte ();
|
||||
gen_push(k);
|
||||
if (k = hier7 (lval2))
|
||||
if ((k = hier7 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
if (nosign(lval) || nosign(lval2)) {
|
||||
gen_unsigned_less_than ();
|
||||
@@ -405,7 +405,7 @@ hier6 (lvalue_t *lval) {
|
||||
!sstreq (">>")) {
|
||||
inbyte ();
|
||||
gen_push(k);
|
||||
if (k = hier7 (lval2))
|
||||
if ((k = hier7 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
if (nosign(lval) || nosign(lval2)) {
|
||||
gen_usigned_greater_than ();
|
||||
@@ -424,7 +424,7 @@ hier6 (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier7 (lvalue_t *lval) {
|
||||
int hier7 (lvalue_t *lval) {
|
||||
int k;
|
||||
lvalue_t lval2[1];
|
||||
|
||||
@@ -439,13 +439,13 @@ hier7 (lvalue_t *lval) {
|
||||
if (sstreq(">>") && ! sstreq(">>=")) {
|
||||
inbyte(); inbyte();
|
||||
gen_push(k);
|
||||
if (k = hier8 (lval2))
|
||||
if ((k = hier8 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
gen_arithm_shift_right ();
|
||||
} else if (sstreq("<<") && ! sstreq("<<=")) {
|
||||
inbyte(); inbyte();
|
||||
gen_push(k);
|
||||
if (k = hier8 (lval2))
|
||||
if ((k = hier8 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
gen_arithm_shift_left();
|
||||
} else
|
||||
@@ -460,7 +460,7 @@ hier7 (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier8 (lvalue_t *lval) {
|
||||
int hier8 (lvalue_t *lval) {
|
||||
int k;
|
||||
lvalue_t lval2[1];
|
||||
|
||||
@@ -473,7 +473,7 @@ hier8 (lvalue_t *lval) {
|
||||
for (;;) {
|
||||
if (match ("+")) {
|
||||
gen_push(k);
|
||||
if (k = hier9 (lval2))
|
||||
if ((k = hier9 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
/* if left is pointer and right is int, scale right */
|
||||
if (dbltest (lval, lval2))
|
||||
@@ -483,7 +483,7 @@ hier8 (lvalue_t *lval) {
|
||||
result (lval, lval2);
|
||||
} else if (match ("-")) {
|
||||
gen_push(k);
|
||||
if (k = hier9 (lval2))
|
||||
if ((k = hier9 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
/* if dbl, can only be: pointer - int, or
|
||||
pointer - pointer, thus,
|
||||
@@ -515,7 +515,7 @@ hier8 (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier9 (lvalue_t *lval) {
|
||||
int hier9 (lvalue_t *lval) {
|
||||
int k;
|
||||
lvalue_t lval2[1];
|
||||
|
||||
@@ -529,12 +529,12 @@ hier9 (lvalue_t *lval) {
|
||||
for (;;) {
|
||||
if (match ("*")) {
|
||||
gen_push(k);
|
||||
if (k = hier10 (lval2))
|
||||
if ((k = hier10 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
gen_mult ();
|
||||
} else if (match ("/")) {
|
||||
gen_push(k);
|
||||
if (k = hier10 (lval2))
|
||||
if ((k = hier10 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
if(nosign(lval) || nosign(lval2)) {
|
||||
gen_udiv();
|
||||
@@ -543,7 +543,7 @@ hier9 (lvalue_t *lval) {
|
||||
}
|
||||
} else if (match ("%")) {
|
||||
gen_push(k);
|
||||
if (k = hier10 (lval2))
|
||||
if ((k = hier10 (lval2)))
|
||||
k = rvalue(lval2, k);
|
||||
if(nosign(lval) || nosign(lval2)) {
|
||||
gen_umod();
|
||||
@@ -561,7 +561,7 @@ hier9 (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier10 (lvalue_t *lval) {
|
||||
int hier10 (lvalue_t *lval) {
|
||||
int k;
|
||||
symbol_t *ptr;
|
||||
|
||||
@@ -610,7 +610,7 @@ hier10 (lvalue_t *lval) {
|
||||
k = hier10 (lval);
|
||||
if (k)
|
||||
k = rvalue(lval, k);
|
||||
if (ptr = lval->symbol)
|
||||
if ((ptr = lval->symbol))
|
||||
lval->indirect = ptr->type;
|
||||
else
|
||||
lval->indirect = CINT;
|
||||
@@ -675,7 +675,7 @@ hier10 (lvalue_t *lval) {
|
||||
* @param lval
|
||||
* @return 0 or 1, fetch or no fetch
|
||||
*/
|
||||
hier11 (lvalue_t *lval) {
|
||||
int hier11 (lvalue_t *lval) {
|
||||
int k;
|
||||
symbol_t *ptr;
|
||||
|
||||
@@ -712,7 +712,7 @@ hier11 (lvalue_t *lval) {
|
||||
k = rvalue(lval, k);
|
||||
callfunction (0);
|
||||
} else
|
||||
callfunction (ptr);
|
||||
callfunction ((char*)ptr);
|
||||
lval->symbol = 0;
|
||||
k = 0;
|
||||
} else
|
||||
@@ -722,7 +722,7 @@ hier11 (lvalue_t *lval) {
|
||||
return (k);
|
||||
if (ptr->identity == FUNCTION) {
|
||||
gen_immediate_a ();
|
||||
output_string (ptr);
|
||||
output_string ((char*)ptr);
|
||||
newline ();
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -10,13 +10,17 @@ int argtop;
|
||||
|
||||
#define ARGOFFSET 20 /* for MIPS32 */
|
||||
|
||||
static int doAnsiArguments(void);
|
||||
static void doLocalAnsiArgument(int type);
|
||||
static void getarg(int t);
|
||||
|
||||
/**
|
||||
* begin a function
|
||||
* called from "parse", this routine tries to make a function out
|
||||
* of what follows
|
||||
* modified version. p.l. woods
|
||||
*/
|
||||
newfunc() {
|
||||
void newfunc() {
|
||||
char n[NAMESIZE];
|
||||
int idx, type;
|
||||
fexitlab = getlabel();
|
||||
@@ -26,7 +30,7 @@ newfunc() {
|
||||
kill();
|
||||
return;
|
||||
}
|
||||
if (idx = findglb(n)) {
|
||||
if ((idx = findglb(n))) {
|
||||
if (symbol_table[idx].identity != FUNCTION)
|
||||
multidef(n);
|
||||
else if (symbol_table[idx].offset == FUNCTION)
|
||||
@@ -71,7 +75,7 @@ newfunc() {
|
||||
stkp = 0;
|
||||
argtop = argstk;
|
||||
while (argstk) {
|
||||
if (type = get_type()) {
|
||||
if ((type = get_type())) {
|
||||
getarg(type);
|
||||
need_semicolon();
|
||||
} else {
|
||||
@@ -99,7 +103,7 @@ newfunc() {
|
||||
* @param t argument type (char, int)
|
||||
* @return
|
||||
*/
|
||||
getarg(int t) {
|
||||
void getarg(int t) {
|
||||
int j, legalname, argptr;
|
||||
char n[NAMESIZE];
|
||||
|
||||
@@ -122,7 +126,7 @@ getarg(int t) {
|
||||
j = POINTER;
|
||||
}
|
||||
if (legalname) {
|
||||
if (argptr = findloc(n)) {
|
||||
if ((argptr = findloc(n))) {
|
||||
symbol_table[argptr].identity = j;
|
||||
symbol_table[argptr].type = t;
|
||||
} else
|
||||
@@ -136,7 +140,7 @@ getarg(int t) {
|
||||
}
|
||||
}
|
||||
|
||||
doAnsiArguments() {
|
||||
int doAnsiArguments() {
|
||||
int type;
|
||||
type = get_type();
|
||||
if (type == 0) {
|
||||
@@ -160,9 +164,10 @@ doAnsiArguments() {
|
||||
}
|
||||
}
|
||||
argtop = argstk;
|
||||
return 1;
|
||||
}
|
||||
|
||||
doLocalAnsiArgument(int type) {
|
||||
void doLocalAnsiArgument(int type) {
|
||||
char symbol_name[NAMESIZE];
|
||||
int identity, argptr, ptr;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* return next available internal label number
|
||||
*
|
||||
*/
|
||||
getlabel ()
|
||||
int getlabel ()
|
||||
{
|
||||
return (nxtlab++);
|
||||
|
||||
@@ -21,7 +21,7 @@ getlabel ()
|
||||
* print specified number as label
|
||||
* @param label
|
||||
*/
|
||||
print_label (label)
|
||||
void print_label (label)
|
||||
int label;
|
||||
{
|
||||
output_label_prefix ();
|
||||
@@ -33,7 +33,7 @@ int label;
|
||||
* not used ?
|
||||
* @param lab label number
|
||||
*/
|
||||
glabel (lab)
|
||||
void glabel (lab)
|
||||
char *lab;
|
||||
{
|
||||
output_string (lab);
|
||||
@@ -46,7 +46,7 @@ char *lab;
|
||||
* @param nlab label number
|
||||
* @return
|
||||
*/
|
||||
generate_label (nlab)
|
||||
void generate_label (nlab)
|
||||
int nlab;
|
||||
{
|
||||
print_label (nlab);
|
||||
@@ -59,8 +59,7 @@ int nlab;
|
||||
* @param c
|
||||
* @return
|
||||
*/
|
||||
output_byte (c)
|
||||
char c;
|
||||
int output_byte (char c)
|
||||
{
|
||||
if (c == 0)
|
||||
return (0);
|
||||
@@ -73,6 +72,7 @@ char c;
|
||||
* @param ptr the string
|
||||
* @return
|
||||
*/
|
||||
void
|
||||
output_string (ptr)
|
||||
char ptr[];
|
||||
{
|
||||
@@ -85,6 +85,7 @@ char ptr[];
|
||||
* outputs a tab
|
||||
* @return
|
||||
*/
|
||||
void
|
||||
print_tab ()
|
||||
{
|
||||
output_byte ('\t');
|
||||
@@ -95,7 +96,7 @@ print_tab ()
|
||||
* @param ptr
|
||||
* @return
|
||||
*/
|
||||
output_line (ptr)
|
||||
void output_line (ptr)
|
||||
char ptr[];
|
||||
{
|
||||
output_with_tab (ptr);
|
||||
@@ -107,7 +108,7 @@ char ptr[];
|
||||
* @param ptr
|
||||
* @return
|
||||
*/
|
||||
output_with_tab (ptr)
|
||||
void output_with_tab (ptr)
|
||||
char ptr[];
|
||||
{
|
||||
print_tab ();
|
||||
@@ -119,7 +120,7 @@ char ptr[];
|
||||
* @param number
|
||||
* @return
|
||||
*/
|
||||
output_decimal (int number)
|
||||
void output_decimal (int number)
|
||||
{
|
||||
fprintf(output, "%d", number);
|
||||
}
|
||||
@@ -129,7 +130,7 @@ output_decimal (int number)
|
||||
* @param lval TODO
|
||||
* @return
|
||||
*/
|
||||
store (lvalue_t *lval)
|
||||
void store (lvalue_t *lval)
|
||||
{
|
||||
if (lval->indirect == 0)
|
||||
gen_put_memory (lval->symbol);
|
||||
@@ -137,7 +138,7 @@ store (lvalue_t *lval)
|
||||
gen_put_indirect (lval->indirect);
|
||||
}
|
||||
|
||||
rvalue (lvalue_t *lval, int reg)
|
||||
int rvalue (lvalue_t *lval, int reg)
|
||||
{
|
||||
if ((lval->symbol != 0) & (lval->indirect == 0))
|
||||
gen_get_memory (lval->symbol);
|
||||
@@ -152,7 +153,7 @@ rvalue (lvalue_t *lval, int reg)
|
||||
* @param ft
|
||||
* @return
|
||||
*/
|
||||
test (label, ft)
|
||||
void test (label, ft)
|
||||
int label,
|
||||
ft;
|
||||
{
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
#include "defs.h"
|
||||
#include "data.h"
|
||||
|
||||
kill ()
|
||||
void kill ()
|
||||
{
|
||||
lptr = 0;
|
||||
line[lptr] = 0;
|
||||
}
|
||||
|
||||
readline ()
|
||||
void readline ()
|
||||
{
|
||||
int k;
|
||||
|
||||
@@ -40,7 +40,7 @@ readline ()
|
||||
}
|
||||
}
|
||||
|
||||
inbyte ()
|
||||
int inbyte ()
|
||||
{
|
||||
while (ch () == 0) {
|
||||
if (feof (input))
|
||||
@@ -50,7 +50,7 @@ inbyte ()
|
||||
return (gch ());
|
||||
}
|
||||
|
||||
inchar ()
|
||||
int inchar ()
|
||||
{
|
||||
if (ch () == 0)
|
||||
readline ();
|
||||
@@ -63,7 +63,7 @@ inchar ()
|
||||
* gets current char from input line and moves to the next one
|
||||
* @return current char
|
||||
*/
|
||||
gch ()
|
||||
int gch ()
|
||||
{
|
||||
int c = line[lptr];
|
||||
if (c == 0)
|
||||
@@ -76,7 +76,7 @@ gch ()
|
||||
* returns next char
|
||||
* @return next char
|
||||
*/
|
||||
nch ()
|
||||
int nch ()
|
||||
{
|
||||
int c = line[lptr];
|
||||
if (c == 0)
|
||||
@@ -88,7 +88,7 @@ nch ()
|
||||
* returns current char
|
||||
* @return current char
|
||||
*/
|
||||
ch ()
|
||||
int ch ()
|
||||
{
|
||||
return line[lptr];
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* @param c
|
||||
* @return
|
||||
*/
|
||||
alpha(char c) {
|
||||
int alpha(char c) {
|
||||
if (c > 127)
|
||||
return 0;
|
||||
return (((c >= 'a') && (c <= 'z')) ||
|
||||
@@ -25,7 +25,7 @@ alpha(char c) {
|
||||
* @param c
|
||||
* @return
|
||||
*/
|
||||
numeric(char c) {
|
||||
int numeric(char c) {
|
||||
if (c > 127)
|
||||
return 0;
|
||||
return ((c >= '0') && (c <= '9'));
|
||||
@@ -36,7 +36,7 @@ numeric(char c) {
|
||||
* @param c
|
||||
* @return
|
||||
*/
|
||||
alphanumeric(char c) {
|
||||
int alphanumeric(char c) {
|
||||
return ((alpha (c)) || (numeric (c)));
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ alphanumeric(char c) {
|
||||
* semicolon enforcer
|
||||
* called whenever syntax requires a semicolon
|
||||
*/
|
||||
need_semicolon() {
|
||||
void need_semicolon() {
|
||||
if (!match (";"))
|
||||
error ("missing semicolon");
|
||||
}
|
||||
|
||||
junk() {
|
||||
void junk() {
|
||||
if (alphanumeric (inbyte ()))
|
||||
while (alphanumeric (ch ()))
|
||||
gch ();
|
||||
@@ -62,7 +62,7 @@ junk() {
|
||||
blanks ();
|
||||
}
|
||||
|
||||
endst() {
|
||||
int endst() {
|
||||
blanks ();
|
||||
return ((streq (line + lptr, ";") | (ch () == 0)));
|
||||
}
|
||||
@@ -72,7 +72,7 @@ endst() {
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
needbrack(char *str) {
|
||||
void needbrack(char *str) {
|
||||
if (!match (str)) {
|
||||
error ("missing bracket");
|
||||
gen_comment ();
|
||||
@@ -86,7 +86,7 @@ needbrack(char *str) {
|
||||
* @param str1
|
||||
* @return
|
||||
*/
|
||||
sstreq(str1) char *str1; {
|
||||
int sstreq(str1) char *str1; {
|
||||
return (streq(line + lptr, str1));
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ sstreq(str1) char *str1; {
|
||||
* @param str2 address2
|
||||
* @return
|
||||
*/
|
||||
streq(char str1[], char str2[]) {
|
||||
int streq(char str1[], char str2[]) {
|
||||
int k;
|
||||
k = 0;
|
||||
while (str2[k]) {
|
||||
@@ -119,7 +119,7 @@ streq(char str1[], char str2[]) {
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
astreq (char str1[], char str2[], int len) {
|
||||
int astreq (char str1[], char str2[], int len) {
|
||||
int k;
|
||||
k = 0;
|
||||
while (k < len) {
|
||||
@@ -146,10 +146,10 @@ astreq (char str1[], char str2[], int len) {
|
||||
* @param lit
|
||||
* @return
|
||||
*/
|
||||
match (char *lit) {
|
||||
int match (char *lit) {
|
||||
int k;
|
||||
blanks();
|
||||
if (k = streq (line + lptr, lit)) {
|
||||
if ((k = streq (line + lptr, lit))) {
|
||||
lptr = lptr + k;
|
||||
return (1);
|
||||
}
|
||||
@@ -166,11 +166,11 @@ match (char *lit) {
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
amatch(char *lit, int len) {
|
||||
int amatch(char *lit, int len) {
|
||||
int k;
|
||||
|
||||
blanks();
|
||||
if (k = astreq (line + lptr, lit, len)) {
|
||||
if ((k = astreq (line + lptr, lit, len))) {
|
||||
lptr = lptr + k;
|
||||
while (alphanumeric (ch ()))
|
||||
inbyte ();
|
||||
@@ -179,7 +179,7 @@ amatch(char *lit, int len) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
blanks() {
|
||||
void blanks() {
|
||||
for (;;) {
|
||||
while (ch () == 0) {
|
||||
readline ();
|
||||
|
||||
@@ -5,10 +5,19 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "defs.h"
|
||||
#include "data.h"
|
||||
|
||||
main(int argc, char *argv[])
|
||||
static void usage(void);
|
||||
static void compile(char *infile, char *outfile);
|
||||
static void parse(void);
|
||||
static void dumplits(void);
|
||||
static void dumpglbs(void);
|
||||
static void errorsummary(void);
|
||||
static int dodcls(int stclass);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *param = NULL;
|
||||
char *infile = NULL;
|
||||
@@ -52,7 +61,7 @@ main(int argc, char *argv[])
|
||||
* @param file filename
|
||||
* @return
|
||||
*/
|
||||
compile(char *infile, char *outfile)
|
||||
void compile(char *infile, char *outfile)
|
||||
{
|
||||
global_table_index = 1;
|
||||
local_table_index = NUMBER_OF_GLOBALS;
|
||||
@@ -112,7 +121,7 @@ compile(char *infile, char *outfile)
|
||||
errs = errs || errfile;
|
||||
}
|
||||
|
||||
frontend_version()
|
||||
void frontend_version()
|
||||
{
|
||||
output_string("\tFront End (2.7,84/11/28)");
|
||||
}
|
||||
@@ -121,7 +130,7 @@ frontend_version()
|
||||
* prints usage
|
||||
* @return exits the execution
|
||||
*/
|
||||
usage()
|
||||
void usage()
|
||||
{
|
||||
fputs("Usage:\n", stderr);
|
||||
fputs(" smallc [-t] [infile [outfile]]\n", stderr);
|
||||
@@ -136,7 +145,7 @@ usage()
|
||||
* enters mode where assembly language statements are passed
|
||||
* intact through parser
|
||||
*/
|
||||
doasm ()
|
||||
void doasm ()
|
||||
{
|
||||
cmode = 0;
|
||||
for (;;) {
|
||||
@@ -157,7 +166,7 @@ doasm ()
|
||||
* at this level, only static declarations, defines, includes,
|
||||
* and function definitions are legal.
|
||||
*/
|
||||
parse()
|
||||
void parse()
|
||||
{
|
||||
while (!feof(input)) {
|
||||
if (amatch("extern", 6)) {
|
||||
@@ -182,11 +191,11 @@ parse()
|
||||
* @param stclass
|
||||
* @return
|
||||
*/
|
||||
dodcls(int stclass)
|
||||
int dodcls(int stclass)
|
||||
{
|
||||
int type;
|
||||
blanks();
|
||||
if (type = get_type()) {
|
||||
if ((type = get_type())) {
|
||||
declare_global(type, stclass);
|
||||
} else if (stclass == PUBLIC) {
|
||||
return (0);
|
||||
@@ -200,7 +209,7 @@ dodcls(int stclass)
|
||||
/**
|
||||
* dump the literal pool
|
||||
*/
|
||||
dumplits()
|
||||
void dumplits()
|
||||
{
|
||||
int j, k;
|
||||
|
||||
@@ -226,7 +235,7 @@ dumplits()
|
||||
/**
|
||||
* dump all static variables
|
||||
*/
|
||||
dumpglbs()
|
||||
void dumpglbs()
|
||||
{
|
||||
int dim, i, list_size, line_count, value;
|
||||
|
||||
@@ -289,7 +298,7 @@ dumpglbs()
|
||||
/*
|
||||
* report errors
|
||||
*/
|
||||
errorsummary()
|
||||
void errorsummary()
|
||||
{
|
||||
if (ncmp)
|
||||
error("missing closing bracket");
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
#include "defs.h"
|
||||
#include "data.h"
|
||||
|
||||
primary (lvalue_t *lval)
|
||||
static int constant(int val[]);
|
||||
static int spechar(void);
|
||||
|
||||
int primary (lvalue_t *lval)
|
||||
{
|
||||
char sname[NAMESIZE];
|
||||
int num[1], k, symbol_table_idx, offset, reg;
|
||||
@@ -47,7 +50,7 @@ primary (lvalue_t *lval)
|
||||
return(0);
|
||||
}
|
||||
if (symname (sname)) {
|
||||
if (symbol_table_idx = findloc (sname)) {
|
||||
if ((symbol_table_idx = findloc (sname))) {
|
||||
symbol = &symbol_table[symbol_table_idx];
|
||||
reg = gen_get_location (symbol);
|
||||
lval->symbol = symbol;
|
||||
@@ -63,7 +66,7 @@ primary (lvalue_t *lval)
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
if (symbol_table_idx = findglb (sname)) {
|
||||
if ((symbol_table_idx = findglb (sname))) {
|
||||
symbol = &symbol_table[symbol_table_idx];
|
||||
lval->symbol = symbol;
|
||||
switch (symbol->identity) {
|
||||
@@ -112,7 +115,7 @@ primary (lvalue_t *lval)
|
||||
* @param val2
|
||||
* @return
|
||||
*/
|
||||
dbltest (lvalue_t *val1, lvalue_t *val2)
|
||||
int dbltest (lvalue_t *val1, lvalue_t *val2)
|
||||
{
|
||||
if (val1 == NULL)
|
||||
return (FALSE);
|
||||
@@ -129,7 +132,7 @@ dbltest (lvalue_t *val1, lvalue_t *val2)
|
||||
* @param lval2
|
||||
* @return
|
||||
*/
|
||||
result (lvalue_t *lval, lvalue_t *lval2)
|
||||
void result (lvalue_t *lval, lvalue_t *lval2)
|
||||
{
|
||||
if (lval->ptr_type && lval2->ptr_type)
|
||||
lval->ptr_type = 0;
|
||||
@@ -140,7 +143,7 @@ result (lvalue_t *lval, lvalue_t *lval2)
|
||||
}
|
||||
}
|
||||
|
||||
constant (val)
|
||||
int constant (val)
|
||||
int val[];
|
||||
{
|
||||
if (number (val))
|
||||
@@ -159,7 +162,7 @@ constant (val)
|
||||
|
||||
}
|
||||
|
||||
number (val)
|
||||
int number (val)
|
||||
int val[];
|
||||
{
|
||||
int k, minus, base;
|
||||
@@ -207,7 +210,7 @@ number (val)
|
||||
* @param value returns the char found
|
||||
* @return 1 if we have, 0 otherwise
|
||||
*/
|
||||
quoted_char (int *value)
|
||||
int quoted_char (int *value)
|
||||
{
|
||||
int k;
|
||||
char c;
|
||||
@@ -229,7 +232,7 @@ quoted_char (int *value)
|
||||
* @param position returns beginning of the string
|
||||
* @return 1 if such string found, 0 otherwise
|
||||
*/
|
||||
quoted_string (int *position)
|
||||
int quoted_string (int *position)
|
||||
{
|
||||
char c;
|
||||
|
||||
@@ -257,7 +260,7 @@ quoted_string (int *position)
|
||||
/**
|
||||
* decode special characters (preceeded by back slashes)
|
||||
*/
|
||||
spechar()
|
||||
int spechar()
|
||||
{
|
||||
char c;
|
||||
c = ch();
|
||||
@@ -326,7 +329,7 @@ void callfunction (ptr)
|
||||
stkp = gen_modify_stack (stkp + nargs);
|
||||
}
|
||||
|
||||
needlval ()
|
||||
void needlval ()
|
||||
{
|
||||
error ("must be lvalue");
|
||||
}
|
||||
|
||||
@@ -6,6 +6,22 @@
|
||||
#include "defs.h"
|
||||
#include "data.h"
|
||||
|
||||
static void do_compound(int func);
|
||||
static void do_statement(void);
|
||||
static int do_local_declares(int stclass);
|
||||
static void doif(void);
|
||||
static void dowhile(void);
|
||||
static void doswitch(void);
|
||||
static void dodo(void);
|
||||
static void dofor(void);
|
||||
static void doreturn(void);
|
||||
static void dobreak(void);
|
||||
static void dobreak(void);
|
||||
static void docont(void);
|
||||
static void docase(void);
|
||||
static void dodefault(void);
|
||||
static void dumpsw(loop_t *loop);
|
||||
|
||||
/**
|
||||
* statement parser
|
||||
* called whenever syntax requires a statement. this routine
|
||||
@@ -15,16 +31,18 @@
|
||||
* "declaration_list" is omitted)
|
||||
* @return statement type
|
||||
*/
|
||||
statement (int func) {
|
||||
int statement (int func) {
|
||||
if ((ch () == 0) & feof (input))
|
||||
return (0);
|
||||
lastst = 0;
|
||||
if (func)
|
||||
if (func) {
|
||||
if (match ("{")) {
|
||||
do_compound (YES);
|
||||
return (lastst);
|
||||
} else
|
||||
} else {
|
||||
error ("function requires compound statement");
|
||||
}
|
||||
}
|
||||
if (match ("{"))
|
||||
do_compound (NO);
|
||||
else
|
||||
@@ -35,7 +53,7 @@ statement (int func) {
|
||||
/**
|
||||
* declaration
|
||||
*/
|
||||
statement_declare() {
|
||||
int statement_declare() {
|
||||
if (amatch("register", 8))
|
||||
do_local_declares(DEFAUTO);
|
||||
else if (amatch("auto", 4))
|
||||
@@ -53,10 +71,10 @@ statement_declare() {
|
||||
* @param stclass
|
||||
* @return
|
||||
*/
|
||||
do_local_declares(int stclass) {
|
||||
int do_local_declares(int stclass) {
|
||||
int type = 0;
|
||||
blanks();
|
||||
if (type = get_type()) {
|
||||
if ((type = get_type())) {
|
||||
declare_local(type, stclass);
|
||||
} else if (stclass == LSTATIC || stclass == DEFAUTO) {
|
||||
declare_local(CINT, stclass);
|
||||
@@ -70,7 +88,7 @@ do_local_declares(int stclass) {
|
||||
/**
|
||||
* non-declaration statement
|
||||
*/
|
||||
do_statement () {
|
||||
void do_statement () {
|
||||
if (amatch ("if", 2)) {
|
||||
doif ();
|
||||
lastst = STIF;
|
||||
@@ -132,7 +150,7 @@ do_statement () {
|
||||
* 'func' is true if we are in a "function_statement", which
|
||||
* must contain "statement_list"
|
||||
*/
|
||||
do_compound(int func) {
|
||||
void do_compound(int func) {
|
||||
int decls;
|
||||
|
||||
decls = YES;
|
||||
@@ -152,7 +170,7 @@ do_compound(int func) {
|
||||
/**
|
||||
* "if" statement
|
||||
*/
|
||||
doif() {
|
||||
void doif() {
|
||||
int fstkp, flab1, flab2;
|
||||
int flev;
|
||||
|
||||
@@ -178,7 +196,7 @@ doif() {
|
||||
/**
|
||||
* "while" statement
|
||||
*/
|
||||
dowhile() {
|
||||
void dowhile() {
|
||||
loop_t loop;
|
||||
|
||||
loop.symbol_idx = local_table_index;
|
||||
@@ -200,7 +218,7 @@ dowhile() {
|
||||
/**
|
||||
* "do" statement
|
||||
*/
|
||||
dodo() {
|
||||
void dodo() {
|
||||
loop_t loop;
|
||||
|
||||
loop.symbol_idx = local_table_index;
|
||||
@@ -227,7 +245,7 @@ dodo() {
|
||||
/**
|
||||
* "for" statement
|
||||
*/
|
||||
dofor() {
|
||||
void dofor() {
|
||||
loop_t loop;
|
||||
loop_t *p;
|
||||
|
||||
@@ -272,7 +290,7 @@ dofor() {
|
||||
/**
|
||||
* "switch" statement
|
||||
*/
|
||||
doswitch() {
|
||||
void doswitch() {
|
||||
loop_t loop;
|
||||
loop_t *ptr;
|
||||
|
||||
@@ -286,7 +304,7 @@ doswitch() {
|
||||
gen_immediate_a ();
|
||||
print_label (loop.body_label);
|
||||
newline ();
|
||||
gen_push ();
|
||||
gen_push (0);
|
||||
needbrack ("(");
|
||||
expression (YES);
|
||||
needbrack (")");
|
||||
@@ -306,7 +324,7 @@ doswitch() {
|
||||
/**
|
||||
* "case" label
|
||||
*/
|
||||
docase() {
|
||||
void docase() {
|
||||
int val;
|
||||
|
||||
val = 0;
|
||||
@@ -324,11 +342,11 @@ docase() {
|
||||
/**
|
||||
* "default" label
|
||||
*/
|
||||
dodefault() {
|
||||
void dodefault() {
|
||||
loop_t *ptr;
|
||||
int lab;
|
||||
|
||||
if (ptr = readswitch ()) {
|
||||
if ((ptr = readswitch ())) {
|
||||
ptr->cont_label = lab = getlabel ();
|
||||
generate_label (lab);
|
||||
if (!match (":"))
|
||||
@@ -340,7 +358,7 @@ dodefault() {
|
||||
/**
|
||||
* "return" statement
|
||||
*/
|
||||
doreturn() {
|
||||
void doreturn() {
|
||||
if (endst () == 0)
|
||||
expression (YES);
|
||||
gen_jump(fexitlab);
|
||||
@@ -349,7 +367,7 @@ doreturn() {
|
||||
/**
|
||||
* "break" statement
|
||||
*/
|
||||
dobreak() {
|
||||
void dobreak() {
|
||||
loop_t *ptr;
|
||||
|
||||
if ((ptr = readloop ()) == 0)
|
||||
@@ -361,7 +379,7 @@ dobreak() {
|
||||
/**
|
||||
* "continue" statement
|
||||
*/
|
||||
docont() {
|
||||
void docont() {
|
||||
loop_t *ptr;
|
||||
|
||||
if ((ptr = findloop ()) == 0)
|
||||
@@ -376,7 +394,7 @@ docont() {
|
||||
/**
|
||||
* dump switch table
|
||||
*/
|
||||
dumpsw(loop_t *loop) {
|
||||
void dumpsw(loop_t *loop) {
|
||||
int i,j;
|
||||
|
||||
data_segment_gdata ();
|
||||
|
||||
@@ -8,13 +8,17 @@
|
||||
|
||||
#define LOCALOFFSET 16 /* for MIPS32 */
|
||||
|
||||
static int needsub(void);
|
||||
static int initials(char *symbol_name, int size, int identity, int dim);
|
||||
static int init(char *symbol_name, int size, int ident, int *dim);
|
||||
|
||||
/**
|
||||
* declare a static variable
|
||||
* @param type
|
||||
* @param storage
|
||||
* @return
|
||||
*/
|
||||
declare_global(int type, int storage) {
|
||||
void declare_global(int type, int storage) {
|
||||
int k, j, count;
|
||||
char sname[NAMESIZE];
|
||||
|
||||
@@ -56,7 +60,7 @@ declare_global(int type, int storage) {
|
||||
* @param typ
|
||||
* @param stclass
|
||||
*/
|
||||
declare_local (typ, stclass)
|
||||
void declare_local (typ, stclass)
|
||||
int typ, stclass;
|
||||
{
|
||||
int k, j, count;
|
||||
@@ -150,7 +154,7 @@ int initials(char *symbol_name, int size, int identity, int dim) {
|
||||
* @param dim
|
||||
* @return
|
||||
*/
|
||||
init(char *symbol_name, int size, int ident, int *dim) {
|
||||
int init(char *symbol_name, int size, int ident, int *dim) {
|
||||
int value, number_of_chars;
|
||||
if(ident == POINTER) {
|
||||
error("cannot assign to pointer");
|
||||
@@ -180,7 +184,7 @@ init(char *symbol_name, int size, int ident, int *dim) {
|
||||
* get required array size. [xx]
|
||||
* @return array size
|
||||
*/
|
||||
needsub () {
|
||||
int needsub () {
|
||||
int num[1];
|
||||
|
||||
if (match ("]"))
|
||||
@@ -281,7 +285,7 @@ int add_local (char *sname, int identity, int type, int offset, int storage_clas
|
||||
char *buffer_ptr;
|
||||
//printf("local - symbol: %s offset: %d count: %d\n", sname, offset, count);
|
||||
|
||||
if (current_symbol_table_idx = findloc (sname)) {
|
||||
if ((current_symbol_table_idx = findloc (sname))) {
|
||||
return (current_symbol_table_idx);
|
||||
}
|
||||
if (local_table_index >= NUMBER_OF_GLOBALS + NUMBER_OF_LOCALS) {
|
||||
@@ -315,7 +319,7 @@ int add_local (char *sname, int identity, int type, int offset, int storage_clas
|
||||
* test if next input string is legal symbol name
|
||||
*
|
||||
*/
|
||||
symname(char *sname) {
|
||||
int symname(char *sname) {
|
||||
int k;
|
||||
|
||||
blanks();
|
||||
@@ -328,7 +332,7 @@ symname(char *sname) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
illname() {
|
||||
void illname() {
|
||||
error ("illegal symbol name");
|
||||
}
|
||||
|
||||
@@ -337,7 +341,7 @@ illname() {
|
||||
* @param symbol_name
|
||||
* @return
|
||||
*/
|
||||
multidef (char *symbol_name) {
|
||||
void multidef (char *symbol_name) {
|
||||
error ("already defined");
|
||||
gen_comment ();
|
||||
output_string (symbol_name);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "defs.h"
|
||||
#include "data.h"
|
||||
|
||||
addloop (loop_t *ptr)
|
||||
void addloop (loop_t *ptr)
|
||||
{
|
||||
if (loop_table_index == WSTABSZ) {
|
||||
error ("too many active loops");
|
||||
@@ -14,7 +14,7 @@ addloop (loop_t *ptr)
|
||||
loopstack[loop_table_index++] = *ptr;
|
||||
}
|
||||
|
||||
delloop ()
|
||||
void delloop ()
|
||||
{
|
||||
if (readloop ()) {
|
||||
loop_table_index--;
|
||||
@@ -46,7 +46,7 @@ loop_t *readswitch ()
|
||||
{
|
||||
loop_t *ptr;
|
||||
|
||||
if (ptr = readloop ()) {
|
||||
if ((ptr = readloop ())) {
|
||||
if (ptr->type == WSSWITCH) {
|
||||
return ptr;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ loop_t *readswitch ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
addcase (int val)
|
||||
void addcase (int val)
|
||||
{
|
||||
int lab;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user