Advertisement
Il_Voza

3.1 Fibonacci series

May 12th, 2013
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Write a program that writes into a vector of 20 DW elements, the first numbers of Fibonacci series
  2. ;Fibonacci series: –vet[i] = vet[i-1] + vet[i-2] => vet = 1, 1, 2, 3, 5, 8, …
  3.  
  4. DIM EQU 20
  5. .MODEL small
  6. .STACK
  7. .DATA
  8. vett DW DIM DUP ?
  9. temp DW ?
  10. .CODE
  11. .START
  12. MOV CX,0
  13. MOV DI,0
  14. MOV AX,0
  15. MOV BX,1
  16. MOV vett[DI],1
  17. ADD DI,2
  18. ciclo:
  19.        ADD AX,BX
  20.        MOV vett[DI],AX
  21.        MOV AX,BX
  22.        MOV BX,vett[DI]
  23.        ADD DI,2
  24.        INC CX
  25.        CMP CX,DIM
  26.        JNE ciclo
  27. ;Program is right, but I don't print because when I print numbers with more digits,
  28. ;so numbers after 9, it considers other
  29. ;characters of ASCII code, since I write MOV DL,'0',
  30. ;and into ASCII code the numbers arriving up to 9.
  31.        
  32. .EXIT
  33. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement