开发者

Error when compiling simple SPARC ASM math code

Writing SPARC asm code to evaluate a hardcoded statement, but I'm getting an error I don't understand. I've searched all over, and while it seems to come up a lot in some bug reports out there, there's no real clues that I've found for programmers. Yes, it is homework, and yes, I'm not finished, and yes I have branch delays all over the place. I'll get to them on my own, but I need to know what the error is. This error's not telling me anything useful, and the books I have aren't any good for it either.

I'm really new at this, so any help would be greatly appreciated.

  1 /*Justin Reeves*/
  2 /*max{x^3-14x^2+56x-64} from [-2,8]*/
  3 /*for (x = lwr, x <= upr, x++) */
  4 define(lwr_b, -2)       !lower bound
  5 define(upr_b, 8)        !upper bound
  6 define(x_r, %l0)        !x
  7 define(sum_r, %l1)      !sum, each pass of loop may update
  8 define(max_r, %l2)      !max, cmp to sum, store in max if larger
  9
 10     .global main
 11 main:
 12     save    %sp, -64, %sp
 13
 14     ba      loop_test
 15     mov     lwr_b,  x_r     /*init x_r = -2 */
 16
 17 loop_test:
 18     cmp     x_r,    upr_b
 19     ble     sum_loop
 20     nop
 21 /*then x > upr_b and the max has been found*/
 22 /*odd spot for it...but this is the end of the program*/
 23
 24
 25 sum_loop: ! starting backwards to give us an intial nonzero constant sum
 26     mov     -64,    sum_r   /* sum = -64 */
 27
 28     mov     x_r,    %o0     /*56x*/
 29     mov     56,     %o0
 30     clr     %o2
 31     call    .mul            /*AFAIK 56x should now be in %o0*/
 32     nop
 33     add     sum_r,  %o0,    sum_r   /* sum = 56x-64 */
 34
 35     mov     x_r,    %o0     /* 14x^2 */
 36     mov     x_r,    %o1
 37     mov     -14,    %o2
 38     call    .mul
 39     nop
 40     add     sum_r,  %o0,    sum_r   /* sum = -14x^2+56x-64 */
 41
 42     mov     x_r,    %o0
 43     mov     x_r,    %o1
 44     mov     x_r,    %o2
 45     call    .mul
 46     nop
 47     add     sum_r,  %o0,    sum_r   /*sum = x^3-14x^2+56x-64 */
 48
 49     add     x_r,    1,  开发者_运维问答    x_r     /* x++ */
 50     cmp     sum_r,  max_r
 51     bge     collect_lrg             /*branches if sum > max*/
 52     nop
 53
 54 collect_lrg:
 55     mov     sum_r,  max_r
 56     ba      loop_test
 57
 58     mov     1,      %g1     /*exit request*/
 59     ta      0               /*trap to system*/

then when I try to define the macros and compile I get:

cs32107@matrix:~$ m4 polynomialv2.m > polynomial.s

cs32107@matrix:~$ gcc -g polynomial.s -o polynomial

ld: fatal: relocation error: R_SPARC_32: file /var/tmp//ccVOrnx2.o: symbol : offset 0xfb5d11dd is non-aligned ld: fatal: relocation error: R_SPARC_32: file /var/tmp//ccVOrnx2.o: symbol : offset 0xfb5d120f is non-aligned ld: fatal: relocation error: R_SPARC_32: file /var/tmp//ccVOrnx2.o: symbol : offset 0xfb5d1215 is non-aligned ld: fatal: relocation error: R_SPARC_32: file /var/tmp//ccVOrnx2.o: symbol : offset 0xfb5d1219 is non-aligned ld: fatal: relocation error: R_SPARC_32: file /var/tmp//ccVOrnx2.o: symbol : offset 0xfb5d121d is non-aligned ld: fatal: relocation error: R_SPARC_32: file /var/tmp//ccVOrnx2.o: symbol : offset 0xfb5d1266 is non-aligned collect2: ld returned 1 exit status cs32107@matrix:~$


A bug in the assembler causes debugging code to add unaligned data access. Don't use -g but perhaps -gstabs if you need debugging information. There maybe an update for gas that fixes the problem too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜