-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeG_simple_r1.txt
308 lines (190 loc) · 10.3 KB
/
CodeG_simple_r1.txt
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
CodeG simple revision 1 (txt format)
- SYNTAX -
Every file must be encoded in ASCII.
The code must be written line by line and each line must end with a line feed (LF).
All characters between 0 and 31 as well as character 127 in the ASCII table will be ignored during compilation.
Multiple spaces are allowed between keywords, during compilation, extra spaces will be removed.
Each written word represents a type of keyword. There is 7 types of keywords :
KEYWORD TYPE DESCRIPTION
target A [target] is a reserved keyword that identifies a physical peripheral or an operation. The only possibilities are «OP», «OPERATION», «P», «PERIPHERAL».
bus* A [bus] is a constant decimal number that represents the identifier of a bus. (this will depend on the processor).
value A [value] can be a [variable], a hexadecimal number, a decimal number, a binary number or any available special arguments.
name A [name] represents a word with a special definition like a label name or a macro.
instruction An [instruction] represents a reserved keyword having a certain action on the code.
variable A [variable] represents a memory location where your value is located. A [variable] is identified with the ‘$’ symbol.
string A [string] is an argument to an instruction or an undefined/unknown keyword.
*Bus 1 always represent the writeable bus 1
Bus 2 always represent the writeable bus 2
Bus 3 always represent the SPI config bus
- RESERVERD KEYWORDS -
“set”
“var”
“label”
“affect”
“function”
“do”
“if_not”
“else”
“end”
“choose”
“OP”
“P”
“write”
“if”
“brut”
“jump”
“call”
“restart”
“PERIPHERAL”
“OPERATION”
“tick”
“simple”
“long”
“repeat”
“_src”
“_bread1”
“_bread2”
“_result”
“_ram”
“_spi”
“_ext1”
“_ext2”
“pool”
“#”
“#[”, “]#”
“SPI”
- VARIABLE POOL -
A variable pool is a grouping of variables subject to certain rules/constraints.
Pool size :
You can change the pool size. You cannot insert more variables if the maximum pool size is reached.
If you specify a size of 0, the size will be dynamically allocated.
Pool address :
You can change the start address of a pool.
If no address is specified, the address will be allocated automatically.
The default pool :
A pool is automatically created by default by the compiler and cannot be configured.
The size and the address is dynamic.
The default pool name is “global”.
- INSTRUCTIONS -
KEYWORD ARGUMENTS DESCRIPTION
set set [name] [string] Define a new macro with a [name] by the content of the [string].
The name must not be a reserved keyword which may send a compilation error.
If the new name has already been defined before, a warning is sent to the user and the compiler replaces the old macro.
KEYWORD ARGUMENTS DESCRIPTION
var var [name] ([name]) Define a new [variable] with a [name].
If the variable already exists, an warning will be sent and if a pool is precised, the pool will be replaced.
The second parameter makes it possible to specify the pool where the variable will be.
If no parameter is entered, the variable will be created in the default pool.
KEYWORD ARGUMENTS DESCRIPTION
label label [name] Define a new jump label to a position in the code.
If the label already exists, an error will be sent.
KEYWORD ARGUMENTS DESCRIPTION
jump jump [name] Jump to a certain label.
If the label does not exist, an error will be sent.
If the label exists, a link will be created to this label. Then the link will be calculated as a fixed address during the link calculation.
KEYWORD ARGUMENTS DESCRIPTION
restart restart Jump to the address 0.
Restarts the program by jumping to address 0.
KEYWORD ARGUMENTS DESCRIPTION
affect affect [variable] [value] Assigns a [variable] to a certain [value].
If the variable does not exist, an error will be sent.
KEYWORD ARGUMENTS DESCRIPTION
write write [bus] [value] Assigns a [bus] to a certain [value].
if the bus does not exist, an error will be sent.
KEYWORD ARGUMENTS DESCRIPTION
choose choose [target] [value] Choose a [target] with an identity [value].
Only peripheral or operation are accepted with the [target] argument.
KEYWORD ARGUMENTS DESCRIPTION
do do [value] [value] [value] Do a calcul : opleft operation opright.
-
KEYWORD ARGUMENTS DESCRIPTION
tick tick [string] ([value]) No effect instruction (delay).
You can choose a «simple» or «long» tick with the first option.
The second argument is the number of times the instruction will be repeated. If no value is set, the instruction will be executed only once.
KEYWORD ARGUMENTS DESCRIPTION
brut brut [value], ... Insert instruction in binary, hexadecimal or decimal form.
A list of constant value can be applied after «brut». Only constant value are authorized.
KEYWORD ARGUMENTS DESCRIPTION
jump jump [name] Jump to a label.
Only labels are allowed as [name].
KEYWORD ARGUMENTS DESCRIPTION
function function [name] Creates a function with a certain [name].
The [name] should not already be used, an error will be sent if it is the case.
Each function must end with the keyword “end”.
KEYWORD ARGUMENTS DESCRIPTION
if if [value] Condition statement.
The code in the condition is executed when the value is other than 0.
The condition is skipped (or the “else” code is executed) when the value is 0.
At the end of the condition, the keyword “else” or “end” must be present.
KEYWORD ARGUMENTS DESCRIPTION
else else The “else” tag is used to specify a code to execute when the condition is false.
The “else” tag has to end with “end”.
KEYWORD ARGUMENTS DESCRIPTION
if_not if_not [value] Inverted condition statement.
The code in the condition is executed when the value is 0.
The condition is skipped (or the “else” code is executed) when the value is other than 0.
At the end of the condition, the keyword “else” or “end” must be present.
KEYWORD ARGUMENTS DESCRIPTION
end end End of statement.
The “end” tag is used to indicate the end of a statement.
The “end” tag must be used at the end of a function, condition, loop or other statement.
KEYWORD ARGUMENTS DESCRIPTION
call call [name] Call a function.
Jump to a certain function, if the function does not exist, an error occurs.
KEYWORD ARGUMENTS DESCRIPTION
repeat repeat [variable] [value] Repeat the code.
Repeats the following code according to the argument [value] and a [variable].
The "end" tag has to be at the end.
KEYWORD ARGUMENTS DESCRIPTION
clock clock [target] ([value]) Sends a specified number of pulses to the [target].
The second [value] is the number of pulse you want to make, if no value is present, the instruction will only do 1 pulse.
KEYWORD ARGUMENTS DESCRIPTION
pool pool [name] [value] ([value]) Create or modify a pool.
The first value is the [name] of the pool.
The second value is the pool size and must be a constant.
The third value is the start address of the pool and must be a constant.
If the pool already exist it will be replaced with a warning.
- ADDRESS LINK -
When affecting a variable, creating a function or jump to a label, the compiler will not directly put the address but will stock a link.
At the end of the compilation, all links will be translated into actual address.
This makes it easier to compile.
- SPECIAL ARGUMENTS -
Special arguments are [value]s that represent a readable physical source :
KEYWORD DESCRIPTION
_src Return the value sored in the memory source. (this argument is useless and is only there for the sake of understanding.).
The returned value will always be ‘0’ and a warning is sent to the user.
_bread1 Return the value on the readable bus 1.
_bread2 Return the value on the readable bus 2.
_result Return the result of the operation.
_ram Return the value stored at the ram.
_spi Return the value stored at the spi buffer.
_ext1 Return the external value 1.
_ext2 Return the external value 2.
- COMMENT -
Comments is ignored by the compiler and must start with a ‘#’.
For multiline comments, you have to start with “#[” and end the multiline comments with “]#”.
- EXEMPLE -
Loop exemple (made with notepad++) :
#ALUminium V1.0 operations
set ~ 0x05
set <= 0x0F
set + 0x00
set ZERO 0
var output
var index
affect $index 0
affect $output 0
do $index <= 10 #loop check
if _result #index is smaller than 10
do $output ~ ZERO #inverting all the write bus 1
write 1 _result
do $index + 1 #index incrementation
affect $index _result
else #end of loop
restart #restart the program
end
You have to define operations symbols before using it.
The operation code depend on the ALU on the processor. In this exemple, the operation code is taken from ALUminium V1.0*.
*https://github.com/JonathSpirit/ALUminium
- NOTEPAD++ -
You can find a CodeG_simple.xml file for notepad++ to apply colors.