j0rd 0 Newbie Poster

Hi i am running linux and intel x86 cpu. I have been learning at&t asm using gcc and gdb and am trying to print the values of the fpu stack with no success. My code is:

.section	.data				#; Uninitialized data section
	output:					#; Mem lable										
		.asciz "The value is %d\n"	#; Null terminated ascii string
	value1:					#; Mem lable										
		.float 00.00			#; Single precision floating point value
	value2:					#; Mem lable										
		.float 01.00			#; Single precision floating point value
	value3:					#; Mem lable										
		.float 02.00			#; Single precision floating point value
	value4:					#; Mem lable										
		.float 03.00			#; Single precision floating point value
	value5:					#; Mem lable										
		.float 04.00			#; Single precision floating point value
	value6:					#; Mem lable										
		.float 05.00			#; Single precision floating point value
	value7:					#; Mem lable										
		.float 06.00			#; Single precision floating point value
.section	.bss				#; Uninitialized data section
	.lcomm data, 4				#; Reserve 4 bytes in memory						
.section	.text				#; Code execute section
.globl	main					#; Make 'main' global
	main:					#; Start execute here								
		nop				#; No operation
		movl	$7, %ecx		#; Load 7 into ecx
		flds	value1			#; Load 'value1' into fpu stack
		flds	value2			#; Load 'value2' into fpu stack
		flds	value3			#; Load 'value3' into fpu stack
		flds	value4			#; Load 'value4' into fpu stack
		flds	value5			#; Load 'value5' into fpu stack
		flds	value6			#; Load 'value6' into fpu stack
		flds	value7			#; Load 'value7' into fpu stack
	loop1:					#; Code lable non globl								
		movl	%ecx, %esi		#; Load ecx into esi
		fsts	data			#; Pop from fpu reg into data						
		push	$data			#; Push mem location for 'data' onto stack			
		push	$output			#; Push 'value1' onto stack							
		call	printf			#; Call C function PRINTF							
		add	$8, %esp		#; Load 8 into esp, quick & dirty stack clear
		movl	%esi, %ecx		#; Load edx into ecx
		jcxz	done			#; Jump to done if ecx is 0
		loop	loop1			#; Decrement ecx and jump to 'loop1' if ecx 0
	done:					#; Code lable										
		call	exit			#; Call C function EXIT

the output i get is:

user@box:~/Documents/assembler$ ./myapp5
The value is 134520912
The value is 134520912
The value is 134520912
The value is 134520912
The value is 134520912
The value is 134520912
The value is 134520912

I did as much debugging as i could in gdb and i think the problem is to do with fsts data If anyone has any advice or tips I would appriciate it loads.
thanks J0rd_

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.