lignite 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -101,7 +101,7 @@ module Lignite
101
101
 
102
102
  # @return [ByteString]
103
103
  def param_multiple(*args)
104
- args.map { |a| param_simple(a) }.join("")
104
+ u8(args.size) + args.map { |a| param_simple(a) }.join("")
105
105
  end
106
106
 
107
107
  # @return [ByteString]
@@ -0,0 +1,108 @@
1
+ module Lignite
2
+ # Methods for user programs that declare subroutine parameters.
3
+ module ParameterDeclarer
4
+ IN = 0x80
5
+ OUT = 0x40
6
+ PAR8 = 0
7
+ PAR16 = 1
8
+ PAR32 = 2
9
+ PARF = 3
10
+ PARS = 4
11
+
12
+ # @!method parameters
13
+ # @return [Variables]
14
+
15
+ # Declare an 8-bit input parameter
16
+ # @param name [Symbol] parameter name
17
+ def in8(name)
18
+ parameters.param(name, 1, PAR8, IN)
19
+ end
20
+
21
+ # Declare an 8-bit output parameter
22
+ # @param name [Symbol] parameter name
23
+ def out8(name)
24
+ parameters.param(name, 1, PAR8, OUT)
25
+ end
26
+
27
+ # Declare an 8-bit input+output parameter
28
+ # @param name [Symbol] parameter name
29
+ def io8(name)
30
+ parameters.param(name, 1, PAR8, IN | OUT)
31
+ end
32
+
33
+ # Declare a 16-bit input parameter
34
+ # @param name [Symbol] parameter name
35
+ def in16(name)
36
+ parameters.param(name, 2, PAR16, IN)
37
+ end
38
+
39
+ # Declare a 16-bit output parameter
40
+ # @param name [Symbol] parameter name
41
+ def out16(name)
42
+ parameters.param(name, 2, PAR16, OUT)
43
+ end
44
+
45
+ # Declare a 16-bit input+output parameter
46
+ # @param name [Symbol] parameter name
47
+ def io16(name)
48
+ parameters.param(name, 2, PAR16, IN | OUT)
49
+ end
50
+
51
+ # Declare a 32-bit input parameter
52
+ # @param name [Symbol] parameter name
53
+ def in32(name)
54
+ parameters.param(name, 4, PAR32, IN)
55
+ end
56
+
57
+ # Declare a 32-bit output parameter
58
+ # @param name [Symbol] parameter name
59
+ def out32(name)
60
+ parameters.param(name, 4, PAR32, OUT)
61
+ end
62
+
63
+ # Declare a 32-bit input+output parameter
64
+ # @param name [Symbol] parameter name
65
+ def io32(name)
66
+ parameters.param(name, 4, PAR32, IN | OUT)
67
+ end
68
+
69
+ # Declare a floating-point input parameter
70
+ # @param name [Symbol] parameter name
71
+ def inf(name)
72
+ parameters.param(name, 4, PARF, IN)
73
+ end
74
+
75
+ # Declare a floating-point output parameter
76
+ # @param name [Symbol] parameter name
77
+ def outf(name)
78
+ parameters.param(name, 4, PARF, OUT)
79
+ end
80
+
81
+ # Declare a floating-point input+output parameter
82
+ # @param name [Symbol] parameter name
83
+ def iof(name)
84
+ parameters.param(name, 4, PARF, IN | OUT)
85
+ end
86
+
87
+ # Declare a string input parameter
88
+ # @param name [Symbol] parameter name
89
+ # @param size [Integer] maximum string size, including the terminating 0
90
+ def ins(name, size)
91
+ parameters.param(name, size, PARS, IN)
92
+ end
93
+
94
+ # Declare a string output parameter
95
+ # @param name [Symbol] parameter name
96
+ # @param size [Integer] maximum string size, including the terminating 0
97
+ def outs(name, size)
98
+ parameters.param(name, size, PARS, OUT)
99
+ end
100
+
101
+ # Declare a string input+output parameter
102
+ # @param name [Symbol] parameter name
103
+ # @param size [Integer] maximum string size, including the terminating 0
104
+ def ios(name, size)
105
+ parameters.param(name, size, PARS, IN | OUT)
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,52 @@
1
+ require "lignite/parameter_declarer"
2
+ require "lignite/variables"
3
+
4
+ module Lignite
5
+ # Implements pass 1, just gathers names
6
+ class RbfDeclarer
7
+ # A dummy {RbfDeclarer} to better report
8
+ # that subroutine calls are not allowed in direct commands
9
+ class Dummy
10
+ def index_of(name)
11
+ raise "Cannot look up #{name.inspect}, subs are not allowed here"
12
+ end
13
+ end
14
+
15
+ def initialize
16
+ # @return [Hash{Symbol => Integer}]
17
+ @object_names = {}
18
+ @counter = 0
19
+ @dummy_globals = Variables.new
20
+ end
21
+
22
+ def index_of(name)
23
+ @object_names[name]
24
+ end
25
+
26
+ def variables
27
+ @dummy_globals
28
+ end
29
+ include VariableDeclarer
30
+
31
+ def vmthread(name, &_body)
32
+ add(name)
33
+ end
34
+
35
+ def sub(name, &_body)
36
+ add(name)
37
+ end
38
+
39
+ private
40
+
41
+ # stupid typeless implementation
42
+ def add(name)
43
+ seen = @object_names[name]
44
+ unless seen.nil?
45
+ raise "Name #{name.inspect} already declared with index #{seen}"
46
+ end
47
+
48
+ @counter += 1
49
+ @object_names[name] = @counter
50
+ end
51
+ end
52
+ end
@@ -27,8 +27,13 @@ module Lignite
27
27
  @body = body
28
28
  end
29
29
 
30
- def header(pos_before_header = 0)
31
- u32(pos_before_header + 12) + # size of header
30
+ HEADER_SIZE = 12
31
+ def size
32
+ HEADER_SIZE + body.bytesize
33
+ end
34
+
35
+ def header(object_instruction_offset)
36
+ u32(object_instruction_offset) +
32
37
  u16(@owner) + u16(@triggers) + u32(@local_bytes)
33
38
  end
34
39
  end
@@ -4,11 +4,15 @@ module Lignite
4
4
  # bad: data8 :speed; data32 :tacho; output_read(...)
5
5
  # good data32 :tacho; data8 :speed; output_read(...)
6
6
  class Variables
7
+ include Bytes
8
+
7
9
  def initialize
8
10
  @offset = 0
9
11
  # for proper decoding of direct replies according to declared types
10
12
  @unpacker = ""
11
13
  @vars = {}
14
+ @param_count = 0
15
+ @param_decl_bytes = ""
12
16
  end
13
17
 
14
18
  # declare
@@ -19,6 +23,16 @@ module Lignite
19
23
  @unpacker += unpacker
20
24
  end
21
25
 
26
+ # declare a subroutine parameter
27
+ def param(name, size, size_code, direction)
28
+ raise "Duplicate parameter #{name}" if @vars.key?(name)
29
+ nonsense_unpacker = "," # FIXME: better
30
+ add(name, size, nonsense_unpacker)
31
+
32
+ @param_count += 1
33
+ @param_decl_bytes += u8(size_code | direction)
34
+ end
35
+
22
36
  # use
23
37
  def key?(sym)
24
38
  @vars.key?(sym)
@@ -34,6 +48,10 @@ module Lignite
34
48
  @offset
35
49
  end
36
50
 
51
+ def param_decl_header
52
+ u8(@param_count) + @param_decl_bytes
53
+ end
54
+
37
55
  # decode reply
38
56
  def unpack(buf)
39
57
  values = buf.unpack(@unpacker)
@@ -63,6 +63,8 @@ TXT
63
63
  "lib/lignite/message.rb",
64
64
  "lib/lignite/motors.rb",
65
65
  "lib/lignite/op_compiler.rb",
66
+ "lib/lignite/parameter_declarer.rb",
67
+ "lib/lignite/rbf_declarer.rb",
66
68
  "lib/lignite/rbf_object.rb",
67
69
  "lib/lignite/system_commands.rb",
68
70
  "lib/lignite/variables.rb",
@@ -82,6 +84,9 @@ TXT
82
84
  "spec/data/NoDebug.lms",
83
85
  "spec/data/NoDebug.rb",
84
86
  "spec/data/NoDebug.rbf",
87
+ "spec/data/Performance.lms",
88
+ "spec/data/Performance.rb",
89
+ "spec/data/Performance.rbf",
85
90
  "spec/data/VernierReadout.lms",
86
91
  "spec/data/VernierReadout.rb",
87
92
  "spec/data/VernierReadout.rbf",
@@ -91,6 +96,9 @@ TXT
91
96
  "spec/data/ev3tool_stop.yml",
92
97
  "spec/data/ev3tool_upload.yml",
93
98
  "spec/data/everstorm.rbf",
99
+ "spec/data/p11.c",
100
+ "spec/data/p11.rb",
101
+ "spec/data/p11.rbf",
94
102
  "spec/direct_commands_spec.rb",
95
103
  "spec/ev3_tool_spec.rb",
96
104
  "spec/spec_helper.rb",
@@ -4,21 +4,24 @@ require "lignite"
4
4
  require "fileutils"
5
5
 
6
6
  describe Lignite::Assembler do
7
- shared_examples "compiles" do |base, asm_version|
7
+ shared_examples "compiles" do |base, asm_version = 109|
8
8
  let(:in_rb) { "#{datadir}/#{base}.rb" }
9
9
  let(:actual_rbf) { "#{datadir}/#{base}.out.rbf" }
10
10
  let(:expected_rbf) { "#{datadir}/#{base}.rbf" }
11
11
 
12
12
  it "correctly assembles #{base}" do
13
13
  subject.assemble(in_rb, actual_rbf, version: asm_version)
14
- expect(FileUtils.compare_file(expected_rbf, actual_rbf)).to be_truthy
14
+
15
+ expect_rbf_files_same(actual_rbf, expected_rbf)
15
16
  FileUtils.rm actual_rbf
16
17
  end
17
18
  end
18
19
 
19
- it_behaves_like "compiles", "HelloWorld", 109
20
- it_behaves_like "compiles", "HelloWorld-subop", 109
21
- it_behaves_like "compiles", "VernierReadout", 109
20
+ it_behaves_like "compiles", "HelloWorld"
21
+ it_behaves_like "compiles", "HelloWorld-subop"
22
+ it_behaves_like "compiles", "VernierReadout"
22
23
  it_behaves_like "compiles", "ColorReadout", 106
23
- it_behaves_like "compiles", "NoDebug", 109
24
+ it_behaves_like "compiles", "NoDebug"
25
+ it_behaves_like "compiles", "p11"
26
+ it_behaves_like "compiles", "Performance"
24
27
  end
@@ -34,7 +34,7 @@ vmthread :MAIN do
34
34
  strings(NUMBER_FORMATTED, :Data1, "%1d", 8, :String)
35
35
  ui_draw(TEXT, FG_COLOR, 64, 30, :String)
36
36
 
37
- input_device(READY_RAW, 0, PORT, 0, :Mode, 3, :Data1, :Data2, :Data3)
37
+ input_device(READY_RAW, 0, PORT, 0, :Mode, :Data1, :Data2, :Data3)
38
38
 
39
39
  and32(:Data1, 0xFFFF, :Data1)
40
40
  strings(NUMBER_FORMATTED, :Data1, "%-5d", 8, :String)
@@ -0,0 +1,735 @@
1
+ /*
2
+ * LEGO® MINDSTORMS EV3
3
+ *
4
+ * Copyright (C) 2010-2013 The LEGO Group
5
+ *
6
+ * This program is free software; you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation; either version 2 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
+ */
20
+
21
+
22
+ // TCP 08.04.2013
23
+ //! \page testperformanceappcode Performance Application
24
+ //!
25
+ //! <hr size="1"/>
26
+ //!
27
+ //! \verbatim
28
+ //**********************************************************************
29
+ define appv 'Performance V1.02' //
30
+ //**********************************************************************
31
+ //
32
+ define TIMES 100000
33
+ define MS 1
34
+
35
+ DATA32 Ref
36
+
37
+ DATA32 Counter
38
+ DATA32 Start
39
+ DATA32 Stop
40
+ DATA32 Time
41
+ DATAF DataF
42
+ DATA32 Data32
43
+ DATA32 Data32_1
44
+ DATA32 Data32_2
45
+ DATA32 Data32_3
46
+ DATA32 Data32_4
47
+ DATA16 hData8
48
+ DATA8 Data8
49
+ ARRAY8 DataS 10
50
+ ARRAY8 Text 36
51
+
52
+
53
+ vmthread MAIN
54
+ {
55
+ DATA8 ShowVersion //
56
+ //
57
+ UI_BUTTON(PRESSED,RIGHT_BUTTON,ShowVersion) // UI_BUTTON(PRESSED,RIGHT_BUTTON,ShowVersion)
58
+ JR_FALSE(ShowVersion,DontShowVersion) // if (ShowVersion)
59
+ // {
60
+ UI_DRAW(FILLRECT,BG_COLOR,4,50,170,28) // UI_DRAW(FILLRECT,BG_COLOR,4,50,170,28)
61
+ UI_DRAW(RECT,FG_COLOR,6,52,166,24) // UI_DRAW(RECT,FG_COLOR,6,52,166,24)
62
+ UI_DRAW(TEXT,FG_COLOR,13,60,appv) // UI_DRAW(TEXT,FG_COLOR,13,60,appv)
63
+ UI_DRAW(UPDATE) // UI_DRAW(UPDATE)
64
+ //
65
+ ShowVersionWait: // do
66
+ // {
67
+ UI_BUTTON(PRESSED,RIGHT_BUTTON,ShowVersion) // UI_BUTTON(PRESSED,RIGHT_BUTTON,ShowVersion)
68
+ // }
69
+ JR_TRUE(ShowVersion,ShowVersionWait) // while (ShowVersion)
70
+ //
71
+ UI_BUTTON(FLUSH) // UI_BUTTON(FLUSH)
72
+ DontShowVersion: // }
73
+ //
74
+ UI_DRAW(RESTORE,0) // UI_DRAW(RESTORE,0)
75
+ UI_DRAW(TOPLINE,0) // UI_DRAW(TOPLINE,0)
76
+ UI_WRITE(LED,LED_GREEN) // UI_WRITE(LED,LED_GREEN)
77
+ //
78
+
79
+ MOVE32_F(TIMES,DataF)
80
+ UI_DRAW(FILLWINDOW,BG_COLOR,0,0) // UI_DRAW(FILLWINDOW,BG_COLOR,0,0)
81
+
82
+ UI_DRAW(SELECT_FONT,TINY_FONT)
83
+ UI_DRAW(TEXT,FG_COLOR,0,120,'-----------------------------------')
84
+ UI_DRAW(UPDATE)
85
+
86
+ UI_DRAW(SCROLL,8)
87
+ UI_DRAW(SELECT_FONT,TINY_FONT)
88
+ UI_DRAW(TEXT,FG_COLOR,0,120,'Performance Test (avr.')
89
+ UI_DRAW(VALUE,FG_COLOR,110,120,DataF,7,0)
90
+ UI_DRAW(TEXT,FG_COLOR,145,120,'instr)')
91
+ UI_DRAW(UPDATE)
92
+
93
+ UI_DRAW(SCROLL,8)
94
+ UI_DRAW(SELECT_FONT,TINY_FONT)
95
+ UI_DRAW(TEXT,FG_COLOR,0,120,'-----------------------------------')
96
+ UI_DRAW(UPDATE)
97
+
98
+ UI_DRAW(SCROLL,8)
99
+ UI_DRAW(SELECT_FONT,TINY_FONT)
100
+ UI_DRAW(TEXT,FG_COLOR,0,120,'Byte Code [uS]')
101
+ UI_DRAW(UPDATE)
102
+
103
+ UI_DRAW(SCROLL,8)
104
+
105
+ UI_WRITE(PUT_STRING,'\r\n ---------------------------------------------')
106
+ UI_WRITE(PUT_STRING,'\r\n Performance test (average over ')
107
+ UI_WRITE(VALUE32,TIMES)
108
+ UI_WRITE(PUT_STRING,' inst.)')
109
+ UI_WRITE(PUT_STRING,'\r\n ---------------------------------------------')
110
+ UI_WRITE(PUT_STRING,'\r\n Byte code Time [uS]\r\n\n')
111
+ UI_FLUSH()
112
+
113
+ CALL(Test_REF)
114
+
115
+
116
+
117
+ CALL(Test_CALL)
118
+ CALL(Test_CALL_4x32)
119
+ CALL(Test_MOVEF_32)
120
+ CALL(Test_MOVE32_F)
121
+ CALL(Test_MOVEF_F)
122
+ CALL(Test_ADD32)
123
+ CALL(Test_ADDF)
124
+ CALL(Test_INPUT_READ)
125
+ // CALL(Test_INPUT_DEVICE_READY_PCT)
126
+ CALL(Test_ARRAY_READ)
127
+ CALL(Test_READ8)
128
+ CALL(Test_UI_BUTTON_SHORTPRESS)
129
+ CALL(Test_JR)
130
+ CALL(Test_NOP)
131
+
132
+ // CALL(Test_UI_DRAW_CLEAN)
133
+ // CALL(Test_UI_DRAW_TEXT_10_aligned)
134
+ // CALL(Test_UI_DRAW_TEXT_10_not_aligned)
135
+ // CALL(Test_UI_DRAW_ICON)
136
+ // CALL(Test_UI_DRAW_BMPFILE)
137
+ // CALL(Test_UI_DRAW_RECT)
138
+ // CALL(Test_UI_DRAW_PIXEL)
139
+ // CALL(Test_UI_DRAW_UPDATE)
140
+ CALL(Test_SLEEP)
141
+
142
+
143
+ UI_WRITE(PUT_STRING,'\r\n ---------------------------------------------\r\n')
144
+ UI_FLUSH()
145
+
146
+ Loop:
147
+ JR(Loop)
148
+ }
149
+
150
+
151
+ subcall Test_REF
152
+ {
153
+ MOVE32_32(0,Counter)
154
+ TIMER_READ_US(Start)
155
+ Loop:
156
+ ADD32(1,Counter,Counter)
157
+ JR_LT32(Counter,TIMES,Loop)
158
+ TIMER_READ_US(Stop)
159
+ SUB32(Stop,Start,Ref)
160
+ }
161
+
162
+ subcall Test_CALL
163
+ {
164
+ UI_DRAW(SCROLL,8)
165
+ UI_DRAW(SELECT_FONT,TINY_FONT)
166
+ UI_DRAW(TEXT,FG_COLOR,0,120,'CALL() . . . . . . . . . . . ')
167
+ UI_DRAW(UPDATE)
168
+
169
+ UI_WRITE(PUT_STRING,' CALL().......................... ')
170
+ UI_FLUSH()
171
+ MOVE32_32(0,Counter)
172
+ TIMER_READ_US(Start)
173
+ Loop1:
174
+ // TEST ***********************************************
175
+ CALL(CallNoPar)
176
+ // ****************************************************
177
+ ADD32(1,Counter,Counter)
178
+ JR_LT32(Counter,TIMES,Loop1)
179
+ TIMER_READ_US(Stop)
180
+ SUB32(Stop,Start,Time)
181
+ SUB32(Time,Ref,Time)
182
+
183
+ CALL(ShowResult,Time)
184
+ }
185
+
186
+
187
+ subcall Test_CALL_4x32
188
+ {
189
+ UI_DRAW(SCROLL,8)
190
+ UI_DRAW(SELECT_FONT,TINY_FONT)
191
+ UI_DRAW(TEXT,FG_COLOR,0,120,'CALL(4xDATA32...) . . . . . ')
192
+ UI_DRAW(UPDATE)
193
+
194
+ UI_WRITE(PUT_STRING,' CALL(4xDATA32...)............... ')
195
+ UI_FLUSH()
196
+ MOVE32_32(0,Counter)
197
+ TIMER_READ_US(Start)
198
+ Loop2:
199
+ // TEST ***********************************************
200
+ CALL(Call4Par,Data32_1,Data32_2,Data32_3,Data32_4)
201
+ // ****************************************************
202
+ ADD32(1,Counter,Counter)
203
+ JR_LT32(Counter,TIMES,Loop2)
204
+ TIMER_READ_US(Stop)
205
+ SUB32(Stop,Start,Time)
206
+ SUB32(Time,Ref,Time)
207
+
208
+ CALL(ShowResult,Time)
209
+ }
210
+
211
+
212
+ subcall Test_MOVEF_32
213
+ {
214
+ UI_DRAW(SCROLL,8)
215
+ UI_DRAW(SELECT_FONT,TINY_FONT)
216
+ UI_DRAW(TEXT,FG_COLOR,0,120,'MOVEF_32 . . . . . . . . . . ')
217
+ UI_DRAW(UPDATE)
218
+
219
+ UI_WRITE(PUT_STRING,' MOVEF_32........................ ')
220
+ UI_FLUSH()
221
+ MOVE32_32(0,Counter)
222
+ TIMER_READ_US(Start)
223
+ Loop3:
224
+ // TEST ***********************************************
225
+ MOVEF_32(DataF,Data32)
226
+ // ****************************************************
227
+ ADD32(1,Counter,Counter)
228
+ JR_LT32(Counter,TIMES,Loop3)
229
+ TIMER_READ_US(Stop)
230
+ SUB32(Stop,Start,Time)
231
+ SUB32(Time,Ref,Time)
232
+
233
+ CALL(ShowResult,Time)
234
+ }
235
+
236
+
237
+ subcall Test_MOVE32_F
238
+ {
239
+ UI_DRAW(SCROLL,8)
240
+ UI_DRAW(SELECT_FONT,TINY_FONT)
241
+ UI_DRAW(TEXT,FG_COLOR,0,120,'MOVE32_F. . . . . . . . . . ')
242
+ UI_DRAW(UPDATE)
243
+
244
+ UI_WRITE(PUT_STRING,' MOVE32_F........................ ')
245
+ UI_FLUSH()
246
+ MOVE32_32(0,Counter)
247
+ TIMER_READ_US(Start)
248
+ Loop4:
249
+ // TEST ***********************************************
250
+ MOVE32_F(Data32,DataF)
251
+ // ****************************************************
252
+ ADD32(1,Counter,Counter)
253
+ JR_LT32(Counter,TIMES,Loop4)
254
+ TIMER_READ_US(Stop)
255
+ SUB32(Stop,Start,Time)
256
+ SUB32(Time,Ref,Time)
257
+
258
+ CALL(ShowResult,Time)
259
+ }
260
+
261
+
262
+ subcall Test_MOVEF_F
263
+ {
264
+ UI_DRAW(SCROLL,8)
265
+ UI_DRAW(SELECT_FONT,TINY_FONT)
266
+ UI_DRAW(TEXT,FG_COLOR,0,120,'MOVEF_F. . . . . . . . . . . ')
267
+ UI_DRAW(UPDATE)
268
+
269
+ UI_WRITE(PUT_STRING,' MOVEF_F......................... ')
270
+ UI_FLUSH()
271
+ MOVE32_32(0,Counter)
272
+ TIMER_READ_US(Start)
273
+ Loop5:
274
+ // TEST ***********************************************
275
+ MOVEF_F(DataF,DataF)
276
+ // ****************************************************
277
+ ADD32(1,Counter,Counter)
278
+ JR_LT32(Counter,TIMES,Loop5)
279
+ TIMER_READ_US(Stop)
280
+ SUB32(Stop,Start,Time)
281
+ SUB32(Time,Ref,Time)
282
+
283
+ CALL(ShowResult,Time)
284
+ }
285
+
286
+ subcall Test_ADD32
287
+ {
288
+ UI_DRAW(SCROLL,8)
289
+ UI_DRAW(SELECT_FONT,TINY_FONT)
290
+ UI_DRAW(TEXT,FG_COLOR,0,120,'ADD32 . . . . . . . . . . . ')
291
+ UI_DRAW(UPDATE)
292
+
293
+ UI_WRITE(PUT_STRING,' ADD32........................... ')
294
+ UI_FLUSH()
295
+ MOVE32_32(0,Counter)
296
+ TIMER_READ_US(Start)
297
+ Loop6:
298
+ // TEST ***********************************************
299
+ ADD32(1,Data32,Data32)
300
+ // ****************************************************
301
+ ADD32(1,Counter,Counter)
302
+ JR_LT32(Counter,TIMES,Loop6)
303
+ TIMER_READ_US(Stop)
304
+ SUB32(Stop,Start,Time)
305
+ SUB32(Time,Ref,Time)
306
+
307
+ CALL(ShowResult,Time)
308
+ }
309
+
310
+
311
+ subcall Test_ADDF
312
+ {
313
+ UI_DRAW(SCROLL,8)
314
+ UI_DRAW(SELECT_FONT,TINY_FONT)
315
+ UI_DRAW(TEXT,FG_COLOR,0,120,'ADDF . . . . . . . . . . . . ')
316
+ UI_DRAW(UPDATE)
317
+
318
+ UI_WRITE(PUT_STRING,' ADDF............................ ')
319
+ UI_FLUSH()
320
+ MOVE32_32(0,Counter)
321
+ TIMER_READ_US(Start)
322
+ Loop7:
323
+ // TEST ***********************************************
324
+ ADDF(1F,DataF,DataF)
325
+ // ****************************************************
326
+ ADD32(1,Counter,Counter)
327
+ JR_LT32(Counter,TIMES,Loop7)
328
+ TIMER_READ_US(Stop)
329
+ SUB32(Stop,Start,Time)
330
+ SUB32(Time,Ref,Time)
331
+
332
+ CALL(ShowResult,Time)
333
+ }
334
+
335
+
336
+ subcall Test_INPUT_READ
337
+ {
338
+ UI_DRAW(SCROLL,8)
339
+ UI_DRAW(SELECT_FONT,TINY_FONT)
340
+ UI_DRAW(TEXT,FG_COLOR,0,120,'INPUT_READ. . . . . . . . . ')
341
+ UI_DRAW(UPDATE)
342
+
343
+ UI_WRITE(PUT_STRING,' INPUT_READ...................... ')
344
+ UI_FLUSH()
345
+ MOVE32_32(0,Counter)
346
+ TIMER_READ_US(Start)
347
+ Loop8:
348
+ // TEST ***********************************************
349
+ INPUT_READ(0,0,0,-1,Data8)
350
+ // ****************************************************
351
+ ADD32(1,Counter,Counter)
352
+ JR_LT32(Counter,TIMES,Loop8)
353
+ TIMER_READ_US(Stop)
354
+ SUB32(Stop,Start,Time)
355
+ SUB32(Time,Ref,Time)
356
+
357
+ CALL(ShowResult,Time)
358
+ }
359
+
360
+
361
+ subcall Test_INPUT_DEVICE_READY_PCT
362
+ {
363
+ UI_DRAW(SCROLL,8)
364
+ UI_DRAW(SELECT_FONT,TINY_FONT)
365
+ UI_DRAW(TEXT,FG_COLOR,0,120,'INPUT_DEVICE(READY_PCT...) . ')
366
+ UI_DRAW(UPDATE)
367
+
368
+ UI_WRITE(PUT_STRING,' INPUT_DEVICE(READY_PCT...)...... ')
369
+ UI_FLUSH()
370
+ MOVE32_32(0,Counter)
371
+ TIMER_READ_US(Start)
372
+ Loop9:
373
+ // TEST ***********************************************
374
+ INPUT_DEVICE(READY_PCT,0,0,0,-1,1,Data8)
375
+ // ****************************************************
376
+ ADD32(1,Counter,Counter)
377
+ JR_LT32(Counter,TIMES,Loop9)
378
+ TIMER_READ_US(Stop)
379
+ SUB32(Stop,Start,Time)
380
+ SUB32(Time,Ref,Time)
381
+
382
+ CALL(ShowResult,Time)
383
+ }
384
+
385
+
386
+ subcall Test_ARRAY_READ
387
+ {
388
+ UI_DRAW(SCROLL,8)
389
+ UI_DRAW(SELECT_FONT,TINY_FONT)
390
+ UI_DRAW(TEXT,FG_COLOR,0,120,'ARRAY_READ(...) . . . . . . ')
391
+ UI_DRAW(UPDATE)
392
+
393
+ UI_WRITE(PUT_STRING,' ARRAY_READ(...)................. ')
394
+ UI_FLUSH()
395
+ ARRAY(CREATE8,10,hData8)
396
+ MOVE32_32(0,Counter)
397
+ TIMER_READ_US(Start)
398
+ Loop10:
399
+ // TEST ***********************************************
400
+ ARRAY_READ(hData8,5,Data8)
401
+ // ****************************************************
402
+ ADD32(1,Counter,Counter)
403
+ JR_LT32(Counter,TIMES,Loop10)
404
+ TIMER_READ_US(Stop)
405
+ SUB32(Stop,Start,Time)
406
+ SUB32(Time,Ref,Time)
407
+
408
+ CALL(ShowResult,Time)
409
+ }
410
+
411
+
412
+ subcall Test_READ8
413
+ {
414
+ UI_DRAW(SCROLL,8)
415
+ UI_DRAW(SELECT_FONT,TINY_FONT)
416
+ UI_DRAW(TEXT,FG_COLOR,0,120,'READ8(...) . . . . . . . . . ')
417
+ UI_DRAW(UPDATE)
418
+
419
+ UI_WRITE(PUT_STRING,' READ8(...)...................... ')
420
+ UI_FLUSH()
421
+ MOVE32_32(0,Counter)
422
+ TIMER_READ_US(Start)
423
+ Loop11:
424
+ // TEST ***********************************************
425
+ READ8(DataS,5,Data8)
426
+ // ****************************************************
427
+ ADD32(1,Counter,Counter)
428
+ JR_LT32(Counter,TIMES,Loop11)
429
+ TIMER_READ_US(Stop)
430
+ SUB32(Stop,Start,Time)
431
+ SUB32(Time,Ref,Time)
432
+
433
+ CALL(ShowResult,Time)
434
+ }
435
+
436
+
437
+ subcall Test_UI_BUTTON_SHORTPRESS
438
+ {
439
+ UI_DRAW(SCROLL,8)
440
+ UI_DRAW(SELECT_FONT,TINY_FONT)
441
+ UI_DRAW(TEXT,FG_COLOR,0,120,'UI_BUTTON(SHORTPRESS...). . ')
442
+ UI_DRAW(UPDATE)
443
+
444
+ UI_WRITE(PUT_STRING,' UI_BUTTON(SHORTPRESS...)........ ')
445
+ UI_FLUSH()
446
+ MOVE32_32(0,Counter)
447
+ TIMER_READ_US(Start)
448
+ Loop12:
449
+ // TEST ***********************************************
450
+ UI_BUTTON(SHORTPRESS,ENTER_BUTTON,Data8)
451
+ // ****************************************************
452
+ ADD32(1,Counter,Counter)
453
+ JR_LT32(Counter,TIMES,Loop12)
454
+ TIMER_READ_US(Stop)
455
+ SUB32(Stop,Start,Time)
456
+ SUB32(Time,Ref,Time)
457
+
458
+ CALL(ShowResult,Time)
459
+ }
460
+
461
+
462
+ subcall Test_JR
463
+ {
464
+ UI_DRAW(SCROLL,8)
465
+ UI_DRAW(SELECT_FONT,TINY_FONT)
466
+ UI_DRAW(TEXT,FG_COLOR,0,120,'JR(...). . . . . . . . . . . ')
467
+ UI_DRAW(UPDATE)
468
+
469
+ UI_WRITE(PUT_STRING,' JR(...)......................... ')
470
+ UI_FLUSH()
471
+ MOVE32_32(0,Counter)
472
+ TIMER_READ_US(Start)
473
+ Loop13:
474
+ // TEST ***********************************************
475
+ JR(Next)
476
+ Next:
477
+ // ****************************************************
478
+ ADD32(1,Counter,Counter)
479
+ JR_LT32(Counter,TIMES,Loop13)
480
+ TIMER_READ_US(Stop)
481
+ SUB32(Stop,Start,Time)
482
+ SUB32(Time,Ref,Time)
483
+
484
+ CALL(ShowResult,Time)
485
+ }
486
+
487
+
488
+ subcall Test_NOP
489
+ {
490
+ UI_DRAW(SCROLL,8)
491
+ UI_DRAW(SELECT_FONT,TINY_FONT)
492
+ UI_DRAW(TEXT,FG_COLOR,0,120,'NOP . . . . . . . . . . . . ')
493
+ UI_DRAW(UPDATE)
494
+
495
+ UI_WRITE(PUT_STRING,' NOP ............................ ')
496
+ UI_FLUSH()
497
+ MOVE32_32(0,Counter)
498
+ TIMER_READ_US(Start)
499
+ Loop40:
500
+ // TEST ***********************************************
501
+ NOP
502
+ // ****************************************************
503
+ ADD32(1,Counter,Counter)
504
+ JR_LT32(Counter,TIMES,Loop40)
505
+ TIMER_READ_US(Stop)
506
+ SUB32(Stop,Start,Time)
507
+ SUB32(Time,Ref,Time)
508
+
509
+ CALL(ShowResult,Time)
510
+ }
511
+
512
+
513
+ subcall Test_SLEEP
514
+ {
515
+ UI_DRAW(SCROLL,8)
516
+ UI_DRAW(SELECT_FONT,TINY_FONT)
517
+ UI_DRAW(TEXT,FG_COLOR,0,120,'SLEEP() . . . . . . . . . . ')
518
+ UI_DRAW(UPDATE)
519
+
520
+ UI_WRITE(PUT_STRING,' SLEEP()......................... ')
521
+ UI_FLUSH()
522
+ MOVE32_32(0,Counter)
523
+ TIMER_READ_US(Start)
524
+ Loop39:
525
+ // TEST ***********************************************
526
+ SLEEP()
527
+ // ****************************************************
528
+ ADD32(1,Counter,Counter)
529
+ JR_LT32(Counter,TIMES,Loop39)
530
+ TIMER_READ_US(Stop)
531
+ SUB32(Stop,Start,Time)
532
+ SUB32(Time,Ref,Time)
533
+
534
+ CALL(ShowResult,Time)
535
+ }
536
+
537
+
538
+ subcall Test_UI_DRAW_CLEAN
539
+ {
540
+ UI_WRITE(PUT_STRING,' UI_DRAW(FILLWINDOW,0,0,0)....... ')
541
+ UI_FLUSH()
542
+ MOVE32_32(0,Counter)
543
+ TIMER_READ_US(Start)
544
+ Loop40:
545
+ // TEST ***********************************************
546
+ UI_DRAW(FILLWINDOW,0,0,0)
547
+ // ****************************************************
548
+ ADD32(1,Counter,Counter)
549
+ JR_LT32(Counter,TIMES,Loop40)
550
+ TIMER_READ_US(Stop)
551
+ SUB32(Stop,Start,Time)
552
+ SUB32(Time,Ref,Time)
553
+
554
+ CALL(ShowResult,Time)
555
+ }
556
+
557
+
558
+ subcall Test_UI_DRAW_TEXT_10_aligned
559
+ {
560
+ UI_WRITE(PUT_STRING,' UI_DRAW(TEXT,1,0,0,"0123456789") ')
561
+ UI_FLUSH()
562
+ MOVE32_32(0,Counter)
563
+ TIMER_READ_US(Start)
564
+ Loop40:
565
+ // TEST ***********************************************
566
+ UI_DRAW(TEXT,FG_COLOR,0,0,'0123456789')
567
+ // ****************************************************
568
+ ADD32(1,Counter,Counter)
569
+ JR_LT32(Counter,TIMES,Loop40)
570
+ TIMER_READ_US(Stop)
571
+ SUB32(Stop,Start,Time)
572
+ SUB32(Time,Ref,Time)
573
+
574
+ CALL(ShowResult,Time)
575
+ }
576
+
577
+
578
+ subcall Test_UI_DRAW_TEXT_10_not_aligned
579
+ {
580
+ UI_WRITE(PUT_STRING,' UI_DRAW(TEXT,1,3,0,"0123456789") ')
581
+ UI_FLUSH()
582
+ MOVE32_32(0,Counter)
583
+ TIMER_READ_US(Start)
584
+ Loop40:
585
+ // TEST ***********************************************
586
+ UI_DRAW(TEXT,FG_COLOR,3,16,'0123456789')
587
+ // ****************************************************
588
+ ADD32(1,Counter,Counter)
589
+ JR_LT32(Counter,TIMES,Loop40)
590
+ TIMER_READ_US(Stop)
591
+ SUB32(Stop,Start,Time)
592
+ SUB32(Time,Ref,Time)
593
+
594
+ CALL(ShowResult,Time)
595
+ }
596
+
597
+
598
+ subcall Test_UI_DRAW_ICON
599
+ {
600
+ UI_WRITE(PUT_STRING,' UI_DRAW(ICON...)................ ')
601
+ UI_FLUSH()
602
+ MOVE32_32(0,Counter)
603
+ TIMER_READ_US(Start)
604
+ Loop40:
605
+ // TEST ***********************************************
606
+ UI_DRAW(ICON,FG_COLOR,0,28,LARGE_ICON,WARNSIGN)
607
+ // ****************************************************
608
+ ADD32(1,Counter,Counter)
609
+ JR_LT32(Counter,TIMES,Loop40)
610
+ TIMER_READ_US(Stop)
611
+ SUB32(Stop,Start,Time)
612
+ SUB32(Time,Ref,Time)
613
+
614
+ CALL(ShowResult,Time)
615
+ }
616
+
617
+
618
+ subcall Test_UI_DRAW_BMPFILE
619
+ {
620
+ UI_WRITE(PUT_STRING,' UI_DRAW(BMPFILE...)............. ')
621
+ UI_FLUSH()
622
+ MOVE32_32(0,Counter)
623
+ TIMER_READ_US(Start)
624
+ Loop40:
625
+ // TEST ***********************************************
626
+ UI_DRAW(BMPFILE,FG_COLOR,16,50,'144x65_POP3')
627
+ // ****************************************************
628
+ ADD32(1,Counter,Counter)
629
+ JR_LT32(Counter,TIMES,Loop40)
630
+ TIMER_READ_US(Stop)
631
+ SUB32(Stop,Start,Time)
632
+ SUB32(Time,Ref,Time)
633
+
634
+ CALL(ShowResult,Time)
635
+ }
636
+
637
+
638
+ subcall Test_UI_DRAW_RECT
639
+ {
640
+ UI_WRITE(PUT_STRING,' UI_DRAW(RECT...)................ ')
641
+ UI_FLUSH()
642
+ MOVE32_32(0,Counter)
643
+ TIMER_READ_US(Start)
644
+ Loop40:
645
+ // TEST ***********************************************
646
+ UI_DRAW(RECT,FG_COLOR,15,49,146,67)
647
+ // ****************************************************
648
+ ADD32(1,Counter,Counter)
649
+ JR_LT32(Counter,TIMES,Loop40)
650
+ TIMER_READ_US(Stop)
651
+ SUB32(Stop,Start,Time)
652
+ SUB32(Time,Ref,Time)
653
+
654
+ CALL(ShowResult,Time)
655
+ }
656
+
657
+
658
+ subcall Test_UI_DRAW_PIXEL
659
+ {
660
+ UI_WRITE(PUT_STRING,' UI_DRAW(PIXEL...)............... ')
661
+ UI_FLUSH()
662
+ MOVE32_32(0,Counter)
663
+ TIMER_READ_US(Start)
664
+ Loop40:
665
+ // TEST ***********************************************
666
+ UI_DRAW(PIXEL,FG_COLOR,0,120)
667
+ // ****************************************************
668
+ ADD32(1,Counter,Counter)
669
+ JR_LT32(Counter,TIMES,Loop40)
670
+ TIMER_READ_US(Stop)
671
+ SUB32(Stop,Start,Time)
672
+ SUB32(Time,Ref,Time)
673
+
674
+ CALL(ShowResult,Time)
675
+ }
676
+
677
+
678
+ subcall Test_UI_DRAW_UPDATE
679
+ {
680
+ UI_WRITE(PUT_STRING,' UI_DRAW(UPDATE)................. ')
681
+ UI_FLUSH()
682
+ MOVE32_32(0,Counter)
683
+ TIMER_READ_US(Start)
684
+ Loop40:
685
+ // TEST ***********************************************
686
+ UI_DRAW(UPDATE)
687
+ // ****************************************************
688
+ ADD32(1,Counter,Counter)
689
+ JR_LT32(Counter,TIMES,Loop40)
690
+ TIMER_READ_US(Stop)
691
+ SUB32(Stop,Start,Time)
692
+ SUB32(Time,Ref,Time)
693
+
694
+ CALL(ShowResult,Time)
695
+ }
696
+
697
+
698
+ subcall ShowResult
699
+ {
700
+ IN_32 Timer
701
+
702
+ DATAF Tmp1
703
+ DATAF Tmp2
704
+
705
+ MOVE32_F(Timer,Tmp1)
706
+ MOVE32_F(MS,Tmp2)
707
+ MULF(Tmp1,Tmp2,Tmp1)
708
+ MOVE32_F(TIMES,Tmp2)
709
+ DIVF(Tmp1,Tmp2,Tmp1)
710
+ UI_WRITE(FLOATVALUE,Tmp1,6,0)
711
+ UI_WRITE(PUT_STRING,'\r\n')
712
+ UI_FLUSH()
713
+
714
+ UI_DRAW(SELECT_FONT,TINY_FONT)
715
+ UI_DRAW(VALUE,FG_COLOR,145,120,Tmp1,6,0);
716
+ UI_DRAW(UPDATE)
717
+ }
718
+
719
+
720
+ subcall CallNoPar
721
+ {
722
+ }
723
+
724
+
725
+ subcall Call4Par
726
+ {
727
+ IN_32 Data32_1
728
+ IN_32 Data32_2
729
+ OUT_32 Data32_3
730
+ OUT_32 Data32_4
731
+ }
732
+
733
+ //
734
+ //! \endverbatim
735
+