# An example of using global variables in functions. (函数使用全局变量传递数据)
#
# 计算给定半径的圆的面积
#
.section .data
precision:
.byte 0x7f, 0x00
.section .bss
.lcomm radius, 4
.lcomm result, 4
.lcomm trash, 4
.section .text
.globl main
main:
nop
finit
fldcw precision
movl $10, radius
call area
movl $2, radius
call area
movl $120, radius
call area
movl $1, %eax
movl $0, %ebx
.type area, @function
area:
fldpi
filds radius
fmul %st(0), %st(0)
fmulp %st(0), %st(1)
fstps result
ret
# gcc -g -o 02 02-global-variables.s -m32
#
# 第一次调用area后:
# (gdb) x/d &radius
# 0x56559010
# (gdb) x/f &result
# 0x56559014
#