Hello all,
The current version of avra has a problem with multiple symbolic name
definitions for a register combined with extended macro syntax. For
example, the following code can not be assembled:
== cut ==
.device ATtiny2313
.macro ldi32
.message "No parameters specified"
.endm
.macro ldi32_32_i
ldi @3, low(@4)
ldi @2, high(@4)
ldi @1, byte3(@4)
ldi @0, byte4(@4)
.endm
.def a0 = r16
.def b0 = r17
.def c0 = r18
.def d0 = r19
.cseg
; ldi32 [r19:r18:r17:r16, 0x12345]
ldi32 [d0:c0:b0:a0, 0x12345]
.def a1 = r16
.def b1 = r17
.def c1 = r18
.def d1 = r19
ldi32 [d1:c1:b1:a1, 0x12345]
== cut ==
The reason for this behavior seems to be that the function
parse_directive in directiv.c returns after emitting the "rxx is already
assigned to foo" warning during the first pass. Normally, the definition
allocation is performed on the second pass; however, this does not work
for macro parser (append_type in macro.c), which expects the definitions
to be present on the first pass.
One possible solution is to remove return() from the corresponding
statement. To avoid redundant definition allocation, the return() is
invoked on the second pass instead. The patch for directiv.c is attached
to this post. I hope it does not break anything elsewere :)
This and previous patches are against git snapshot from June 11, but
they're simple enough to be applied manually.
--
Sincerely yours,
Alexey
--- directiv.c.original Sat Jun 11 00:24:44 2011
+++ directiv.c Wed Jun 15 15:20:16 2011
@@ -204,11 +204,20 @@
/* check range of given register */
if(i > 31)
print_msg(pi, MSGTYPE_ERROR, "R%d is not a
valid register", i);
+ /* B.A.: Check, if symbol is already defined as a label
or constant */
+ if(pi->pass == PASS_2) {
+ if(get_label(pi,next,NULL))
+ print_msg(pi, MSGTYPE_WARNING, "Name
'%s' is used for a register and a label", next);
+ if(get_constant(pi,next,NULL))
+ print_msg(pi, MSGTYPE_WARNING, "Name
'%s' is used for a register and a constant", next);
+ }
/* check if this reg is already assigned */
for(def = pi->first_def; def; def = def->next) {
- if(def->reg == i && pi->pass == PASS_1 &&
!pi->NoRegDef) {
- print_msg(pi, MSGTYPE_WARNING, "r%d is
already assigned to '%s'!", i, def->name);
- return(True);
+ if(def->reg == i && !pi->NoRegDef) {
+ if (pi->pass == PASS_1)
+ print_msg(pi, MSGTYPE_WARNING,
"r%d is already assigned to '%s'!", i, def->name);
+ else
+ return(True);
}
}
/* check if this regname is already defined */
@@ -220,13 +229,6 @@
def->reg = i;
return(True);
}
- }
- /* B.A.: Check, if symbol is already defined as a label
or constant */
- if(pi->pass == PASS_2) {
- if(get_label(pi,next,NULL))
- print_msg(pi, MSGTYPE_WARNING, "Name
'%s' is used for a register and a label", next);
- if(get_constant(pi,next,NULL))
- print_msg(pi, MSGTYPE_WARNING, "Name
'%s' is used for a register and a constant", next);
}
def = malloc(sizeof(struct def));
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Avra-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/avra-user