fork download
  1. ; Title : Fibonacci Series Sum(FibonacciSeriesSum.asm)
  2. ; Program Description : Write an Assembly program that input the Number of terms and
  3. ; Display Fibonacci Series. It also Display the Sum of Fibonacci Series.
  4. ; Author : robustprogramming.com
  5. ; Architecture : Intel x86
  6. ; Library : Irvine32
  7. ; Assembler : Microsoft Macro Assembler (MASM 32-bit) version (12.0)
  8. ; Interface : Console
  9. ; IDE : Microsoft Visual Studio Ultimate 2013
  10. ; Operating System : Windows 8.1
  11.  
  12. INCLUDE Irvine32.inc
  13.  
  14. .DATA
  15. ; insert variables here
  16. dPrevious DWORD 0
  17. dCurrent DWORD 1
  18. dNext DWORD 1
  19. dNumberOfTerms DWORD 0
  20. dSum DWORD 0
  21. msg1 BYTE "Enter Number of Fibonacci Series Terms : ",0 ; A null-terminated string
  22. msg2 BYTE "Fibonacci Series is ",0
  23. msg3 BYTE "Sum of Fibonacci Series = ",0
  24. msg4 BYTE "Error: Fibonacci Series Contain at least 2 number of terms",0
  25. msgFibonacciSeries BYTE "Display Fibonacci Series and Sum of Fibonacci Series in Assembly Language ",0
  26.  
  27.  
  28. .CODE
  29. ; insert all executable statements here
  30. main PROC
  31. mov edx, OFFSET msgFibonacciSeries ; "Display Fibonacci Series and Sum of Fibonacci Series in Assembly Language "
  32. call WriteString ; Display a null-terminated string.
  33. call Crlf ; Writes an end-of-line sequence to the console window.
  34.  
  35. mov edx, OFFSET msg1 ; "Enter Number of Fibonacci Series Terms : "
  36. call WriteString ; Display a null-terminated string.
  37. call ReadInt ; Input a 32-bit signed decimal integer
  38. ; from the keyboard and save in EAX.
  39. mov dNumberOfTerms, eax
  40.  
  41. mov ebx,dNumberOfTerms
  42. cmp ebx,1 ; compare EBX and 1
  43. jle Error ; jump if Less than or equal (<=)
  44.  
  45. mov edx, OFFSET msg2 ; "Fibonacci Series is "
  46. call WriteString
  47. call Crlf ; Writes an end-of-line sequence to the console window.
  48.  
  49. mov eax,dPrevious
  50. call WriteDec ; Display an unsigned 32-bit integer value
  51. ; in EAX in decimal format.
  52. add dSum,eax
  53. call Crlf
  54.  
  55.  
  56. mov eax,dCurrent
  57. call WriteDec
  58. add dSum,eax
  59. call Crlf
  60.  
  61. mov ecx,dNumberOfTerms ; ECX initialize with Number Of Terms
  62. sub ecx,2 ; Exclude First Two Terms
  63.  
  64. cmp ecx,0 ; compare EBX and 0
  65. je showSum ; jump if equal (=)
  66.  
  67. doPart1:
  68. mov ebx,dPrevious
  69. add ebx,dCurrent
  70. mov dNext,ebx
  71. mov eax,DNext
  72. call WriteDec
  73. call Crlf
  74.  
  75. add dSum,eax
  76. mov eax,dCurrent
  77. mov dPrevious,eax
  78. mov eax,dNext
  79. mov dCurrent,eax
  80. loop doPart1 ; if ECX == 0 Then loop stop
  81. showSum:
  82. mov edx, offset msg3
  83. call WriteString
  84. mov eax,dSum
  85. call WriteDec
  86. call Crlf
  87. jmp next
  88. Error:
  89. mov edx, OFFSET msg4 ; "Error: Fibonacci Series Contain at least 2 number of terms"
  90. call WriteString
  91. call Crlf
  92. next:
  93. call WaitMsg ; Displays a message and waits for a key to be pressed.
  94. exit ; The exit statement (indirectly) calls a predefined
  95. ; MS-Windows function that halts the program.
  96. main ENDP ; The ENDP directive marks the end of the main procedure.
  97. END main ; The END directive marks the last line of the program to be assembled.
  98.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.asm:12: error: parser: instruction expected
prog.asm:16: error: parser: instruction expected
prog.asm:17: error: parser: instruction expected
prog.asm:18: error: parser: instruction expected
prog.asm:19: error: parser: instruction expected
prog.asm:20: error: parser: instruction expected
prog.asm:21: error: parser: instruction expected
prog.asm:22: error: parser: instruction expected
prog.asm:23: error: parser: instruction expected
prog.asm:24: error: parser: instruction expected
prog.asm:25: error: parser: instruction expected
prog.asm:30: error: parser: instruction expected
prog.asm:31: error: comma, colon, decorator or end of line expected after operand
prog.asm:35: error: comma, colon, decorator or end of line expected after operand
prog.asm:45: error: comma, colon, decorator or end of line expected after operand
prog.asm:82: error: comma, colon, decorator or end of line expected after operand
prog.asm:89: error: comma, colon, decorator or end of line expected after operand
prog.asm:96: error: symbol `main' redefined
prog.asm:96: error: parser: instruction expected
prog.asm:97: error: parser: instruction expected
ld: cannot find prog.o: No such file or directory
stdout
Standard output is empty