; Author:
; Date:
; This is the Visual Studio 2012 version
; Preprocessor directives
.586 ; use the 80586 set of instructions
.MODEL FLAT ; use the flat memory model (only 32 bit addresses, no segment:offset)
; External source files
INCLUDE io.h ; header file for input/output
INCLUDE fio.h ; header file for floating point conversions to and from ASCII
; Stack configuration
.STACK 4096 ; allocate 4096 bytes for the stack
; Named memory allocation and initialization
; Use REAL4 for floating point values
.DATA
prompt1 BYTE "Enter circumference: ", 0 ; Basic prompt
string BYTE 40 DUP (?)
BoxLabel1 BYTE "The radius is "
radius BYTE 12 DUP (?), 0
msg1 BYTE "The circle circumference is: ", 0ah
circumf2 BYTE 12 DUP (?), 0ah
msg2 BYTE "The circle area is: ", 0ah
area2 BYTE 12 DUP (?), 0
radiusInput REAL4 1.0
pi REAL4 3.14
two REAL4 2.0
areA REAL4 1.0
circumf REAL4 1.0
; procedure definitions
.CODE
_MainProc PROC
;************ INPUT *************
input prompt1, string, 40 ; read ASCII characters
atof radiusInput, string ; Convert (ASCII TO FLOAT) macro
;********************************
finit
push radiusInput
call findCircumf ; BREAKS HERE!!!!
; call findArea
;done:
;************ OUTPUT ************
ftoa radius, radiusInput
ftoa area2, areA
ftoa circumf2, circumf
output BoxLabel1, msg1
;********************************
;*********** CLEAN-UP ***********
mov EAX, 0 ; exit with return code 0
ret
;********************************
_MainProc ENDP
;##################### findCircumf PROCEDURE ##################
findCircumf PROC
; ******** CIRCUMFERENCE ********
; Formula 2*Pi*R
fld two ; ST(0) has 2.0
fld pi ; ST(0) has 3.14 ST(1) 2.0
fmul st(0), st(1) ; ST(0) has 6.28 2*Pi
fld radiusInput ; ST(0) has radius input (3.5) ST(1) has 6.28
fmul ST(0), ST(1) ; ST(0) has 21.98 2*Pi*R
fst circumf
;********************************
findCircumf ENDP
;###################### findArea PROCEDURE #####################
findArea PROC
;************ AREA **************
; Forumla R*R*Pi
fld radiusInput ; ST(0) has radius input (3.5)
fmul st(0), st(0) ; ST(0) has 12.25 R*R (or R^2)
fld pi ; ST(0) has 3.14 ST(1) has 12.25
fmul st(0), st(1) ; ST(0) has 38.465 R*R*Pi
fstp areA ; areA has 38.465
;********************************
findArea ENDP
END ; end of source code
Breaks at call findCircumf with error list saying
windows32.exe has triggered a breakpoint.
The thread 0x1570 has exited with code 0 (0x0).
The program '[628] windows32.exe' has exited with code 0 (0x0).
I know I did something wrong. I am assuming it has to do with my return. In the procedure the reurn value is in ST(0). I am not sure what I did wrong, I am using floating points.