Advertisement
Guest User

Dry Run generator for LMC Fibonacci

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