Im trying to create a small program where it asks for a number (radius) and then calculates the area of a circle. BUT when I square the input and multiply it by pi, i get a whole number. I need it in decimal. Could someone explain? Thanks.

TITLE Area of Circle					(main.asm)

; Find Area of Circle: Area = pi * r2
; 
; Revision date:

INCLUDE Irvine32.inc
.data
myMessage BYTE "Enter radius: ",0dh,0ah,0
pi DWORD 3.14

.code
main PROC
	
	mov edx, OFFSET myMessage ; ask user for input
	call WriteString
	
	call Readdec
	
	
	imul eax, eax	
	imul eax, pi	
	call Writedec
	call Crlf
	
	exit
main ENDP

END main

You can only use the conventional registers for whole numbers.
If you need to program with floating points, you will need to work with the FPU-engine, which has seperate registers and instructions (many info is available online, look for 80x87 FPU).

The solution is then:

...
pi real4 3.14159265
temp real4 ?

...

mov temp,eax
fild temp
fmul st0, st0
fmul st0, pi
fstp temp
mov eax,temp
call Writedec
call Crlf
...
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.