-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathCount_Instruction_Cycles.xml
More file actions
224 lines (180 loc) · 3.39 KB
/
Count_Instruction_Cycles.xml
File metadata and controls
224 lines (180 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="Count_Instruction_Cycles"
author="Nick Gammon"
id="03ac189809b6acc00ee4a1f4"
language="Lua"
purpose="Works out instruction cycles for AVR object"
date_written="2012-10-31"
requires="4.40"
version="1.0"
sequence="90"
>
<description trim="y">
<![CDATA[
1. Copy some AVR object dump to the Clipboard
2. Type: count_cycles
3. Converted data will be echoed to output.
]]>
</description>
</plugin>
<!-- Aliases -->
<aliases>
<alias
script="count_cycles"
match="count_cycles"
enabled="y"
sequence="100"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
require "getlines"
function count_cycles (name, line, wildcards)
-- get clipboard
local clip = GetClipboard ()
-- starting line of hyphens
print (string.rep ("-", 60))
re = rex.new ("^\\s*[0-9a-f]+:\\s+([0-9a-f]{2}\\s)+\\s*(?P<inst>[a-z]+)")
for line in getlines (clip) do
Tell (line)
local s, e, t = re:match (line)
if s then
lookupCycles (t.inst:upper ())
end -- if
print ""
end -- for loop
print ("") -- new line
print (string.rep ("-", 60))
end -- function count_cycles
cycles = {
-- ARITHMETIC AND LOGIC INSTRUCTIONS
ADC = "1",
ADD = "1",
ADIW = "2",
AND = "1",
ANDI = "1",
CBR = "1",
CLR = "1",
COM = "1",
DEC = "1",
EOR = "1",
FMUL = "2",
FMULS = "2",
FMULSU = "2",
INC = "1",
MUL = "2",
MULS = "2",
MULSU = "2",
NEG = "1",
OR = "1",
ORI = "1",
SBC = "1",
SBCI = "1",
SBIW = "2",
SBR = "1",
SER = "1",
SUB = "1",
SUBI = "1",
TST = "1",
-- BRANCH INSTRUCTIONS
BRBC = "1/2",
BRBS = "1/2",
BRCC = "1/2",
BRCS = "1/2",
BREQ = "1/2",
BRGE = "1/2",
BRHC = "1/2",
BRHS = "1/2",
BRID = "1/2",
BRIE = "1/2",
BRLO = "1/2",
BRLT = "1/2",
BRMI = "1/2",
BRNE = "1/2",
BRPL = "1/2",
BRSH = "1/2",
BRTC = "1/2",
BRTS = "1/2",
BRVC = "1/2",
BRVS = "1/2",
CALL = "4",
CP = "1",
CPC = "1",
CPI = "1",
CPSE = "1/2/3",
ICALL = "3",
IJMP = "2",
JMP = "3",
RCALL = "3",
RET = "4",
RETI = "4",
RJMP = "2",
SBIC = "1/2/3",
SBIS = "1/2/3",
SBRC = "1/2/3",
SBRS = "1/2/3",
-- BIT AND BIT-TEST INSTRUCTIONS
ASR = "1",
BCLR = "1",
BLD = "1",
BSET = "1",
BST = "1",
CBI = "2",
CLC = "1",
CLH = "1",
CLI = "1",
CLN = "1",
CLS = "1",
CLT = "1",
CLV = "1",
CLZ = "1",
LSL = "1",
LSR = "1",
ROL = "1",
ROR = "1",
SBI = "2",
SEC = "1",
SEH = "1",
SEI = "1",
SEN = "1",
SES = "1",
SET = "1",
SEV = "1",
SEZ = "1",
SWAP = "1",
-- DATA TRANSFER INSTRUCTIONS
IN = "1",
LD = "2",
LDD = "2",
LDI = "1",
LDS = "2",
LPM = "3",
MOV = "1",
MOVW = "1",
OUT = "1",
POP = "2",
PUSH = "2",
ST = "2",
STD = "2",
STS = "2",
-- MCU CONTROL INSTRUCTIONS
NOP = "1",
SLEEP = "1",
WDR = "1",
} -- end of cycles table
function lookupCycles (instruction)
local count = cycles [instruction]
if count then
Tell (" (", count, ")")
else
Tell (" <unknown>")
end -- if
end -- lookupCycles
]]>
</script>
</muclient>