Advertisement
Guest User

Dry Run generator LMC Fibonacci

a guest
Apr 27th, 2015
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Generating a Dry Run for LMC Fibonacci Code by August Pemberton.
  2. #First of all, open up Excel, and if you haven't already, go to File > Options > Customize Ribbon > Select Developer tab. Then, #go to the developer tab and click view code. On the left you should see a hierarchy tree. Right-Click on 'VBAProject(Book1)' - #replace Book1 with the excel book name - and select Insert > Module. Then, double-click on the newly-created Module1 in the #hierarchy tree. In this window, copy & paste the first section of code - the code that generates the table. Next, go to the #hierarchy tree and double-click Sheet1. In this window, paste the second section of code (the highlighting code). Now, go back #to the excel table, and select box A1. Then go to the developer tab. Click 'Macros'. Then, double-click RunProgram. Now, select #box A2. Go back to macros, and double-click Sheet1.hilite. This should highlight everything! You may need to fiddle around with #the text colours / background colours to be able to see everything.
  3.  
  4. #===========================================This code generates the table.==============================================
  5.  
  6. Dim PC As Integer
  7. Dim ACC As Integer
  8. Dim X As Integer
  9. Dim A As Integer
  10. Dim B As Integer
  11. Dim COUNT As Integer
  12. Dim ONE As Integer
  13. Dim TEN As Integer
  14. Dim OUTBOX As Integer
  15. Dim CellCounter As Integer
  16. Dim Counter As Integer
  17. Dim numba As Integer
  18. Dim Counter2 As Integer
  19. Sub LDA(number)
  20. ACC = number
  21. End Sub
  22. Sub STA(number)
  23. number = ACC
  24. End Sub
  25. Sub output(number)
  26. OUTBOX = number
  27. End Sub
  28. Sub ADD(number)
  29. ACC = ACC + number
  30. End Sub
  31. Sub SUBT(number)
  32. ACC = ACC - number
  33. End Sub
  34. Sub endyet1()
  35. If ACC >= 0 Then End
  36. End Sub
  37. Sub BRA(identify)
  38. GoTo identify
  39. End Sub
  40. Sub RunProgram()
  41. Call HeaderGen
  42. A = 0
  43. X = 0
  44. B = 1
  45. ONE = 1
  46. TEN = 10
  47. CellCounter = 0
  48. Counter = 0
  49. Counter2 = 0
  50. Do
  51. Loopy:  PC = -1
  52.         ACC = A
  53.       Call GenTable
  54.       X = ACC
  55.       Call GenTable
  56.       OUTBOX = ACC
  57.       Call GenTable
  58.       OUTBOX = 0
  59.       Call GenTable
  60.       ACC = B
  61.       Call GenTable
  62.       A = ACC
  63.       Call GenTable
  64.       ACC = ACC + X
  65.       Call GenTable
  66.       B = ACC
  67.       Call GenTable
  68.       ACC = COUNT
  69.       Call GenTable
  70.       ACC = ACC + ONE
  71.       Call GenTable
  72.       COUNT = ACC
  73.       Call GenTable
  74.       ACC = ACC - 10
  75.       Call GenTable
  76.       If ACC >= 0 Then
  77.         Call GenTable
  78.         Exit Do
  79.       End If
  80.       Call GenTable
  81.       GoTo Loopy
  82.       Loop
  83.       End
  84.       Call GenTable
  85. End Sub
  86. Sub GenTable()
  87. hilitecounter = hilitecounter + 1
  88.  
  89.  
  90.  
  91. PC = PC + 1
  92. ActiveCell.FormulaR1C1 = PC
  93. Call of
  94.  
  95.  
  96.  
  97. ActiveCell.FormulaR1C1 = ACC
  98. Call of
  99.  
  100.  
  101.  
  102. ActiveCell.FormulaR1C1 = ""
  103. Call of
  104.  
  105.  
  106.  
  107. ActiveCell.FormulaR1C1 = X
  108. Call of
  109.  
  110.  
  111.  
  112. ActiveCell.FormulaR1C1 = A
  113. Call of
  114.  
  115.  
  116.  
  117. ActiveCell.FormulaR1C1 = B
  118. Call of
  119.  
  120.  
  121.  
  122. ActiveCell.FormulaR1C1 = COUNT
  123. Call of
  124.  
  125.  
  126.  
  127. ActiveCell.FormulaR1C1 = ONE
  128. Call of
  129.  
  130.  
  131.  
  132. ActiveCell.FormulaR1C1 = TEN
  133. Call of
  134.  
  135.  
  136.  
  137. ActiveCell.FormulaR1C1 = OUTBOX
  138. Call of
  139.  
  140.  
  141.  
  142. End Sub
  143. Sub of()
  144. CellCounter = CellCounter + 1
  145.     If CellCounter = 10 Then
  146.     ActiveCell.Offset(RowOffset:=1, ColumnOffset:=-9).Activate
  147.     CellCounter = 0
  148.     Else
  149.     ActiveCell.Offset(RowOffset:=0, ColumnOffset:=1).Activate
  150.     End If
  151. End Sub
  152. Sub HeaderGen()
  153. ActiveCell.FormulaR1C1 = "PC"
  154. Call of
  155. ActiveCell.FormulaR1C1 = "Accumulator"
  156. Call of
  157. ActiveCell.FormulaR1C1 = "Operator"
  158. Call of
  159. ActiveCell.FormulaR1C1 = "X"
  160. Call of
  161. ActiveCell.FormulaR1C1 = "A"
  162. Call of
  163. ActiveCell.FormulaR1C1 = "B"
  164. Call of
  165. ActiveCell.FormulaR1C1 = "COUNT"
  166. Call of
  167. ActiveCell.FormulaR1C1 = "ONE"
  168. Call of
  169. ActiveCell.FormulaR1C1 = "TEN"
  170. Call of
  171. ActiveCell.FormulaR1C1 = "OUTBOX"
  172. Call of
  173. End Sub
  174.  
  175.  
  176. #==============================================This code highlights the table.===============================================
  177.  
  178. Dim Counter As Integer
  179. Dim Counter2 As Integer
  180. Dim num As Integer
  181. Dim nam As Integer
  182. Sub of()
  183.     ActiveCell.Offset(RowOffset:=1, ColumnOffset:=0).Activate
  184. End Sub
  185. Sub of2()
  186.     ActiveCell.Offset(RowOffset:=-130, ColumnOffset:=1).Activate
  187. End Sub
  188. Sub hilite()
  189. Counter = 0
  190. Counter2 = 0
  191. Do
  192. Counter = Counter + 1
  193. num = ActiveCell.Value
  194. Call of
  195.  
  196. If ActiveCell.Value <> num Then
  197. ActiveCell.Interior.Color = 5
  198. End If
  199.  
  200. If Counter >= 130 Then
  201. Call of2
  202. Counter = 0
  203. Counter2 = Counter2 + 1
  204. End If
  205.  
  206. If Counter2 >= 11 Then
  207. Exit Do
  208. End If
  209.  
  210. Loop
  211. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement