[英]Seg Faulting SPARC Assembly
I am determining if a number is zero in my function. 我正在确定函数中的数字是否为零。 If it is zero I need to pass some string like "Is Zero" into the variable I have declared as B. My function to determine if it is zero works but when I try to pass the string into the variable B with my SPARC source code I seg fault.
如果为零,则需要将一些字符串(例如“为零”)传递到已声明为B的变量中。确定该函数是否为零的函数有效,但是当我尝试使用SPARC源代码将字符串传递给变量B时我断断续续。
Here is what I have been trying in my C driver: 这是我在C驱动程序中一直在尝试的方法:
void display( double, char* );
char B[100];
double x = 0.000;
display(x, &B);
printf("%s", B);
Here is my SPARC code: 这是我的SPARC代码:
ZERO: .asciz "Is Zero\n"
.global display
.section ".text"
.align 4
display:
save %sp, -96, %sp
mov %i0, %o0
mov %i1, %o1
mov%i2, %o2
call is_zero ! check if number is zero
cmp %o0, 0
bne zero
nop
zero:
save %sp, -96, %sp
set ZERO, %l0
ldub [%l0], %l1
cmp %l1, 0 ! exit when zero byte reached
beq done
nop
stb %l1, [%i2]
inc %l0
inc %i2
ba zero
nop
done:
ret
restore
&B is the pointer to char array B. display function take a char pointer in 2nd parameter. &B是指向char数组B的指针。显示函数在第二个参数中使用char指针。 display(x, &B) should be display(x, B).
display(x,&B)应该是display(x,B)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.