Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Generating a Dry Run for LMC Fibonacci Code by August Pemberton.
- #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.
- #===========================================This code generates the table.==============================================
- Dim PC As Integer
- Dim ACC As Integer
- Dim X As Integer
- Dim A As Integer
- Dim B As Integer
- Dim COUNT As Integer
- Dim ONE As Integer
- Dim TEN As Integer
- Dim OUTBOX As Integer
- Dim CellCounter As Integer
- Dim Counter As Integer
- Dim numba As Integer
- Dim Counter2 As Integer
- Sub LDA(number)
- ACC = number
- End Sub
- Sub STA(number)
- number = ACC
- End Sub
- Sub output(number)
- OUTBOX = number
- End Sub
- Sub ADD(number)
- ACC = ACC + number
- End Sub
- Sub SUBT(number)
- ACC = ACC - number
- End Sub
- Sub endyet1()
- If ACC >= 0 Then End
- End Sub
- Sub BRA(identify)
- GoTo identify
- End Sub
- Sub RunProgram()
- Call HeaderGen
- A = 0
- X = 0
- B = 1
- ONE = 1
- TEN = 10
- CellCounter = 0
- Counter = 0
- Counter2 = 0
- Do
- Loopy: PC = -1
- ACC = A
- Call GenTable
- X = ACC
- Call GenTable
- OUTBOX = ACC
- Call GenTable
- OUTBOX = 0
- Call GenTable
- ACC = B
- Call GenTable
- A = ACC
- Call GenTable
- ACC = ACC + X
- Call GenTable
- B = ACC
- Call GenTable
- ACC = COUNT
- Call GenTable
- ACC = ACC + ONE
- Call GenTable
- COUNT = ACC
- Call GenTable
- ACC = ACC - 10
- Call GenTable
- If ACC >= 0 Then
- Call GenTable
- Exit Do
- End If
- Call GenTable
- GoTo Loopy
- Loop
- End
- Call GenTable
- End Sub
- Sub GenTable()
- hilitecounter = hilitecounter + 1
- PC = PC + 1
- ActiveCell.FormulaR1C1 = PC
- Call of
- ActiveCell.FormulaR1C1 = ACC
- Call of
- ActiveCell.FormulaR1C1 = ""
- Call of
- ActiveCell.FormulaR1C1 = X
- Call of
- ActiveCell.FormulaR1C1 = A
- Call of
- ActiveCell.FormulaR1C1 = B
- Call of
- ActiveCell.FormulaR1C1 = COUNT
- Call of
- ActiveCell.FormulaR1C1 = ONE
- Call of
- ActiveCell.FormulaR1C1 = TEN
- Call of
- ActiveCell.FormulaR1C1 = OUTBOX
- Call of
- End Sub
- Sub of()
- CellCounter = CellCounter + 1
- If CellCounter = 10 Then
- ActiveCell.Offset(RowOffset:=1, ColumnOffset:=-9).Activate
- CellCounter = 0
- Else
- ActiveCell.Offset(RowOffset:=0, ColumnOffset:=1).Activate
- End If
- End Sub
- Sub HeaderGen()
- ActiveCell.FormulaR1C1 = "PC"
- Call of
- ActiveCell.FormulaR1C1 = "Accumulator"
- Call of
- ActiveCell.FormulaR1C1 = "Operator"
- Call of
- ActiveCell.FormulaR1C1 = "X"
- Call of
- ActiveCell.FormulaR1C1 = "A"
- Call of
- ActiveCell.FormulaR1C1 = "B"
- Call of
- ActiveCell.FormulaR1C1 = "COUNT"
- Call of
- ActiveCell.FormulaR1C1 = "ONE"
- Call of
- ActiveCell.FormulaR1C1 = "TEN"
- Call of
- ActiveCell.FormulaR1C1 = "OUTBOX"
- Call of
- End Sub
- #==============================================This code highlights the table.===============================================
- Dim Counter As Integer
- Dim Counter2 As Integer
- Dim num As Integer
- Dim nam As Integer
- Sub of()
- ActiveCell.Offset(RowOffset:=1, ColumnOffset:=0).Activate
- End Sub
- Sub of2()
- ActiveCell.Offset(RowOffset:=-130, ColumnOffset:=1).Activate
- End Sub
- Sub hilite()
- Counter = 0
- Counter2 = 0
- Do
- Counter = Counter + 1
- num = ActiveCell.Value
- Call of
- If ActiveCell.Value <> num Then
- ActiveCell.Interior.Color = 5
- End If
- If Counter >= 130 Then
- Call of2
- Counter = 0
- Counter2 = Counter2 + 1
- End If
- If Counter2 >= 11 Then
- Exit Do
- End If
- Loop
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement