- 论坛徽章:
- 0
|
Following-up,
对于 printf("s1=%s s2=%s\n", try("123"), try("456"));
Sparc的结果是
LLC3:
.asciz "123"
.align 8
.LLC4:
.asciz "456"
#...main: lable
#...Namely the register group "out" is utilized for out-going var
# but they are more offen to be seen as temp var storage
sethi %hi(.LLC3), %o1 #reg out[1], %o1 to retrieve 22 high bits
or %o1, %lo(.LLC3), %o0 #reg out[0], %o0 to retrieve 10 low bits
call try, 0
nop
mov %o0, %l0 #move the result to reg local[0]
sethi %hi(.LLC4), %o1 #store high 22b addr into reg out[1]
or %o1, %lo(.LLC4), %o0 #store whole 32b addr into reg out[0]
call try, 0
nop
mov %o0, %o2 #move the result to reg out[2]
sethi %hi(.LLC2), %o1 #store the high 22b addr into reg out[1]
or %o1, %lo(.LLC2), %o0 #store the whole 32b addr into reg out[0]
mov %l0, %o1 #the 1st res of try() to out[1]
#thus the argument sequence'd be
#the const str in out[0],
#the 1st try() res in out[1],
#the 2nd try() res in out[2],
#如果一定要排序,从%o0到%o2是从左往右的顺序
call printf, 0
同样版本gcc在LinuxOnX86上就是
LC1:
.string "456"
.LC2:
.string "123"
.LC3:
.string "s1=%s s2=%s\n"
!... some lines
!... push op...
movl $.LC1, (%esp) !put argument into %esp
!X86上先算了最右边的参数
call try
movl %eax, %ebx !put the temp result into %ebx
movl $.LC2, (%esp)
call try
movl %ebx, 8(%esp)
movl %eax, 4(%esp) !put in the temp result
movl $.LC3, (%esp)
call printf
后者就是先计算右边的参数,再计算左边的参数. |
|