From: maartenbrock Date: Mon, 27 Jun 2005 06:03:52 +0000 (+0000) Subject: * as/mcs51/asexpr.c (expr): disabled warning "not in .flat24 mode", X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=4db4740164fed3cb25145cfdaadb986fc0690507;p=fw%2Fsdcc * as/mcs51/asexpr.c (expr): disabled warning "not in .flat24 mode", fixed old K&R prototypes * as/mcs51/asout.c (outrb): always output as if generating 24bit addresses * device/lib/_gptrget.c, * device/lib/_gptrgetc.c, * device/lib/_gptrput.c: changed versions for new memory indicator values, also new versions for small generic pointers and banked generic pointers * src/port.h: added const_name * src/SDCC.lex: added keywords sfr16, __sfr16, sfr32, __sfr32 * src/SDCC.y: added tokens SFR16, SFR32 and their sfr_attributes * src/SDCCcse.c (findPrevIc): check all associative operators * src/SDCCglue.c (emitMaps): use CONST_NAME if defined * src/SDCCicode.h: added macro IS_ASSOCIATIVE * src/SDCCmem.c: updated comments, set far-space to 0 for pdata, results in optimized code * src/SDCCmem.h: added macro CONST_NAME * src/SDCCsymt.h: renumerated generic pointer types GPTYPE_... thereby moving the info into the highest bits, see also gptrget/gptrput * src/src.dsp: added sdcc.ico to project files * src/avr/gen.c (genCast): fixed bug 0x%d * src/avr/main.c (avr_port): added "CONST (CODE)" for const_name * src/ds390/gen.c (aopForRemat, adjustArithmeticResult): disconnected direct relation between ptr_type and DCL_TYPE, (genCast): fixed bug 0x%d * src/ds390/main.c (ds390_port, tininative_port, ds400_port): added "CONST (CODE)" for const_name * src/hc08/gen.c (genCast): fixed bug 0x%d * src/hc08/main.c (_hc08_genAssemblerPreamble): added .area ...const_name, (hc08_port): added "CONST (CODE)" for const_name * src/mcs51/gen.c (aopForSym): optimized pushing ACC, (aopForRemat, adjustArithmeticResult): disconnected direct relation between ptr_type and DCL_TYPE, (aopGetUsesAcc, aopGet, aopPut): changed first parameter from asmop* to operand* and took AOP() inside function so sfr-ness can be checked, (all over): repaired calls to aopGetUsesAcc, aopGet, aopPut to comply with new prototype, (genFunction, genEndFunction): optimized stack setup, (genMinus): optimized for literals with ending zeroes (in bytes), (genCast): fixed bug 0x%d * src/mcs51/main.c (_mcs51_keywords): added sfr16 and sfr32, (mcs51_port): added "CONST (CODE)" for const_name * src/mcs51/peeph.def: made rule 226 more generic * src/pic/main.c (pic_port): added "CONST (CODE)" for const_name * src/pic16/main.c (pic16_port): added "CONST (CODE)" for const_name * src/xa51/main.c (xa51_port): added "CONST (CODE)" for const_name * src/z80/main.c (z80_port): added NULL for const_name, (gbz80_port): added NULL for const_name * support/regression/tests/bug663539.c, * support/regression/tests/sfr16.c: new tests git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3789 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index a663d660..31e62b6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,58 @@ +2005-06-27 Maarten Brock + + * as/mcs51/asexpr.c (expr): disabled warning "not in .flat24 mode", + fixed old K&R prototypes + * as/mcs51/asout.c (outrb): always output as if generating 24bit addresses + * device/lib/_gptrget.c, + * device/lib/_gptrgetc.c, + * device/lib/_gptrput.c: changed versions for new memory indicator values, + also new versions for small generic pointers and banked generic pointers + * src/port.h: added const_name + * src/SDCC.lex: added keywords sfr16, __sfr16, sfr32, __sfr32 + * src/SDCC.y: added tokens SFR16, SFR32 and their sfr_attributes + * src/SDCCcse.c (findPrevIc): check all associative operators + * src/SDCCglue.c (emitMaps): use CONST_NAME if defined + * src/SDCCicode.h: added macro IS_ASSOCIATIVE + * src/SDCCmem.c: updated comments, + set far-space to 0 for pdata, results in optimized code + * src/SDCCmem.h: added macro CONST_NAME + * src/SDCCsymt.h: renumerated generic pointer types GPTYPE_... thereby + moving the info into the highest bits, see also gptrget/gptrput + * src/src.dsp: added sdcc.ico to project files + * src/avr/gen.c (genCast): fixed bug 0x%d + * src/avr/main.c (avr_port): added "CONST (CODE)" for const_name + * src/ds390/gen.c (aopForRemat, adjustArithmeticResult): disconnected direct + relation between ptr_type and DCL_TYPE, + (genCast): fixed bug 0x%d + * src/ds390/main.c (ds390_port, tininative_port, ds400_port): added "CONST + (CODE)" for const_name + * src/hc08/gen.c (genCast): fixed bug 0x%d + * src/hc08/main.c (_hc08_genAssemblerPreamble): added .area ...const_name, + (hc08_port): added "CONST (CODE)" for const_name + * src/mcs51/gen.c (aopForSym): optimized pushing ACC, + (aopForRemat, adjustArithmeticResult): disconnected direct relation + between ptr_type and DCL_TYPE, + (aopGetUsesAcc, aopGet, aopPut): changed first parameter from asmop* to + operand* and took AOP() inside function so sfr-ness can be checked, + (all over): repaired calls to aopGetUsesAcc, aopGet, aopPut to comply with + new prototype, + (genFunction, genEndFunction): optimized stack setup, + (genMinus): optimized for literals with ending zeroes (in bytes), + (genCast): fixed bug 0x%d + * src/mcs51/main.c (_mcs51_keywords): added sfr16 and sfr32, + (mcs51_port): added "CONST (CODE)" for const_name + * src/mcs51/peeph.def: made rule 226 more generic + * src/pic/main.c (pic_port): added "CONST (CODE)" for const_name + * src/pic16/main.c (pic16_port): added "CONST (CODE)" for const_name + * src/xa51/main.c (xa51_port): added "CONST (CODE)" for const_name + * src/z80/main.c (z80_port): added NULL for const_name, + (gbz80_port): added NULL for const_name + * support/regression/tests/bug663539.c, + * support/regression/tests/sfr16.c: new tests + 2005-06-25 Jesus Calvino-Fraga - * device/include/mcs51/p89v51rd2.h, device/include/mcs51/at89s53.h: added. + * device/include/mcs51/p89v51rd2.h, device/include/mcs51/at89s53.h: added. 2005-06-24 Raphael Neider @@ -23,7 +75,7 @@ 2005-06-20 Slade Rich - * src/pic/pcode.c : Fixed problem when a string constant contains a "\r\n" + * src/pic/pcode.c : Fixed problem when a string constant contains a "\r\n" and the output asm file line is printed on two lines. 2005-06-19 Erik Petrich @@ -36,7 +88,7 @@ negatedCmp, exchangedCmp, genhc08Code): rewrite of comparison handling, fixes bug #1216342 * src/hc08/peeph.def: added rules 2g - 2l for new conditional branches - + 2005-06-15 Raphael Neider * src/pic16/NOTES: moved Vangelis from active developers to people to contact @@ -52,7 +104,8 @@ 2005-06-02 Slade Rich - * src/pic/pcode.c : Changed pseudo stack size to 15 to allow WSAVE to be located in shared memory bank. + * src/pic/pcode.c : Changed pseudo stack size to 15 to allow WSAVE to be + located in shared memory bank. 2005-05-31 Raphael Neider diff --git a/as/mcs51/asexpr.c b/as/mcs51/asexpr.c index a21e9b0f..8eb5519f 100644 --- a/as/mcs51/asexpr.c +++ b/as/mcs51/asexpr.c @@ -1,4 +1,4 @@ - /* asexpr.c */ + /* asexpr.c */ /* * (C) Copyright 1989-1995 @@ -14,74 +14,72 @@ #include #include "asm.h" -/*)Module asexpr.c - * - * The module asexpr.c contains the routines to evaluate - * arithmetic/numerical expressions. The functions in - * asexpr.c perform a recursive evaluation of the arithmetic - * expression read from the assembler-source text line. - * The expression may include binary/unary operators, brackets, - * symbols, labels, and constants in hexadecimal, decimal, octal - * and binary. Arithmetic operations are prioritized and - * evaluated by normal arithmetic conventions. - * - * asexpr.c contains the following functions: - * VOID abscheck() - * Addr_T absexpr() - * VOID clrexpr() - * int digit() - * VOID expr() - * int oprio() - * VOID term() - * - * asexpr.c contains no local/static variables +/*)Module asexpr.c + * + * The module asexpr.c contains the routines to evaluate + * arithmetic/numerical expressions. The functions in + * asexpr.c perform a recursive evaluation of the arithmetic + * expression read from the assembler-source text line. + * The expression may include binary/unary operators, brackets, + * symbols, labels, and constants in hexadecimal, decimal, octal + * and binary. Arithmetic operations are prioritized and + * evaluated by normal arithmetic conventions. + * + * asexpr.c contains the following functions: + * VOID abscheck() + * Addr_T absexpr() + * VOID clrexpr() + * int digit() + * VOID expr() + * int oprio() + * VOID term() + * + * asexpr.c contains no local/static variables */ -/*)Function VOID expr(esp, n) - * - * expr * esp pointer to an expr structure - * int n a firewall priority; all top - * level calls (from the user) - * should be made with n set to 0. - * - * The function expr() evaluates an expression and - * stores its value and relocation information into - * the expr structure supplied by the user. - * - * local variables: - * int c current assembler-source - * text character - * int p current operator priority - * area * ap pointer to an area structure - * exp re internal expr structure - * - * global variables: - * char ctype[] array of character types, one per - * ASCII character - * - * functions called: - * VOID abscheck() asexpr.c - * VOID clrexpr() asexpr.c - * VOID expr() asexpr.c - * int getnb() aslex.c - * int oprio() asexpr.c - * VOID qerr() assubr.c - * VOID rerr() assubr.c - * VOID term() asexpr.c - * VOID unget() aslex.c - * - * - * side effects: - * An expression is evaluated modifying the user supplied - * expr structure, a sym structure maybe created for an - * undefined symbol, and the parse of the expression may - * terminate if a 'q' error occurs. +/*)Function VOID expr(esp, n) + * + * expr * esp pointer to an expr structure + * int n a firewall priority; all top + * level calls (from the user) + * should be made with n set to 0. + * + * The function expr() evaluates an expression and + * stores its value and relocation information into + * the expr structure supplied by the user. + * + * local variables: + * int c current assembler-source + * text character + * int p current operator priority + * area * ap pointer to an area structure + * exp re internal expr structure + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * + * functions called: + * VOID abscheck() asexpr.c + * VOID clrexpr() asexpr.c + * VOID expr() asexpr.c + * int getnb() aslex.c + * int oprio() asexpr.c + * VOID qerr() assubr.c + * VOID rerr() assubr.c + * VOID term() asexpr.c + * VOID unget() aslex.c + * + * + * side effects: + * An expression is evaluated modifying the user supplied + * expr structure, a sym structure maybe created for an + * undefined symbol, and the parse of the expression may + * terminate if a 'q' error occurs. */ VOID -expr(esp, n) -register struct expr *esp; -int n; +expr(register struct expr *esp, int n) { register int c, p; struct area *ap; @@ -89,31 +87,31 @@ int n; term(esp); while (ctype[c = getnb()] & BINOP) { - /* - * Handle binary operators + - * / & | % ^ << >> - */ + /* + * Handle binary operators + - * / & | % ^ << >> + */ if ((p = oprio(c)) <= n) break; if ((c == '>' || c == '<') && c != get()) qerr(); - clrexpr(&re); + clrexpr(&re); expr(&re, p); - esp->e_rlcf |= re.e_rlcf; + esp->e_rlcf |= re.e_rlcf; if (c == '+') { - /* - * esp + re, at least one must be absolute - */ + /* + * esp + re, at least one must be absolute + */ if (esp->e_base.e_ap == NULL) { - /* - * esp is absolute (constant), - * use area from re - */ + /* + * esp is absolute (constant), + * use area from re + */ esp->e_base.e_ap = re.e_base.e_ap; } else if (re.e_base.e_ap) { - /* - * re should be absolute (constant) - */ + /* + * re should be absolute (constant) + */ rerr(); } if (esp->e_flag && re.e_flag) @@ -123,9 +121,9 @@ int n; esp->e_addr += re.e_addr; } else if (c == '-') { - /* - * esp - re - */ + /* + * esp - re + */ if ((ap = re.e_base.e_ap) != NULL) { if (esp->e_base.e_ap == ap) { esp->e_base.e_ap = NULL; @@ -137,179 +135,178 @@ int n; rerr(); esp->e_addr -= re.e_addr; } else { - /* - * Both operands (esp and re) must be constants - */ - /* SD :- moved the abscheck to each case - case and change the right shift operator.. if - right shift by 8 bits of a relocatable address then - the user wants the higher order byte. set the R_MSB - for the expression */ + /* + * Both operands (esp and re) must be constants + */ + /* SD :- moved the abscheck to each case + case and change the right shift operator.. if + right shift by 8 bits of a relocatable address then + the user wants the higher order byte. set the R_MSB + for the expression */ switch (c) { case '*': - abscheck(esp); - abscheck(&re); - esp->e_addr *= re.e_addr; - break; + abscheck(esp); + abscheck(&re); + esp->e_addr *= re.e_addr; + break; case '/': - abscheck(esp); - abscheck(&re); - esp->e_addr /= re.e_addr; - break; + abscheck(esp); + abscheck(&re); + esp->e_addr /= re.e_addr; + break; case '&': - abscheck(esp); - abscheck(&re); - esp->e_addr &= re.e_addr; - break; + abscheck(esp); + abscheck(&re); + esp->e_addr &= re.e_addr; + break; case '|': - abscheck(esp); - abscheck(&re); - esp->e_addr |= re.e_addr; - break; + abscheck(esp); + abscheck(&re); + esp->e_addr |= re.e_addr; + break; case '%': - abscheck(esp); - abscheck(&re); - esp->e_addr %= re.e_addr; - break; + abscheck(esp); + abscheck(&re); + esp->e_addr %= re.e_addr; + break; case '^': - abscheck(esp); - abscheck(&re); - esp->e_addr ^= re.e_addr; - break; + abscheck(esp); + abscheck(&re); + esp->e_addr ^= re.e_addr; + break; case '<': - abscheck(esp); - abscheck(&re); - esp->e_addr <<= re.e_addr; - break; + abscheck(esp); + abscheck(&re); + esp->e_addr <<= re.e_addr; + break; case '>': - /* SD change here */ - abscheck(&re); - /* if the left is a relative address & - the right side is == 8 then */ - if (esp->e_base.e_ap && re.e_addr == 8) { - esp->e_rlcf |= R_MSB ; - break; - } - else if (esp->e_base.e_ap && re.e_addr == 16) - { - if (flat24Mode) - { - esp->e_rlcf |= R_HIB; - } - else - { - warnBanner(); - fprintf(stderr, - "(expr >> 16) is only meaningful in " - ".flat24 mode.\n"); - qerr(); - } - - break; - } - /* else continue with the normal processing */ - abscheck(esp); - esp->e_addr >>= re.e_addr; - break; - - default: - qerr(); - break; - } + /* SD change here */ + abscheck(&re); + /* if the left is a relative address & + the right side is == 8 then */ + if (esp->e_base.e_ap && re.e_addr == 8) { + esp->e_rlcf |= R_MSB ; + break; + } + else if (esp->e_base.e_ap && re.e_addr == 16) + { +// if (flat24Mode) +// { + esp->e_rlcf |= R_HIB; +// } +// else +// { +// warnBanner(); +// fprintf(stderr, +// "(expr >> 16) is only meaningful in " +// ".flat24 mode.\n"); +// qerr(); +// } + + break; + } + /* else continue with the normal processing */ + abscheck(esp); + esp->e_addr >>= re.e_addr; + break; + + default: + qerr(); + break; + } } } unget(c); } -/*)Function Addr_T absexpr() +/*)Function Addr_T absexpr() * - * The function absexpr() evaluates an expression, verifies it - * is absolute (i.e. not position dependent or relocatable), and - * returns its value. + * The function absexpr() evaluates an expression, verifies it + * is absolute (i.e. not position dependent or relocatable), and + * returns its value. * - * local variables: - * expr e expr structure + * local variables: + * expr e expr structure * - * global variables: - * none + * global variables: + * none * - * functions called: - * VOID abscheck() asexpr.c - * VOID clrexpr() asexpr.c - * VOID expr() asexpr.c + * functions called: + * VOID abscheck() asexpr.c + * VOID clrexpr() asexpr.c + * VOID expr() asexpr.c * - * side effects: - * If the expression is not absolute then - * a 'r' error is reported. + * side effects: + * If the expression is not absolute then + * a 'r' error is reported. */ Addr_T -absexpr() +absexpr(void) { struct expr e; - clrexpr(&e); - expr(&e, 0); - abscheck(&e); - return (e.e_addr); + clrexpr(&e); + expr(&e, 0); + abscheck(&e); + return (e.e_addr); } -/*)Function VOID term(esp) - * - * expr * esp pointer to an expr structure - * - * The function term() evaluates a single constant - * or symbol value prefaced by any unary operator - * ( +, -, ~, ', ", >, or < ). This routine is also - * responsible for setting the relocation type to symbol - * based (e.flag != 0) on global references. - * - * local variables: - * int c current character - * char id[] symbol name - * char * jp pointer to assembler-source text - * int n constant evaluation running sum - * int r current evaluation radix - * sym * sp pointer to a sym structure - * tsym * tp pointer to a tsym structure - * int v current digit evaluation - * - * global variables: - * char ctype[] array of character types, one per - * ASCII character - * sym * symp pointer to a symbol structure - * - * functions called: - * VOID abscheck() asexpr.c - * int digit() asexpr.c - * VOID err() assubr.c - * VOID expr() asexpr.c - * int is_abs() asexpr.c - * int get() aslex.c - * VOID getid() aslex.c - * int getmap() aslex.c - * int getnb() aslex.c - * sym * lookup() assym.c - * VOID qerr() assubr.c - * VOID unget() aslex.c - * - * side effects: - * An arithmetic term is evaluated, a symbol structure - * may be created, term evaluation may be terminated - * by a 'q' error. +/*)Function VOID term(esp) + * + * expr * esp pointer to an expr structure + * + * The function term() evaluates a single constant + * or symbol value prefaced by any unary operator + * ( +, -, ~, ', ", >, or < ). This routine is also + * responsible for setting the relocation type to symbol + * based (e.flag != 0) on global references. + * + * local variables: + * int c current character + * char id[] symbol name + * char * jp pointer to assembler-source text + * int n constant evaluation running sum + * int r current evaluation radix + * sym * sp pointer to a sym structure + * tsym * tp pointer to a tsym structure + * int v current digit evaluation + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * sym * symp pointer to a symbol structure + * + * functions called: + * VOID abscheck() asexpr.c + * int digit() asexpr.c + * VOID err() assubr.c + * VOID expr() asexpr.c + * int is_abs() asexpr.c + * int get() aslex.c + * VOID getid() aslex.c + * int getmap() aslex.c + * int getnb() aslex.c + * sym * lookup() assym.c + * VOID qerr() assubr.c + * VOID unget() aslex.c + * + * side effects: + * An arithmetic term is evaluated, a symbol structure + * may be created, term evaluation may be terminated + * by a 'q' error. */ VOID -term(esp) -register struct expr *esp; +term(register struct expr *esp) { register int c, n; register char *jp; @@ -319,16 +316,16 @@ register struct expr *esp; int r=0, v; c = getnb(); - /* - * Discard the unary '+' at this point and - * also any reference to numerical arguments - * associated with the '#' prefix. - */ + /* + * Discard the unary '+' at this point and + * also any reference to numerical arguments + * associated with the '#' prefix. + */ while (c == '+' || c == '#') { c = getnb(); } - /* - * Evaluate all binary operators - * by recursively calling expr(). - */ + /* + * Evaluate all binary operators + * by recursively calling expr(). + */ if (c == LFTERM) { expr(esp, 0); if (getnb() != RTTERM) @@ -365,28 +362,28 @@ register struct expr *esp; } if (c == '>' || c == '<') { expr(esp, 100); - if (is_abs (esp)) { - /* - * evaluate msb/lsb directly - */ - if (c == '>') - esp->e_addr >>= 8; - esp->e_addr &= 0377; - return; - } else { - /* - * let linker perform msb/lsb, lsb is default - */ - esp->e_rlcf |= R_BYT2; - if (c == '>') - esp->e_rlcf |= R_MSB; - return; - } + if (is_abs (esp)) { + /* + * evaluate msb/lsb directly + */ + if (c == '>') + esp->e_addr >>= 8; + esp->e_addr &= 0377; + return; + } else { + /* + * let linker perform msb/lsb, lsb is default + */ + esp->e_rlcf |= R_BYT2; + if (c == '>') + esp->e_rlcf |= R_MSB; + return; + } } - /* - * Evaluate digit sequences as local symbols - * if followed by a '$' or as constants. - */ + /* + * Evaluate digit sequences as local symbols + * if followed by a '$' or as constants. + */ if (ctype[c] & DIGIT) { esp->e_mode = S_USER; jp = ip; @@ -452,58 +449,58 @@ register struct expr *esp; esp->e_addr = n; return; } - /* - * Evaluate '$' sequences as a temporary radix - * if followed by a '%', '&', '#', or '$'. - */ + /* + * Evaluate '$' sequences as a temporary radix + * if followed by a '%', '&', '#', or '$'. + */ if (c == '$') { c = get(); if (c == '%' || c == '&' || c == '#' || c == '$') { - switch (c) { - case '%': - r = 2; - break; - case '&': - r = 8; - break; - case '#': - r = 10; - break; - case '$': - r = 16; - break; - default: - break; - } - c = get(); - n = 0; - while ((v = digit(c, r)) >= 0) { - n = r*n + v; - c = get(); - } - unget(c); - esp->e_mode = S_USER; - esp->e_addr = n; - return; - } - unget(c); - c = '$'; + switch (c) { + case '%': + r = 2; + break; + case '&': + r = 8; + break; + case '#': + r = 10; + break; + case '$': + r = 16; + break; + default: + break; + } + c = get(); + n = 0; + while ((v = digit(c, r)) >= 0) { + n = r*n + v; + c = get(); + } + unget(c); + esp->e_mode = S_USER; + esp->e_addr = n; + return; + } + unget(c); + c = '$'; } - /* - * Evaluate symbols and labels - */ + /* + * Evaluate symbols and labels + */ if (ctype[c] & LETTER) { esp->e_mode = S_USER; getid(id, c); sp = lookup(id); if (sp->s_type == S_NEW) { esp->e_addr = 0; - if (sp->s_flag&S_GBL) { - esp->e_flag = 1; - esp->e_base.e_sp = sp; - return; - } - /* err('u'); */ + if (sp->s_flag&S_GBL) { + esp->e_flag = 1; + esp->e_base.e_sp = sp; + return; + } + /* err('u'); */ } else { esp->e_mode = sp->s_type; esp->e_addr = sp->s_addr; @@ -511,38 +508,37 @@ register struct expr *esp; } return; } - /* - * Else not a term. - */ + /* + * Else not a term. + */ qerr(); } -/*)Function int digit(c, r) +/*)Function int digit(c, r) * - * int c digit character - * int r current radix + * int c digit character + * int r current radix * - * The function digit() returns the value of c - * in the current radix r. If the c value is not - * a number of the current radix then a -1 is returned. + * The function digit() returns the value of c + * in the current radix r. If the c value is not + * a number of the current radix then a -1 is returned. * - * local variables: - * none + * local variables: + * none * - * global variables: - * char ctype[] array of character types, one per - * ASCII character + * global variables: + * char ctype[] array of character types, one per + * ASCII character * - * functions called: - * none + * functions called: + * none * - * side effects: - * none + * side effects: + * none */ int -digit(c, r) -register int c, r; +digit(register int c, register int r) { if (r == 16) { if (ctype[c] & RAD16) { @@ -568,36 +564,35 @@ register int c, r; return (-1); } -/*)Function VOID abscheck(esp) +/*)Function VOID abscheck(esp) * - * expr * esp pointer to an expr structure + * expr * esp pointer to an expr structure * - * The function abscheck() tests the evaluation of an - * expression to verify it is absolute. If the evaluation - * is relocatable then an 'r' error is noted and the expression - * made absolute. + * The function abscheck() tests the evaluation of an + * expression to verify it is absolute. If the evaluation + * is relocatable then an 'r' error is noted and the expression + * made absolute. * - * Note: The area type (i.e. ABS) is not checked because - * the linker can be told to explicitly relocate an - * absolute area. + * Note: The area type (i.e. ABS) is not checked because + * the linker can be told to explicitly relocate an + * absolute area. * - * local variables: - * none + * local variables: + * none * - * global variables: - * none + * global variables: + * none * - * functions called: - * VOID rerr() assubr.c + * functions called: + * VOID rerr() assubr.c * - * side effects: - * The expression may be changed to absolute and the - * 'r' error invoked. + * side effects: + * The expression may be changed to absolute and the + * 'r' error invoked. */ VOID -abscheck(esp) -register struct expr *esp; +abscheck(register struct expr *esp) { if (esp->e_flag || esp->e_base.e_ap) { esp->e_flag = 0; @@ -606,64 +601,62 @@ register struct expr *esp; } } -/*)Function int is_abs(esp) +/*)Function int is_abs(esp) * - * expr * esp pointer to an expr structure + * expr * esp pointer to an expr structure * - * The function is_abs() tests the evaluation of an - * expression to verify it is absolute. If the evaluation - * is absolute then 1 is returned, else 0 is returned. + * The function is_abs() tests the evaluation of an + * expression to verify it is absolute. If the evaluation + * is absolute then 1 is returned, else 0 is returned. * - * Note: The area type (i.e. ABS) is not checked because - * the linker can be told to explicitly relocate an - * absolute area. + * Note: The area type (i.e. ABS) is not checked because + * the linker can be told to explicitly relocate an + * absolute area. * - * local variables: - * none + * local variables: + * none * - * global variables: - * none + * global variables: + * none * - * functions called: - * none + * functions called: + * none * - * side effects: - * none + * side effects: + * none */ int -is_abs (esp) -register struct expr *esp; +is_abs (register struct expr *esp) { if (esp->e_flag || esp->e_base.e_ap) { - return(0); + return(0); } - return(1); + return(1); } -/*)Function int oprio(c) +/*)Function int oprio(c) * - * int c operator character + * int c operator character * - * The function oprio() returns a relative priority - * for all valid unary and binary operators. + * The function oprio() returns a relative priority + * for all valid unary and binary operators. * - * local variables: - * none + * local variables: + * none * - * global variables: - * none + * global variables: + * none * - * functions called: - * none + * functions called: + * none * - * side effects: - * none + * side effects: + * none */ - + int -oprio(c) -register int c; +oprio(register int c) { if (c == '*' || c == '/' || c == '%') return (10); @@ -680,32 +673,31 @@ register int c; return (0); } -/*)Function VOID clrexpr(esp) +/*)Function VOID clrexpr(esp) * - * expr * esp pointer to expression structure + * expr * esp pointer to expression structure * - * The function clrexpr() clears the expression structure. + * The function clrexpr() clears the expression structure. * - * local variables: - * none + * local variables: + * none * - * global variables: - * none + * global variables: + * none * - * functions called: - * none + * functions called: + * none * - * side effects: - * expression structure cleared. + * side effects: + * expression structure cleared. */ - + VOID -clrexpr(esp) -register struct expr *esp; +clrexpr(register struct expr *esp) { - esp->e_mode = 0; - esp->e_flag = 0; - esp->e_addr = 0; - esp->e_base.e_ap = NULL; - esp->e_rlcf = 0; + esp->e_mode = 0; + esp->e_flag = 0; + esp->e_addr = 0; + esp->e_base.e_ap = NULL; + esp->e_rlcf = 0; } diff --git a/as/mcs51/asout.c b/as/mcs51/asout.c index 363a2c12..7c548fdc 100644 --- a/as/mcs51/asout.c +++ b/as/mcs51/asout.c @@ -8,8 +8,8 @@ * 721 Berkeley St. * Kent, Ohio 44240 * - * 28-Oct-97 JLH: - * - outsym: show s_id as string rather than array [NCPS] + * 28-Oct-97 JLH: + * - outsym: show s_id as string rather than array [NCPS] * - Added outr11 to support 8051's 11 bit destination address */ @@ -19,280 +19,280 @@ #include "asm.h" -/*)Module asout.c +/*)Module asout.c * - * The module asout.c contains all the functions used to - * generate the .REL assembler output file. + * The module asout.c contains all the functions used to + * generate the .REL assembler output file. * * - * The assemblers' output object file is an ascii file containing - * the information needed by the linker to bind multiple object - * modules into a complete loadable memory image. + * The assemblers' output object file is an ascii file containing + * the information needed by the linker to bind multiple object + * modules into a complete loadable memory image. * - * The object module contains the following designators: + * The object module contains the following designators: * - * [XDQ][HL] - * X Hexadecimal radix - * D Decimal radix - * Q Octal radix - * - * H Most significant byte first - * L Least significant byte first - * - * H Header - * M Module - * A Area - * S Symbol - * T Object code - * R Relocation information - * P Paging information + * [XDQ][HL] + * X Hexadecimal radix + * D Decimal radix + * Q Octal radix * + * H Most significant byte first + * L Least significant byte first * - * (1) Radix Line + * H Header + * M Module + * A Area + * S Symbol + * T Object code + * R Relocation information + * P Paging information * - * The first line of an object module contains the [XDQ][HL] - * format specifier (i.e. XH indicates a hexadecimal file with - * most significant byte first) for the following designators. * + * (1) Radix Line * - * (2) Header Line + * The first line of an object module contains the [XDQ][HL] + * format specifier (i.e. XH indicates a hexadecimal file with + * most significant byte first) for the following designators. * - * H aa areas gg global symbols * - * The header line specifies the number of areas(aa) and the - * number of global symbols(gg) defined or referenced in this ob- - * ject module segment. + * (2) Header Line * + * H aa areas gg global symbols * - * (3) Module Line + * The header line specifies the number of areas(aa) and the + * number of global symbols(gg) defined or referenced in this ob- + * ject module segment. * - * M name * - * The module line specifies the module name from which this - * header segment was assembled. The module line will not appear - * if the .module directive was not used in the source program. + * (3) Module Line * + * M name * - * (4) Symbol Line + * The module line specifies the module name from which this + * header segment was assembled. The module line will not appear + * if the .module directive was not used in the source program. * - * S string Defnnnn * - * or + * (4) Symbol Line * - * S string Refnnnn + * S string Defnnnn * - * The symbol line defines (Def) or references (Ref) the symbol - * 'string' with the value nnnn. The defined value is relative to - * the current area base address. References to constants and ex- - * ternal global symbols will always appear before the first area - * definition. References to external symbols will have a value of - * zero. + * or * + * S string Refnnnn * - * (5) Area Line + * The symbol line defines (Def) or references (Ref) the symbol + * 'string' with the value nnnn. The defined value is relative to + * the current area base address. References to constants and ex- + * ternal global symbols will always appear before the first area + * definition. References to external symbols will have a value of + * zero. * - * A label size ss flags ff * - * The area line defines the area label, the size (ss) of the - * area in bytes, and the area flags (ff). The area flags specify - * the ABS, REL, CON, OVR, and PAG parameters: + * (5) Area Line * - * OVR/CON (0x04/0x00 i.e. bit position 2) + * A label size ss flags ff * - * ABS/REL (0x08/0x00 i.e. bit position 3) + * The area line defines the area label, the size (ss) of the + * area in bytes, and the area flags (ff). The area flags specify + * the ABS, REL, CON, OVR, and PAG parameters: * - * PAG (0x10 i.e. bit position 4) + * OVR/CON (0x04/0x00 i.e. bit position 2) * + * ABS/REL (0x08/0x00 i.e. bit position 3) * - * (6) T Line + * PAG (0x10 i.e. bit position 4) * - * T xx xx nn nn nn nn nn ... * - * The T line contains the assembled code output by the assem- - * bler with xx xx being the offset address from the current area - * base address and nn being the assembled instructions and data in - * byte format. + * (6) T Line * + * T xx xx nn nn nn nn nn ... * - * (7) R Line + * The T line contains the assembled code output by the assem- + * bler with xx xx being the offset address from the current area + * base address and nn being the assembled instructions and data in + * byte format. * - * R 0 0 nn nn n1 n2 xx xx ... * - * The R line provides the relocation information to the linker. - * The nn nn value is the current area index, i.e. which area the - * current values were assembled. Relocation information is en- - * coded in groups of 4 bytes: + * (7) R Line * - * 1. n1 is the relocation mode and object format - * 1. bit 0 word(0x00)/byte(0x01) - * 2. bit 1 relocatable area(0x00)/symbol(0x02) - * 3. bit 2 normal(0x00)/PC relative(0x04) relocation - * 4. bit 3 1-byte(0x00)/2-byte(0x08) object format for - * byte data - * 5. bit 4 signed(0x00)/unsigned(0x10) byte data - * 6. bit 5 normal(0x00)/page '0'(0x20) reference - * 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference - * 8. bit 7 normal(0x00)/MSB of value + * R 0 0 nn nn n1 n2 xx xx ... * - * 2. n2 is a byte index into the corresponding (i.e. pre- - * ceeding) T line data (i.e. a pointer to the data to be - * updated by the relocation). The T line data may be - * 1-byte or 2-byte byte data format or 2-byte word - * format. + * The R line provides the relocation information to the linker. + * The nn nn value is the current area index, i.e. which area the + * current values were assembled. Relocation information is en- + * coded in groups of 4 bytes: * - * 3. xx xx is the area/symbol index for the area/symbol be- - * ing referenced. the corresponding area/symbol is found - * in the header area/symbol lists. + * 1. n1 is the relocation mode and object format + * 1. bit 0 word(0x00)/byte(0x01) + * 2. bit 1 relocatable area(0x00)/symbol(0x02) + * 3. bit 2 normal(0x00)/PC relative(0x04) relocation + * 4. bit 3 1-byte(0x00)/2-byte(0x08) object format for + * byte data + * 5. bit 4 signed(0x00)/unsigned(0x10) byte data + * 6. bit 5 normal(0x00)/page '0'(0x20) reference + * 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference + * 8. bit 7 normal(0x00)/MSB of value * + * 2. n2 is a byte index into the corresponding (i.e. pre- + * ceeding) T line data (i.e. a pointer to the data to be + * updated by the relocation). The T line data may be + * 1-byte or 2-byte byte data format or 2-byte word + * format. * - * The groups of 4 bytes are repeated for each item requiring relo- - * cation in the preceeding T line. + * 3. xx xx is the area/symbol index for the area/symbol be- + * ing referenced. the corresponding area/symbol is found + * in the header area/symbol lists. * * - * (8) P Line + * The groups of 4 bytes are repeated for each item requiring relo- + * cation in the preceeding T line. * - * P 0 0 nn nn n1 n2 xx xx * - * The P line provides the paging information to the linker as - * specified by a .setdp directive. The format of the relocation - * information is identical to that of the R line. The correspond- - * ing T line has the following information: - * T xx xx aa aa bb bb + * (8) P Line * - * Where aa aa is the area reference number which specifies the - * selected page area and bb bb is the base address of the page. - * bb bb will require relocation processing if the 'n1 n2 xx xx' is - * specified in the P line. The linker will verify that the base - * address is on a 256 byte boundary and that the page length of an - * area defined with the PAG type is not larger than 256 bytes. + * P 0 0 nn nn n1 n2 xx xx * - * The linker defaults any direct page references to the first - * area defined in the input REL file. All ASxxxx assemblers will - * specify the _CODE area first, making this the default page area. + * The P line provides the paging information to the linker as + * specified by a .setdp directive. The format of the relocation + * information is identical to that of the R line. The correspond- + * ing T line has the following information: + * T xx xx aa aa bb bb * + * Where aa aa is the area reference number which specifies the + * selected page area and bb bb is the base address of the page. + * bb bb will require relocation processing if the 'n1 n2 xx xx' is + * specified in the P line. The linker will verify that the base + * address is on a 256 byte boundary and that the page length of an + * area defined with the PAG type is not larger than 256 bytes. * - * asout.c contains the following functions: - * int lobyte() - * int hibyte() - * VOID out() - * VOID outab() - * VOID outall() - * VOID outarea() - * VOID outaw() - * VOID outbuf() - * VOID outchk() - * VOID outdot() - * VOID outdp() - * VOID outgsd() - * VOID outrb() - * VOID outrw() - * VOID outsym() - * VOID out_lb() - * VOID out_lw() - * VOID out_rw() - * VOID out_tw() + * The linker defaults any direct page references to the first + * area defined in the input REL file. All ASxxxx assemblers will + * specify the _CODE area first, making this the default page area. * - * The module asout.c contains the following local variables: - * int rel[] relocation data for code/data array - * int * relp pointer to rel array - * int txt[] assembled code/data array - * int * txtp pointer to txt array + * + * asout.c contains the following functions: + * int lobyte() + * int hibyte() + * VOID out() + * VOID outab() + * VOID outall() + * VOID outarea() + * VOID outaw() + * VOID outbuf() + * VOID outchk() + * VOID outdot() + * VOID outdp() + * VOID outgsd() + * VOID outrb() + * VOID outrw() + * VOID outsym() + * VOID out_lb() + * VOID out_lw() + * VOID out_rw() + * VOID out_tw() + * + * The module asout.c contains the following local variables: + * int rel[] relocation data for code/data array + * int * relp pointer to rel array + * int txt[] assembled code/data array + * int * txtp pointer to txt array */ -#define NTXT 16 -#define NREL 16 +#define NTXT 16 +#define NREL 16 -char txt[NTXT]; -char rel[NREL]; +char txt[NTXT]; +char rel[NREL]; -char *txtp = { &txt[0] }; -char *relp = { &rel[0] }; +char *txtp = { &txt[0] }; +char *relp = { &rel[0] }; -/*)Function VOID outab(b) +/*)Function VOID outab(b) * - * int b assembler data word + * int b assembler data word * - * The function outab() processes a single word of - * assembled data in absolute format. + * The function outab() processes a single word of + * assembled data in absolute format. * - * local variables: - * int * txtp pointer to data word + * local variables: + * int * txtp pointer to data word * - * global variables: - * int oflag -o, generate relocatable output flag - * int pass assembler pass number + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number * - * functions called: - * VOID outchk() asout.c - * VOID out_lb() asout.c + * functions called: + * VOID outchk() asout.c + * VOID out_lb() asout.c * - * side effects: - * The current assembly address is incremented by 1. + * side effects: + * The current assembly address is incremented by 1. */ VOID outab(b) { - if (pass == 2) { - out_lb(b,0); - if (oflag) { - outchk(1, 0); - *txtp++ = lobyte(b); - } - } - ++dot.s_addr; + if (pass == 2) { + out_lb(b,0); + if (oflag) { + outchk(1, 0); + *txtp++ = lobyte(b); + } + } + ++dot.s_addr; } -/*)Function VOID outaw(w) +/*)Function VOID outaw(w) * - * int w assembler data word + * int w assembler data word * - * The function outaw() processes a single word of - * assembled data in absolute format. + * The function outaw() processes a single word of + * assembled data in absolute format. * - * local variables: - * int * txtp pointer to data word + * local variables: + * int * txtp pointer to data word * - * global variables: - * int oflag -o, generate relocatable output flag - * int pass assembler pass number + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number * - * functions called: - * VOID outchk() asout.c - * VOID out_lw() asout.c + * functions called: + * VOID outchk() asout.c + * VOID out_lw() asout.c * - * side effects: - * The current assembly address is incremented by 2. + * side effects: + * The current assembly address is incremented by 2. */ VOID outaw(w) { - if (pass == 2) { - out_lw(w,0); - if (oflag) { - outchk(2, 0); - out_tw(w); - } - } - dot.s_addr += 2; + if (pass == 2) { + out_lw(w,0); + if (oflag) { + outchk(2, 0); + out_tw(w); + } + } + dot.s_addr += 2; } -/*)Function VOID write_rmode(r) +/*)Function VOID write_rmode(r) * - * int r relocation mode + * int r relocation mode * - * write_rmode puts the passed relocation mode into the - * output relp buffer, escaping it if necessary. + * write_rmode puts the passed relocation mode into the + * output relp buffer, escaping it if necessary. * - * global variables: - * int * relp pointer to rel array + * global variables: + * int * relp pointer to rel array * - * functions called: - * VOID rerr() assubr.c + * functions called: + * VOID rerr() assubr.c * - * side effects: - * relp is incremented appropriately. + * side effects: + * relp is incremented appropriately. */ VOID write_rmode(int r) @@ -304,355 +304,328 @@ write_rmode(int r) */ if ((r > 0xff) || ((r & R_ESCAPE_MASK) == R_ESCAPE_MASK)) { - /* Hack in up to an extra 4 bits of flags with escape. */ - if (r > 0xfff) - { - /* uh-oh.. we have more than 4 extra bits. */ - fprintf(stderr, - "Internal error: relocation mode 0x%X too big.\n", - r); - rerr(); - } - /* printf("escaping relocation mode\n"); */ - *relp++ = R_ESCAPE_MASK | (r >> 8); - *relp++ = r & 0xff; + /* Hack in up to an extra 4 bits of flags with escape. */ + if (r > 0xfff) + { + /* uh-oh.. we have more than 4 extra bits. */ + fprintf(stderr, + "Internal error: relocation mode 0x%X too big.\n", + r); + rerr(); + } + /* printf("escaping relocation mode\n"); */ + *relp++ = R_ESCAPE_MASK | (r >> 8); + *relp++ = r & 0xff; } else { - *relp++ = r; + *relp++ = r; } } -/*)Function VOID outrb(esp, r) - * - * expr * esp pointer to expr structure - * int r relocation mode - * - * The function outrb() processes a byte of generated code - * in either absolute or relocatable format dependent upon - * the data contained in the expr structure esp. If the - * .REL output is enabled then the appropriate information - * is loaded into the txt and rel buffers. - * - * local variables: - * int n symbol/area reference number - * int * relp pointer to rel array - * int * txtp pointer to txt array - * - * global variables: - * sym dot defined as sym[0] - * int oflag -o, generate relocatable output flag - * int pass assembler pass number - * - * functions called: - * VOID aerr() assubr.c - * VOID outchk() asout.c - * VOID out_lb() asout.c - * VOID out_rb() asout.c - * VOID out_tb() asout.c - * - * side effects: - * The current assembly address is incremented by 1. +/*)Function VOID outrb(esp, r) + * + * expr * esp pointer to expr structure + * int r relocation mode + * + * The function outrb() processes a byte of generated code + * in either absolute or relocatable format dependent upon + * the data contained in the expr structure esp. If the + * .REL output is enabled then the appropriate information + * is loaded into the txt and rel buffers. + * + * local variables: + * int n symbol/area reference number + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * sym dot defined as sym[0] + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID aerr() assubr.c + * VOID outchk() asout.c + * VOID out_lb() asout.c + * VOID out_rb() asout.c + * VOID out_tb() asout.c + * + * side effects: + * The current assembly address is incremented by 1. */ VOID outrb(struct expr *esp, int r) { - register int n; - - if (pass == 2) { - if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { - /* This is a constant; simply write the - * const byte to the T line and don't - * generate any relocation info. - */ - out_lb(lobyte(esp->e_addr),0); - if (oflag) { - outchk(1, 0); - *txtp++ = lobyte(esp->e_addr); - } - } else { - /* We are generating a single byte of relocatable - * info. - * - * In 8051 mode, we generate a 16 bit address. The - * linker will later select a single byte based on - * whether R_MSB is set. - * - * In flat24 mode, we generate a 24 bit address. The - * linker will select a single byte based on - * whether R_MSB or R_HIB is set. - */ - if (!flat24Mode) - { - r |= R_BYTE | R_BYT2 | esp->e_rlcf; - if (r & R_MSB) { - out_lb(hibyte(esp->e_addr),r|R_RELOC|R_HIGH); - } else { - out_lb(lobyte(esp->e_addr),r|R_RELOC); - } - if (oflag) { - outchk(2, 5); - out_tw(esp->e_addr); - if (esp->e_flag) { - n = esp->e_base.e_sp->s_ref; - r |= R_SYM; - } else { - n = esp->e_base.e_ap->a_ref; - } - write_rmode(r); - *relp++ = txtp - txt - 2; - out_rw(n); - } - } - else - { - /* 24 bit mode. */ - r |= R_BYTE | R_BYT3 | esp->e_rlcf; - if (r & R_HIB) - { - /* Probably should mark this differently in the - * listing file. - */ - out_lb(byte3(esp->e_addr),r|R_RELOC|R_HIGH); - } - else if (r & R_MSB) { - out_lb(hibyte(esp->e_addr),r|R_RELOC|R_HIGH); - } else { - out_lb(lobyte(esp->e_addr),r|R_RELOC); - } - if (oflag) { - outchk(3, 5); - out_t24(esp->e_addr); - if (esp->e_flag) { - n = esp->e_base.e_sp->s_ref; - r |= R_SYM; - } else { - n = esp->e_base.e_ap->a_ref; - } - write_rmode(r); - *relp++ = txtp - txt - 3; - out_rw(n); - } - } - } - } - ++dot.s_addr; + register int n; + + if (pass == 2) { + if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { + /* This is a constant; simply write the + * const byte to the T line and don't + * generate any relocation info. + */ + out_lb(lobyte(esp->e_addr),0); + if (oflag) { + outchk(1, 0); + *txtp++ = lobyte(esp->e_addr); + } + } else { + /* We are generating a single byte of relocatable + * info. + * + * We generate a 24 bit address. The linker will + * select a single byte based on whether R_MSB or + * R_HIB is set. + */ + { + /* 24 bit mode. */ + r |= R_BYTE | R_BYT3 | esp->e_rlcf; + if (r & R_HIB) + { + /* Probably should mark this differently in the + * listing file. + */ + out_lb(byte3(esp->e_addr),r|R_RELOC|R_HIGH); + } + else if (r & R_MSB) { + out_lb(hibyte(esp->e_addr),r|R_RELOC|R_HIGH); + } else { + out_lb(lobyte(esp->e_addr),r|R_RELOC); + } + if (oflag) { + outchk(3, 5); + out_t24(esp->e_addr); + if (esp->e_flag) { + n = esp->e_base.e_sp->s_ref; + r |= R_SYM; + } else { + n = esp->e_base.e_ap->a_ref; + } + write_rmode(r); + *relp++ = txtp - txt - 3; + out_rw(n); + } + } + } + } + ++dot.s_addr; } -/*)Function VOID outrw(esp, r) - * - * expr * esp pointer to expr structure - * int r relocation mode - * - * The function outrw() processes a word of generated code - * in either absolute or relocatable format dependent upon - * the data contained in the expr structure esp. If the - * .REL output is enabled then the appropriate information - * is loaded into the txt and rel buffers. - * - * local variables: - * int n symbol/area reference number - * int * relp pointer to rel array - * int * txtp pointer to txt array - * - * global variables: - * sym dot defined as sym[0] - * int oflag -o, generate relocatable output flag - * int pass assembler pass number - * - * functions called: - * VOID aerr() assubr.c - * VOID outchk() asout.c - * VOID out_lw() asout.c - * VOID out_rw() asout.c - * VOID out_tw() asout.c - * - * side effects: - * The current assembly address is incremented by 2. +/*)Function VOID outrw(esp, r) + * + * expr * esp pointer to expr structure + * int r relocation mode + * + * The function outrw() processes a word of generated code + * in either absolute or relocatable format dependent upon + * the data contained in the expr structure esp. If the + * .REL output is enabled then the appropriate information + * is loaded into the txt and rel buffers. + * + * local variables: + * int n symbol/area reference number + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * sym dot defined as sym[0] + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID aerr() assubr.c + * VOID outchk() asout.c + * VOID out_lw() asout.c + * VOID out_rw() asout.c + * VOID out_tw() asout.c + * + * side effects: + * The current assembly address is incremented by 2. */ VOID outrw(struct expr *esp, int r) { - register int n; - - if (pass == 2) { - - if (esp->e_addr > 0xffff) - { - warnBanner(); - fprintf(stderr, - "large constant 0x%x truncated to 16 bits\n", - esp->e_addr); - } - if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { - out_lw(esp->e_addr,0); - if (oflag) { - outchk(2, 0); - out_tw(esp->e_addr); - } - } else { - r |= R_WORD | esp->e_rlcf; - if (r & R_BYT2) { - rerr(); - if (r & R_MSB) { - out_lw(hibyte(esp->e_addr),r|R_RELOC); - } else { - out_lw(lobyte(esp->e_addr),r|R_RELOC); - } - } else { - out_lw(esp->e_addr,r|R_RELOC); - } - if (oflag) { - outchk(2, 5); - out_tw(esp->e_addr); - if (esp->e_flag) { - n = esp->e_base.e_sp->s_ref; - r |= R_SYM; - } else { - n = esp->e_base.e_ap->a_ref; - } - - if (IS_C24(r)) - { - /* If this happens, the linker will - * attempt to process this 16 bit field - * as 24 bits. That would be bad. - */ - fprintf(stderr, - "***Internal error: C24 out in " - "outrw()\n"); - rerr(); - } - write_rmode(r); - *relp++ = txtp - txt - 2; - out_rw(n); - } - } - } - dot.s_addr += 2; + register int n; + + if (pass == 2) { + + if (esp->e_addr > 0xffff) + { + warnBanner(); + fprintf(stderr, + "large constant 0x%x truncated to 16 bits\n", + esp->e_addr); + } + if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { + out_lw(esp->e_addr,0); + if (oflag) { + outchk(2, 0); + out_tw(esp->e_addr); + } + } else { + r |= R_WORD | esp->e_rlcf; + if (r & R_BYT2) { + rerr(); + if (r & R_MSB) { + out_lw(hibyte(esp->e_addr),r|R_RELOC); + } else { + out_lw(lobyte(esp->e_addr),r|R_RELOC); + } + } else { + out_lw(esp->e_addr,r|R_RELOC); + } + if (oflag) { + outchk(2, 5); + out_tw(esp->e_addr); + if (esp->e_flag) { + n = esp->e_base.e_sp->s_ref; + r |= R_SYM; + } else { + n = esp->e_base.e_ap->a_ref; + } + + if (IS_C24(r)) + { + /* If this happens, the linker will + * attempt to process this 16 bit field + * as 24 bits. That would be bad. + */ + fprintf(stderr, + "***Internal error: C24 out in " + "outrw()\n"); + rerr(); + } + write_rmode(r); + *relp++ = txtp - txt - 2; + out_rw(n); + } + } + } + dot.s_addr += 2; } -/*)Function VOID outr24(esp, r) - * - * expr * esp pointer to expr structure - * int r relocation mode - * - * The function outr24() processes 24 bits of generated code - * in either absolute or relocatable format dependent upon - * the data contained in the expr structure esp. If the - * .REL output is enabled then the appropriate information - * is loaded into the txt and rel buffers. - * - * local variables: - * int n symbol/area reference number - * int * relp pointer to rel array - * int * txtp pointer to txt array - * - * global variables: - * sym dot defined as sym[0] - * int oflag -o, generate relocatable output flag - * int pass assembler pass number - * - * functions called: - * VOID aerr() assubr.c - * VOID outchk() asout.c - * VOID out_l24() asout.c - * VOID out_rw() asout.c - * VOID out_t24() asout.c - * - * side effects: - * The current assembly address is incremented by 3. +/*)Function VOID outr24(esp, r) + * + * expr * esp pointer to expr structure + * int r relocation mode + * + * The function outr24() processes 24 bits of generated code + * in either absolute or relocatable format dependent upon + * the data contained in the expr structure esp. If the + * .REL output is enabled then the appropriate information + * is loaded into the txt and rel buffers. + * + * local variables: + * int n symbol/area reference number + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * sym dot defined as sym[0] + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID aerr() assubr.c + * VOID outchk() asout.c + * VOID out_l24() asout.c + * VOID out_rw() asout.c + * VOID out_t24() asout.c + * + * side effects: + * The current assembly address is incremented by 3. */ VOID outr24(struct expr *esp, int r) { - register int n; - - if (pass == 2) { - if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { - /* This is a constant expression. */ - out_l24(esp->e_addr,0); - if (oflag) { - outchk(3, 0); - out_t24(esp->e_addr); - } - } else { - /* This is a symbol. */ - r |= R_WORD | esp->e_rlcf; - if (r & R_BYT2) { - /* I have no idea what this case is. */ - rerr(); - if (r & R_MSB) { - out_lw(hibyte(esp->e_addr),r|R_RELOC); - } else { - out_lw(lobyte(esp->e_addr),r|R_RELOC); - } - } else { - out_l24(esp->e_addr,r|R_RELOC); - } - if (oflag) { - outchk(3, 5); - out_t24(esp->e_addr); - if (esp->e_flag) { - n = esp->e_base.e_sp->s_ref; - r |= R_SYM; - } else { - n = esp->e_base.e_ap->a_ref; - } - - if (r & R_BYTE) - { - /* If this occurs, we cannot properly - * code the relocation data with the - * R_C24 flag. This means the linker - * will fail to do the 24 bit relocation. - * Which will suck. - */ - fprintf(stderr, - "***Internal error: BYTE out in 24 " - "bit flat mode unexpected.\n"); - rerr(); - } - - write_rmode(r | R_C24); - *relp++ = txtp - txt - 3; - out_rw(n); - } - } - } - dot.s_addr += 3; + register int n; + + if (pass == 2) { + if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { + /* This is a constant expression. */ + out_l24(esp->e_addr,0); + if (oflag) { + outchk(3, 0); + out_t24(esp->e_addr); + } + } else { + /* This is a symbol. */ + r |= R_WORD | esp->e_rlcf; + if (r & R_BYT2) { + /* I have no idea what this case is. */ + rerr(); + if (r & R_MSB) { + out_lw(hibyte(esp->e_addr),r|R_RELOC); + } else { + out_lw(lobyte(esp->e_addr),r|R_RELOC); + } + } else { + out_l24(esp->e_addr,r|R_RELOC); + } + if (oflag) { + outchk(3, 5); + out_t24(esp->e_addr); + if (esp->e_flag) { + n = esp->e_base.e_sp->s_ref; + r |= R_SYM; + } else { + n = esp->e_base.e_ap->a_ref; + } + + if (r & R_BYTE) + { + /* If this occurs, we cannot properly + * code the relocation data with the + * R_C24 flag. This means the linker + * will fail to do the 24 bit relocation. + * Which will suck. + */ + fprintf(stderr, + "***Internal error: BYTE out in 24 " + "bit flat mode unexpected.\n"); + rerr(); + } + + write_rmode(r | R_C24); + *relp++ = txtp - txt - 3; + out_rw(n); + } + } + } + dot.s_addr += 3; } -/*)Function VOID outdp(carea, esp) - * - * area * carea pointer to current area strcuture - * expr * esp pointer to expr structure - * - * The function outdp() flushes the output buffer and - * outputs paging information to the .REL file. - * - * local variables: - * int n symbol/area reference number - * int r relocation mode - * int * relp pointer to rel array - * int * txtp pointer to txt array - * - * global variables: - * int oflag -o, generate relocatable output flag - * int pass assembler pass number - * - * functions called: - * VOID outbuf() asout.c - * VOID outchk() asout.c - * VOID out_rw() asout.c - * VOID out_tw() asout.c - * - * side effects: - * Output buffer flushed to .REL fiel. - * Paging information dumped to .REL file. +/*)Function VOID outdp(carea, esp) + * + * area * carea pointer to current area strcuture + * expr * esp pointer to expr structure + * + * The function outdp() flushes the output buffer and + * outputs paging information to the .REL file. + * + * local variables: + * int n symbol/area reference number + * int r relocation mode + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID outbuf() asout.c + * VOID outchk() asout.c + * VOID out_rw() asout.c + * VOID out_tw() asout.c + * + * side effects: + * Output buffer flushed to .REL fiel. + * Paging information dumped to .REL file. */ VOID @@ -660,727 +633,727 @@ outdp(carea, esp) register struct area *carea; register struct expr *esp; { - register int n, r; - - if (oflag && pass==2) { - outchk(HUGE,HUGE); - out_tw(carea->a_ref); - out_tw(esp->e_addr); - if (esp->e_flag || esp->e_base.e_ap!=NULL) { - r = R_WORD; - if (esp->e_flag) { - n = esp->e_base.e_sp->s_ref; - r |= R_SYM; - } else { - n = esp->e_base.e_ap->a_ref; - } - write_rmode(r); - *relp++ = txtp - txt - 2; - out_rw(n); - } - outbuf("P"); - } + register int n, r; + + if (oflag && pass==2) { + outchk(HUGE,HUGE); + out_tw(carea->a_ref); + out_tw(esp->e_addr); + if (esp->e_flag || esp->e_base.e_ap!=NULL) { + r = R_WORD; + if (esp->e_flag) { + n = esp->e_base.e_sp->s_ref; + r |= R_SYM; + } else { + n = esp->e_base.e_ap->a_ref; + } + write_rmode(r); + *relp++ = txtp - txt - 2; + out_rw(n); + } + outbuf("P"); + } } -/*)Function VOID outall() +/*)Function VOID outall() * - * The function outall() will output any bufferred assembled - * data and relocation information (during pass 2 if the .REL - * output has been enabled). + * The function outall() will output any bufferred assembled + * data and relocation information (during pass 2 if the .REL + * output has been enabled). * - * local variables: - * none + * local variables: + * none * - * global variables: - * int oflag -o, generate relocatable output flag - * int pass assembler pass number + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number * - * functions called: - * VOID outbuf() asout.c + * functions called: + * VOID outbuf() asout.c * - * side effects: - * assembled data and relocation buffers will be cleared. + * side effects: + * assembled data and relocation buffers will be cleared. */ VOID outall() { - if (oflag && pass==2) - outbuf("R"); + if (oflag && pass==2) + outbuf("R"); } -/*)Function VOID outdot() +/*)Function VOID outdot() * - * The function outdot() outputs information about the - * current program counter value (during pass 2 if the .REL - * output has been enabled). + * The function outdot() outputs information about the + * current program counter value (during pass 2 if the .REL + * output has been enabled). * - * local variables: - * none + * local variables: + * none * - * global variables: - * int oflag -o, generate relocatable output flag - * int pass assembler pass number + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number * - * functions called: - * int fprintf() c_library - * VOID out() asout.c + * functions called: + * int fprintf() c_library + * VOID out() asout.c * - * side effects: - * assembled data and relocation buffers will be cleared. + * side effects: + * assembled data and relocation buffers will be cleared. */ VOID outdot() { - if (oflag && pass==2) { - fprintf(ofp, "T"); - out(txt,(int) (txtp-txt)); - fprintf(ofp, "\n"); - fprintf(ofp, "R"); - out(rel,(int) (relp-rel)); - fprintf(ofp, "\n"); - txtp = txt; - relp = rel; - } + if (oflag && pass==2) { + fprintf(ofp, "T"); + out(txt,(int) (txtp-txt)); + fprintf(ofp, "\n"); + fprintf(ofp, "R"); + out(rel,(int) (relp-rel)); + fprintf(ofp, "\n"); + txtp = txt; + relp = rel; + } } -/*)Function outchk(nt, nr) +/*)Function outchk(nt, nr) * - * int nr number of additional relocation words - * int nt number of additional data words + * int nr number of additional relocation words + * int nt number of additional data words * - * The function outchk() checks the data and relocation buffers - * for space to insert the nt data words and nr relocation words. - * If space is not available then output the current data and - * initialize the data buffers to receive the new data. + * The function outchk() checks the data and relocation buffers + * for space to insert the nt data words and nr relocation words. + * If space is not available then output the current data and + * initialize the data buffers to receive the new data. * - * local variables: - * area * ap pointer to an area structure - * int * relp pointer to rel array - * int * txtp pointer to txt array + * local variables: + * area * ap pointer to an area structure + * int * relp pointer to rel array + * int * txtp pointer to txt array * - * global variables: - * sym dot defined as sym[0] + * global variables: + * sym dot defined as sym[0] * - * functions called: - * VOID outbuf() asout.c + * functions called: + * VOID outbuf() asout.c * - * side effects: - * Data and relocation buffers may be emptied and initialized. + * side effects: + * Data and relocation buffers may be emptied and initialized. */ VOID outchk(nt, nr) { - register struct area *ap; - - if (txtp+nt > &txt[NTXT] || relp+nr > &rel[NREL]) { - outbuf("R"); - } - if (txtp == txt) { - out_tw(dot.s_addr); - if ((ap = dot.s_area) != NULL) { - write_rmode(R_WORD|R_AREA); - *relp++ = 0; - out_rw(ap->a_ref); - } - } + register struct area *ap; + + if (txtp+nt > &txt[NTXT] || relp+nr > &rel[NREL]) { + outbuf("R"); + } + if (txtp == txt) { + out_tw(dot.s_addr); + if ((ap = dot.s_area) != NULL) { + write_rmode(R_WORD|R_AREA); + *relp++ = 0; + out_rw(ap->a_ref); + } + } } -/*)Function VOID outbuf() +/*)Function VOID outbuf() * - * The function outbuf() will output any bufferred data - * and relocation information to the .REL file. The output - * buffer pointers and counters are initialized. + * The function outbuf() will output any bufferred data + * and relocation information to the .REL file. The output + * buffer pointers and counters are initialized. * - * local variables: - * int rel[] relocation data for code/data array - * int * relp pointer to rel array - * int txt[] assembled code/data array - * int * txtp pointer to txt array + * local variables: + * int rel[] relocation data for code/data array + * int * relp pointer to rel array + * int txt[] assembled code/data array + * int * txtp pointer to txt array * - * global variables: - * FILE * ofp relocation output file handle + * global variables: + * FILE * ofp relocation output file handle * - * functions called: - * VOID out() asout.c + * functions called: + * VOID out() asout.c * - * side effects: - * All bufferred data written to .REL file and - * buffer pointers and counters initialized. + * side effects: + * All bufferred data written to .REL file and + * buffer pointers and counters initialized. */ VOID outbuf(s) char *s; { - if (txtp > &txt[2]) { - fprintf(ofp, "T"); - out(txt,(int) (txtp-txt)); - fprintf(ofp, "\n"); - fprintf(ofp, "%s", s); - out(rel,(int) (relp-rel)); - fprintf(ofp, "\n"); - } - txtp = txt; - relp = rel; + if (txtp > &txt[2]) { + fprintf(ofp, "T"); + out(txt,(int) (txtp-txt)); + fprintf(ofp, "\n"); + fprintf(ofp, "%s", s); + out(rel,(int) (relp-rel)); + fprintf(ofp, "\n"); + } + txtp = txt; + relp = rel; } -/*)Function VOID outgsd() - * - * The function outgsd() performs the following: - * (1) outputs the .REL file radix - * (2) outputs the header specifying the number - * of areas and global symbols - * (3) outputs the module name - * (4) set the reference number and output a symbol line - * for all external global variables and absolutes - * (5) output an area name, set reference number and output - * a symbol line for all global relocatables in the area. - * Repeat this proceedure for all areas. - * - * local variables: - * area * ap pointer to an area structure - * sym * sp pointer to a sym structure - * int i loop counter - * int j loop counter - * int c string character value - * int narea number of code areas - * char * ptr string pointer - * int nglob number of global symbols - * int rn symbol reference number - * - * global variables: - * area * areap pointer to an area structure - * char module[] module name string - * sym * symhash[] array of pointers to NHASH - * linked symbol lists - * int xflag -x, listing radix flag - * - * functions called: - * int fprintf() c_library - * VOID outarea() asout.c - * VOID outsym() asout.c - * int putc() c_library - * - * side effects: - * All symbols are given reference numbers, all symbol - * and area information is output to the .REL file. +/*)Function VOID outgsd() + * + * The function outgsd() performs the following: + * (1) outputs the .REL file radix + * (2) outputs the header specifying the number + * of areas and global symbols + * (3) outputs the module name + * (4) set the reference number and output a symbol line + * for all external global variables and absolutes + * (5) output an area name, set reference number and output + * a symbol line for all global relocatables in the area. + * Repeat this proceedure for all areas. + * + * local variables: + * area * ap pointer to an area structure + * sym * sp pointer to a sym structure + * int i loop counter + * int j loop counter + * int c string character value + * int narea number of code areas + * char * ptr string pointer + * int nglob number of global symbols + * int rn symbol reference number + * + * global variables: + * area * areap pointer to an area structure + * char module[] module name string + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * VOID outarea() asout.c + * VOID outsym() asout.c + * int putc() c_library + * + * side effects: + * All symbols are given reference numbers, all symbol + * and area information is output to the .REL file. */ VOID outgsd() { - register struct area *ap; - register struct sym *sp; - register int i, j; - char *ptr; - int c, narea, nglob, rn; - - /* - * Number of areas - */ - narea = areap->a_ref + 1; - - /* - * Number of global references/absolutes - */ - nglob = 0; - for (i = 0; i < NHASH; ++i) { - sp = symhash[i]; - while (sp) { - if (sp->s_flag&S_GBL) - ++nglob; - sp = sp->s_sp; - } - } - - /* - * Output Radix and number of areas and symbols - */ - if (xflag == 0) { - fprintf(ofp, "X%c\n", hilo ? 'H' : 'L'); - fprintf(ofp, "H %X areas %X global symbols\n", narea, nglob); - } else - if (xflag == 1) { - fprintf(ofp, "Q%c\n", hilo ? 'H' : 'L'); - fprintf(ofp, "H %o areas %o global symbols\n", narea, nglob); - } else - if (xflag == 2) { - fprintf(ofp, "D%c\n", hilo ? 'H' : 'L'); - fprintf(ofp, "H %u areas %u global symbols\n", narea, nglob); - } - - /* - * Module name - */ - if (module[0]) { - fprintf(ofp, "M "); - ptr = &module[0]; - while (ptr < &module[NCPS]) { - if ((c = *ptr++) != 0) - putc(c, ofp); - } - putc('\n', ofp); - } + register struct area *ap; + register struct sym *sp; + register int i, j; + char *ptr; + int c, narea, nglob, rn; + + /* + * Number of areas + */ + narea = areap->a_ref + 1; + + /* + * Number of global references/absolutes + */ + nglob = 0; + for (i = 0; i < NHASH; ++i) { + sp = symhash[i]; + while (sp) { + if (sp->s_flag&S_GBL) + ++nglob; + sp = sp->s_sp; + } + } + + /* + * Output Radix and number of areas and symbols + */ + if (xflag == 0) { + fprintf(ofp, "X%c\n", hilo ? 'H' : 'L'); + fprintf(ofp, "H %X areas %X global symbols\n", narea, nglob); + } else + if (xflag == 1) { + fprintf(ofp, "Q%c\n", hilo ? 'H' : 'L'); + fprintf(ofp, "H %o areas %o global symbols\n", narea, nglob); + } else + if (xflag == 2) { + fprintf(ofp, "D%c\n", hilo ? 'H' : 'L'); + fprintf(ofp, "H %u areas %u global symbols\n", narea, nglob); + } + + /* + * Module name + */ + if (module[0]) { + fprintf(ofp, "M "); + ptr = &module[0]; + while (ptr < &module[NCPS]) { + if ((c = *ptr++) != 0) + putc(c, ofp); + } + putc('\n', ofp); + } /* * Sdcc compile options */ - if (strlen(optsdcc)) fprintf(ofp, "O %s\n", optsdcc); - - /* - * Global references and absolutes. - */ - rn = 0; - for (i=0; is_area==NULL && sp->s_flag&S_GBL) { - sp->s_ref = rn++; - outsym(sp); - } - sp = sp->s_sp; - } - } - - /* - * Global relocatables. - */ - for (i=0; ia_ref != i) - ap = ap->a_ap; - outarea(ap); - for (j=0; js_area==ap && sp->s_flag&S_GBL) { - sp->s_ref = rn++; - outsym(sp); - } - sp = sp->s_sp; - } - } - } + if (strlen(optsdcc)) fprintf(ofp, "O %s\n", optsdcc); + + /* + * Global references and absolutes. + */ + rn = 0; + for (i=0; is_area==NULL && sp->s_flag&S_GBL) { + sp->s_ref = rn++; + outsym(sp); + } + sp = sp->s_sp; + } + } + + /* + * Global relocatables. + */ + for (i=0; ia_ref != i) + ap = ap->a_ap; + outarea(ap); + for (j=0; js_area==ap && sp->s_flag&S_GBL) { + sp->s_ref = rn++; + outsym(sp); + } + sp = sp->s_sp; + } + } + } } -/*)Function VOID outarea(ap) +/*)Function VOID outarea(ap) * - * area * ap pointer to an area structure + * area * ap pointer to an area structure * - * The function outarea() outputs the A line to the .REL - * file. The A line contains the area's name, size, and - * attributes. + * The function outarea() outputs the A line to the .REL + * file. The A line contains the area's name, size, and + * attributes. * - * local variables: - * char * ptr pointer to area id string - * int c character value + * local variables: + * char * ptr pointer to area id string + * int c character value * - * global variables: - * FILE * ofp relocation output file handle - * int xflag -x, listing radix flag + * global variables: + * FILE * ofp relocation output file handle + * int xflag -x, listing radix flag * - * functions called: - * int fprintf() c_library - * int putc() c_library + * functions called: + * int fprintf() c_library + * int putc() c_library * - * side effects: - * The A line is sent to the .REL file. + * side effects: + * The A line is sent to the .REL file. */ VOID outarea(ap) register struct area *ap; { - register char *ptr; - register int c; - - fprintf(ofp, "A "); - ptr = &ap->a_id[0]; - while (ptr < &ap->a_id[NCPS]) { - if ((c = *ptr++) != 0) - putc(c, ofp); - } - if (xflag == 0) { - fprintf(ofp, " size %X flags %X\n", ap->a_size, ap->a_flag); - } else - if (xflag == 1) { - fprintf(ofp, " size %o flags %o\n", ap->a_size, ap->a_flag); - } else - if (xflag == 2) { - fprintf(ofp, " size %u flags %u\n", ap->a_size, ap->a_flag); - } + register char *ptr; + register int c; + + fprintf(ofp, "A "); + ptr = &ap->a_id[0]; + while (ptr < &ap->a_id[NCPS]) { + if ((c = *ptr++) != 0) + putc(c, ofp); + } + if (xflag == 0) { + fprintf(ofp, " size %X flags %X\n", ap->a_size, ap->a_flag); + } else + if (xflag == 1) { + fprintf(ofp, " size %o flags %o\n", ap->a_size, ap->a_flag); + } else + if (xflag == 2) { + fprintf(ofp, " size %u flags %u\n", ap->a_size, ap->a_flag); + } } -/*)Function VOID outsym(sp) +/*)Function VOID outsym(sp) * - * sym * sp pointer to a sym structure + * sym * sp pointer to a sym structure * - * The function outsym() outputs the S line to the .REL - * file. The S line contains the symbols name and whether the - * the symbol is defined or referenced. + * The function outsym() outputs the S line to the .REL + * file. The S line contains the symbols name and whether the + * the symbol is defined or referenced. * - * local variables: - * char * ptr pointer to symbol id string - * int c character value + * local variables: + * char * ptr pointer to symbol id string + * int c character value * - * global variables: - * FILE * ofp relocation output file handle - * int xflag -x, listing radix flag + * global variables: + * FILE * ofp relocation output file handle + * int xflag -x, listing radix flag * - * functions called: - * int fprintf() c_library - * int putc() c_library + * functions called: + * int fprintf() c_library + * int putc() c_library * - * side effects: - * The S line is sent to the .REL file. + * side effects: + * The S line is sent to the .REL file. */ VOID outsym(sp) register struct sym *sp; { - register char *ptr; - - fprintf(ofp, "S "); - ptr = &sp->s_id[0]; - fprintf(ofp, "%s", ptr ); - fprintf(ofp, " %s", sp->s_type==S_NEW ? "Ref" : "Def"); - if (xflag == 0) { - fprintf(ofp, "%04X\n", sp->s_addr); - } else - if (xflag == 1) { - fprintf(ofp, "%06o\n", sp->s_addr); - } else - if (xflag == 2) { - fprintf(ofp, "%05u\n", sp->s_addr); - } + register char *ptr; + + fprintf(ofp, "S "); + ptr = &sp->s_id[0]; + fprintf(ofp, "%s", ptr ); + fprintf(ofp, " %s", sp->s_type==S_NEW ? "Ref" : "Def"); + if (xflag == 0) { + fprintf(ofp, "%04X\n", sp->s_addr); + } else + if (xflag == 1) { + fprintf(ofp, "%06o\n", sp->s_addr); + } else + if (xflag == 2) { + fprintf(ofp, "%05u\n", sp->s_addr); + } } -/*)Function VOID out(p, n) +/*)Function VOID out(p, n) * - * int n number of words to output - * int * p pointer to data words + * int n number of words to output + * int * p pointer to data words * - * The function out() outputs the data words to the .REL file - * int the specified radix. + * The function out() outputs the data words to the .REL file + * int the specified radix. * - * local variables: - * none + * local variables: + * none * - * global variables: - * FILE * ofp relocation output file handle - * int xflag -x, listing radix flag + * global variables: + * FILE * ofp relocation output file handle + * int xflag -x, listing radix flag * - * functions called: - * int fprintf() c_library + * functions called: + * int fprintf() c_library * - * side effects: - * Data is sent to the .REL file. + * side effects: + * Data is sent to the .REL file. */ VOID out(char *p, int n) { - while (n--) { - if (xflag == 0) { - fprintf(ofp, " %02X", (*p++)&0xff); - } else - if (xflag == 1) { - fprintf(ofp, " %03o", (*p++)&0xff); - } else - if (xflag == 2) { - fprintf(ofp, " %03u", (*p++)&0xff); - } - } + while (n--) { + if (xflag == 0) { + fprintf(ofp, " %02X", (*p++)&0xff); + } else + if (xflag == 1) { + fprintf(ofp, " %03o", (*p++)&0xff); + } else + if (xflag == 2) { + fprintf(ofp, " %03u", (*p++)&0xff); + } + } } -/*)Function VOID out_lb(b, t) +/*)Function VOID out_lb(b, t) * - * int b assembled data - * int t relocation type + * int b assembled data + * int t relocation type * - * The function out_lb() copies the assembled data and - * its relocation type to the list data buffers. + * The function out_lb() copies the assembled data and + * its relocation type to the list data buffers. * - * local variables: - * none + * local variables: + * none * - * global variables: - * int * cp pointer to assembler output array cb[] - * int * cpt pointer to assembler relocation type - * output array cbt[] + * global variables: + * int * cp pointer to assembler output array cb[] + * int * cpt pointer to assembler relocation type + * output array cbt[] * - * functions called: - * none + * functions called: + * none * - * side effects: - * Pointers to data and relocation buffers incremented by 1. + * side effects: + * Pointers to data and relocation buffers incremented by 1. */ VOID out_lb(b,t) register int b,t; { - if (cp < &cb[NCODE]) { - *cp++ = b; - *cpt++ = t; - } + if (cp < &cb[NCODE]) { + *cp++ = b; + *cpt++ = t; + } } -/*)Function VOID out_lw(n, t) +/*)Function VOID out_lw(n, t) * - * int n assembled data - * int t relocation type + * int n assembled data + * int t relocation type * - * The function out_lw() copies the assembled data and - * its relocation type to the list data buffers. + * The function out_lw() copies the assembled data and + * its relocation type to the list data buffers. * - * local variables: - * none + * local variables: + * none * - * global variables: - * int * cp pointer to assembler output array cb[] - * int * cpt pointer to assembler relocation type - * output array cbt[] + * global variables: + * int * cp pointer to assembler output array cb[] + * int * cpt pointer to assembler relocation type + * output array cbt[] * - * functions called: - * none + * functions called: + * none * - * side effects: - * Pointers to data and relocation buffers incremented by 2. + * side effects: + * Pointers to data and relocation buffers incremented by 2. */ VOID out_lw(n,t) register int n,t; { - if (hilo) { - out_lb(hibyte(n),t ? t|R_HIGH : 0); - out_lb(lobyte(n),t); - } else { - out_lb(lobyte(n),t); - out_lb(hibyte(n),t ? t|R_HIGH : 0); - } + if (hilo) { + out_lb(hibyte(n),t ? t|R_HIGH : 0); + out_lb(lobyte(n),t); + } else { + out_lb(lobyte(n),t); + out_lb(hibyte(n),t ? t|R_HIGH : 0); + } } -/*)Function VOID out_l24(n, t) +/*)Function VOID out_l24(n, t) * - * int n assembled data - * int t relocation type + * int n assembled data + * int t relocation type * - * The function out_l24() copies the assembled data and - * its relocation type to the list data buffers. + * The function out_l24() copies the assembled data and + * its relocation type to the list data buffers. * - * local variables: - * none + * local variables: + * none * - * global variables: - * int * cp pointer to assembler output array cb[] - * int * cpt pointer to assembler relocation type - * output array cbt[] + * global variables: + * int * cp pointer to assembler output array cb[] + * int * cpt pointer to assembler relocation type + * output array cbt[] * - * functions called: - * none + * functions called: + * none * - * side effects: - * Pointers to data and relocation buffers incremented by 3. + * side effects: + * Pointers to data and relocation buffers incremented by 3. */ VOID out_l24(int n, int t) { - if (hilo) { - out_lb(byte3(n),t ? t|R_HIGH : 0); - out_lb(hibyte(n),t); - out_lb(lobyte(n),t); - } else { - out_lb(lobyte(n),t); - out_lb(hibyte(n),t); - out_lb(byte3(n),t ? t|R_HIGH : 0); - } + if (hilo) { + out_lb(byte3(n),t ? t|R_HIGH : 0); + out_lb(hibyte(n),t); + out_lb(lobyte(n),t); + } else { + out_lb(lobyte(n),t); + out_lb(hibyte(n),t); + out_lb(byte3(n),t ? t|R_HIGH : 0); + } } -/*)Function VOID out_rw(n) +/*)Function VOID out_rw(n) * - * int n data word + * int n data word * - * The function out_rw() outputs the relocation (R) - * data word as two bytes ordered according to hilo. + * The function out_rw() outputs the relocation (R) + * data word as two bytes ordered according to hilo. * - * local variables: - * int * relp pointer to rel array + * local variables: + * int * relp pointer to rel array * - * global variables: - * none + * global variables: + * none * - * functions called: - * int lobyte() asout.c - * int hibyte() asout.c + * functions called: + * int lobyte() asout.c + * int hibyte() asout.c * - * side effects: - * Pointer to relocation buffer incremented by 2. + * side effects: + * Pointer to relocation buffer incremented by 2. */ VOID out_rw(n) register int n; { - if (hilo) { - *relp++ = hibyte(n); - *relp++ = lobyte(n); - } else { - *relp++ = lobyte(n); - *relp++ = hibyte(n); - } + if (hilo) { + *relp++ = hibyte(n); + *relp++ = lobyte(n); + } else { + *relp++ = lobyte(n); + *relp++ = hibyte(n); + } } -/*)Function VOID out_tw(n) +/*)Function VOID out_tw(n) * - * int n data word + * int n data word * - * The function out_tw() outputs the text (T) - * data word as two bytes ordered according to hilo. + * The function out_tw() outputs the text (T) + * data word as two bytes ordered according to hilo. * - * local variables: - * int * txtp pointer to txt array + * local variables: + * int * txtp pointer to txt array * - * global variables: - * none + * global variables: + * none * - * functions called: - * int lobyte() asout.c - * int hibyte() asout.c + * functions called: + * int lobyte() asout.c + * int hibyte() asout.c * - * side effects: - * Pointer to relocation buffer incremented by 2. + * side effects: + * Pointer to relocation buffer incremented by 2. */ VOID out_tw(n) register int n; { - if (hilo) { - *txtp++ = hibyte(n); - *txtp++ = lobyte(n); - } else { - *txtp++ = lobyte(n); - *txtp++ = hibyte(n); - } + if (hilo) { + *txtp++ = hibyte(n); + *txtp++ = lobyte(n); + } else { + *txtp++ = lobyte(n); + *txtp++ = hibyte(n); + } } -/*)Function VOID out_t24(n) +/*)Function VOID out_t24(n) * - * int n data word + * int n data word * - * The function out_t24() outputs the text (T) - * data word as three bytes ordered according to hilo. + * The function out_t24() outputs the text (T) + * data word as three bytes ordered according to hilo. * - * local variables: - * int * txtp pointer to txt array + * local variables: + * int * txtp pointer to txt array * - * global variables: - * none + * global variables: + * none * - * functions called: - * int lobyte() asout.c - * int hibyte() asout.c + * functions called: + * int lobyte() asout.c + * int hibyte() asout.c * - * side effects: - * Pointer to relocation buffer incremented by 3. + * side effects: + * Pointer to relocation buffer incremented by 3. */ VOID out_t24(int n) { - if (hilo) { - *txtp++ = byte3(n); - *txtp++ = hibyte(n); - *txtp++ = lobyte(n); - } else { - *txtp++ = lobyte(n); - *txtp++ = hibyte(n); - *txtp++ = byte3(n); - } + if (hilo) { + *txtp++ = byte3(n); + *txtp++ = hibyte(n); + *txtp++ = lobyte(n); + } else { + *txtp++ = lobyte(n); + *txtp++ = hibyte(n); + *txtp++ = byte3(n); + } } -/*)Function int lobyte(n) +/*)Function int lobyte(n) * - * int n data word + * int n data word * - * The function lobyte() returns the lower byte of - * integer n. + * The function lobyte() returns the lower byte of + * integer n. * - * local variables: - * none + * local variables: + * none * - * global variables: - * none + * global variables: + * none * - * functions called: - * none + * functions called: + * none * - * side effects: - * none + * side effects: + * none */ int lobyte(n) { - return (n&0377); + return (n&0377); } -/*)Function int hibyte(n) +/*)Function int hibyte(n) * - * int n data word + * int n data word * - * The function hibyte() returns the higher byte of - * integer n. + * The function hibyte() returns the higher byte of + * integer n. * - * local variables: - * none + * local variables: + * none * - * global variables: - * none + * global variables: + * none * - * functions called: - * none + * functions called: + * none * - * side effects: - * none + * side effects: + * none */ int hibyte(n) { - return ((n>>8)&0377); + return ((n>>8)&0377); } -/*)Function int byte3(n) +/*)Function int byte3(n) * - * int n 24 bit data + * int n 24 bit data * - * The function byte3() returns the MSB of the - * 24 bit integer n. + * The function byte3() returns the MSB of the + * 24 bit integer n. * - * local variables: - * none + * local variables: + * none * - * global variables: - * none + * global variables: + * none * - * functions called: - * none + * functions called: + * none * - * side effects: - * none + * side effects: + * none */ int byte3(int n) { - return ((n >> 16) & 0xff); + return ((n >> 16) & 0xff); } /* @@ -1395,21 +1368,21 @@ register struct expr *esp; int op; int r; { - register int n; + register int n; - if (pass == 2) { - if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { - /* equated absolute destination. Assume value + if (pass == 2) { + if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { + /* equated absolute destination. Assume value * relative to current area */ esp->e_base.e_ap = dot.s_area; - } + } /* Relocatable destination. Build THREE * byte output: relocatable word, followed * by op-code. Linker will combine them. * Listing shows only the address. */ - r |= R_WORD | esp->e_rlcf; + r |= R_WORD | esp->e_rlcf; out_lw(esp->e_addr,r|R_RELOC); if (oflag) { outchk(3, 5); @@ -1426,8 +1399,8 @@ int r; *relp++ = txtp - txt - 3; out_rw(n); } - } - dot.s_addr += 2; + } + dot.s_addr += 2; } /* @@ -1440,27 +1413,27 @@ int r; VOID outr19(struct expr * esp, int op, int r) { - register int n; + register int n; - if (pass == 2) { - if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { - /* equated absolute destination. Assume value + if (pass == 2) { + if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { + /* equated absolute destination. Assume value * relative to current area */ esp->e_base.e_ap = dot.s_area; - } + } /* Relocatable destination. Build FOUR * byte output: relocatable 24-bit entity, followed * by op-code. Linker will combine them. * Listing shows only the address. */ - r |= R_WORD | esp->e_rlcf; + r |= R_WORD | esp->e_rlcf; out_l24(esp->e_addr,r|R_RELOC); if (oflag) { outchk(4, 5); out_t24(esp->e_addr); *txtp++ = op; - + if (esp->e_flag) { n = esp->e_base.e_sp->s_ref; r |= R_SYM; @@ -1471,6 +1444,6 @@ outr19(struct expr * esp, int op, int r) *relp++ = txtp - txt - 4; out_rw(n); } - } - dot.s_addr += 3; + } + dot.s_addr += 3; } diff --git a/device/lib/_gptrget.c b/device/lib/_gptrget.c index adcbd7e3..18a2f588 100644 --- a/device/lib/_gptrget.c +++ b/device/lib/_gptrget.c @@ -30,60 +30,241 @@ (don't drive high byte of address bus for movx @Ri only) */ #define USE_PDATA_PAGING_REGISTER 0 +__sbit __at (0xF7) B_7; +__sbit __at (0xF6) B_6; +__sbit __at (0xF5) B_5; + /* the return value is expected to be in acc, and not in the standard * location dpl. Therefore we choose return type void here: */ +#if defined DSDCC_MODEL_HUGE void _gptrget (char *gptr) _naked { +/* This is the banked version with pointers up to 23 bits. + B cannot be trashed */ + gptr; /* hush the compiler */ _asm - ar0 = 0x00 - ; save values passed ; ; depending on the pointer type acc. to SDCCsymt.h ; - mov a,b - jz 00001$ ; 0 near - dec a - jz 00002$ ; 1 far - dec a - jz 00003$ ; 2 code - dec a - jz 00004$ ; 3 pdata - dec a ; 4 skip generic pointer - dec a - jz 00001$ ; 5 idata + jb _B_7,codeptr$ ; >0x80 code ; 3 + jnb _B_6,xdataptr$ ; <0x40 far ; 3 + + mov dph,r0 ; save r0 independant of regbank ; 2 + mov r0,dpl ; use only low order address ; 2 + + jb _B_5,pdataptr$ ; >0x60 pdata ; 3 + ; + ; Pointer to data space + ; + mov a,@r0 ; 1 + mov r0,dph ; restore r0 ; 2 + mov dph,#0 ; restore dph ; 2 + ret ; 1 + ; + ; pointer to external stack or pdata + ; + pdataptr$: + movx a,@r0 ; 1 + mov r0,dph ; restore r0 ; 2 + mov dph,#0 ; restore dph ; 2 + ret ; 1 + ; + ; pointer to code area + ; + codeptr$: + ; implementation for SiLabs C8051F12x + mov a,b ; 2 + anl a,0x03 ; 2 + swap a ; 1 + anl _PSBANK,#0x0F ; 3 + orl _PSBANK,a ; 2 + + clr a ; 1 + movc a,@a+dptr ; 1 + ret ; 1 + ; + ; pointer to xternal data + ; + xdataptr$: + ; implementation for xram a16-a21 tied to P3 + mov _P3,b ; 3 + + movx a,@dptr ; 1 + ret ; 1 + ;=== + ;43 bytes + _endasm ; +} + +#elif defined DSDCC_MODEL_MEDIUM + +void +_gptrget (char *gptr) _naked +{ +/* This is the non-banked version with pointers up to 15 bits. + Assumes B is free to be used */ + + gptr; /* hush the compiler */ + + _asm + ; + ; depending on the pointer type acc. to SDCCsymt.h + ; + mov b,dph ; 3 + jb _B_7,codeptr$ ; >0x80 code ; 3 + jnb _B_6,xdataptr$ ; <0x40 far ; 3 + + mov b,r0 ; save r0 independant of regbank ; 2 + mov r0,dpl ; use only low order address ; 2 + + jb _B_5,pdataptr$ ; >0x60 pdata ; 3 + ; + ; Pointer to data space + ; + mov a,@r0 ; 1 + mov r0,b ; restore r0 ; 2 + ret ; 1 + ; + ; pointer to xternal stack or pdata + ; + pdataptr$: + movx a,@r0 ; 1 + mov r0,b ; restore r0 ; 2 + ret ; 1 + ; + ; pointer to code area, max 15 bits + ; + codeptr$: + ; 0x8000 <= dptr <= 0xFFFF + ; no need to AND dph and restore from B if hardware wraps code memory + anl dph,#0x7F ; 3 + clr a ; 1 + movc a,@a+dptr ; 1 + mov dph,b ; 3 + ret ; 1 + ; + ; pointer to xternal data, max 14 bits + ; + xdataptr$: + ; 0 <= dptr <= 0x3FFF + movx a,@dptr ; 1 + ret ; 1 + ;=== + ;35 bytes + _endasm ; +} + +#elif 1 + +void +_gptrget (char *gptr) _naked +{ +/* This is the new version with pointers up to 16 bits. + B cannot be trashed */ + + gptr; /* hush the compiler */ + + _asm + ; + ; depending on the pointer type acc. to SDCCsymt.h + ; + jb _B_7,codeptr$ ; >0x80 code ; 3 + jnb _B_6,xdataptr$ ; <0x40 far ; 3 + + mov dph,r0 ; save r0 independant of regbank ; 2 + mov r0,dpl ; use only low order address ; 2 + + jb _B_5,pdataptr$ ; >0x60 pdata ; 3 + ; + ; Pointer to data space + ; + mov a,@r0 ; 1 + mov r0,dph ; restore r0 ; 2 + mov dph,#0 ; restore dph ; 2 + ret ; 1 + ; + ; pointer to xternal stack or pdata + ; + pdataptr$: + movx a,@r0 ; 1 + mov r0,dph ; restore r0 ; 2 + mov dph,#0 ; restore dph ; 2 + ret ; 1 + ; + ; pointer to code area, max 16 bits + ; + codeptr$: + clr a ; 1 + movc a,@a+dptr ; 1 + ret ; 1 + ; + ; pointer to xternal data, max 16 bits + ; + xdataptr$: + movx a,@dptr ; 1 + ret ; 1 + ;=== + ;30 bytes + _endasm ; +} + +#else + +void +_gptrget (char *gptr) _naked +{ +/* This is the old version with pointers up to 16 bits. */ + + gptr; /* hush the compiler */ + + _asm + ; + ; depending on the pointer type acc. to SDCCsymt.h + ; + mov a,b ; 2 + jz 00001$ ; 0 near ; 2 + dec a ; 1 + jz 00002$ ; 1 far ; 2 + dec a ; 1 + jz 00003$ ; 2 code ; 2 + dec a ; 1 + jz 00004$ ; 3 pdata ; 2 + dec a ; 4 skip generic pointer ; 1 + dec a ; 1 + jz 00001$ ; 5 idata ; 2 ; ; any other value for type ; return xFF - mov a,#0xff - ret + mov a,#0xff ; 2 + ret ; 1 ; ; Pointer to data space ; 00001$: - push ar0 + push ar0 ; 2 ; - mov r0,dpl ; use only low order address - mov a,@r0 + mov r0,dpl ; use only low order address ; 2 + mov a,@r0 ; 1 ; - pop ar0 + pop ar0 ; 2 ; - ret + ret ; 1 ; ; pointer to xternal data ; 00002$: - movx a,@dptr - ret + movx a,@dptr ; 1 + ret ; 1 ; ; pointer to code area ; 00003$: ; clr a is already 0 - movc a,@a+dptr - ret + movc a,@a+dptr ; 1 + ret ; 1 ; ; pointer to xternal stack or pdata ; @@ -92,18 +273,91 @@ _gptrget (char *gptr) _naked mov dph,__XPAGE ; __XPAGE (usually p2) holds high byte for pdata access movx a,@dptr #else - push ar0 - mov r0,dpl - movx a,@r0 - pop ar0 + push ar0 ; 2 + mov r0,dpl ; 2 + movx a,@r0 ; 1 + pop ar0 ; 2 #endif - ret + ret ; 1 + ;=== + ;40 bytes _endasm ; } +#endif #ifdef SDCC_ds390 /* the return value is expected to be in acc/_ap, and not in the standard * location dpl/dph. Therefore we choose return type void here: */ + +#if 1 + +void +_gptrgetWord (unsigned *gptr) +{ +/* This is the new version */ + gptr; /* hush the compiler */ + + _asm + ; + ; depending on the pointer type acc. to SDCCsymt.h + ; + jb _B_7,00003$ ; >0x80 code + jnb _B_6,00002$ ; <0x40 far + + mov dph,r0 ; save r0 independant of regbank + mov r0,dpl ; use only low order address + + jb _B_5,00004$ ; >0x60 pdata + ; + ; Pointer to data space + ; + mov _ap,@r0 + inc r0 + mov a,@r0 + inc dpl + sjmp 00005$ + ; + ; pointer to xternal data + ; + 00002$: + movx a,@dptr + mov _ap,a + inc dptr + movx a,@dptr + sjmp 00006$ +; +; pointer to code area +; + 00003$: + clr a + movc a,@a+dptr + mov _ap,a + clr a + inc dptr + movc a,@a+dptr + sjmp 00006$ +; +; pointer to xternal stack +; + 00004$: + movx a,@r0 + mov _ap,a + inc r0 + movx a,@r0 + inc dpl +; +; restore and return +; + 00005$: + mov r0,dph ; restore r0 + mov dph,#0 ; restore dph + 00006$: + _endasm ; + +} + +#else + void _gptrgetWord (unsigned *gptr) { @@ -175,9 +429,11 @@ _gptrgetWord (unsigned *gptr) ; restore and return ; 00005$: - pop ar0 + pop ar0 00006$: - _endasm ; + _endasm ; } #endif + +#endif diff --git a/device/lib/_gptrgetc.c b/device/lib/_gptrgetc.c index 745fe4a4..1ea7c5b9 100644 --- a/device/lib/_gptrgetc.c +++ b/device/lib/_gptrgetc.c @@ -26,6 +26,60 @@ /* the return value is expected to be in acc, and not in the standard * location dpl. Therefore we choose return type void here: */ + +#if 1 + +void +_gptrgetc (char *gptr) _naked +{ +/* This is the new version with pointers up to 16 bits. + B cannot be trashed */ + + gptr; /* hush the compiler */ + + _asm + ; save values passed + ; + ; depending on the pointer type acc. to SDCCsymt.h + ; + jb _B_7,codeptr$ ; >0x80 code ; 3 + jnb _B_6,xdataptr$ ; <0x40 far ; 3 + + mov dph,r0 ; save r0 independant of regbank ; 2 + mov r0,dpl ; use only low order address ; 2 + + jb _B_5,pdataptr$ ; >0x60 pdata ; 3 + ; + ; Pointer to data space + ; + mov a,@r0 ; 1 + mov r0,dph ; restore r0 ; 2 + mov dph,#0 ; restore dph ; 2 + ret ; 1 + ; + ; pointer to external stack or pdata + ; + pdataptr$: + movx a,@r0 ; 1 + mov r0,dph ; restore r0 ; 2 + mov dph,#0 ; restore dph ; 2 + ret ; 1 +; +; pointer to xternal data +; pointer to code area +; + codeptr$: + xdataptr$: + clr a ; 1 + movc a,@a+dptr ; 1 + ret ; 1 + ;=== + ;28 bytes + _endasm ; +} + +#else + void _gptrgetc (char *gptr) _naked { @@ -85,3 +139,4 @@ _gptrgetc (char *gptr) _naked _endasm ; } +#endif diff --git a/device/lib/_gptrput.c b/device/lib/_gptrput.c index 316a1834..b424b4d7 100644 --- a/device/lib/_gptrput.c +++ b/device/lib/_gptrput.c @@ -30,47 +30,205 @@ (don't drive high byte of address bus for movx @Ri only) */ #define USE_PDATA_PAGING_REGISTER 0 +__sbit __at (0xF7) B_7; +__sbit __at (0xF6) B_6; +__sbit __at (0xF5) B_5; + +#if defined DSDCC_MODEL_HUGE +void +_gptrput (char *gptr, char c) _naked +{ +/* This is the banked version with pointers up to 22 bits. + B cannot be trashed */ + + gptr; c; /* hush the compiler */ + + _asm + ; + ; depending on the pointer type according to SDCCsymt.h + ; + jb _B_7,codeptr$ ; >0x80 code ; 3 + jnb _B_6,xdataptr$ ; <0x40 far ; 3 + + mov dph,r0 ; save r0 independant of regbank ; 2 + mov r0,dpl ; use only low order address ; 2 + + jb _B_5,pdataptr$ ; >0x60 pdata ; 3 + ; + ; store into near/idata space + ; + mov @r0,a ; 1 + mov r0,dph ; restore r0 ; 2 + mov dph,#0 ; restore dph ; 2 + + codeptr$: + ret ; 1 + ; + ; store into external stack/pdata space + ; + pdataptr$: + movx @r0,a ; 1 + mov r0,dph ; restore r0 ; 2 + mov dph,#0 ; restore dph ; 2 + ret ; 1 + ; + ; store into far space + ; + xdataptr$: + mov _P3,b ; 3 + + movx @dptr,a ; 1 + ret ; 1 + + ;=== + ;30 bytes +_endasm; +} + +#elif defined DSDCC_MODEL_MEDIUM + +void +_gptrput (char *gptr, char c) _naked +{ +/* This is the non-banked version with pointers up to 14 bits. + Assumes B is free to be used */ + + gptr; c; /* hush the compiler */ + + _asm + ; + ; depending on the pointer type according to SDCCsymt.h + ; + mov b,dph ; 3 + jb _B_7,codeptr$ ; >0x80 code ; 3 + jnb _B_6,xdataptr$ ; <0x40 far ; 3 + + mov b,r0 ; save r0 independant of regbank ; 2 + mov r0,dpl ; use only low order address ; 2 + + jb _B_5,pdataptr$ ; >0x60 pdata ; 3 + ; + ; store into near/idata space + ; + mov @r0,a ; 1 + mov r0,b ; restore r0 ; 2 + + codeptr$: + ret ; 1 + ; + ; store into external stack/pdata space + ; + pdataptr$: + movx @r0,a ; 1 + mov r0,b ; restore r0 ; 2 + ret ; 1 + ; + ; store into far space, max 14 bits + ; + xdataptr$: + ; 0 <= dptr <= 0x3FFF + movx @dptr,a ; 1 + ret ; 1 + ;=== + ;26 bytes + _endasm; +} + +#elif 1 + +void +_gptrput (char *gptr, char c) _naked +{ +/* This is the new version with pointers up to 16 bits. + B cannot be trashed */ + + gptr; c; /* hush the compiler */ + + _asm + ; + ; depending on the pointer type according to SDCCsymt.h + ; + jb _B_7,codeptr$ ; >0x80 code ; 3 + jnb _B_6,xdataptr$ ; <0x40 far ; 3 + + mov dph,r0 ; save r0 independant of regbank ; 2 + mov r0,dpl ; use only low order address ; 2 + + jb _B_5,pdataptr$ ; >0x60 pdata ; 3 + ; + ; store into near/idata space + ; + mov @r0,a ; 1 + mov r0,dph ; restore r0 ; 2 + mov dph,#0 ; restore dph ; 2 + + codeptr$: + ret ; 1 + ; + ; store into external stack/pdata space + ; + pdataptr$: + movx @r0,a ; 1 + mov r0,dph ; restore r0 ; 2 + mov dph,#0 ; restore dph ; 2 + ret ; 1 + ; + ; store into far space + ; + xdataptr$: + movx @dptr,a ; 1 + ret ; 1 + + ;=== + ;27 bytes +_endasm; +} + +#else + void _gptrput (char *gptr, char c) _naked { +/* This is the old version with pointers up to 16 bits. */ + gptr; c; /* hush the compiler */ _asm ar0 = 0x00 - push acc + push acc ; 2 ; ; depending on the pointer type acc. to SDCCsymt.h ; - mov a,b - jz 00001$ ; 0 near - dec a - jz 00002$ ; 1 far - dec a - jz 00003$ ; 2 code - dec a - jz 00004$ ; 3 pdata - dec a ; 4 skip generic pointer - dec a - jz 00001$ ; 5 idata + mov a,b ; 2 + jz 00001$ ; 0 near ; 2 + dec a ; 1 + jz 00002$ ; 1 far ; 2 + dec a ; 1 + jz 00003$ ; 2 code ; 2 + dec a ; 1 + jz 00004$ ; 3 pdata ; 2 + dec a ; 4 skip generic pointer ; 1 + dec a ; 1 + jz 00001$ ; 5 idata ; 2 00003$: - pop acc ; do nothing - ret + pop acc ; do nothing ; 2 + ret ; 1 ; ; store into near space ; 00001$: - pop acc - push ar0 - mov r0,dpl - mov @r0,a - pop ar0 - ret + pop acc ; 2 + push ar0 ; 2 + mov r0,dpl ; 2 + mov @r0,a ; 1 + pop ar0 ; 2 + ret ; 1 00002$: - pop acc - movx @dptr,a - ret + pop acc ; 2 + movx @dptr,a ; 1 + ret ; 1 00004$: #if USE_PDATA_PAGING_REGISTER @@ -78,17 +236,79 @@ _gptrput (char *gptr, char c) _naked mov dph,__XPAGE ; __XPAGE (usually p2) holds high byte for pdata access movx @dptr,a #else - pop acc - push ar0 - mov r0,dpl - movx @r0,a - pop ar0 + pop acc ; 2 + push ar0 ; 2 + mov r0,dpl ; 2 + movx @r0,a ; 1 + pop ar0 ; 2 #endif - ret + ret ; 1 + ;=== + ;46 bytes _endasm; } +#endif #ifdef SDCC_ds390 + +#if 1 + +void +_gptrputWord () +{ + _asm + ; + ; depending on the pointer type acc. to SDCCsymt.h + ; + jb _B_7,00013$ ; >0x80 code + jnb _B_6,00012$ ; <0x40 far + + mov dph,r0 ; save r0 independant of regbank + mov r0,dpl ; use only low order address + + jb _B_5,00014$ ; >0x60 pdata +; +; store into near space +; + mov @r0,_ap + inc r0 + mov @r0,a + sjmp 00015$ +; +; store into far space +; + 00012$: + xch a,_ap + movx @dptr,a + inc dptr + xch a,_ap + movx @dptr,a + sjmp 00016$ +; +; store into code space +; + 00013$: + inc dptr ; do nothing + sjmp 00016$ +; +; store into xstack space +; + 00014$: + xch a,_ap + movx @r0,a + inc r0 + xch a,_ap + movx @r0, a + 00015$: + mov dpl,r0 + mov r0,dph ; restore r0 + mov dph,#0 ; restore dph + 00016$: + _endasm; +} + +#else + void _gptrputWord () { @@ -149,5 +369,6 @@ _gptrputWord () 00016$: _endasm; } +#endif #endif diff --git a/src/SDCC.lex b/src/SDCC.lex index 169d9aea..c7bb9181 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -151,6 +151,10 @@ _?"_asm" { "return" { count(); return(RETURN); } "sfr" { count(); TKEYWORDSDCC(SFR); } "__sfr" { count(); TKEYWORD(SFR); } +"sfr16" { count(); TKEYWORDSDCC(SFR16); } +"__sfr16" { count(); TKEYWORD(SFR16); } +"sfr32" { count(); TKEYWORDSDCC(SFR32); } +"__sfr32" { count(); TKEYWORD(SFR32); } "sbit" { count(); TKEYWORDSDCC(SBIT); } "__sbit" { count(); TKEYWORD(SBIT); } "short" { count(); return(SHORT); } diff --git a/src/SDCC.y b/src/SDCC.y index aa106b0d..3e084fcd 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -87,9 +87,9 @@ bool uselessDecl = TRUE; %token MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN %token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN %token XOR_ASSIGN OR_ASSIGN -%token TYPEDEF EXTERN STATIC AUTO REGISTER CODE EEPROM INTERRUPT SFR AT SBIT -%token REENTRANT USING XDATA DATA IDATA PDATA VAR_ARGS CRITICAL NONBANKED BANKED -%token SHADOWREGS WPARAM +%token TYPEDEF EXTERN STATIC AUTO REGISTER CODE EEPROM INTERRUPT SFR SFR16 SFR32 +%token AT SBIT REENTRANT USING XDATA DATA IDATA PDATA VAR_ARGS CRITICAL +%token NONBANKED BANKED SHADOWREGS WPARAM %token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID BIT %token STRUCT UNION ENUM ELIPSIS RANGE FAR %token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN @@ -737,6 +737,29 @@ sfr_attributes } ; +sfr_attributes + : SFR16 { + $$ = newLink(SPECIFIER) ; + FUNC_REGBANK($$) = 0; + SPEC_NOUN($$) = V_INT; + SPEC_SCLS($$) = S_SFR; + SPEC_USIGN($$) = 1 ; + ignoreTypedefType = 1; + } + ; + +sfr_attributes + : SFR32 { + $$ = newLink(SPECIFIER) ; + FUNC_REGBANK($$) = 0; + SPEC_NOUN($$) = V_INT; + SPEC_SCLS($$) = S_SFR; + SPEC_LONG($$) = 1; + SPEC_USIGN($$) = 1; + ignoreTypedefType = 1; + } + ; + struct_or_union_specifier : struct_or_union opt_stag { diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 316c5c9c..83863baa 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -492,7 +492,7 @@ DEFSETFUNC (findPrevIc) /* if iCodes are not the same */ /* see the operands maybe interchanged */ if (ic->op == cdp->diCode->op && - (ic->op == '+' || ic->op == '*') && // MB: why not check for &, &&, |, ||, ^ ??? + IS_ASSOCIATIVE(ic) && isOperandEqual (IC_LEFT (ic), IC_RIGHT (cdp->diCode)) && isOperandEqual (IC_RIGHT (ic), IC_LEFT (cdp->diCode))) { diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 21edf2b9..158d9fbb 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -1330,6 +1330,9 @@ emitMaps (void) emitRegularMap (home, TRUE, FALSE); emitRegularMap (code, TRUE, FALSE); + if (CONST_NAME) { + tfprintf (code->oFile, "\t!area\n", CONST_NAME); + } emitStaticSeg (statsg, code->oFile); if (port->genXINIT) { tfprintf (code->oFile, "\t!area\n", xinit->sname); diff --git a/src/SDCCicode.h b/src/SDCCicode.h index d0aab4c0..f57acc7e 100644 --- a/src/SDCCicode.h +++ b/src/SDCCicode.h @@ -256,6 +256,14 @@ iCodeTable; x->op == '|' || \ x->op == '^')) +#define IS_ASSOCIATIVE(x) (x && (x->op == EQ_OP || \ + x->op == NE_OP || \ + x->op == '+' || \ + x->op == '*' || \ + x->op == BITWISEAND || \ + x->op == '|' || \ + x->op == '^')) + #define ASSIGNMENT(ic) ( ic && ic->op == '=') #define ASSIGN_SYM_TO_ITEMP(ic) (ic && ic->op == '=' && \ diff --git a/src/SDCCmem.c b/src/SDCCmem.c index cb092aa7..49da6ee3 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -89,7 +89,7 @@ initMem () PAGED - YES DIRECT-ACCESS - NO BIT-ACCESS - NO - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'A' POINTER-TYPE - FPOINTER */ @@ -101,7 +101,7 @@ initMem () PAGED - NO DIRECT-ACCESS - NO BIT-ACCESS - NO - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'B' POINTER-TYPE - POINTER */ @@ -118,7 +118,7 @@ initMem () PAGED - NO DIRECT-ACCESS - NO BIT-ACCESS - NO - CODE-ACESS - YES + CODE-ACCESS - YES DEBUG-NAME - 'C' POINTER-TYPE - CPOINTER */ @@ -130,7 +130,7 @@ initMem () PAGED - NO DIRECT-ACCESS - NO BIT-ACCESS - NO - CODE-ACESS - YES + CODE-ACCESS - YES DEBUG-NAME - 'C' POINTER-TYPE - CPOINTER */ @@ -142,7 +142,7 @@ initMem () PAGED - NO DIRECT-ACCESS - NO BIT-ACCESS - NO - CODE-ACESS - YES + CODE-ACCESS - YES DEBUG-NAME - 'D' POINTER-TYPE - CPOINTER */ @@ -154,7 +154,7 @@ initMem () PAGED - NO DIRECT-ACCESS - YES BIT-ACCESS - NO - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'E' POINTER-TYPE - POINTER */ @@ -166,7 +166,7 @@ initMem () PAGED - NO DIRECT-ACCESS - YES BIT-ACCESS - NO - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'E' POINTER-TYPE - POINTER */ @@ -178,16 +178,16 @@ initMem () /* Xternal paged segment ; SFRSPACE - NO - FAR-SPACE - YES + FAR-SPACE - NO PAGED - YES DIRECT-ACCESS - NO BIT-ACCESS - NO - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'P' POINTER-TYPE - PPOINTER */ if (PDATA_NAME) { - pdata = allocMap (0, 1, 1, 0, 0, 0, options.xstack_loc, PDATA_NAME, 'P', PPOINTER); + pdata = allocMap (0, 0, 1, 0, 0, 0, options.xstack_loc, PDATA_NAME, 'P', PPOINTER); } else { pdata = NULL; } @@ -198,7 +198,7 @@ initMem () PAGED - NO DIRECT-ACCESS - NO BIT-ACCESS - NO - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'F' POINTER-TYPE - FPOINTER */ @@ -212,7 +212,7 @@ initMem () PAGED - NO DIRECT-ACCESS - NO BIT-ACCESS - NO - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'G' POINTER-TYPE - IPOINTER */ @@ -223,13 +223,13 @@ initMem () idata=NULL; } - /* Static segment (code for variables ); + /* Bit space ; SFRSPACE - NO FAR-SPACE - NO PAGED - NO DIRECT-ACCESS - YES BIT-ACCESS - YES - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'H' POINTER-TYPE - _NONE_ */ @@ -241,7 +241,7 @@ initMem () PAGED - NO DIRECT-ACCESS - YES BIT-ACCESS - NO - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'I' POINTER-TYPE - _NONE_ */ @@ -253,7 +253,7 @@ initMem () PAGED - NO DIRECT-ACCESS - NO BIT-ACCESS - NO - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - ' ' POINTER-TYPE - _NONE_ */ @@ -265,19 +265,19 @@ initMem () PAGED - NO DIRECT-ACCESS - YES BIT-ACCESS - YES - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'J' POINTER-TYPE - _NONE_ */ sfrbit = allocMap (1, 0, 0, 1, 1, 0, 0, REG_NAME, 'J', 0); - /* EEPROM bit space + /* EEPROM space SFRSPACE - NO FAR-SPACE - YES PAGED - NO DIRECT-ACCESS - NO BIT-ACCESS - NO - CODE-ACESS - NO + CODE-ACCESS - NO DEBUG-NAME - 'K' POINTER-TYPE - EEPPOINTER */ diff --git a/src/SDCCmem.h b/src/SDCCmem.h index 6b9dcfcc..301fa339 100644 --- a/src/SDCCmem.h +++ b/src/SDCCmem.h @@ -45,6 +45,7 @@ extern FILE *junkFile; #define STATIC_NAME port->mem.static_name #define HOME_NAME port->mem.home_name #define OVERLAY_NAME port->mem.overlay_name +#define CONST_NAME port->mem.const_name /* forward definition for variables */ extern memmap *xstack; /* xternal stack data */ diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index dac7cbdf..cf8097ea 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -58,11 +58,11 @@ enum { TYPEOF_EEPPOINTER }; -// values for first byte of generic pointer. -#define GPTYPE_NEAR 0 -#define GPTYPE_FAR 1 -#define GPTYPE_CODE 2 -#define GPTYPE_XSTACK 3 +// values for first byte (or 3 most significant bits) of generic pointer. +#define GPTYPE_FAR 0x00 +#define GPTYPE_NEAR 0x40 +#define GPTYPE_XSTACK 0x60 +#define GPTYPE_CODE 0x80 #define HASHTAB_SIZE 256 diff --git a/src/avr/gen.c b/src/avr/gen.c index 08b68b1c..e9fc7a73 100644 --- a/src/avr/gen.c +++ b/src/avr/gen.c @@ -4971,7 +4971,7 @@ genCast (iCode * ic) exit(1); } - sprintf(gpValStr, "#0x%d", gpVal); + sprintf(gpValStr, "#0x%x", gpVal); aopPut (AOP (result), gpValStr, GPTRSIZE - 1); } goto release; diff --git a/src/avr/main.c b/src/avr/main.c index 5c499e9e..aa9a9d3e 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -217,6 +217,7 @@ PORT avr_port = { "HOME", NULL, // initialized xdata NULL, // a code copy of xiseg + "CONST (CODE)", // const_name - const data (code or not) NULL, NULL, 0, diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 94563741..b1f3b2e8 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -741,11 +741,7 @@ aopForRemat (symbol * sym) sym_link *from_type = operandType(IC_RIGHT(ic)); aop->aopu.aop_immd.from_cast_remat = 1; ic = OP_SYMBOL (IC_RIGHT (ic))->rematiCode; - ptr_type = DCL_TYPE(from_type); - if (ptr_type == IPOINTER) { - // bug #481053 - ptr_type = POINTER; - } + ptr_type = pointerTypeToGPByte (DCL_TYPE(from_type), NULL, NULL); continue ; } else break; @@ -4007,7 +4003,7 @@ adjustArithmeticResult (iCode * ic) { char buff[5]; SNPRINTF (buff, sizeof(buff), - "#%d", pointerCode (getSpec (operandType (IC_LEFT (ic))))); + "#%d", pointerTypeToGPByte (pointerCode (getSpec (operandType (IC_LEFT (ic)))), NULL, NULL)); aopPut (AOP (IC_RESULT (ic)), buff, GPTRSIZE - 1); } } @@ -11725,7 +11721,7 @@ genCast (iCode * ic) exit(1); } - SNPRINTF(gpValStr, sizeof(gpValStr), "#0x%d", gpVal); + SNPRINTF(gpValStr, sizeof(gpValStr), "#0x%x", gpVal); aopPut (AOP (result), gpValStr, GPTRSIZE - 1); } goto release; diff --git a/src/ds390/main.c b/src/ds390/main.c index 9d41bf26..639ab5df 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -875,6 +875,7 @@ PORT ds390_port = "HOME (CODE)", "XISEG (XDATA)", // initialized xdata "XINIT (CODE)", // a code copy of xiseg + "CONST (CODE)", // const_name - const data (code or not) NULL, NULL, 1 @@ -1187,6 +1188,7 @@ PORT tininative_port = "HOME (CODE)", NULL, NULL, + "CONST (CODE)", // const_name - const data (code or not) NULL, NULL, 1 @@ -1414,6 +1416,7 @@ PORT ds400_port = "HOME (CODE)", "XISEG (XDATA)", // initialized xdata "XINIT (CODE)", // a code copy of xiseg + "CONST (CODE)", // const_name - const data (code or not) NULL, NULL, 1 diff --git a/src/hc08/gen.c b/src/hc08/gen.c index c04d9205..f0e9853e 100644 --- a/src/hc08/gen.c +++ b/src/hc08/gen.c @@ -7894,7 +7894,7 @@ genCast (iCode * ic) exit(1); } - sprintf(gpValStr, "#0x%d", gpVal); + sprintf(gpValStr, "#0x%x", gpVal); aopPut (AOP (result), gpValStr, GPTRSIZE - 1); } #endif diff --git a/src/hc08/main.c b/src/hc08/main.c index a4399cfc..2e1c7cd0 100644 --- a/src/hc08/main.c +++ b/src/hc08/main.c @@ -169,6 +169,7 @@ _hc08_genAssemblerPreamble (FILE * of) fprintf (of, "\t.area %s\n",port->mem.static_name); fprintf (of, "\t.area %s\n",port->mem.post_static_name); fprintf (of, "\t.area %s\n",port->mem.xinit_name); + fprintf (of, "\t.area %s\n",port->mem.const_name); fprintf (of, "\t.area %s\n",port->mem.data_name); fprintf (of, "\t.area %s\n",port->mem.overlay_name); fprintf (of, "\t.area %s\n",port->mem.bit_name); @@ -433,6 +434,7 @@ PORT hc08_port = "HOME (CODE)", "XISEG", // initialized xdata "XINIT", // a code copy of xiseg + "CONST (CODE)", // const_name - const data (code or not) NULL, NULL, 1 diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index e7e31c82..e2252b7e 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -64,6 +64,20 @@ static char *accUse[] = static unsigned short rbank = -1; +#define AOP(op) op->aop +#define AOP_TYPE(op) AOP(op)->type +#define AOP_SIZE(op) AOP(op)->size +#define IS_AOP_PREG(x) (AOP(x) && (AOP_TYPE(x) == AOP_R1 || \ + AOP_TYPE(x) == AOP_R0)) + +#define AOP_NEEDSACC(x) (AOP(x) && (AOP_TYPE(x) == AOP_CRY || \ + AOP_TYPE(x) == AOP_DPTR || AOP(x)->paged)) + +#define AOP_INPREG(x) (x && (x->type == AOP_REG && \ + (x->aopu.aop_reg[0] == mcs51_regWithIdx(R0_IDX) || \ + x->aopu.aop_reg[0] == mcs51_regWithIdx(R1_IDX) ))) + + #define SYM_BP(sym) (SPEC_OCLS (sym->etype)->paged ? "_bpx" : "_bp") #define R0INB _G.bu.bs.r0InB @@ -519,8 +533,6 @@ aopForSym (iCode * ic, symbol * sym, bool result) char offset = ((sym->stack < 0) ? ((char) (sym->stack - _G.nRegsSaved)) : ((char) sym->stack)) & 0xff; - if (_G.accInUse || leftRightUseAcc (ic)) - emitcode ("push", "acc"); if ((offset >= -3) && (offset <= 3)) { @@ -539,13 +551,15 @@ aopForSym (iCode * ic, symbol * sym, bool result) } else { + if (_G.accInUse || leftRightUseAcc (ic)) + emitcode ("push", "acc"); emitcode ("mov", "a,%s", SYM_BP (sym)); emitcode ("add", "a,#0x%02x", offset); emitcode ("mov", "%s,a", aop->aopu.aop_ptr->name); + if (_G.accInUse || leftRightUseAcc (ic)) + emitcode ("pop", "acc"); } - if (_G.accInUse || leftRightUseAcc (ic)) - emitcode ("pop", "acc"); } else emitcode ("mov", "%s,#%s", @@ -622,11 +636,7 @@ aopForRemat (symbol * sym) sym_link *from_type = operandType(IC_RIGHT(ic)); aop->aopu.aop_immd.from_cast_remat = 1; ic = OP_SYMBOL (IC_RIGHT (ic))->rematiCode; - ptr_type = DCL_TYPE(from_type); - if (ptr_type == IPOINTER) { - // bug #481053 - ptr_type = POINTER; - } + ptr_type = pointerTypeToGPByte (DCL_TYPE(from_type), NULL, NULL); continue ; } else break; @@ -1082,8 +1092,10 @@ freeForBranchAsmop (operand * op) /* clobber the accumulator */ /*-----------------------------------------------------------------*/ static bool -aopGetUsesAcc (asmop *aop, int offset) +aopGetUsesAcc (operand * oper, int offset) { + asmop * aop = AOP (oper); + if (offset > (aop->size - 1)) return FALSE; @@ -1129,10 +1141,11 @@ aopGetUsesAcc (asmop *aop, int offset) /* aopGet - for fetching value of the aop */ /*-----------------------------------------------------------------*/ static char * -aopGet (asmop * aop, int offset, bool bit16, bool dname) +aopGet (operand * oper, int offset, bool bit16, bool dname) { char *s = buffer; char *rs; + asmop * aop = AOP (oper); /* offset is greater than size then zero */ @@ -1221,7 +1234,10 @@ aopGet (asmop * aop, int offset, bool bit16, bool dname) return rs; case AOP_DIR: - if (offset) + if (SPEC_SCLS (getSpec (operandType (oper))) == S_SFR && offset) + sprintf (s, "(%s >> %d)", + aop->aopu.aop_dir, offset * 8); + else if (offset) sprintf (s, "(%s + %d)", aop->aopu.aop_dir, offset); @@ -1269,10 +1285,11 @@ aopGet (asmop * aop, int offset, bool bit16, bool dname) /* aopPut - puts a string for a aop and indicates if acc is in use */ /*-----------------------------------------------------------------*/ static bool -aopPut (asmop * aop, const char *s, int offset, bool bvolatile) +aopPut (operand * result, const char *s, int offset, bool bvolatile) { char *d = buffer; bool accuse = FALSE; + asmop * aop = AOP (result); if (aop->size && offset > (aop->size - 1)) { @@ -1291,7 +1308,10 @@ aopPut (asmop * aop, const char *s, int offset, bool bvolatile) break; case AOP_DIR: - if (offset) + if (SPEC_SCLS (getSpec (operandType (result))) == S_SFR && offset) + sprintf (d, "(%s >> %d)", + aop->aopu.aop_dir, offset * 8); + else if (offset) sprintf (d, "(%s + %d)", aop->aopu.aop_dir, offset); else @@ -1521,20 +1541,6 @@ reAdjustPreg (asmop * aop) aop->coff = 0; } -#define AOP(op) op->aop -#define AOP_TYPE(op) AOP(op)->type -#define AOP_SIZE(op) AOP(op)->size -#define IS_AOP_PREG(x) (AOP(x) && (AOP_TYPE(x) == AOP_R1 || \ - AOP_TYPE(x) == AOP_R0)) - -#define AOP_NEEDSACC(x) (AOP(x) && (AOP_TYPE(x) == AOP_CRY || \ - AOP_TYPE(x) == AOP_DPTR || AOP(x)->paged)) - -#define AOP_INPREG(x) (x && (x->type == AOP_REG && \ - (x->aopu.aop_reg[0] == mcs51_regWithIdx(R0_IDX) || \ - x->aopu.aop_reg[0] == mcs51_regWithIdx(R1_IDX) ))) - - /*-----------------------------------------------------------------*/ /* opIsGptr: returns non-zero if the passed operand is */ /* a generic pointer type. */ @@ -1583,13 +1589,13 @@ outAcc (operand * result) size = getDataSize (result); if (size) { - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); size--; offset = 1; /* unsigned or positive */ while (size--) { - aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); + aopPut (result, zero, offset++, isOperandVolatile (result, FALSE)); } } } @@ -1602,7 +1608,7 @@ outBitC (operand * result) { /* if the result is bit */ if (AOP_TYPE (result) == AOP_CRY) - aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "c", 0, isOperandVolatile (result, FALSE)); else { emitcode ("clr", "a"); @@ -1624,22 +1630,22 @@ toBoolean (operand * oper) while (!AccUsed && size--) { - AccUsed |= aopGetUsesAcc(AOP (oper), offset++); + AccUsed |= aopGetUsesAcc(oper, offset++); } size = AOP_SIZE (oper) - 1; offset = 1; - MOVA (aopGet (AOP (oper), 0, FALSE, FALSE)); + MOVA (aopGet (oper, 0, FALSE, FALSE)); if (size && AccUsed && (AOP (oper)->type != AOP_ACC)) { pushedB = pushB (); emitcode("mov", "b,a"); while (--size) { - MOVA (aopGet (AOP (oper), offset++, FALSE, FALSE)); + MOVA (aopGet (oper, offset++, FALSE, FALSE)); emitcode ("orl", "b,a"); } - MOVA (aopGet (AOP (oper), offset++, FALSE, FALSE)); + MOVA (aopGet (oper, offset++, FALSE, FALSE)); emitcode ("orl", "a,b"); popB (pushedB); } @@ -1647,7 +1653,7 @@ toBoolean (operand * oper) { while (size--) { - emitcode ("orl", "a,%s", aopGet (AOP (oper), offset++, FALSE, FALSE)); + emitcode ("orl", "a,%s", aopGet (oper, offset++, FALSE, FALSE)); } } } @@ -1725,7 +1731,7 @@ genCpl (iCode * ic) } tlbl=newiTempLabel(NULL); - l = aopGet (AOP (IC_LEFT (ic)), offset++, FALSE, FALSE); + l = aopGet (IC_LEFT (ic), offset++, FALSE, FALSE); if ((AOP_TYPE (IC_LEFT (ic)) == AOP_ACC && offset == 0) || AOP_TYPE (IC_LEFT (ic)) == AOP_REG || IS_AOP_PREG (IC_LEFT (ic))) @@ -1745,10 +1751,10 @@ genCpl (iCode * ic) size = AOP_SIZE (IC_RESULT (ic)); while (size--) { - char *l = aopGet (AOP (IC_LEFT (ic)), offset, FALSE, FALSE); + char *l = aopGet (IC_LEFT (ic), offset, FALSE, FALSE); MOVA (l); emitcode ("cpl", "a"); - aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } @@ -1775,19 +1781,19 @@ genUminusFloat (operand * op, operand * result) while (size--) { - aopPut (AOP (result), - aopGet (AOP (op), offset, FALSE, FALSE), + aopPut (result, + aopGet (op, offset, FALSE, FALSE), offset, isOperandVolatile (result, FALSE)); offset++; } - l = aopGet (AOP (op), offset, FALSE, FALSE); + l = aopGet (op, offset, FALSE, FALSE); MOVA (l); emitcode ("cpl", "acc.7"); - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -1834,7 +1840,7 @@ genUminus (iCode * ic) //CLRC ; while (size--) { - char *l = aopGet (AOP (IC_LEFT (ic)), offset, FALSE, FALSE); + char *l = aopGet (IC_LEFT (ic), offset, FALSE, FALSE); if (!strcmp (l, "a")) { if (offset == 0) @@ -1849,7 +1855,7 @@ genUminus (iCode * ic) emitcode ("clr", "a"); emitcode ("subb", "a,%s", l); } - aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } /* if any remaining bytes in the result */ @@ -1859,7 +1865,7 @@ genUminus (iCode * ic) emitcode ("rlc", "a"); emitcode ("subb", "a,acc"); while (size--) - aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } release: @@ -2029,7 +2035,7 @@ pushSide (operand * oper, int size) int offset = 0; while (size--) { - char *l = aopGet (AOP (oper), offset++, FALSE, TRUE); + char *l = aopGet (oper, offset++, FALSE, TRUE); if (AOP_TYPE (oper) != AOP_REG && AOP_TYPE (oper) != AOP_DIR && strcmp (l, "a")) @@ -2054,7 +2060,7 @@ assignResultValue (operand * oper) while (size--) { - accuse |= aopPut (AOP (oper), fReturn[offset], offset, isOperandVolatile (oper, FALSE)); + accuse |= aopPut (oper, fReturn[offset], offset, isOperandVolatile (oper, FALSE)); offset++; } return accuse; @@ -2080,7 +2086,7 @@ genXpush (iCode * ic) if (size == 1) { - MOVA (aopGet (AOP (IC_LEFT (ic)), 0, FALSE, FALSE)); + MOVA (aopGet (IC_LEFT (ic), 0, FALSE, FALSE)); emitcode ("mov", "%s,%s", r->name, spname); emitcode ("inc", "%s", spname); // allocate space first emitcode ("movx", "@%s,a", r->name); @@ -2095,7 +2101,7 @@ genXpush (iCode * ic) while (size--) { - MOVA (aopGet (AOP (IC_LEFT (ic)), offset++, FALSE, FALSE)); + MOVA (aopGet (IC_LEFT (ic), offset++, FALSE, FALSE)); emitcode ("movx", "@%s,a", r->name); emitcode ("inc", "%s", r->name); } @@ -2130,7 +2136,7 @@ genIpush (iCode * ic) /* push it on the stack */ while (size--) { - l = aopGet (AOP (IC_LEFT (ic)), offset++, FALSE, TRUE); + l = aopGet (IC_LEFT (ic), offset++, FALSE, TRUE); if (*l == '#') { MOVA (l); @@ -2162,7 +2168,7 @@ genIpush (iCode * ic) while (size--) { - l = aopGet (AOP (IC_LEFT (ic)), offset++, FALSE, TRUE); + l = aopGet (IC_LEFT (ic), offset++, FALSE, TRUE); if (AOP_TYPE (IC_LEFT (ic)) != AOP_REG && AOP_TYPE (IC_LEFT (ic)) != AOP_DIR && strcmp (l, "a")) @@ -2195,7 +2201,7 @@ genIpop (iCode * ic) size = AOP_SIZE (IC_LEFT (ic)); offset = (size - 1); while (size--) - emitcode ("pop", "%s", aopGet (AOP (IC_LEFT (ic)), offset--, + emitcode ("pop", "%s", aopGet (IC_LEFT (ic), offset--, FALSE, TRUE)); freeAsmop (IC_LEFT (ic), NULL, ic, TRUE); @@ -2355,7 +2361,7 @@ static void genSend(set *sendSet) if (sic->argreg == 1) { while (size--) { - char *l = aopGet (AOP (IC_LEFT (sic)), offset, + char *l = aopGet (IC_LEFT (sic), offset, FALSE, FALSE); if (strcmp (l, fReturn[offset])) emitcode ("mov", "%s,%s", fReturn[offset], l); @@ -2365,7 +2371,7 @@ static void genSend(set *sendSet) } else { while (size--) { emitcode ("mov","b1_%d,%s",rb1_count++, - aopGet (AOP (IC_LEFT (sic)), offset++,FALSE, FALSE)); + aopGet (IC_LEFT (sic), offset++,FALSE, FALSE)); } } freeAsmop (IC_LEFT (sic), NULL, sic, TRUE); @@ -2892,21 +2898,30 @@ genFunction (iCode * ic) { if (options.useXstack) { - emitcode ("mov", "r0,%s", spname); - emitcode ("inc", "%s", spname); - emitcode ("xch", "a,_bpx"); - emitcode ("movx", "@r0,a"); - emitcode ("inc", "r0"); - emitcode ("mov", "a,r0"); - emitcode ("xch", "a,_bpx"); - emitcode ("push", "_bp"); /* save the callers stack */ - emitcode ("mov", "_bp,sp"); + if (sym->xstack || FUNC_HASSTACKPARM(sym->type)) + { + emitcode ("mov", "r0,%s", spname); + emitcode ("inc", "%s", spname); + emitcode ("xch", "a,_bpx"); + emitcode ("movx", "@r0,a"); + emitcode ("inc", "r0"); + emitcode ("mov", "a,r0"); + emitcode ("xch", "a,_bpx"); + } + if (sym->stack) + { + emitcode ("push", "_bp"); /* save the callers stack */ + emitcode ("mov", "_bp,sp"); + } } else { - /* set up the stack */ - emitcode ("push", "_bp"); /* save the callers stack */ - emitcode ("mov", "_bp,sp"); + if (sym->stack || FUNC_HASSTACKPARM(sym->type)) + { + /* set up the stack */ + emitcode ("push", "_bp"); /* save the callers stack */ + emitcode ("mov", "_bp,sp"); + } } } @@ -3088,17 +3103,27 @@ genEndFunction (iCode * ic) if ((IFFUNC_ISREENT (sym->type) || options.stackAuto)) { - emitcode ("mov", "sp,_bp"); - emitcode ("pop", "_bp"); - if (options.useXstack) { - emitcode ("xch", "a,_bpx"); - emitcode ("mov", "r0,a"); - emitcode ("dec", "r0"); - emitcode ("movx", "a,@r0"); - emitcode ("xch", "a,_bpx"); - emitcode ("mov", "%s,r0", spname); //read before freeing stack space (interrupts) + if (sym->stack) + { + emitcode ("mov", "sp,_bp"); + emitcode ("pop", "_bp"); + } + if (sym->xstack || FUNC_HASSTACKPARM(sym->type)) + { + emitcode ("xch", "a,_bpx"); + emitcode ("mov", "r0,a"); + emitcode ("dec", "r0"); + emitcode ("movx", "a,@r0"); + emitcode ("xch", "a,_bpx"); + emitcode ("mov", "%s,r0", spname); //read before freeing stack space (interrupts) + } + } + else if (sym->stack || FUNC_HASSTACKPARM(sym->type)) + { + emitcode ("mov", "sp,_bp"); + emitcode ("pop", "_bp"); } } @@ -3355,14 +3380,14 @@ genRet (iCode * ic) if (AOP_TYPE (IC_LEFT (ic)) == AOP_DPTR) { /* #NOCHANGE */ - l = aopGet (AOP (IC_LEFT (ic)), offset++, + l = aopGet (IC_LEFT (ic), offset++, FALSE, TRUE); emitcode ("push", "%s", l); pushed++; } else { - l = aopGet (AOP (IC_LEFT (ic)), offset, + l = aopGet (IC_LEFT (ic), offset, FALSE, FALSE); if (strcmp (fReturn[offset], l)) emitcode ("mov", "%s,%s", fReturn[offset++], l); @@ -3495,49 +3520,49 @@ genPlusIncr (iCode * ic) tlbl = newiTempLabel (NULL); emitTlbl = 1; } - emitcode ("inc", "%s", aopGet (AOP (IC_RESULT (ic)), LSB, FALSE, FALSE)); + emitcode ("inc", "%s", aopGet (IC_RESULT (ic), LSB, FALSE, FALSE)); if (AOP_TYPE (IC_RESULT (ic)) == AOP_REG || IS_AOP_PREG (IC_RESULT (ic))) emitcode ("cjne", "%s,#0x00,%05d$", - aopGet (AOP (IC_RESULT (ic)), LSB, FALSE, FALSE), + aopGet (IC_RESULT (ic), LSB, FALSE, FALSE), tlbl->key + 100); else { emitcode ("clr", "a"); emitcode ("cjne", "a,%s,%05d$", - aopGet (AOP (IC_RESULT (ic)), LSB, FALSE, FALSE), + aopGet (IC_RESULT (ic), LSB, FALSE, FALSE), tlbl->key + 100); } - emitcode ("inc", "%s", aopGet (AOP (IC_RESULT (ic)), MSB16, FALSE, FALSE)); + emitcode ("inc", "%s", aopGet (IC_RESULT (ic), MSB16, FALSE, FALSE)); if (size > 2) { if (AOP_TYPE (IC_RESULT (ic)) == AOP_REG || IS_AOP_PREG (IC_RESULT (ic))) emitcode ("cjne", "%s,#0x00,%05d$", - aopGet (AOP (IC_RESULT (ic)), MSB16, FALSE, FALSE), + aopGet (IC_RESULT (ic), MSB16, FALSE, FALSE), tlbl->key + 100); else emitcode ("cjne", "a,%s,%05d$", - aopGet (AOP (IC_RESULT (ic)), MSB16, FALSE, FALSE), + aopGet (IC_RESULT (ic), MSB16, FALSE, FALSE), tlbl->key + 100); - emitcode ("inc", "%s", aopGet (AOP (IC_RESULT (ic)), MSB24, FALSE, FALSE)); + emitcode ("inc", "%s", aopGet (IC_RESULT (ic), MSB24, FALSE, FALSE)); } if (size > 3) { if (AOP_TYPE (IC_RESULT (ic)) == AOP_REG || IS_AOP_PREG (IC_RESULT (ic))) emitcode ("cjne", "%s,#0x00,%05d$", - aopGet (AOP (IC_RESULT (ic)), MSB24, FALSE, FALSE), + aopGet (IC_RESULT (ic), MSB24, FALSE, FALSE), tlbl->key + 100); else { emitcode ("cjne", "a,%s,%05d$", - aopGet (AOP (IC_RESULT (ic)), MSB24, FALSE, FALSE), + aopGet (IC_RESULT (ic), MSB24, FALSE, FALSE), tlbl->key + 100); } - emitcode ("inc", "%s", aopGet (AOP (IC_RESULT (ic)), MSB32, FALSE, FALSE)); + emitcode ("inc", "%s", aopGet (IC_RESULT (ic), MSB32, FALSE, FALSE)); } if (emitTlbl) @@ -3560,15 +3585,15 @@ genPlusIncr (iCode * ic) if (icount > 3) { - MOVA (aopGet (AOP (IC_LEFT (ic)), 0, FALSE, FALSE)); + MOVA (aopGet (IC_LEFT (ic), 0, FALSE, FALSE)); emitcode ("add", "a,#0x%02x", ((char) icount) & 0xff); - aopPut (AOP (IC_RESULT (ic)), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE)); } else { while (icount--) - emitcode ("inc", "%s", aopGet (AOP (IC_LEFT (ic)), 0, FALSE, FALSE)); + emitcode ("inc", "%s", aopGet (IC_LEFT (ic), 0, FALSE, FALSE)); } return TRUE; @@ -3587,7 +3612,7 @@ outBitAcc (operand * result) /* if the result is a bit */ if (AOP_TYPE (result) == AOP_CRY) { - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); } else { @@ -3638,16 +3663,16 @@ adjustArithmeticResult (iCode * ic) if (AOP_SIZE (IC_RESULT (ic)) == 3 && AOP_SIZE (IC_LEFT (ic)) == 3 && !sameRegs (AOP (IC_RESULT (ic)), AOP (IC_LEFT (ic)))) - aopPut (AOP (IC_RESULT (ic)), - aopGet (AOP (IC_LEFT (ic)), 2, FALSE, FALSE), + aopPut (IC_RESULT (ic), + aopGet (IC_LEFT (ic)), 2, FALSE, FALSE), 2, isOperandVolatile (IC_RESULT (ic), FALSE)); if (AOP_SIZE (IC_RESULT (ic)) == 3 && AOP_SIZE (IC_RIGHT (ic)) == 3 && !sameRegs (AOP (IC_RESULT (ic)), AOP (IC_RIGHT (ic)))) - aopPut (AOP (IC_RESULT (ic)), - aopGet (AOP (IC_RIGHT (ic)), 2, FALSE, FALSE), + aopPut (IC_RESULT (ic), + aopGet (IC_RIGHT (ic)), 2, FALSE, FALSE), 2, isOperandVolatile (IC_RESULT (ic), FALSE)); @@ -3658,8 +3683,8 @@ adjustArithmeticResult (iCode * ic) !sameRegs (AOP (IC_RESULT (ic)), AOP (IC_RIGHT (ic)))) { char buffer[5]; - sprintf (buffer, "#%d", pointerCode (getSpec (operandType (IC_LEFT (ic))))); - aopPut (AOP (IC_RESULT (ic)), buffer, 2, isOperandVolatile (IC_RESULT (ic), FALSE)); + sprintf (buffer, "#%d", pointerTypeToGPByte (pointerCode (getSpec (operandType (IC_LEFT (ic)))), NULL, NULL)); + aopPut (IC_RESULT (ic), buffer, 2, isOperandVolatile (IC_RESULT (ic), FALSE)); } } #else @@ -3674,8 +3699,8 @@ adjustArithmeticResult (iCode * ic) opIsGptr (IC_LEFT (ic)) && !sameRegs (AOP (IC_RESULT (ic)), AOP (IC_LEFT (ic)))) { - aopPut (AOP (IC_RESULT (ic)), - aopGet (AOP (IC_LEFT (ic)), GPTRSIZE - 1, FALSE, FALSE), + aopPut (IC_RESULT (ic), + aopGet (IC_LEFT (ic), GPTRSIZE - 1, FALSE, FALSE), GPTRSIZE - 1, isOperandVolatile (IC_RESULT (ic), FALSE)); } @@ -3684,8 +3709,8 @@ adjustArithmeticResult (iCode * ic) opIsGptr (IC_RIGHT (ic)) && !sameRegs (AOP (IC_RESULT (ic)), AOP (IC_RIGHT (ic)))) { - aopPut (AOP (IC_RESULT (ic)), - aopGet (AOP (IC_RIGHT (ic)), GPTRSIZE - 1, FALSE, FALSE), + aopPut (IC_RESULT (ic), + aopGet (IC_RIGHT (ic), GPTRSIZE - 1, FALSE, FALSE), GPTRSIZE - 1, isOperandVolatile (IC_RESULT (ic), FALSE)); } @@ -3697,8 +3722,8 @@ adjustArithmeticResult (iCode * ic) !sameRegs (AOP (IC_RESULT (ic)), AOP (IC_RIGHT (ic)))) { char buffer[5]; - sprintf (buffer, "#%d", pointerCode (getSpec (operandType (IC_LEFT (ic))))); - aopPut (AOP (IC_RESULT (ic)), buffer, GPTRSIZE - 1, isOperandVolatile (IC_RESULT (ic), FALSE)); + sprintf (buffer, "#%d", pointerTypeToGPByte (pointerCode (getSpec (operandType (IC_LEFT (ic)))), NULL, NULL)); + aopPut (IC_RESULT (ic), buffer, GPTRSIZE - 1, isOperandVolatile (IC_RESULT (ic), FALSE)); } } #endif @@ -3712,7 +3737,7 @@ genPlus (iCode * ic) int size, offset = 0; int skip_bytes = 0; char *add = "add"; - asmop *leftOp, *rightOp; + operand *leftOp, *rightOp; operand * op; /* special cases :- */ @@ -3761,9 +3786,9 @@ genPlus (iCode * ic) size = getDataSize (IC_RESULT (ic)); while (size--) { - MOVA (aopGet (AOP (IC_RIGHT (ic)), offset, FALSE, FALSE)); + MOVA (aopGet (IC_RIGHT (ic), offset, FALSE, FALSE)); emitcode ("addc", "a,#00"); - aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } } goto release; @@ -3775,8 +3800,8 @@ genPlus (iCode * ic) goto release; size = getDataSize (IC_RESULT (ic)); - leftOp = AOP(IC_LEFT(ic)); - rightOp = AOP(IC_RIGHT(ic)); + leftOp = IC_LEFT(ic); + rightOp = IC_RIGHT(ic); op=IC_LEFT(ic); /* if this is an add for an array access @@ -3790,23 +3815,23 @@ genPlus (iCode * ic) ) { D(emitcode ("; genPlus aligned array","")); - aopPut (AOP (IC_RESULT (ic)), + aopPut (IC_RESULT (ic), aopGet (rightOp, 0, FALSE, FALSE), 0, isOperandVolatile (IC_RESULT (ic), FALSE)); if( 1 == getDataSize (IC_RIGHT (ic)) ) { - aopPut (AOP (IC_RESULT (ic)), + aopPut (IC_RESULT (ic), aopGet (leftOp, 1, FALSE, FALSE), 1, isOperandVolatile (IC_RESULT (ic), FALSE)); } else { - MOVA (aopGet (AOP (IC_LEFT (ic)), 1, FALSE, FALSE)); + MOVA (aopGet (IC_LEFT (ic), 1, FALSE, FALSE)); emitcode ("add", "a,%s", aopGet (rightOp, 1, FALSE, FALSE)); - aopPut (AOP (IC_RESULT (ic)), "a", 1, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", 1, isOperandVolatile (IC_RESULT (ic), FALSE)); } goto release; } @@ -3847,7 +3872,7 @@ genPlus (iCode * ic) MOVA (aopGet (rightOp, offset, FALSE, TRUE)); emitcode (add, "a,%s", aopGet (leftOp, offset, FALSE, TRUE)); } - aopPut (AOP (IC_RESULT (ic)), "a", offset, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", offset, isOperandVolatile (IC_RESULT (ic), FALSE)); add = "addc"; /* further adds must propagate carry */ } else @@ -3856,7 +3881,7 @@ genPlus (iCode * ic) isOperandVolatile (IC_RESULT (ic), FALSE)) { /* just move */ - aopPut (AOP (IC_RESULT (ic)), + aopPut (IC_RESULT (ic), aopGet (leftOp, offset, FALSE, FALSE), offset, isOperandVolatile (IC_RESULT (ic), FALSE)); @@ -3923,49 +3948,49 @@ genMinusDec (iCode * ic) emitTlbl = 1; } - emitcode ("dec", "%s", aopGet (AOP (IC_RESULT (ic)), LSB, FALSE, FALSE)); + emitcode ("dec", "%s", aopGet (IC_RESULT (ic), LSB, FALSE, FALSE)); if (AOP_TYPE (IC_RESULT (ic)) == AOP_REG || IS_AOP_PREG (IC_RESULT (ic))) emitcode ("cjne", "%s,#0xff,%05d$" - ,aopGet (AOP (IC_RESULT (ic)), LSB, FALSE, FALSE) + ,aopGet (IC_RESULT (ic), LSB, FALSE, FALSE) ,tlbl->key + 100); else { emitcode ("mov", "a,#0xff"); emitcode ("cjne", "a,%s,%05d$" - ,aopGet (AOP (IC_RESULT (ic)), LSB, FALSE, FALSE) + ,aopGet (IC_RESULT (ic), LSB, FALSE, FALSE) ,tlbl->key + 100); } - emitcode ("dec", "%s", aopGet (AOP (IC_RESULT (ic)), MSB16, FALSE, FALSE)); + emitcode ("dec", "%s", aopGet (IC_RESULT (ic), MSB16, FALSE, FALSE)); if (size > 2) { if (AOP_TYPE (IC_RESULT (ic)) == AOP_REG || IS_AOP_PREG (IC_RESULT (ic))) emitcode ("cjne", "%s,#0xff,%05d$" - ,aopGet (AOP (IC_RESULT (ic)), MSB16, FALSE, FALSE) + ,aopGet (IC_RESULT (ic), MSB16, FALSE, FALSE) ,tlbl->key + 100); else { emitcode ("cjne", "a,%s,%05d$" - ,aopGet (AOP (IC_RESULT (ic)), MSB16, FALSE, FALSE) + ,aopGet (IC_RESULT (ic), MSB16, FALSE, FALSE) ,tlbl->key + 100); } - emitcode ("dec", "%s", aopGet (AOP (IC_RESULT (ic)), MSB24, FALSE, FALSE)); + emitcode ("dec", "%s", aopGet (IC_RESULT (ic), MSB24, FALSE, FALSE)); } if (size > 3) { if (AOP_TYPE (IC_RESULT (ic)) == AOP_REG || IS_AOP_PREG (IC_RESULT (ic))) emitcode ("cjne", "%s,#0xff,%05d$" - ,aopGet (AOP (IC_RESULT (ic)), MSB24, FALSE, FALSE) + ,aopGet (IC_RESULT (ic), MSB24, FALSE, FALSE) ,tlbl->key + 100); else { emitcode ("cjne", "a,%s,%05d$" - ,aopGet (AOP (IC_RESULT (ic)), MSB24, FALSE, FALSE) + ,aopGet (IC_RESULT (ic), MSB24, FALSE, FALSE) ,tlbl->key + 100); } - emitcode ("dec", "%s", aopGet (AOP (IC_RESULT (ic)), MSB32, FALSE, FALSE)); + emitcode ("dec", "%s", aopGet (IC_RESULT (ic), MSB32, FALSE, FALSE)); } if (emitTlbl) { @@ -3986,7 +4011,7 @@ genMinusDec (iCode * ic) { while (icount--) - emitcode ("dec", "%s", aopGet (AOP (IC_RESULT (ic)), 0, FALSE, FALSE)); + emitcode ("dec", "%s", aopGet (IC_RESULT (ic), 0, FALSE, FALSE)); return TRUE; } @@ -4008,11 +4033,11 @@ addSign (operand * result, int offset, int sign) emitcode ("rlc", "a"); emitcode ("subb", "a,acc"); while (size--) - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); } else while (size--) - aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); + aopPut (result, zero, offset++, isOperandVolatile (result, FALSE)); } } @@ -4041,7 +4066,7 @@ genMinusBits (iCode * ic) emitcode ("jnb", "%s,%05d$", AOP (IC_LEFT (ic))->aopu.aop_dir, (lbl->key + 100)); emitcode ("inc", "a"); emitcode ("", "%05d$:", (lbl->key + 100)); - aopPut (AOP (IC_RESULT (ic)), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE)); addSign (IC_RESULT (ic), MSB16, SPEC_USIGN (getSpec (operandType (IC_RESULT (ic))))); } } @@ -4080,34 +4105,39 @@ genMinus (iCode * ic) if (AOP_TYPE (IC_RIGHT (ic)) == AOP_LIT) { unsigned long lit = 0L; + bool useCarry = FALSE; lit = (unsigned long) floatFromVal (AOP (IC_RIGHT (ic))->aopu.aop_lit); lit = -(long) lit; while (size--) { - MOVA (aopGet (AOP (IC_LEFT (ic)), offset, FALSE, FALSE)); - /* first add without previous c */ - if (!offset) { - if (!size && lit== (unsigned long) -1) { + if (useCarry || ((lit >> (offset * 8)) & 0x0FFL)) { + MOVA (aopGet (IC_LEFT (ic), offset, FALSE, FALSE)); + if (!offset && !size && lit== (unsigned long) -1) { emitcode ("dec", "a"); - } else { + } else if (!useCarry) { + /* first add without previous c */ emitcode ("add", "a,#0x%02x", - (unsigned int) (lit & 0x0FFL)); - } + (unsigned int) ((lit >> (offset * 8)) & 0x0FFL)); + useCarry = TRUE; } else { emitcode ("addc", "a,#0x%02x", (unsigned int) ((lit >> (offset * 8)) & 0x0FFL)); } - aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); + } else { + /* no need to add zeroes */ + offset++; + } } } else { - asmop *leftOp, *rightOp; + operand *leftOp, *rightOp; - leftOp = AOP(IC_LEFT(ic)); - rightOp = AOP(IC_RIGHT(ic)); + leftOp = IC_LEFT(ic); + rightOp = IC_RIGHT(ic); while (size--) { @@ -4140,7 +4170,7 @@ genMinus (iCode * ic) aopGet(rightOp, offset, FALSE, TRUE)); } - aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } } @@ -4227,19 +4257,19 @@ genMultOneByte (operand * left, if (AOP_TYPE (right) == AOP_LIT) { /* moving to accumulator first helps peepholes */ - MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); + MOVA (aopGet (left, 0, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); } else { - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); - MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); + MOVA (aopGet (left, 0, FALSE, FALSE)); } emitcode ("mul", "ab"); - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); if (size == 2) - aopPut (AOP (result), "b", 1, isOperandVolatile (result, FALSE)); + aopPut (result, "b", 1, isOperandVolatile (result, FALSE)); popB (pushedB); return; @@ -4307,10 +4337,10 @@ genMultOneByte (operand * left, { if (rUnsigned) /* emitcode (";", "signed"); */ - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); else { - MOVA (aopGet (AOP (right), 0, FALSE, FALSE)); + MOVA (aopGet (right, 0, FALSE, FALSE)); lbl = newiTempLabel (NULL); emitcode ("jnb", "acc.7,%05d$", (lbl->key + 100)); emitcode ("cpl", "F0"); /* complement sign flag */ @@ -4332,7 +4362,7 @@ genMultOneByte (operand * left, } else /* ! literal */ { - MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); + MOVA (aopGet (left, 0, FALSE, FALSE)); if (!lUnsigned) { @@ -4365,9 +4395,9 @@ genMultOneByte (operand * left, } emitcode ("", "%05d$:", (lbl->key + 100)); } - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); if (size == 2) - aopPut (AOP (result), "b", 1, isOperandVolatile (result, FALSE)); + aopPut (result, "b", 1, isOperandVolatile (result, FALSE)); popB (pushedB); } @@ -4437,8 +4467,8 @@ genDivbits (operand * left, pushedB = pushB (); /* the result must be bit */ - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); - l = aopGet (AOP (left), 0, FALSE, FALSE); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); + l = aopGet (left, 0, FALSE, FALSE); MOVA (l); @@ -4447,7 +4477,7 @@ genDivbits (operand * left, popB (pushedB); - aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "c", 0, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -4502,12 +4532,12 @@ genDivOneByte (operand * left, if (lUnsigned && rUnsigned) { /* unsigned is easy */ - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); - MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); + MOVA (aopGet (left, 0, FALSE, FALSE)); emitcode ("div", "ab"); - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); while (size--) - aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); + aopPut (result, zero, offset++, isOperandVolatile (result, FALSE)); popB (pushedB); return; @@ -4573,10 +4603,10 @@ genDivOneByte (operand * left, else /* ! literal */ { if (rUnsigned) - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); else { - MOVA (aopGet (AOP (right), 0, FALSE, FALSE)); + MOVA (aopGet (right, 0, FALSE, FALSE)); lbl = newiTempLabel (NULL); emitcode ("jnb", "acc.7,%05d$", (lbl->key + 100)); emitcode ("cpl", "F0"); /* complement sign flag */ @@ -4598,7 +4628,7 @@ genDivOneByte (operand * left, } else /* ! literal */ { - MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); + MOVA (aopGet (left, 0, FALSE, FALSE)); if (!lUnsigned) { @@ -4623,7 +4653,7 @@ genDivOneByte (operand * left, emitcode ("inc", "a"); emitcode ("", "%05d$:", (lbl->key + 100)); - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); if (size > 0) { /* msb is 0x00 or 0xff depending on the sign */ @@ -4632,18 +4662,18 @@ genDivOneByte (operand * left, emitcode ("mov", "c,F0"); emitcode ("subb", "a,acc"); while (size--) - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); } else /* compiletimeSign */ while (size--) - aopPut (AOP (result), "#0xff", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "#0xff", offset++, isOperandVolatile (result, FALSE)); } } else { - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); while (size--) - aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); + aopPut (result, zero, offset++, isOperandVolatile (result, FALSE)); } popB (pushedB); @@ -4707,8 +4737,8 @@ genModbits (operand * left, pushedB = pushB (); /* the result must be bit */ - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); - l = aopGet (AOP (left), 0, FALSE, FALSE); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); + l = aopGet (left, 0, FALSE, FALSE); MOVA (l); @@ -4718,7 +4748,7 @@ genModbits (operand * left, popB (pushedB); - aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "c", 0, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -4763,7 +4793,7 @@ genModOneByte (operand * left, /* because iCode should have been changed to genAnd */ /* see file "SDCCopt.c", function "convertToFcall()" */ - MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); + MOVA (aopGet (left, 0, FALSE, FALSE)); emitcode ("mov", "c,acc.7"); emitcode ("anl", "a,#0x%02x", val - 1); lbl = newiTempLabel (NULL); @@ -4775,16 +4805,16 @@ genModOneByte (operand * left, int size2 = size; int offs2 = offset; - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); while (size2--) - aopPut (AOP (result), "#0xff", offs2++, isOperandVolatile (result, FALSE)); + aopPut (result, "#0xff", offs2++, isOperandVolatile (result, FALSE)); lbl2 = newiTempLabel (NULL); emitcode ("sjmp", "%05d$", (lbl2->key + 100)); } emitcode ("", "%05d$:", (lbl->key + 100)); - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); while (size--) - aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); + aopPut (result, zero, offset++, isOperandVolatile (result, FALSE)); if (lbl2) { emitcode ("", "%05d$:", (lbl2->key + 100)); @@ -4802,12 +4832,12 @@ genModOneByte (operand * left, if (lUnsigned && rUnsigned) { /* unsigned is easy */ - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); - MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); + MOVA (aopGet (left, 0, FALSE, FALSE)); emitcode ("div", "ab"); - aopPut (AOP (result), "b", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "b", 0, isOperandVolatile (result, FALSE)); while (size--) - aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); + aopPut (result, zero, offset++, isOperandVolatile (result, FALSE)); popB (pushedB); return; @@ -4830,10 +4860,10 @@ genModOneByte (operand * left, else /* not literal */ { if (rUnsigned) - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); else { - MOVA (aopGet (AOP (right), 0, FALSE, FALSE)); + MOVA (aopGet (right, 0, FALSE, FALSE)); lbl = newiTempLabel (NULL); emitcode ("jnb", "acc.7,%05d$", (lbl->key + 100)); emitcode ("cpl", "a"); /* 2's complement */ @@ -4864,7 +4894,7 @@ genModOneByte (operand * left, } else /* ! literal */ { - MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); + MOVA (aopGet (left, 0, FALSE, FALSE)); if (!lUnsigned) { @@ -4893,7 +4923,7 @@ genModOneByte (operand * left, emitcode ("inc", "a"); emitcode ("", "%05d$:", (lbl->key + 100)); - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); if (size > 0) { /* msb is 0x00 or 0xff depending on the sign */ @@ -4902,18 +4932,18 @@ genModOneByte (operand * left, emitcode ("mov", "c,F0"); emitcode ("subb", "a,acc"); while (size--) - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); } else /* compiletimeSign */ while (size--) - aopPut (AOP (result), "#0xff", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "#0xff", offset++, isOperandVolatile (result, FALSE)); } } else { - aopPut (AOP (result), "b", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "b", 0, isOperandVolatile (result, FALSE)); while (size--) - aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); + aopPut (result, zero, offset++, isOperandVolatile (result, FALSE)); } popB (pushedB); @@ -5036,8 +5066,8 @@ genCmp (operand * left, operand * right, { symbol *lbl = newiTempLabel (NULL); emitcode ("cjne", "%s,%s,%05d$", - aopGet (AOP (left), offset, FALSE, FALSE), - aopGet (AOP (right), offset, FALSE, FALSE), + aopGet (left, offset, FALSE, FALSE), + aopGet (right, offset, FALSE, FALSE), lbl->key + 100); emitcode ("", "%05d$:", lbl->key + 100); } @@ -5055,7 +5085,7 @@ genCmp (operand * left, operand * right, } else { - MOVA (aopGet (AOP (left), AOP_SIZE (left) - 1, FALSE, FALSE)); + MOVA (aopGet (left, AOP_SIZE (left) - 1, FALSE, FALSE)); if (!(AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result)) && ifx) { genIfxJump (ifx, "acc.7", left, right, result); @@ -5074,13 +5104,13 @@ genCmp (operand * left, operand * right, while (size--) { bool pushedB = FALSE; - rightInB = aopGetUsesAcc(AOP (right), offset); + rightInB = aopGetUsesAcc(right, offset); if (rightInB) { pushedB = pushB (); - emitcode ("mov", "b,%s", aopGet (AOP (right), offset, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, offset, FALSE, FALSE)); } - MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); + MOVA (aopGet (left, offset, FALSE, FALSE)); if (sign && size == 0) { emitcode ("xrl", "a,#0x80"); @@ -5097,7 +5127,7 @@ genCmp (operand * left, operand * right, { pushedB = pushB (); rightInB++; - emitcode ("mov", "b,%s", aopGet (AOP (right), offset, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, offset, FALSE, FALSE)); } emitcode ("xrl", "b,#0x80"); emitcode ("subb", "a,b"); @@ -5108,7 +5138,7 @@ genCmp (operand * left, operand * right, if (rightInB) emitcode ("subb", "a,b"); else - emitcode ("subb", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); + emitcode ("subb", "a,%s", aopGet (right, offset, FALSE, FALSE)); } if (rightInB) popB (pushedB); @@ -5230,8 +5260,8 @@ gencjneshort (operand * left, operand * right, symbol * lbl) while (size--) { emitcode ("cjne", "%s,%s,%05d$", - aopGet (AOP (left), offset, FALSE, FALSE), - aopGet (AOP (right), offset, FALSE, FALSE), + aopGet (left, offset, FALSE, FALSE), + aopGet (right, offset, FALSE, FALSE), lbl->key + 100); offset++; } @@ -5248,13 +5278,13 @@ gencjneshort (operand * left, operand * right, symbol * lbl) { while (size--) { - MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); + MOVA (aopGet (left, offset, FALSE, FALSE)); if ((AOP_TYPE (left) == AOP_DIR && AOP_TYPE (right) == AOP_LIT) && ((unsigned int) ((lit >> (offset * 8)) & 0x0FFL) == 0)) emitcode ("jnz", "%05d$", lbl->key + 100); else emitcode ("cjne", "a,%s,%05d$", - aopGet (AOP (right), offset, FALSE, TRUE), + aopGet (right, offset, FALSE, TRUE), lbl->key + 100); offset++; } @@ -5267,10 +5297,10 @@ gencjneshort (operand * left, operand * right, symbol * lbl) char *l; //if B in use: push B; mov B,left; mov A,right; clrc; subb A,B; pop B; jnz wassertl(!BINUSE, "B was in use"); - l = aopGet (AOP (left), offset, FALSE, FALSE); + l = aopGet (left, offset, FALSE, FALSE); if (strcmp (l, "b")) emitcode ("mov", "b,%s", l); - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); emitcode ("cjne", "a,b,%05d$", lbl->key + 100); offset++; } @@ -5452,7 +5482,7 @@ genCmpEq (iCode * ic, iCode * ifx) gencjne (left, right, newiTempLabel (NULL)); if (AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result)) { - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); goto release; } if (ifx) @@ -5786,7 +5816,7 @@ genAnd (iCode * ic, iCode * ifx) else { // c = bit & val; - MOVA (aopGet (AOP (right), 0, FALSE, FALSE)); + MOVA (aopGet (right, 0, FALSE, FALSE)); // c = lsb emitcode ("rrc", "a"); emitcode ("anl", "c,%s", AOP (left)->aopu.aop_dir); @@ -5813,7 +5843,7 @@ genAnd (iCode * ic, iCode * ifx) if (posbit) { posbit--; - MOVA (aopGet (AOP (left), posbit >> 3, FALSE, FALSE)); + MOVA (aopGet (left, posbit >> 3, FALSE, FALSE)); // bit = left & 2^n if (size) { @@ -5853,7 +5883,7 @@ genAnd (iCode * ic, iCode * ifx) { if ((bytelit = ((lit >> (offset * 8)) & 0x0FFL)) != 0x0L) { - MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); + MOVA (aopGet (left, offset, FALSE, FALSE)); // byte == 2^n ? if ((posbit = isLiteralBit (bytelit)) != 0) emitcode ("jb", "acc.%d,%05d$", (posbit - 1) & 0x07, tlbl->key + 100); @@ -5861,7 +5891,7 @@ genAnd (iCode * ic, iCode * ifx) { if (bytelit != 0x0FFL) emitcode ("anl", "a,%s", - aopGet (AOP (right), offset, FALSE, TRUE)); + aopGet (right, offset, FALSE, TRUE)); emitcode ("jnz", "%05d$", tlbl->key + 100); } } @@ -5899,42 +5929,42 @@ genAnd (iCode * ic, iCode * ifx) { /* dummy read of volatile operand */ if (isOperandVolatile (left, FALSE)) - MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); + MOVA (aopGet (left, offset, FALSE, FALSE)); else continue; } else if (bytelit == 0) { - aopPut (AOP (result), zero, offset, isOperandVolatile (result, FALSE)); + aopPut (result, zero, offset, isOperandVolatile (result, FALSE)); } else if (IS_AOP_PREG (result)) { - MOVA (aopGet (AOP (left), offset, FALSE, TRUE)); - emitcode ("anl", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + MOVA (aopGet (left, offset, FALSE, TRUE)); + emitcode ("anl", "a,%s", aopGet (right, offset, FALSE, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } else emitcode ("anl", "%s,%s", - aopGet (AOP (left), offset, FALSE, TRUE), - aopGet (AOP (right), offset, FALSE, FALSE)); + aopGet (left, offset, FALSE, TRUE), + aopGet (right, offset, FALSE, FALSE)); } else { if (AOP_TYPE (left) == AOP_ACC && offset == 0) { - emitcode ("anl", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); + emitcode ("anl", "a,%s", aopGet (right, offset, FALSE, FALSE)); } else { - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); if (IS_AOP_PREG (result)) { - emitcode ("anl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE)); - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + emitcode ("anl", "a,%s", aopGet (left, offset, FALSE, TRUE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } else emitcode ("anl", "%s,a", - aopGet (AOP (left), offset, FALSE, TRUE)); + aopGet (left, offset, FALSE, TRUE)); } } } @@ -5959,7 +5989,7 @@ genAnd (iCode * ic, iCode * ifx) if (offset) emitcode("mov", "a,b"); emitcode ("anl", "a,%s", - aopGet (AOP (right), offset, FALSE, FALSE)); + aopGet (right, offset, FALSE, FALSE)); } else { if (AOP_TYPE(left)==AOP_ACC) { @@ -5967,19 +5997,19 @@ genAnd (iCode * ic, iCode * ifx) { bool pushedB = pushB (); emitcode("mov", "b,a"); - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); emitcode("anl", "a,b"); popB (pushedB); } else { - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); emitcode("anl", "a,b"); } } else { - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); emitcode ("anl", "a,%s", - aopGet (AOP (left), offset, FALSE, FALSE)); + aopGet (left, offset, FALSE, FALSE)); } } emitcode ("jnz", "%05d$", tlbl->key + 100); @@ -6007,8 +6037,8 @@ genAnd (iCode * ic, iCode * ifx) bytelit = (int) ((lit >> (offset * 8)) & 0x0FFL); if (bytelit == 0x0FF) { - aopPut (AOP (result), - aopGet (AOP (left), offset, FALSE, FALSE), + aopPut (result, + aopGet (left, offset, FALSE, FALSE), offset, isOperandVolatile (result, FALSE)); continue; @@ -6017,22 +6047,22 @@ genAnd (iCode * ic, iCode * ifx) { /* dummy read of volatile operand */ if (isOperandVolatile (left, FALSE)) - MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); - aopPut (AOP (result), zero, offset, isOperandVolatile (result, FALSE)); + MOVA (aopGet (left, offset, FALSE, FALSE)); + aopPut (result, zero, offset, isOperandVolatile (result, FALSE)); continue; } else if (AOP_TYPE (left) == AOP_ACC) { if (!offset) { - emitcode ("anl", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + emitcode ("anl", "a,%s", aopGet (right, offset, FALSE, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); continue; } else { - emitcode ("anl", "b,%s", aopGet (AOP (right), offset, FALSE, FALSE)); - aopPut (AOP (result), "b", offset, isOperandVolatile (result, FALSE)); + emitcode ("anl", "b,%s", aopGet (right, offset, FALSE, FALSE)); + aopPut (result, "b", offset, isOperandVolatile (result, FALSE)); continue; } } @@ -6043,15 +6073,15 @@ genAnd (iCode * ic, iCode * ifx) { if (offset) emitcode("mov", "a,b"); - emitcode ("anl", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); + emitcode ("anl", "a,%s", aopGet (right, offset, FALSE, FALSE)); } else { - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); emitcode ("anl", "a,%s", - aopGet (AOP (left), offset, FALSE, FALSE)); + aopGet (left, offset, FALSE, FALSE)); } - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } } } @@ -6236,25 +6266,25 @@ genOr (iCode * ic, iCode * ifx) { /* dummy read of volatile operand */ if (isOperandVolatile (left, FALSE)) - MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); + MOVA (aopGet (left, offset, FALSE, FALSE)); else continue; } else if (bytelit == 0x0FF) { - aopPut (AOP (result), "#0xFF", offset, isOperandVolatile (result, FALSE)); + aopPut (result, "#0xFF", offset, isOperandVolatile (result, FALSE)); } else if (IS_AOP_PREG (left)) { - MOVA (aopGet (AOP (left), offset, FALSE, TRUE)); - emitcode ("orl", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + MOVA (aopGet (left, offset, FALSE, TRUE)); + emitcode ("orl", "a,%s", aopGet (right, offset, FALSE, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } else { emitcode ("orl", "%s,%s", - aopGet (AOP (left), offset, FALSE, TRUE), - aopGet (AOP (right), offset, FALSE, FALSE)); + aopGet (left, offset, FALSE, TRUE), + aopGet (right, offset, FALSE, FALSE)); } } else @@ -6263,20 +6293,20 @@ genOr (iCode * ic, iCode * ifx) { if (offset) emitcode("mov", "a,b"); - emitcode ("orl", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); + emitcode ("orl", "a,%s", aopGet (right, offset, FALSE, FALSE)); } else { - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); if (IS_AOP_PREG (left)) { - emitcode ("orl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE)); - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + emitcode ("orl", "a,%s", aopGet (left, offset, FALSE, TRUE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } else { emitcode ("orl", "%s,a", - aopGet (AOP (left), offset, FALSE, TRUE)); + aopGet (left, offset, FALSE, TRUE)); } } } @@ -6300,11 +6330,11 @@ genOr (iCode * ic, iCode * ifx) if (offset) emitcode("mov", "a,b"); emitcode ("orl", "a,%s", - aopGet (AOP (right), offset, FALSE, FALSE)); + aopGet (right, offset, FALSE, FALSE)); } else { - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); emitcode ("orl", "a,%s", - aopGet (AOP (left), offset, FALSE, FALSE)); + aopGet (left, offset, FALSE, FALSE)); } emitcode ("jnz", "%05d$", tlbl->key + 100); offset++; @@ -6331,8 +6361,8 @@ genOr (iCode * ic, iCode * ifx) bytelit = (int) ((lit >> (offset * 8)) & 0x0FFL); if (bytelit == 0) { - aopPut (AOP (result), - aopGet (AOP (left), offset, FALSE, FALSE), + aopPut (result, + aopGet (left, offset, FALSE, FALSE), offset, isOperandVolatile (result, FALSE)); continue; @@ -6341,8 +6371,8 @@ genOr (iCode * ic, iCode * ifx) { /* dummy read of volatile operand */ if (isOperandVolatile (left, FALSE)) - MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); - aopPut (AOP (result), "#0xFF", offset, isOperandVolatile (result, FALSE)); + MOVA (aopGet (left, offset, FALSE, FALSE)); + aopPut (result, "#0xFF", offset, isOperandVolatile (result, FALSE)); continue; } } @@ -6352,15 +6382,15 @@ genOr (iCode * ic, iCode * ifx) { if (offset) emitcode("mov", "a,b"); - emitcode ("orl", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); + emitcode ("orl", "a,%s", aopGet (right, offset, FALSE, FALSE)); } else { - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); emitcode ("orl", "a,%s", - aopGet (AOP (left), offset, FALSE, FALSE)); + aopGet (left, offset, FALSE, FALSE)); } - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } } } @@ -6492,7 +6522,7 @@ genXor (iCode * ic, iCode * ifx) emitcode ("setb", "c"); while (sizer) { - MOVA (aopGet (AOP (right), sizer - 1, FALSE, FALSE)); + MOVA (aopGet (right, sizer - 1, FALSE, FALSE)); if (sizer == 1) // test the msb of the lsb emitcode ("anl", "a,#0xfe"); @@ -6528,21 +6558,21 @@ genXor (iCode * ic, iCode * ifx) { /* dummy read of volatile operand */ if (isOperandVolatile (left, FALSE)) - MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); + MOVA (aopGet (left, offset, FALSE, FALSE)); else continue; } else if (IS_AOP_PREG (left)) { - MOVA (aopGet (AOP (left), offset, FALSE, TRUE)); - emitcode ("xrl", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + MOVA (aopGet (left, offset, FALSE, TRUE)); + emitcode ("xrl", "a,%s", aopGet (right, offset, FALSE, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } else { emitcode ("xrl", "%s,%s", - aopGet (AOP (left), offset, FALSE, TRUE), - aopGet (AOP (right), offset, FALSE, FALSE)); + aopGet (left, offset, FALSE, TRUE), + aopGet (right, offset, FALSE, FALSE)); } } else @@ -6551,19 +6581,19 @@ genXor (iCode * ic, iCode * ifx) { if (offset) emitcode("mov", "a,b"); - emitcode ("xrl", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); + emitcode ("xrl", "a,%s", aopGet (right, offset, FALSE, FALSE)); } else { - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); if (IS_AOP_PREG (left)) { - emitcode ("xrl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE)); - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + emitcode ("xrl", "a,%s", aopGet (left, offset, FALSE, TRUE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } else emitcode ("xrl", "%s,a", - aopGet (AOP (left), offset, FALSE, TRUE)); + aopGet (left, offset, FALSE, TRUE)); } } } @@ -6585,7 +6615,7 @@ genXor (iCode * ic, iCode * ifx) if ((AOP_TYPE (right) == AOP_LIT) && (((lit >> (offset * 8)) & 0x0FFL) == 0x00L)) { - MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); + MOVA (aopGet (left, offset, FALSE, FALSE)); } else { @@ -6593,11 +6623,11 @@ genXor (iCode * ic, iCode * ifx) if (offset) emitcode("mov", "a,b"); emitcode ("xrl", "a,%s", - aopGet (AOP (right), offset, FALSE, FALSE)); + aopGet (right, offset, FALSE, FALSE)); } else { - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); emitcode ("xrl", "a,%s", - aopGet (AOP (left), offset, FALSE, FALSE)); + aopGet (left, offset, FALSE, FALSE)); } } emitcode ("jnz", "%05d$", tlbl->key + 100); @@ -6623,8 +6653,8 @@ genXor (iCode * ic, iCode * ifx) bytelit = (int) ((lit >> (offset * 8)) & 0x0FFL); if (bytelit == 0) { - aopPut (AOP (result), - aopGet (AOP (left), offset, FALSE, FALSE), + aopPut (result, + aopGet (left, offset, FALSE, FALSE), offset, isOperandVolatile (result, FALSE)); continue; @@ -6636,15 +6666,15 @@ genXor (iCode * ic, iCode * ifx) { if (offset) emitcode("mov", "a,b"); - emitcode ("xrl", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); + emitcode ("xrl", "a,%s", aopGet (right, offset, FALSE, FALSE)); } else { - MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); + MOVA (aopGet (right, offset, FALSE, FALSE)); emitcode ("xrl", "a,%s", - aopGet (AOP (left), offset, FALSE, TRUE)); + aopGet (left, offset, FALSE, TRUE)); } - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } } } @@ -6722,7 +6752,7 @@ genRRC (iCode * ic) size = AOP_SIZE (result); offset = size - 1; if (size == 1) { /* special case for 1 byte */ - l = aopGet (AOP (left), offset, FALSE, FALSE); + l = aopGet (left, offset, FALSE, FALSE); MOVA (l); emitcode ("rr", "a"); goto release; @@ -6730,22 +6760,22 @@ genRRC (iCode * ic) /* no need to clear carry, bit7 will be written later */ while (size--) { - l = aopGet (AOP (left), offset, FALSE, FALSE); + l = aopGet (left, offset, FALSE, FALSE); MOVA (l); emitcode ("rrc", "a"); if (AOP_SIZE (result) > 1) - aopPut (AOP (result), "a", offset--, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset--, isOperandVolatile (result, FALSE)); } /* now we need to put the carry into the highest order byte of the result */ if (AOP_SIZE (result) > 1) { - l = aopGet (AOP (result), AOP_SIZE (result) - 1, FALSE, FALSE); + l = aopGet (result, AOP_SIZE (result) - 1, FALSE, FALSE); MOVA (l); } emitcode ("mov", "acc.7,c"); release: - aopPut (AOP (result), "a", AOP_SIZE (result) - 1, isOperandVolatile (result, FALSE)); + aopPut (result, "a", AOP_SIZE (result) - 1, isOperandVolatile (result, FALSE)); freeAsmop (left, NULL, ic, TRUE); freeAsmop (result, NULL, ic, TRUE); } @@ -6773,7 +6803,7 @@ genRLC (iCode * ic) offset = 0; if (size--) { - l = aopGet (AOP (left), offset, FALSE, FALSE); + l = aopGet (left, offset, FALSE, FALSE); MOVA (l); if (size == 0) { /* special case for 1 byte */ emitcode("rl","a"); @@ -6781,26 +6811,26 @@ genRLC (iCode * ic) } emitcode("rlc","a"); /* bit0 will be written later */ if (AOP_SIZE (result) > 1) - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); while (size--) { - l = aopGet (AOP (left), offset, FALSE, FALSE); + l = aopGet (left, offset, FALSE, FALSE); MOVA (l); emitcode ("rlc", "a"); if (AOP_SIZE (result) > 1) - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); } } /* now we need to put the carry into the highest order byte of the result */ if (AOP_SIZE (result) > 1) { - l = aopGet (AOP (result), 0, FALSE, FALSE); + l = aopGet (result, 0, FALSE, FALSE); MOVA (l); } emitcode ("mov", "acc.0,c"); release: - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); freeAsmop (left, NULL, ic, TRUE); freeAsmop (result, NULL, ic, TRUE); } @@ -6821,7 +6851,7 @@ genGetHbit (iCode * ic) aopOp (result, ic, FALSE); /* get the highest order byte into a */ - MOVA (aopGet (AOP (left), AOP_SIZE (left) - 1, FALSE, FALSE)); + MOVA (aopGet (left, AOP_SIZE (left) - 1, FALSE, FALSE)); if (AOP_TYPE (result) == AOP_CRY) { emitcode ("rlc", "a"); @@ -6857,43 +6887,43 @@ genSwap (iCode * ic) switch (AOP_SIZE (left)) { case 1: /* swap nibbles in byte */ - MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); + MOVA (aopGet (left, 0, FALSE, FALSE)); emitcode ("swap", "a"); - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); break; case 2: /* swap bytes in word */ if (AOP_TYPE(left) == AOP_REG && sameRegs(AOP(left), AOP(result))) { - MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); - aopPut (AOP (result), aopGet (AOP (left), 1, FALSE, FALSE), + MOVA (aopGet (left, 0, FALSE, FALSE)); + aopPut (result, aopGet (left, 1, FALSE, FALSE), 0, isOperandVolatile (result, FALSE)); - aopPut (AOP (result), "a", 1, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 1, isOperandVolatile (result, FALSE)); } else if (operandsEqu (left, result)) { char * reg = "a"; bool pushedB = FALSE, leftInB = FALSE; - MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); - if (aopGetUsesAcc(AOP (left), 1) || aopGetUsesAcc(AOP (result), 0)) + MOVA (aopGet (left, 0, FALSE, FALSE)); + if (aopGetUsesAcc(left, 1) || aopGetUsesAcc(result, 0)) { pushedB = pushB (); emitcode ("mov", "b,a"); reg = "b"; leftInB = TRUE; } - aopPut (AOP (result), aopGet (AOP (left), 1, FALSE, FALSE), + aopPut (result, aopGet (left, 1, FALSE, FALSE), 0, isOperandVolatile (result, FALSE)); - aopPut (AOP (result), reg, 1, isOperandVolatile (result, FALSE)); + aopPut (result, reg, 1, isOperandVolatile (result, FALSE)); if (leftInB) popB (pushedB); } else { - aopPut (AOP (result), aopGet (AOP (left), 1, FALSE, FALSE), + aopPut (result, aopGet (left, 1, FALSE, FALSE), 0, isOperandVolatile (result, FALSE)); - aopPut (AOP (result), aopGet (AOP (left), 0, FALSE, FALSE), + aopPut (result, aopGet (left, 0, FALSE, FALSE), 1, isOperandVolatile (result, FALSE)); } break; @@ -7038,13 +7068,13 @@ shiftR1Left2Result (operand * left, int offl, operand * result, int offr, int shCount, int sign) { - MOVA (aopGet (AOP (left), offl, FALSE, FALSE)); + MOVA (aopGet (left, offl, FALSE, FALSE)); /* shift right accumulator */ if (sign) AccSRsh (shCount); else AccRsh (shCount); - aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offr, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -7055,11 +7085,11 @@ shiftL1Left2Result (operand * left, int offl, operand * result, int offr, int shCount) { char *l; - l = aopGet (AOP (left), offl, FALSE, FALSE); + l = aopGet (left, offl, FALSE, FALSE); MOVA (l); /* shift left accumulator */ AccLsh (shCount); - aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offr, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -7072,24 +7102,24 @@ movLeft2Result (operand * left, int offl, char *l; if (!sameRegs (AOP (left), AOP (result)) || (offl != offr)) { - l = aopGet (AOP (left), offl, FALSE, FALSE); + l = aopGet (left, offl, FALSE, FALSE); if (*l == '@' && (IS_AOP_PREG (result))) { emitcode ("mov", "a,%s", l); - aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offr, isOperandVolatile (result, FALSE)); } else { if (!sign) - aopPut (AOP (result), l, offr, isOperandVolatile (result, FALSE)); + aopPut (result, l, offr, isOperandVolatile (result, FALSE)); else { /* MSB sign in acc.7 ! */ if (getDataSize (left) == offl + 1) { emitcode ("mov", "a,%s", l); - aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offr, isOperandVolatile (result, FALSE)); } } } @@ -7407,17 +7437,17 @@ shiftL2Left2Result (operand * left, int offl, ((offl + MSB16) == offr)) { /* don't crash result[offr] */ - MOVA (aopGet (AOP (left), offl, FALSE, FALSE)); - emitcode ("xch", "a,%s", aopGet (AOP (left), offl + MSB16, FALSE, FALSE)); + MOVA (aopGet (left, offl, FALSE, FALSE)); + emitcode ("xch", "a,%s", aopGet (left, offl + MSB16, FALSE, FALSE)); } else { movLeft2Result (left, offl, result, offr, 0); - MOVA (aopGet (AOP (left), offl + MSB16, FALSE, FALSE)); + MOVA (aopGet (left, offl + MSB16, FALSE, FALSE)); } /* ax << shCount (x = lsb(result)) */ - AccAXLsh (aopGet (AOP (result), offr, FALSE, FALSE), shCount); - aopPut (AOP (result), "a", offr + MSB16, isOperandVolatile (result, FALSE)); + AccAXLsh (aopGet (result, offr, FALSE, FALSE), shCount); + aopPut (result, "a", offr + MSB16, isOperandVolatile (result, FALSE)); } @@ -7433,21 +7463,21 @@ shiftR2Left2Result (operand * left, int offl, ((offl + MSB16) == offr)) { /* don't crash result[offr] */ - MOVA (aopGet (AOP (left), offl, FALSE, FALSE)); - emitcode ("xch", "a,%s", aopGet (AOP (left), offl + MSB16, FALSE, FALSE)); + MOVA (aopGet (left, offl, FALSE, FALSE)); + emitcode ("xch", "a,%s", aopGet (left, offl + MSB16, FALSE, FALSE)); } else { movLeft2Result (left, offl, result, offr, 0); - MOVA (aopGet (AOP (left), offl + MSB16, FALSE, FALSE)); + MOVA (aopGet (left, offl + MSB16, FALSE, FALSE)); } /* a:x >> shCount (x = lsb(result)) */ if (sign) - AccAXRshS (aopGet (AOP (result), offr, FALSE, FALSE), shCount); + AccAXRshS (aopGet (result, offr, FALSE, FALSE), shCount); else - AccAXRsh (aopGet (AOP (result), offr, FALSE, FALSE), shCount); + AccAXRsh (aopGet (result, offr, FALSE, FALSE), shCount); if (getDataSize (result) > 1) - aopPut (AOP (result), "a", offr + MSB16, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offr + MSB16, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -7457,13 +7487,13 @@ static void shiftLLeftOrResult (operand * left, int offl, operand * result, int offr, int shCount) { - MOVA (aopGet (AOP (left), offl, FALSE, FALSE)); + MOVA (aopGet (left, offl, FALSE, FALSE)); /* shift left accumulator */ AccLsh (shCount); /* or with result */ - emitcode ("orl", "a,%s", aopGet (AOP (result), offr, FALSE, FALSE)); + emitcode ("orl", "a,%s", aopGet (result, offr, FALSE, FALSE)); /* back to result */ - aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offr, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -7473,13 +7503,13 @@ static void shiftRLeftOrResult (operand * left, int offl, operand * result, int offr, int shCount) { - MOVA (aopGet (AOP (left), offl, FALSE, FALSE)); + MOVA (aopGet (left, offl, FALSE, FALSE)); /* shift right accumulator */ AccRsh (shCount); /* or with result */ - emitcode ("orl", "a,%s", aopGet (AOP (result), offr, FALSE, FALSE)); + emitcode ("orl", "a,%s", aopGet (result, offr, FALSE, FALSE)); /* back to result */ - aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offr, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -7517,7 +7547,7 @@ genlshTwo (operand * result, operand * left, int shCount) else movLeft2Result (left, LSB, result, MSB16, 0); } - aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); + aopPut (result, zero, LSB, isOperandVolatile (result, FALSE)); } /* 1 <= shCount <= 7 */ @@ -7542,61 +7572,61 @@ shiftLLong (operand * left, operand * result, int offr) if (size >= LSB + offr) { - l = aopGet (AOP (left), LSB, FALSE, FALSE); + l = aopGet (left, LSB, FALSE, FALSE); MOVA (l); emitcode ("add", "a,acc"); if (sameRegs (AOP (left), AOP (result)) && size >= MSB16 + offr && offr != LSB) emitcode ("xch", "a,%s", - aopGet (AOP (left), LSB + offr, FALSE, FALSE)); + aopGet (left, LSB + offr, FALSE, FALSE)); else - aopPut (AOP (result), "a", LSB + offr, isOperandVolatile (result, FALSE)); + aopPut (result, "a", LSB + offr, isOperandVolatile (result, FALSE)); } if (size >= MSB16 + offr) { if (!(sameRegs (AOP (result), AOP (left)) && size >= MSB16 + offr && offr != LSB)) { - l = aopGet (AOP (left), MSB16, FALSE, FALSE); + l = aopGet (left, MSB16, FALSE, FALSE); MOVA (l); } emitcode ("rlc", "a"); if (sameRegs (AOP (left), AOP (result)) && size >= MSB24 + offr && offr != LSB) emitcode ("xch", "a,%s", - aopGet (AOP (left), MSB16 + offr, FALSE, FALSE)); + aopGet (left, MSB16 + offr, FALSE, FALSE)); else - aopPut (AOP (result), "a", MSB16 + offr, isOperandVolatile (result, FALSE)); + aopPut (result, "a", MSB16 + offr, isOperandVolatile (result, FALSE)); } if (size >= MSB24 + offr) { if (!(sameRegs (AOP (result), AOP (left)) && size >= MSB24 + offr && offr != LSB)) { - l = aopGet (AOP (left), MSB24, FALSE, FALSE); + l = aopGet (left, MSB24, FALSE, FALSE); MOVA (l); } emitcode ("rlc", "a"); if (sameRegs (AOP (left), AOP (result)) && size >= MSB32 + offr && offr != LSB) emitcode ("xch", "a,%s", - aopGet (AOP (left), MSB24 + offr, FALSE, FALSE)); + aopGet (left, MSB24 + offr, FALSE, FALSE)); else - aopPut (AOP (result), "a", MSB24 + offr, isOperandVolatile (result, FALSE)); + aopPut (result, "a", MSB24 + offr, isOperandVolatile (result, FALSE)); } if (size > MSB32 + offr) { if (!(sameRegs (AOP (result), AOP (left)) && size >= MSB32 + offr && offr != LSB)) { - l = aopGet (AOP (left), MSB32, FALSE, FALSE); + l = aopGet (left, MSB32, FALSE, FALSE); MOVA (l); } emitcode ("rlc", "a"); - aopPut (AOP (result), "a", MSB32 + offr, isOperandVolatile (result, FALSE)); + aopPut (result, "a", MSB32 + offr, isOperandVolatile (result, FALSE)); } if (offr != LSB) - aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); + aopPut (result, zero, LSB, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -7621,9 +7651,9 @@ genlshFour (operand * result, operand * left, int shCount) shiftL1Left2Result (left, LSB, result, MSB32, shCount); else movLeft2Result (left, LSB, result, MSB32, 0); - aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); - aopPut (AOP (result), zero, MSB16, isOperandVolatile (result, FALSE)); - aopPut (AOP (result), zero, MSB24, isOperandVolatile (result, FALSE)); + aopPut (result, zero, LSB, isOperandVolatile (result, FALSE)); + aopPut (result, zero, MSB16, isOperandVolatile (result, FALSE)); + aopPut (result, zero, MSB24, isOperandVolatile (result, FALSE)); return; } @@ -7640,8 +7670,8 @@ genlshFour (operand * result, operand * left, int shCount) movLeft2Result (left, MSB16, result, MSB32, 0); movLeft2Result (left, LSB, result, MSB24, 0); } - aopPut (AOP (result), zero, MSB16, isOperandVolatile (result, FALSE)); - aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); + aopPut (result, zero, MSB16, isOperandVolatile (result, FALSE)); + aopPut (result, zero, LSB, isOperandVolatile (result, FALSE)); return; } @@ -7664,7 +7694,7 @@ genlshFour (operand * result, operand * left, int shCount) movLeft2Result (left, MSB24, result, MSB32, 0); movLeft2Result (left, MSB16, result, MSB24, 0); movLeft2Result (left, LSB, result, MSB16, 0); - aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); + aopPut (result, zero, LSB, isOperandVolatile (result, FALSE)); } else if (shCount == 1) shiftLLong (left, result, MSB16); @@ -7673,7 +7703,7 @@ genlshFour (operand * result, operand * left, int shCount) shiftL2Left2Result (left, MSB16, result, MSB24, shCount); shiftL1Left2Result (left, LSB, result, MSB16, shCount); shiftRLeftOrResult (left, LSB, result, MSB24, 8 - shCount); - aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); + aopPut (result, zero, LSB, isOperandVolatile (result, FALSE)); } } } @@ -7731,7 +7761,7 @@ genLeftShiftLiteral (operand * left, else if (shCount >= (size * 8)) while (size--) - aopPut (AOP (result), zero, size, isOperandVolatile (result, FALSE)); + aopPut (result, zero, size, isOperandVolatile (result, FALSE)); else { switch (size) @@ -7792,7 +7822,7 @@ genLeftShift (iCode * ic) largest size of an object can be only 32 bits ) */ pushedB = pushB (); - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); emitcode ("inc", "b"); freeAsmop (right, NULL, ic, TRUE); aopOp (left, ic, FALSE); @@ -7807,15 +7837,15 @@ genLeftShift (iCode * ic) offset = 0; while (size--) { - l = aopGet (AOP (left), offset, FALSE, TRUE); + l = aopGet (left, offset, FALSE, TRUE); if (*l == '@' && (IS_AOP_PREG (result))) { emitcode ("mov", "a,%s", l); - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } else - aopPut (AOP (result), l, offset, isOperandVolatile (result, FALSE)); + aopPut (result, l, offset, isOperandVolatile (result, FALSE)); offset++; } } @@ -7830,7 +7860,7 @@ genLeftShift (iCode * ic) { symbol *tlbl1 = newiTempLabel (NULL); - l = aopGet (AOP (left), 0, FALSE, FALSE); + l = aopGet (left, 0, FALSE, FALSE); MOVA (l); emitcode ("sjmp", "%05d$", tlbl1->key + 100); emitcode ("", "%05d$:", tlbl->key + 100); @@ -7838,7 +7868,7 @@ genLeftShift (iCode * ic) emitcode ("", "%05d$:", tlbl1->key + 100); emitcode ("djnz", "b,%05d$", tlbl->key + 100); popB (pushedB); - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); goto release; } @@ -7846,16 +7876,16 @@ genLeftShift (iCode * ic) emitcode ("sjmp", "%05d$", tlbl1->key + 100); emitcode ("", "%05d$:", tlbl->key + 100); - l = aopGet (AOP (result), offset, FALSE, FALSE); + l = aopGet (result, offset, FALSE, FALSE); MOVA (l); emitcode ("add", "a,acc"); - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); while (--size) { - l = aopGet (AOP (result), offset, FALSE, FALSE); + l = aopGet (result, offset, FALSE, FALSE); MOVA (l); emitcode ("rlc", "a"); - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); } reAdjustPreg (AOP (result)); @@ -7920,7 +7950,7 @@ shiftRLong (operand * left, int offl, werror(E_INTERNAL_ERROR, __FILE__, __LINE__); } - MOVA (aopGet (AOP (left), MSB32, FALSE, FALSE)); + MOVA (aopGet (left, MSB32, FALSE, FALSE)); if (offl==MSB16) { // shift is > 8 @@ -7928,13 +7958,13 @@ shiftRLong (operand * left, int offl, emitcode ("rlc", "a"); emitcode ("subb", "a,acc"); if (isSameRegs) - emitcode ("xch", "a,%s", aopGet(AOP(left), MSB32, FALSE, FALSE)); + emitcode ("xch", "a,%s", aopGet (left, MSB32, FALSE, FALSE)); else { - aopPut (AOP (result), "a", MSB32, isOperandVolatile (result, FALSE)); - MOVA (aopGet (AOP (left), MSB32, FALSE, FALSE)); + aopPut (result, "a", MSB32, isOperandVolatile (result, FALSE)); + MOVA (aopGet (left, MSB32, FALSE, FALSE)); } } else { - aopPut (AOP(result), zero, MSB32, isOperandVolatile (result, FALSE)); + aopPut (result, zero, MSB32, isOperandVolatile (result, FALSE)); } } @@ -7947,27 +7977,27 @@ shiftRLong (operand * left, int offl, emitcode ("rrc", "a"); if (isSameRegs && offl==MSB16) { - emitcode ("xch", "a,%s",aopGet (AOP (left), MSB24, FALSE, FALSE)); + emitcode ("xch", "a,%s",aopGet (left, MSB24, FALSE, FALSE)); } else { - aopPut (AOP (result), "a", MSB32-offl, isOperandVolatile (result, FALSE)); - MOVA (aopGet (AOP (left), MSB24, FALSE, FALSE)); + aopPut (result, "a", MSB32-offl, isOperandVolatile (result, FALSE)); + MOVA (aopGet (left, MSB24, FALSE, FALSE)); } emitcode ("rrc", "a"); if (isSameRegs && offl==1) { - emitcode ("xch", "a,%s",aopGet (AOP (left), MSB16, FALSE, FALSE)); + emitcode ("xch", "a,%s",aopGet (left, MSB16, FALSE, FALSE)); } else { - aopPut (AOP (result), "a", MSB24-offl, isOperandVolatile (result, FALSE)); - MOVA (aopGet (AOP (left), MSB16, FALSE, FALSE)); + aopPut (result, "a", MSB24-offl, isOperandVolatile (result, FALSE)); + MOVA (aopGet (left, MSB16, FALSE, FALSE)); } emitcode ("rrc", "a"); - aopPut (AOP (result), "a", MSB16 - offl, isOperandVolatile (result, FALSE)); + aopPut (result, "a", MSB16 - offl, isOperandVolatile (result, FALSE)); if (offl == LSB) { - MOVA (aopGet (AOP (left), LSB, FALSE, FALSE)); + MOVA (aopGet (left, LSB, FALSE, FALSE)); emitcode ("rrc", "a"); - aopPut (AOP (result), "a", LSB, isOperandVolatile (result, FALSE)); + aopPut (result, "a", LSB, isOperandVolatile (result, FALSE)); } } @@ -8080,7 +8110,7 @@ genRightShiftLiteral (operand * left, { if (sign) { /* get sign in acc.7 */ - MOVA (aopGet (AOP (left), size - 1, FALSE, FALSE)); + MOVA (aopGet (left, size - 1, FALSE, FALSE)); } addSign (result, LSB, sign); } @@ -8143,7 +8173,7 @@ genSignedRightShift (iCode * ic) largest size of an object can be only 32 bits ) */ pushedB = pushB (); - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); emitcode ("inc", "b"); freeAsmop (right, NULL, ic, TRUE); aopOp (left, ic, FALSE); @@ -8159,15 +8189,15 @@ genSignedRightShift (iCode * ic) offset = 0; while (size--) { - l = aopGet (AOP (left), offset, FALSE, TRUE); + l = aopGet (left, offset, FALSE, TRUE); if (*l == '@' && IS_AOP_PREG (result)) { emitcode ("mov", "a,%s", l); - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } else - aopPut (AOP (result), l, offset, isOperandVolatile (result, FALSE)); + aopPut (result, l, offset, isOperandVolatile (result, FALSE)); offset++; } } @@ -8178,13 +8208,13 @@ genSignedRightShift (iCode * ic) size = AOP_SIZE (result); offset = size - 1; - MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); + MOVA (aopGet (left, offset, FALSE, FALSE)); emitcode ("rlc", "a"); emitcode ("mov", "ov,c"); /* if it is only one byte then */ if (size == 1) { - l = aopGet (AOP (left), 0, FALSE, FALSE); + l = aopGet (left, 0, FALSE, FALSE); MOVA (l); emitcode ("sjmp", "%05d$", tlbl1->key + 100); emitcode ("", "%05d$:", tlbl->key + 100); @@ -8193,7 +8223,7 @@ genSignedRightShift (iCode * ic) emitcode ("", "%05d$:", tlbl1->key + 100); emitcode ("djnz", "b,%05d$", tlbl->key + 100); popB (pushedB); - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); goto release; } @@ -8203,10 +8233,10 @@ genSignedRightShift (iCode * ic) emitcode ("mov", "c,ov"); while (size--) { - l = aopGet (AOP (result), offset, FALSE, FALSE); + l = aopGet (result, offset, FALSE, FALSE); MOVA (l); emitcode ("rrc", "a"); - aopPut (AOP (result), "a", offset--, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset--, isOperandVolatile (result, FALSE)); } reAdjustPreg (AOP (result)); emitcode ("", "%05d$:", tlbl1->key + 100); @@ -8271,7 +8301,7 @@ genRightShift (iCode * ic) largest size of an object can be only 32 bits ) */ pushedB = pushB (); - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE)); emitcode ("inc", "b"); freeAsmop (right, NULL, ic, TRUE); aopOp (left, ic, FALSE); @@ -8287,15 +8317,15 @@ genRightShift (iCode * ic) offset = 0; while (size--) { - l = aopGet (AOP (left), offset, FALSE, TRUE); + l = aopGet (left, offset, FALSE, TRUE); if (*l == '@' && IS_AOP_PREG (result)) { emitcode ("mov", "a,%s", l); - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } else - aopPut (AOP (result), l, offset, isOperandVolatile (result, FALSE)); + aopPut (result, l, offset, isOperandVolatile (result, FALSE)); offset++; } } @@ -8308,7 +8338,7 @@ genRightShift (iCode * ic) /* if it is only one byte then */ if (size == 1) { - l = aopGet (AOP (left), 0, FALSE, FALSE); + l = aopGet (left, 0, FALSE, FALSE); MOVA (l); emitcode ("sjmp", "%05d$", tlbl1->key + 100); emitcode ("", "%05d$:", tlbl->key + 100); @@ -8317,7 +8347,7 @@ genRightShift (iCode * ic) emitcode ("", "%05d$:", tlbl1->key + 100); emitcode ("djnz", "b,%05d$", tlbl->key + 100); popB (pushedB); - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); goto release; } @@ -8327,10 +8357,10 @@ genRightShift (iCode * ic) CLRC; while (size--) { - l = aopGet (AOP (result), offset, FALSE, FALSE); + l = aopGet (result, offset, FALSE, FALSE); MOVA (l); emitcode ("rrc", "a"); - aopPut (AOP (result), "a", offset--, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset--, isOperandVolatile (result, FALSE)); } reAdjustPreg (AOP (result)); @@ -8476,7 +8506,7 @@ genUnpackBits (operand * result, char *rname, int ptype, iCode *ifx) emitPtrByteGet (rname, ptype, FALSE); AccRsh (bstr); emitcode ("anl", "a,#0x%02x", ((unsigned char) -1) >> (8 - blen)); - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); goto finish; } @@ -8485,7 +8515,7 @@ genUnpackBits (operand * result, char *rname, int ptype, iCode *ifx) for (rlen=blen;rlen>=8;rlen-=8) { emitPtrByteGet (rname, ptype, FALSE); - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); if (rlen>8) emitcode ("inc", "%s", rname); } @@ -8495,7 +8525,7 @@ genUnpackBits (operand * result, char *rname, int ptype, iCode *ifx) { emitPtrByteGet (rname, ptype, FALSE); emitcode ("anl", "a,#0x%02x", ((unsigned char) -1) >> (8-rlen)); - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); } finish: @@ -8503,7 +8533,7 @@ finish: { rsize -= offset; while (rsize--) - aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); + aopPut (result, zero, offset++, isOperandVolatile (result, FALSE)); } } @@ -8525,7 +8555,7 @@ genDataPointerGet (operand * left, aopOp (result, ic, TRUE); /* get the string representation of the name */ - l = aopGet (AOP (left), 0, FALSE, TRUE); + l = aopGet (left, 0, FALSE, TRUE); size = AOP_SIZE (result); while (size--) { @@ -8533,7 +8563,7 @@ genDataPointerGet (operand * left, sprintf (buffer, "(%s + %d)", l + 1, offset); else sprintf (buffer, "%s", l + 1); - aopPut (AOP (result), buffer, offset++, isOperandVolatile (result, FALSE)); + aopPut (result, buffer, offset++, isOperandVolatile (result, FALSE)); } freeAsmop (left, NULL, ic, TRUE); @@ -8583,7 +8613,7 @@ genNearPointerGet (operand * left, if (IS_AOP_PREG (left)) { // Aha, it is a pointer, just in disguise. - rname = aopGet (AOP (left), 0, FALSE, FALSE); + rname = aopGet (left, 0, FALSE, FALSE); if (*rname != '@') { fprintf(stderr, "probable internal error: unexpected rname @ %s:%d\n", @@ -8603,12 +8633,12 @@ genNearPointerGet (operand * left, preg = getFreePtr (ic, &aop, FALSE); emitcode ("mov", "%s,%s", preg->name, - aopGet (AOP (left), 0, FALSE, TRUE)); + aopGet (left, 0, FALSE, TRUE)); rname = preg->name; } } else - rname = aopGet (AOP (left), 0, FALSE, FALSE); + rname = aopGet (left, 0, FALSE, FALSE); //aopOp (result, ic, FALSE); aopOp (result, ic, result?TRUE:FALSE); @@ -8629,12 +8659,12 @@ genNearPointerGet (operand * left, emitcode ("mov", "a,@%s", rname); if (!ifx) - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); } else { sprintf (buffer, "@%s", rname); - aopPut (AOP (result), buffer, offset, isOperandVolatile (result, FALSE)); + aopPut (result, buffer, offset, isOperandVolatile (result, FALSE)); } offset++; if (size || pi) @@ -8646,7 +8676,7 @@ genNearPointerGet (operand * left, if (aop) /* we had to allocate for this iCode */ { if (pi) { /* post increment present */ - aopPut(AOP ( left ),rname,0, isOperandVolatile (left, FALSE)); + aopPut (left, rname, 0, isOperandVolatile (left, FALSE)); } freeAsmop (NULL, aop, ic, RESULTONSTACK (ic) ? FALSE : TRUE); } @@ -8711,11 +8741,11 @@ genPagedPointerGet (operand * left, preg = getFreePtr (ic, &aop, FALSE); emitcode ("mov", "%s,%s", preg->name, - aopGet (AOP (left), 0, FALSE, TRUE)); + aopGet (left, 0, FALSE, TRUE)); rname = preg->name; } else - rname = aopGet (AOP (left), 0, FALSE, FALSE); + rname = aopGet (left, 0, FALSE, FALSE); aopOp (result, ic, FALSE); @@ -8733,7 +8763,7 @@ genPagedPointerGet (operand * left, emitcode ("movx", "a,@%s", rname); if (!ifx) - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); offset++; @@ -8745,7 +8775,7 @@ genPagedPointerGet (operand * left, /* now some housekeeping stuff */ if (aop) /* we had to allocate for this iCode */ { - if (pi) aopPut ( AOP (left), rname, 0, isOperandVolatile (left, FALSE)); + if (pi) aopPut (left, rname, 0, isOperandVolatile (left, FALSE)); freeAsmop (NULL, aop, ic, TRUE); } else @@ -8790,11 +8820,11 @@ loadDptrFromOperand (operand *op, bool loadBToo) /* if this is rematerializable */ if (AOP_TYPE (op) == AOP_IMMD) { - emitcode ("mov", "dptr,%s", aopGet (AOP (op), 0, TRUE, FALSE)); + emitcode ("mov", "dptr,%s", aopGet (op, 0, TRUE, FALSE)); if (loadBToo) { if (AOP(op)->aopu.aop_immd.from_cast_remat) - emitcode ("mov", "b,%s",aopGet(AOP (op), AOP_SIZE(op)-1, FALSE, FALSE)); + emitcode ("mov", "b,%s",aopGet (op, AOP_SIZE(op)-1, FALSE, FALSE)); else { wassertl(FALSE, "need pointerCode"); @@ -8804,7 +8834,7 @@ loadDptrFromOperand (operand *op, bool loadBToo) ** from genPointerGet: ** emitcode ("mov", "b,#%d", pointerCode (retype)); ** from genPointerSet: - ** emitcode ("mov", "b,%s + 1", aopGet (AOP (result), 0, TRUE, FALSE)); + ** emitcode ("mov", "b,%s + 1", aopGet (result, 0, TRUE, FALSE)); */ } } @@ -8813,28 +8843,28 @@ loadDptrFromOperand (operand *op, bool loadBToo) { if (loadBToo) { - MOVA (aopGet (AOP (op), 0, FALSE, FALSE)); + MOVA (aopGet (op, 0, FALSE, FALSE)); emitcode ("push", "acc"); - MOVA (aopGet (AOP (op), 1, FALSE, FALSE)); + MOVA (aopGet (op, 1, FALSE, FALSE)); emitcode ("push", "acc"); - emitcode ("mov", "b,%s", aopGet (AOP (op), 2, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (op, 2, FALSE, FALSE)); emitcode ("pop", "dph"); emitcode ("pop", "dpl"); } else { - MOVA (aopGet (AOP (op), 0, FALSE, FALSE)); + MOVA (aopGet (op, 0, FALSE, FALSE)); emitcode ("push", "acc"); - emitcode ("mov", "dph,%s", aopGet (AOP (op), 1, FALSE, FALSE)); + emitcode ("mov", "dph,%s", aopGet (op, 1, FALSE, FALSE)); emitcode ("pop", "dpl"); } } else { /* we need to get it byte by byte */ - emitcode ("mov", "dpl,%s", aopGet (AOP (op), 0, FALSE, FALSE)); - emitcode ("mov", "dph,%s", aopGet (AOP (op), 1, FALSE, FALSE)); + emitcode ("mov", "dpl,%s", aopGet (op, 0, FALSE, FALSE)); + emitcode ("mov", "dph,%s", aopGet (op, 1, FALSE, FALSE)); if (loadBToo) - emitcode ("mov", "b,%s", aopGet (AOP (op), 2, FALSE, FALSE)); + emitcode ("mov", "b,%s", aopGet (op, 2, FALSE, FALSE)); } } } @@ -8869,7 +8899,7 @@ genFarPointerGet (operand * left, { emitcode ("movx", "a,@dptr"); if (!ifx) - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); if (size || pi) emitcode ("inc", "dptr"); } @@ -8877,8 +8907,8 @@ genFarPointerGet (operand * left, if (pi && AOP_TYPE (left) != AOP_IMMD && AOP_TYPE (left) != AOP_STR) { - aopPut ( AOP (left), "dpl", 0, isOperandVolatile (left, FALSE)); - aopPut ( AOP (left), "dph", 1, isOperandVolatile (left, FALSE)); + aopPut (left, "dpl", 0, isOperandVolatile (left, FALSE)); + aopPut (left, "dph", 1, isOperandVolatile (left, FALSE)); pi->generated = 1; } @@ -8924,7 +8954,7 @@ genCodePointerGet (operand * left, emitcode ("clr", "a"); emitcode ("movc", "a,@a+dptr"); if (!ifx) - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); emitcode ("inc", "dptr"); } else @@ -8932,15 +8962,15 @@ genCodePointerGet (operand * left, emitcode ("mov", "a,#0x%02x", offset); emitcode ("movc", "a,@a+dptr"); if (!ifx) - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); } } } if (pi && AOP_TYPE (left) != AOP_IMMD && AOP_TYPE (left) != AOP_STR) { - aopPut ( AOP (left), "dpl", 0, isOperandVolatile (left, FALSE)); - aopPut ( AOP (left), "dph", 1, isOperandVolatile (left, FALSE)); + aopPut (left, "dpl", 0, isOperandVolatile (left, FALSE)); + aopPut (left, "dph", 1, isOperandVolatile (left, FALSE)); pi->generated = 1; } @@ -8983,7 +9013,7 @@ genGenPointerGet (operand * left, { emitcode ("lcall", "__gptrget"); if (!ifx) - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); if (size || pi) emitcode ("inc", "dptr"); } @@ -8991,8 +9021,8 @@ genGenPointerGet (operand * left, if (pi && AOP_TYPE (left) != AOP_IMMD && AOP_TYPE (left) != AOP_STR) { - aopPut ( AOP (left), "dpl", 0, isOperandVolatile (left, FALSE)); - aopPut ( AOP (left), "dph", 1, isOperandVolatile (left, FALSE)); + aopPut (left, "dpl", 0, isOperandVolatile (left, FALSE)); + aopPut (left, "dph", 1, isOperandVolatile (left, FALSE)); pi->generated = 1; } @@ -9124,7 +9154,7 @@ genPackBits (sym_link * etype, emitcode ("mov", "c,%s", AOP(right)->aopu.aop_dir); else { - MOVA (aopGet (AOP (right), 0, FALSE, FALSE)); + MOVA (aopGet (right, 0, FALSE, FALSE)); emitcode ("rrc","a"); } emitPtrByteGet (rname, p_type, FALSE); @@ -9135,7 +9165,7 @@ genPackBits (sym_link * etype, bool pushedB; /* Case with a bitfield length < 8 and arbitrary source */ - MOVA (aopGet (AOP (right), 0, FALSE, FALSE)); + MOVA (aopGet (right, 0, FALSE, FALSE)); /* shift and mask source value */ AccLsh (bstr); emitcode ("anl", "a,#0x%02x", (~mask) & 0xff); @@ -9162,7 +9192,7 @@ genPackBits (sym_link * etype, for (rlen=blen;rlen>=8;rlen-=8) { emitPtrByteSet (rname, p_type, - aopGet (AOP (right), offset++, FALSE, TRUE) ); + aopGet (right, offset++, FALSE, TRUE) ); if (rlen>8) emitcode ("inc", "%s", rname); } @@ -9190,7 +9220,7 @@ genPackBits (sym_link * etype, bool pushedB; /* Case with partial byte and arbitrary source */ - MOVA (aopGet (AOP (right), offset++, FALSE, FALSE)); + MOVA (aopGet (right, offset++, FALSE, FALSE)); emitcode ("anl", "a,#0x%02x", (~mask) & 0xff); pushedB = pushB (); @@ -9225,7 +9255,7 @@ genDataPointerSet (operand * right, aopOp (right, ic, FALSE); - l = aopGet (AOP (result), 0, FALSE, TRUE); + l = aopGet (result, 0, FALSE, TRUE); size = AOP_SIZE (right); while (size--) { @@ -9234,7 +9264,7 @@ genDataPointerSet (operand * right, else sprintf (buffer, "%s", l + 1); emitcode ("mov", "%s,%s", buffer, - aopGet (AOP (right), offset++, FALSE, FALSE)); + aopGet (right, offset++, FALSE, FALSE)); } freeAsmop (right, NULL, ic, TRUE); @@ -9283,7 +9313,7 @@ genNearPointerSet (operand * right, ) { // Aha, it is a pointer, just in disguise. - rname = aopGet (AOP (result), 0, FALSE, FALSE); + rname = aopGet (result, 0, FALSE, FALSE); if (*rname != '@') { fprintf(stderr, "probable internal error: unexpected rname @ %s:%d\n", @@ -9303,13 +9333,13 @@ genNearPointerSet (operand * right, preg = getFreePtr (ic, &aop, FALSE); emitcode ("mov", "%s,%s", preg->name, - aopGet (AOP (result), 0, FALSE, TRUE)); + aopGet (result, 0, FALSE, TRUE)); rname = preg->name; } } else { - rname = aopGet (AOP (result), 0, FALSE, FALSE); + rname = aopGet (result, 0, FALSE, FALSE); } aopOp (right, ic, FALSE); @@ -9325,7 +9355,7 @@ genNearPointerSet (operand * right, while (size--) { - l = aopGet (AOP (right), offset, FALSE, TRUE); + l = aopGet (right, offset, FALSE, TRUE); if (*l == '@') { MOVA (l); @@ -9343,7 +9373,7 @@ genNearPointerSet (operand * right, if (aop) /* we had to allocate for this iCode */ { if (pi) - aopPut (AOP (result), rname, 0, isOperandVolatile (result, FALSE)); + aopPut (result, rname, 0, isOperandVolatile (result, FALSE)); freeAsmop (NULL, aop, ic, TRUE); } else @@ -9401,11 +9431,11 @@ genPagedPointerSet (operand * right, preg = getFreePtr (ic, &aop, FALSE); emitcode ("mov", "%s,%s", preg->name, - aopGet (AOP (result), 0, FALSE, TRUE)); + aopGet (result, 0, FALSE, TRUE)); rname = preg->name; } else - rname = aopGet (AOP (result), 0, FALSE, FALSE); + rname = aopGet (result, 0, FALSE, FALSE); aopOp (right, ic, FALSE); @@ -9420,7 +9450,7 @@ genPagedPointerSet (operand * right, while (size--) { - l = aopGet (AOP (right), offset, FALSE, TRUE); + l = aopGet (right, offset, FALSE, TRUE); MOVA (l); emitcode ("movx", "@%s,a", rname); @@ -9436,7 +9466,7 @@ genPagedPointerSet (operand * right, if (aop) /* we had to allocate for this iCode */ { if (pi) - aopPut (AOP (result), rname, 0, isOperandVolatile (result, FALSE)); + aopPut (result, rname, 0, isOperandVolatile (result, FALSE)); freeAsmop (NULL, aop, ic, TRUE); } else @@ -9494,7 +9524,7 @@ genFarPointerSet (operand * right, while (size--) { - char *l = aopGet (AOP (right), offset++, FALSE, FALSE); + char *l = aopGet (right, offset++, FALSE, FALSE); MOVA (l); emitcode ("movx", "@dptr,a"); if (size || pi) @@ -9502,8 +9532,8 @@ genFarPointerSet (operand * right, } } if (pi && AOP_TYPE (result) != AOP_STR && AOP_TYPE (result) != AOP_IMMD) { - aopPut (AOP(result), "dpl", 0, isOperandVolatile (result, FALSE)); - aopPut (AOP(result), "dph", 1, isOperandVolatile (result, FALSE)); + aopPut (result, "dpl", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "dph", 1, isOperandVolatile (result, FALSE)); pi->generated=1; } freeAsmop (result, NULL, ic, TRUE); @@ -9539,7 +9569,7 @@ genGenPointerSet (operand * right, while (size--) { - char *l = aopGet (AOP (right), offset++, FALSE, FALSE); + char *l = aopGet (right, offset++, FALSE, FALSE); MOVA (l); emitcode ("lcall", "__gptrput"); if (size || pi) @@ -9548,8 +9578,8 @@ genGenPointerSet (operand * right, } if (pi && AOP_TYPE (result) != AOP_STR && AOP_TYPE (result) != AOP_IMMD) { - aopPut (AOP(result), "dpl", 0, isOperandVolatile (result, FALSE)); - aopPut (AOP(result), "dph", 1, isOperandVolatile (result, FALSE)); + aopPut (result, "dpl", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "dph", 1, isOperandVolatile (result, FALSE)); pi->generated=1; } freeAsmop (result, NULL, ic, TRUE); @@ -9684,12 +9714,12 @@ genAddrOf (iCode * ic) emitcode ("add", "a,#0x%02x", ((sym->stack < 0) ? ((char) (sym->stack - _G.nRegsSaved)) : ((char) sym->stack)) & 0xff); - aopPut (AOP (IC_RESULT (ic)), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE)); } else { /* we can just move _bp */ - aopPut (AOP (IC_RESULT (ic)), SYM_BP (sym), 0, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), SYM_BP (sym), 0, isOperandVolatile (IC_RESULT (ic), FALSE)); } /* fill the result with zero */ size = AOP_SIZE (IC_RESULT (ic)) - 1; @@ -9697,7 +9727,7 @@ genAddrOf (iCode * ic) offset = 1; while (size--) { - aopPut (AOP (IC_RESULT (ic)), zero, offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), zero, offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } goto release; @@ -9716,7 +9746,7 @@ genAddrOf (iCode * ic) offset * 8); else sprintf (s, "#%s", sym->rname); - aopPut (AOP (IC_RESULT (ic)), s, offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), s, offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } release: @@ -9739,7 +9769,7 @@ genFarFarAssign (operand * result, operand * right, iCode * ic) /* first push the right side on to the stack */ while (size--) { - l = aopGet (AOP (right), offset++, FALSE, FALSE); + l = aopGet (right, offset++, FALSE, FALSE); MOVA (l); emitcode ("push", "acc"); } @@ -9751,7 +9781,7 @@ genFarFarAssign (operand * result, operand * right, iCode * ic) while (size--) { emitcode ("pop", "acc"); - aopPut (AOP (result), "a", --offset, isOperandVolatile (result, FALSE)); + aopPut (result, "a", --offset, isOperandVolatile (result, FALSE)); } freeAsmop (result, NULL, ic, FALSE); @@ -9807,9 +9837,9 @@ genAssign (iCode * ic) if (AOP_TYPE (right) == AOP_LIT) { if (((int) operandLitValue (right))) - aopPut (AOP (result), one, 0, isOperandVolatile (result, FALSE)); + aopPut (result, one, 0, isOperandVolatile (result, FALSE)); else - aopPut (AOP (result), zero, 0, isOperandVolatile (result, FALSE)); + aopPut (result, zero, 0, isOperandVolatile (result, FALSE)); goto release; } @@ -9817,13 +9847,13 @@ genAssign (iCode * ic) if (AOP_TYPE (right) == AOP_CRY) { emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir); - aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "c", 0, isOperandVolatile (result, FALSE)); goto release; } /* we need to or */ toBoolean (right); - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); goto release; } @@ -9841,8 +9871,8 @@ genAssign (iCode * ic) { while ((size) && (lit)) { - aopPut (AOP (result), - aopGet (AOP (right), offset, FALSE, FALSE), + aopPut (result, + aopGet (right, offset, FALSE, FALSE), offset, isOperandVolatile (result, FALSE)); lit >>= 8; @@ -9852,7 +9882,7 @@ genAssign (iCode * ic) emitcode ("clr", "a"); while (size--) { - aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset, isOperandVolatile (result, FALSE)); offset++; } } @@ -9860,8 +9890,8 @@ genAssign (iCode * ic) { while (size--) { - aopPut (AOP (result), - aopGet (AOP (right), offset, FALSE, FALSE), + aopPut (result, + aopGet (right, offset, FALSE, FALSE), offset, isOperandVolatile (result, FALSE)); offset++; @@ -9896,11 +9926,11 @@ genJumpTab (iCode * ic) How will multiply by three be updated ???*/ aopOp (IC_JTCOND (ic), ic, FALSE); /* get the condition into accumulator */ - l = aopGet (AOP (IC_JTCOND (ic)), 0, FALSE, FALSE); + l = aopGet (IC_JTCOND (ic), 0, FALSE, FALSE); MOVA (l); /* multiply by three */ emitcode ("add", "a,acc"); - emitcode ("add", "a,%s", aopGet (AOP (IC_JTCOND (ic)), 0, FALSE, FALSE)); + emitcode ("add", "a,%s", aopGet (IC_JTCOND (ic), 0, FALSE, FALSE)); freeAsmop (IC_JTCOND (ic), NULL, ic, TRUE); jtab = newiTempLabel (NULL); @@ -9923,7 +9953,7 @@ genJumpTab (iCode * ic) /* get the condition into accumulator. Using b as temporary storage, if register push/pop is needed */ aopOp (IC_JTCOND (ic), ic, FALSE); - l = aopGet (AOP (IC_JTCOND (ic)), 0, FALSE, FALSE); + l = aopGet (IC_JTCOND (ic), 0, FALSE, FALSE); if ((AOP_TYPE (IC_JTCOND (ic)) == AOP_R0 && _G.r0Pushed) || (AOP_TYPE (IC_JTCOND (ic)) == AOP_R1 && _G.r1Pushed)) { @@ -10006,9 +10036,9 @@ genCast (iCode * ic) if (AOP_TYPE (right) == AOP_LIT) { if (((int) operandLitValue (right))) - aopPut (AOP (result), one, 0, isOperandVolatile (result, FALSE)); + aopPut (result, one, 0, isOperandVolatile (result, FALSE)); else - aopPut (AOP (result), zero, 0, isOperandVolatile (result, FALSE)); + aopPut (result, zero, 0, isOperandVolatile (result, FALSE)); goto release; } @@ -10017,13 +10047,13 @@ genCast (iCode * ic) if (AOP_TYPE (right) == AOP_CRY) { emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir); - aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "c", 0, isOperandVolatile (result, FALSE)); goto release; } /* we need to or */ toBoolean (right); - aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); + aopPut (result, "a", 0, isOperandVolatile (result, FALSE)); goto release; } @@ -10041,8 +10071,8 @@ genCast (iCode * ic) offset = 0; while (size--) { - aopPut (AOP (result), - aopGet (AOP (right), offset, FALSE, FALSE), + aopPut (result, + aopGet (right, offset, FALSE, FALSE), offset, isOperandVolatile (result, FALSE)); offset++; @@ -10080,8 +10110,8 @@ genCast (iCode * ic) offset = 0; while (size--) { - aopPut (AOP (result), - aopGet (AOP (right), offset, FALSE, FALSE), + aopPut (result, + aopGet (right, offset, FALSE, FALSE), offset, isOperandVolatile (result, FALSE)); offset++; @@ -10097,8 +10127,8 @@ genCast (iCode * ic) exit(1); } - sprintf(gpValStr, "#0x%d", gpVal); - aopPut (AOP (result), gpValStr, GPTRSIZE - 1, isOperandVolatile (result, FALSE)); + sprintf(gpValStr, "#0x%x", gpVal); + aopPut (result, gpValStr, GPTRSIZE - 1, isOperandVolatile (result, FALSE)); } goto release; } @@ -10108,8 +10138,8 @@ genCast (iCode * ic) offset = 0; while (size--) { - aopPut (AOP (result), - aopGet (AOP (right), offset, FALSE, FALSE), + aopPut (result, + aopGet (right, offset, FALSE, FALSE), offset, isOperandVolatile (result, FALSE)); offset++; @@ -10124,8 +10154,8 @@ genCast (iCode * ic) offset = 0; while (size--) { - aopPut (AOP (result), - aopGet (AOP (right), offset, FALSE, FALSE), + aopPut (result, + aopGet (right, offset, FALSE, FALSE), offset, isOperandVolatile (result, FALSE)); offset++; @@ -10137,18 +10167,18 @@ genCast (iCode * ic) if (!IS_SPEC (rtype) || SPEC_USIGN (rtype) || AOP_TYPE(right)==AOP_CRY) { while (size--) - aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); + aopPut (result, zero, offset++, isOperandVolatile (result, FALSE)); } else { /* we need to extend the sign :{ */ - char *l = aopGet (AOP (right), AOP_SIZE (right) - 1, + char *l = aopGet (right, AOP_SIZE (right) - 1, FALSE, FALSE); MOVA (l); emitcode ("rlc", "a"); emitcode ("subb", "a,acc"); while (size--) - aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); + aopPut (result, "a", offset++, isOperandVolatile (result, FALSE)); } /* we are done hurray !!!! */ @@ -10202,7 +10232,7 @@ genDjnz (iCode * ic, iCode * ifx) * the accumulator, we must explicitly write * it back after the decrement. */ - char *rByte = aopGet(AOP(IC_RESULT(ic)), 0, FALSE, FALSE); + char *rByte = aopGet (IC_RESULT(ic), 0, FALSE, FALSE); if (strcmp(rByte, "a")) { @@ -10216,19 +10246,19 @@ genDjnz (iCode * ic, iCode * ifx) return 0; } emitcode ("dec", "%s", rByte); - aopPut(AOP(IC_RESULT(ic)), rByte, 0, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), rByte, 0, isOperandVolatile (IC_RESULT (ic), FALSE)); emitcode ("jnz", "%05d$", lbl->key + 100); } else if (IS_AOP_PREG (IC_RESULT (ic))) { emitcode ("dec", "%s", - aopGet (AOP (IC_RESULT (ic)), 0, FALSE, FALSE)); - MOVA (aopGet (AOP (IC_RESULT (ic)), 0, FALSE, FALSE)); + aopGet (IC_RESULT (ic), 0, FALSE, FALSE)); + MOVA (aopGet (IC_RESULT (ic), 0, FALSE, FALSE)); emitcode ("jnz", "%05d$", lbl->key + 100); } else { - emitcode ("djnz", "%s,%05d$", aopGet (AOP (IC_RESULT (ic)), 0, FALSE, FALSE), + emitcode ("djnz", "%s,%05d$", aopGet (IC_RESULT (ic), 0, FALSE, FALSE), lbl->key + 100); } emitcode ("sjmp", "%05d$", lbl1->key + 100); @@ -10274,10 +10304,10 @@ genReceive (iCode * ic) _G.accInUse++; aopOp (IC_RESULT (ic), ic, FALSE); _G.accInUse--; - aopPut (AOP (IC_RESULT (ic)), "a", offset, + aopPut (IC_RESULT (ic), "a", offset, isOperandVolatile (IC_RESULT (ic), FALSE)); for (offset = 1; offsetname, offset, + aopPut (IC_RESULT (ic), tempRegs[--roffset]->name, offset, isOperandVolatile (IC_RESULT (ic), FALSE)); goto release; } @@ -10290,7 +10320,7 @@ genReceive (iCode * ic) emitcode("mov","%s,%s", tempRegs[offset]->name, fReturn[offset]); aopOp (IC_RESULT (ic), ic, FALSE); for (offset = 0; offsetname, offset, + aopPut (IC_RESULT (ic), tempRegs[offset]->name, offset, isOperandVolatile (IC_RESULT (ic), FALSE)); goto release; } @@ -10307,7 +10337,7 @@ genReceive (iCode * ic) offset = 0; while (size--) { emitcode ("pop", "acc"); - aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } } else { @@ -10321,7 +10351,7 @@ genReceive (iCode * ic) aopOp (IC_RESULT (ic), ic, FALSE); rb1off = ic->argreg; while (size--) { - aopPut (AOP (IC_RESULT (ic)), rb1regs[rb1off++ -5], offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); + aopPut (IC_RESULT (ic), rb1regs[rb1off++ -5], offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } } @@ -10356,7 +10386,7 @@ genDummyRead (iCode * ic) offset = 0; while (size--) { - MOVA (aopGet (AOP (op), offset, FALSE, FALSE)); + MOVA (aopGet (op, offset, FALSE, FALSE)); offset++; } } @@ -10380,7 +10410,7 @@ genDummyRead (iCode * ic) offset = 0; while (size--) { - MOVA (aopGet (AOP (op), offset, FALSE, FALSE)); + MOVA (aopGet (op, offset, FALSE, FALSE)); offset++; } } @@ -10402,9 +10432,9 @@ genCritical (iCode *ic) if (IC_RESULT (ic)) { aopOp (IC_RESULT (ic), ic, TRUE); - aopPut (AOP (IC_RESULT (ic)), one, 0, 0); + aopPut (IC_RESULT (ic), one, 0, 0); emitcode ("jbc", "ea,%05d$", (tlbl->key + 100)); /* atomic test & clear */ - aopPut (AOP (IC_RESULT (ic)), zero, 0, 0); + aopPut (IC_RESULT (ic), zero, 0, 0); emitcode ("", "%05d$:", (tlbl->key + 100)); freeAsmop (IC_RESULT (ic), NULL, ic, TRUE); } @@ -10437,7 +10467,7 @@ genEndCritical (iCode *ic) else { if (AOP_TYPE (IC_RIGHT (ic)) != AOP_DUMMY) - MOVA (aopGet (AOP (IC_RIGHT (ic)), 0, FALSE, FALSE)); + MOVA (aopGet (IC_RIGHT (ic), 0, FALSE, FALSE)); emitcode ("rrc", "a"); emitcode ("mov", "ea,c"); } diff --git a/src/mcs51/main.c b/src/mcs51/main.c index bddc63e0..61ca32ed 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -30,6 +30,8 @@ static char *_mcs51_keywords[] = "pdata", "reentrant", "sfr", + "sfr16", + "sfr32", "sbit", "using", "xdata", @@ -706,21 +708,22 @@ PORT mcs51_port = 1, 2, 2, 4, 1, 2, 3, 1, 4, 4 }, { - "XSTK (PAG,XDATA)", - "STACK (DATA)", - "CSEG (CODE)", - "DSEG (DATA)", - "ISEG (DATA)", - "PSEG (PAG,XDATA)", - "XSEG (XDATA)", - "BSEG (BIT)", - "RSEG (DATA)", - "GSINIT (CODE)", - "OSEG (OVR,DATA)", - "GSFINAL (CODE)", - "HOME (CODE)", - "XISEG (XDATA)", // initialized xdata - "XINIT (CODE)", // a code copy of xiseg + "XSTK (PAG,XDATA)", // xstack_name + "STACK (DATA)", // istack_name + "CSEG (CODE)", // code_name + "DSEG (DATA)", // data_name + "ISEG (DATA)", // idata_name + "PSEG (PAG,XDATA)", // pdata_name + "XSEG (XDATA)", // xdata_name + "BSEG (BIT)", // bit_name + "RSEG (DATA)", // reg_name + "GSINIT (CODE)", // static_name + "OSEG (OVR,DATA)", // overlay_name + "GSFINAL (CODE)", // post_static_name + "HOME (CODE)", // home_name + "XISEG (XDATA)", // xidata_name - initialized xdata initialized xdata + "XINIT (CODE)", // xinit_name - a code copy of xiseg + "CONST (CODE)", // const_name - const data (code or not) NULL, NULL, 1 diff --git a/src/mcs51/peeph.def b/src/mcs51/peeph.def index ca2caec2..97095ba5 100644 --- a/src/mcs51/peeph.def +++ b/src/mcs51/peeph.def @@ -2210,18 +2210,18 @@ replace { replace { clr a - movx @dptr,a - inc dptr - movx @dptr,a - inc dptr + movx @%1,a + inc %1 + movx @%1,a + inc %1 clr a } by { ; Peephole 226 removed unnecessary clr clr a - movx @dptr,a - inc dptr - movx @dptr,a - inc dptr + movx @%1,a + inc %1 + movx @%1,a + inc %1 } replace { diff --git a/src/pic/main.c b/src/pic/main.c index 34784358..ca0a7cb4 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -446,6 +446,7 @@ PORT pic_port = "HOME (CODE)", NULL, // xidata NULL, // xinit + "CONST (CODE)", // const_name - const data (code or not) NULL, NULL, 1 // code is read only diff --git a/src/pic16/main.c b/src/pic16/main.c index bb5bd72b..e57c2999 100644 --- a/src/pic16/main.c +++ b/src/pic16/main.c @@ -1078,6 +1078,7 @@ PORT pic16_port = "HOME (CODE)", // home NULL, // xidata NULL, // xinit + "CONST (CODE)", // const_name - const data (code or not) NULL, // default location for auto vars NULL, // default location for global vars 1 // code is read only 1=yes diff --git a/src/port.h b/src/port.h index 06210e57..e44e610b 100644 --- a/src/port.h +++ b/src/port.h @@ -129,9 +129,9 @@ typedef struct int short_size; int int_size; int long_size; - int ptr_size; - int fptr_size; - int gptr_size; + int ptr_size; //near + int fptr_size; //far + int gptr_size; //generic int bit_size; int float_size; int max_base_size; @@ -156,6 +156,7 @@ typedef struct const char *home_name; const char *xidata_name; // initialized xdata const char *xinit_name; // a code copy of xidata + const char *const_name; // const data (code or not) struct memmap *default_local_map; // default location for auto vars struct memmap *default_globl_map; // default location for globl vars int code_ro; /* code space read-only 1=yes */ diff --git a/src/src.dsp b/src/src.dsp index c15d29dc..aedde6ac 100644 --- a/src/src.dsp +++ b/src/src.dsp @@ -177,7 +177,7 @@ SOURCE=.\SDCCdwarf2.c # End Source File # Begin Source File -SOURCE=..\support\Util\sdccerr.c +SOURCE=..\support\Util\SDCCerr.c # End Source File # Begin Source File @@ -453,5 +453,9 @@ SOURCE=.\regression\while.c # PROP Exclude_From_Build 1 # End Source File # End Group +# Begin Source File + +SOURCE=..\support\scripts\sdcc.ico +# End Source File # End Target # End Project diff --git a/src/xa51/main.c b/src/xa51/main.c index 37bf599e..8030dbdd 100755 --- a/src/xa51/main.c +++ b/src/xa51/main.c @@ -285,6 +285,7 @@ PORT xa51_port = "HOME (CODE)", "XISEG (XDATA)", // initialized xdata "XINIT (CODE)", // a code copy of xiseg + "CONST (CODE)", // const_name - const data (code or not) NULL, // default local map NULL, // default global map 1 diff --git a/src/z80/main.c b/src/z80/main.c index 3706b172..33f5bbd4 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -614,6 +614,7 @@ PORT z80_port = "HOME", NULL, /* xidata */ NULL, /* xinit */ + NULL, /* const_name */ NULL, NULL, 1 @@ -730,6 +731,7 @@ PORT gbz80_port = "HOME", NULL, /* xidata */ NULL, /* xinit */ + NULL, /* const_name */ NULL, NULL, 1 diff --git a/support/regression/tests/bug663539.c b/support/regression/tests/bug663539.c new file mode 100644 index 00000000..28db6064 --- /dev/null +++ b/support/regression/tests/bug663539.c @@ -0,0 +1,21 @@ +/* + bug663539.c +*/ + +#include + +#if defined (SDCC_ds390) || defined (SDCC_mcs51) + volatile xdata at 0x7654 char x; +#endif + +void +test_volatile(void) +{ + ASSERT (1); + +#if defined (SDCC_ds390) || defined (SDCC_mcs51) + x; //this should end the simulation + + while (1); //let the "watchdog" bite +#endif +} diff --git a/support/regression/tests/sfr16.c b/support/regression/tests/sfr16.c new file mode 100644 index 00000000..81ea7ad8 --- /dev/null +++ b/support/regression/tests/sfr16.c @@ -0,0 +1,33 @@ +/* + sfr16.c +*/ + +#include + +#if defined (SDCC_mcs51) +sfr at 0x8A TL0; //timer 0 low byte +sfr at 0x8C TH0; //timer 0 high byte + +sfr16 at 0x8C8A TMR0; //timer 0 +#endif + +void +test_sfr(void) +{ +#if defined (SDCC_mcs51) + TMR0 = 0x00FE; + ASSERT (TH0 == 0x00); + ASSERT (TL0 == 0xFE); + + TMR0++; + ASSERT (TH0 == 0x00); + ASSERT (TL0 == 0xFF); + + TMR0++; + ASSERT (TH0 == 0x01); + ASSERT (TL0 == 0x00); + + TL0++; + ASSERT (TMR0 == 0x0101); +#endif +}