Advertisement
Guest User

Untitled

a guest
May 5th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. ; Author:
  2. ; Date:
  3. ; This is the Visual Studio 2012 version
  4.  
  5. ; Preprocessor directives
  6. .586 ; use the 80586 set of instructions
  7. .MODEL FLAT ; use the flat memory model (only 32 bit addresses, no segment:offset)
  8.  
  9. ; External source files
  10. INCLUDE io.h ; header file for input/output
  11. INCLUDE fio.h ; header file for floating point conversions to and from ASCII
  12.  
  13. ; Stack configuration
  14. .STACK 4096 ; allocate 4096 bytes for the stack
  15.  
  16. ; Named memory allocation and initialization
  17. ; Use REAL4 for floating point values
  18. .DATA
  19. prompt1 BYTE "Enter circumference: ", 0 ; Basic prompt
  20. string BYTE 40 DUP (?)
  21. BoxLabel1 BYTE "The radius is "
  22. radius BYTE 12 DUP (?), 0
  23.  
  24. msg1 BYTE "The circle circumference is: ", 0ah
  25. circumf2 BYTE 12 DUP (?), 0ah
  26. msg2 BYTE "The circle area is: ", 0ah
  27. area2 BYTE 12 DUP (?), 0
  28.  
  29. radiusInput REAL4 1.0
  30. pi REAL4 3.14
  31. two REAL4 2.0
  32. areA REAL4 1.0
  33. circumf REAL4 1.0
  34.  
  35. ; procedure definitions
  36. .CODE
  37. _MainProc PROC
  38. ;************ INPUT *************
  39. input prompt1, string, 40 ; read ASCII characters
  40. atof radiusInput, string ; Convert (ASCII TO FLOAT) macro
  41. ;********************************
  42. finit
  43. push radiusInput
  44. call findCircumf ; BREAKS HERE!!!!
  45.  
  46.  
  47. ; call findArea
  48.  
  49. ;done:
  50.  
  51. ;************ OUTPUT ************
  52. ftoa radius, radiusInput
  53. ftoa area2, areA
  54. ftoa circumf2, circumf
  55. output BoxLabel1, msg1
  56. ;********************************
  57.  
  58. ;*********** CLEAN-UP ***********
  59. mov EAX, 0 ; exit with return code 0
  60. ret
  61. ;********************************
  62. _MainProc ENDP
  63.  
  64. ;##################### findCircumf PROCEDURE ##################
  65. findCircumf PROC
  66. ; ******** CIRCUMFERENCE ********
  67. ; Formula 2*Pi*R
  68. fld two ; ST(0) has 2.0
  69. fld pi ; ST(0) has 3.14 ST(1) 2.0
  70. fmul st(0), st(1) ; ST(0) has 6.28 2*Pi
  71. fld radiusInput ; ST(0) has radius input (3.5) ST(1) has 6.28
  72. fmul ST(0), ST(1) ; ST(0) has 21.98 2*Pi*R
  73. fst circumf
  74. ;********************************
  75. findCircumf ENDP
  76.  
  77. ;###################### findArea PROCEDURE #####################
  78. findArea PROC
  79. ;************ AREA **************
  80. ; Forumla R*R*Pi
  81. fld radiusInput ; ST(0) has radius input (3.5)
  82. fmul st(0), st(0) ; ST(0) has 12.25 R*R (or R^2)
  83. fld pi ; ST(0) has 3.14 ST(1) has 12.25
  84. fmul st(0), st(1) ; ST(0) has 38.465 R*R*Pi
  85. fstp areA ; areA has 38.465
  86. ;********************************
  87. findArea ENDP
  88. END ; end of source code
  89.  
  90. windows32.exe has triggered a breakpoint.
  91. The thread 0x1570 has exited with code 0 (0x0).
  92. The program '[628] windows32.exe' has exited with code 0 (0x0).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement