avr.d 20.7 KB
Newer Older
Axel Simon's avatar
Axel Simon committed
1
granularity = 16
mb0's avatar
Up.    
mb0 committed
2
3
4
5
6
7
export = decode

val decode =
  do update@{rd='',rr='',ck='',cs='',cb='',io='',dq=''};
     /
  end
Axel Simon's avatar
Axel Simon committed
8

Julian Kranz's avatar
Julian Kranz committed
9
10
11
12
13
type side-effect =
   NONE
 | INCR
 | DECR

Axel Simon's avatar
Axel Simon committed
14
type imm =
Julian Kranz's avatar
Julian Kranz committed
15
   IMM3 of 3
Julian Kranz's avatar
Julian Kranz committed
16
 | IMM4 of 4
Julian Kranz's avatar
Julian Kranz committed
17
 | IMM6 of 6
Julian Kranz's avatar
Julian Kranz committed
18
 | IMM7 of 7
Julian Kranz's avatar
Julian Kranz committed
19
 | IMM8 of 8
Julian Kranz's avatar
Julian Kranz committed
20
 | IMM12 of 12
Julian Kranz's avatar
Julian Kranz committed
21
 | IMM16 of 16
Julian Kranz's avatar
Julian Kranz committed
22
 | IMM22 of 22
Julian Kranz's avatar
Julian Kranz committed
23

Axel Simon's avatar
Axel Simon committed
24
type operand =
Julian Kranz's avatar
Julian Kranz committed
25
26
   REG of register
 | REGHL of {regh:register,regl:register}
Julian Kranz's avatar
Julian Kranz committed
27
 | IOREG of io-register
Julian Kranz's avatar
Julian Kranz committed
28
 | IMM of imm
Julian Kranz's avatar
Julian Kranz committed
29
 | OPSE of {op:operand,se:side-effect}
Julian Kranz's avatar
Julian Kranz committed
30
 | OPDI of {op:operand,imm:imm}
Julian Kranz's avatar
Julian Kranz committed
31

Julian Kranz's avatar
Julian Kranz committed
32
type binop = {first:operand,second:operand}
Julian Kranz's avatar
Julian Kranz committed
33
type unop = {operand:operand}
Julian Kranz's avatar
Julian Kranz committed
34

mb0's avatar
Foo.    
mb0 committed
35
type instruction =
Julian Kranz's avatar
Julian Kranz committed
36
37
   ADC of binop
 | ADD of binop
Axel Simon's avatar
Axel Simon committed
38
 | ADIW of binop
Julian Kranz's avatar
Julian Kranz committed
39
40
 | AND of binop
 | ANDI of binop
Julian Kranz's avatar
Julian Kranz committed
41
42
 | ASR of unop
 | BCLR of unop
Julian Kranz's avatar
Julian Kranz committed
43
 | BLD of binop
Julian Kranz's avatar
Julian Kranz committed
44
45
 | BRBC of binop
 | BRBS of binop
Julian Kranz's avatar
Julian Kranz committed
46
47
 | BRCC of unop
 | BRCS of unop
Axel Simon's avatar
Axel Simon committed
48
 | BREAK
Julian Kranz's avatar
Julian Kranz committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 | BREQ of unop
 | BRGE of unop
 | BRHC of unop
 | BRHS of unop
 | BRID of unop
 | BRIE of unop
 | BRLO of unop
 | BRLT of unop
 | BRMI of unop
 | BRNE of unop
 | BRPL of unop
 | BRSH of unop
 | BRTC of unop
 | BRTS of unop
 | BRVC of unop
 | BRVS of unop
Julian Kranz's avatar
Julian Kranz committed
65
 | BSET of unop
Axel Simon's avatar
Axel Simon committed
66
 | BST of binop
Julian Kranz's avatar
Julian Kranz committed
67
68
 | CALL of unop
 | CBI of binop
Julian Kranz's avatar
Julian Kranz committed
69
 | CBR of binop
Axel Simon's avatar
Axel Simon committed
70
71
72
73
 | CLC
 | CLH
 | CLI
 | CLN
Julian Kranz's avatar
Julian Kranz committed
74
 | CLR of unop
Axel Simon's avatar
Axel Simon committed
75
76
77
78
 | CLS
 | CLT
 | CLV
 | CLZ
Julian Kranz's avatar
Julian Kranz committed
79
80
81
82
83
84
85
 | COM of unop
 | CP of binop
 | CPC of binop
 | CPI of binop
 | CPSE of binop
 | DEC of unop
 | DES of unop
Axel Simon's avatar
Axel Simon committed
86
87
 | EICALL
 | EIJMP
Julian Kranz's avatar
Julian Kranz committed
88
89
90
91
92
93
94
95
 | ELPM of binop
 | EOR of binop
 | FMUL of binop
 | FMULS of binop
 | FMULSU of binop
 | ICALL
 | IJMP
 | IN of binop
Julian Kranz's avatar
Julian Kranz committed
96
97
98
99
100
101
 | INC of unop
 | JMP of unop
 | LAC of binop
 | LAS of binop
 | LAT of binop
 | LD of binop
Julian Kranz's avatar
Julian Kranz committed
102
103
104
 | LDI of binop
 | LDS of binop
 | LPM of binop
Julian Kranz's avatar
Julian Kranz committed
105
 | LSL of unop
Julian Kranz's avatar
Julian Kranz committed
106
 | LSR of unop
Julian Kranz's avatar
Julian Kranz committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 | MOV of binop
 | MOVW of binop
 | MUL of binop
 | MULS of binop
 | MULSU of binop
 | NEG of unop
 | NOP
 | OR of binop
 | ORI of binop
 | OUT of binop
 | POP of unop
 | PUSH of unop
 | RCALL of unop
 | RET
 | RETI
 | RJMP of unop
Julian Kranz's avatar
Julian Kranz committed
123
 | ROL of unop
Julian Kranz's avatar
Julian Kranz committed
124
125
126
127
128
129
 | ROR of unop
 | SBC of binop
 | SBCI of binop
 | SBI of binop
 | SBIC of binop
 | SBIS of binop
Julian Kranz's avatar
Julian Kranz committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
 | SBIW of binop
 | SBR of binop
 | SBRC of binop
 | SBRS of binop
 | SEC
 | SEH
 | SEI
 | SEN
 | SER of unop
 | SES
 | SET
 | SEV
 | SEZ
 | SLEEP
 | SPM of unop
 | ST of binop
Julian Kranz's avatar
Julian Kranz committed
146
147
148
149
 | STS of binop
 | SUB of binop
 | SUBI of binop
 | SWAP of unop
Julian Kranz's avatar
Julian Kranz committed
150
 | TST of unop
Julian Kranz's avatar
Julian Kranz committed
151
152
 | WDR
 | XCH of binop
Julian Kranz's avatar
Julian Kranz committed
153

mb0's avatar
Foo.    
mb0 committed
154
type register =
Julian Kranz's avatar
Julian Kranz committed
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
   R0
 | R1
 | R2
 | R3
 | R4
 | R5
 | R6
 | R7
 | R8
 | R9
 | R10
 | R11
 | R12
 | R13
 | R14
 | R15
 | R16
 | R17
 | R18
 | R19
 | R20
 | R21
 | R22
 | R23
 | R24
 | R25
 | R26
 | R27
 | R28
 | R29
 | R30
 | R31

Axel Simon's avatar
Axel Simon committed
188
type io-register =
Julian Kranz's avatar
Julian Kranz committed
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
   IO0
 | IO1
 | IO2
 | IO3
 | IO4
 | IO5
 | IO6
 | IO7
 | IO8
 | IO9
 | IO10
 | IO11
 | IO12
 | IO13
 | IO14
 | IO15
 | IO16
 | IO17
 | IO18
 | IO19
 | IO20
 | IO21
 | IO22
 | IO23
 | IO24
 | IO25
 | IO26
 | IO27
 | IO28
 | IO29
 | IO30
 | IO31
Julian Kranz's avatar
Julian Kranz committed
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
 | IO32
 | IO33
 | IO34
 | IO35
 | IO36
 | IO37
 | IO38
 | IO39
 | IO40
 | IO41
 | IO42
 | IO43
 | IO44
 | IO45
 | IO46
 | IO47
 | IO48
 | IO49
 | IO50
 | IO51
 | IO52
 | IO53
 | IO54
 | IO55
 | IO56
 | IO57
 | IO58
 | IO59
 | IO60
 | IO61
 | IO62
 | IO63

Julian Kranz's avatar
Julian Kranz committed
254

Julian Kranz's avatar
Julian Kranz committed
255
256
val register-from-bits bits =
 case bits of
Julian Kranz's avatar
Julian Kranz committed
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
    '00000': R0
  | '00001': R1
  | '00010': R2
  | '00011': R3
  | '00100': R4
  | '00101': R5
  | '00110': R6
  | '00111': R7
  | '01000': R8
  | '01001': R9
  | '01010': R10
  | '01011': R11
  | '01100': R12
  | '01101': R13
  | '01110': R14
  | '01111': R15
  | '10000': R16
  | '10001': R17
  | '10010': R18
  | '10011': R19
  | '10100': R20
  | '10101': R21
  | '10110': R22
  | '10111': R23
  | '11000': R24
  | '11001': R25
  | '11010': R26
  | '11011': R27
  | '11100': R28
  | '11101': R29
  | '11110': R30
  | '11111': R31
 end
Julian Kranz's avatar
Julian Kranz committed
290

Julian Kranz's avatar
Julian Kranz committed
291
292
val io-register-from-bits bits =
 case bits of
Julian Kranz's avatar
Julian Kranz committed
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
    '000000': IO0
  | '000001': IO1
  | '000010': IO2
  | '000011': IO3
  | '000100': IO4
  | '000101': IO5
  | '000110': IO6
  | '000111': IO7
  | '001000': IO8
  | '001001': IO9
  | '001010': IO10
  | '001011': IO11
  | '001100': IO12
  | '001101': IO13
  | '001110': IO14
  | '001111': IO15
  | '010000': IO16
  | '010001': IO17
  | '010010': IO18
  | '010011': IO19
  | '010100': IO20
  | '010101': IO21
  | '010110': IO22
  | '010111': IO23
  | '011000': IO24
  | '011001': IO25
  | '011010': IO26
  | '011011': IO27
  | '011100': IO28
  | '011101': IO29
  | '011110': IO30
  | '011111': IO31
  | '100000': IO32
  | '100001': IO33
  | '100010': IO34
  | '100011': IO35
  | '100100': IO36
  | '100101': IO37
  | '100110': IO38
  | '100111': IO39
  | '101000': IO40
  | '101001': IO41
  | '101010': IO42
  | '101011': IO43
  | '101100': IO44
  | '101101': IO45
  | '101110': IO46
  | '101111': IO47
  | '110000': IO48
  | '110001': IO49
  | '110010': IO50
  | '110011': IO51
  | '110100': IO52
  | '110101': IO53
  | '110110': IO54
  | '110111': IO55
  | '111000': IO56
  | '111001': IO57
  | '111010': IO58
  | '111011': IO59
  | '111100': IO60
  | '111101': IO61
  | '111110': IO62
  | '111111': IO63
Julian Kranz's avatar
Julian Kranz committed
357
358
 end

Julian Kranz's avatar
Julian Kranz committed
359
360
361
val /X = return (REGHL {regh=R27,regl=R26})
val /Y = return (REGHL {regh=R29,regl=R28})
val /Z = return (REGHL {regh=R31,regl=R30})
Julian Kranz's avatar
Julian Kranz committed
362
363
364

val r0 = return (REG R0)

Julian Kranz's avatar
Julian Kranz committed
365
366
367
368
369
370
371
372
373
374
375
376
val //X se = do
 /X <- /X;
 return (OPSE {op=(/X),se=se})
end
val //Y se = do
 /Y <- /Y;
 return (OPSE {op=(/Y),se=se})
end
val //Z se = do
 /Z <- /Z;
 return (OPSE {op=(/Z),se=se})
end
Julian Kranz's avatar
Julian Kranz committed
377
378

val ///X imm = do
Julian Kranz's avatar
Julian Kranz committed
379
 /X <- /X;
Julian Kranz's avatar
Julian Kranz committed
380
381
382
383
 imm <- imm;
 return (OPDI {op=(/X),imm=imm})
end
val ///Y imm = do
Julian Kranz's avatar
Julian Kranz committed
384
 /Y <- /Y;
Julian Kranz's avatar
Julian Kranz committed
385
386
387
388
 imm <- imm;
 return (OPDI {op=(/Y),imm=imm})
end
val ///Z imm = do
Julian Kranz's avatar
Julian Kranz committed
389
 /Z <- /Z;
Julian Kranz's avatar
Julian Kranz committed
390
391
392
 imm <- imm;
 return (OPDI {op=(/Z),imm=imm})
end
Julian Kranz's avatar
Julian Kranz committed
393

Julian Kranz's avatar
Julian Kranz committed
394
val d ['bit:1'] = do
Axel Simon's avatar
Axel Simon committed
395
396
 rd <- query $rd;
 update@{rd=rd ^ bit}
Julian Kranz's avatar
Julian Kranz committed
397
398
end

Julian Kranz's avatar
Julian Kranz committed
399
val r ['bit:1'] = do
Axel Simon's avatar
Axel Simon committed
400
401
 rr <- query $rr;
 update@{rr=rr ^ bit}
Julian Kranz's avatar
Julian Kranz committed
402
403
end

Julian Kranz's avatar
Julian Kranz committed
404
val k ['bit:1'] = do
Axel Simon's avatar
Axel Simon committed
405
406
 ck <- query $ck;
 update@{ck=ck ^ bit}
Julian Kranz's avatar
Julian Kranz committed
407
408
end

Julian Kranz's avatar
Julian Kranz committed
409
val s ['bit:1'] = do
Axel Simon's avatar
Axel Simon committed
410
411
 cs <- query $cs;
 update@{cs=cs ^ bit}
Julian Kranz's avatar
Julian Kranz committed
412
413
end

Julian Kranz's avatar
Julian Kranz committed
414
val a ['bit:1'] = do
Axel Simon's avatar
Axel Simon committed
415
416
417
418
419
420
421
 io <- query $io;
 update@{io=io ^ bit}
end

val b ['bit:1'] = do
 cb <- query $cb;
 update@{cb=cb ^ bit}
Julian Kranz's avatar
Julian Kranz committed
422
423
end

Julian Kranz's avatar
Julian Kranz committed
424
425
426
427
428
val q ['bit:1'] = do
 dq <- query $dq;
 update@{dq=dq ^ bit}
end

Julian Kranz's avatar
Julian Kranz committed
429
val rd5 = do
Julian Kranz's avatar
Julian Kranz committed
430
 rd <- query $rd;
Axel Simon's avatar
Axel Simon committed
431
 update @{rd=''};
Julian Kranz's avatar
Julian Kranz committed
432
 return (REG (register-from-bits rd))
Julian Kranz's avatar
Julian Kranz committed
433
end
Julian Kranz's avatar
Julian Kranz committed
434
435
436

val rd4 = do
 rd <- query $rd;
Axel Simon's avatar
Axel Simon committed
437
 update @{rd=''};
Julian Kranz's avatar
Julian Kranz committed
438
 return (REG (register-from-bits ('1' ^ rd)))
Julian Kranz's avatar
Julian Kranz committed
439
end
Julian Kranz's avatar
Julian Kranz committed
440
441
442
443
444
445

val rd3 = do
 rd <- query $rd;
 update @{rd=''};
 return (REG (register-from-bits ('10' ^ rd)))
end
Julian Kranz's avatar
Julian Kranz committed
446
447
448
449
450
451

val rd2 = do
 rd <- query $rd;
 update @{rd=''};
 return (REG (register-from-bits ('11' ^ rd ^ '0')))
end
Julian Kranz's avatar
Julian Kranz committed
452
 
Julian Kranz's avatar
Julian Kranz committed
453
val rr5 = do
Axel Simon's avatar
Axel Simon committed
454
455
 rr <- query $rr;
 update @{rr=''};
Julian Kranz's avatar
Julian Kranz committed
456
 return (REG (register-from-bits rr))
Julian Kranz's avatar
Julian Kranz committed
457
end
Julian Kranz's avatar
Julian Kranz committed
458
459
 
val rr4 = do
Axel Simon's avatar
Axel Simon committed
460
461
 rr <- query $rr;
 update @{rr=''};
Julian Kranz's avatar
Julian Kranz committed
462
 return (REG (register-from-bits ('1' ^ rr)))
Julian Kranz's avatar
Julian Kranz committed
463
end
Julian Kranz's avatar
Julian Kranz committed
464
465
466
467
468
469
 
val rr3 = do
 rr <- query $rr;
 update @{rr=''};
 return (REG (register-from-bits ('10' ^ rr)))
end
Julian Kranz's avatar
Julian Kranz committed
470

Julian Kranz's avatar
Julian Kranz committed
471
472
val ck4 = do
 ck <- query $ck;
Axel Simon's avatar
Axel Simon committed
473
 update @{ck=''};
Julian Kranz's avatar
Julian Kranz committed
474
475
476
 return (IMM (IMM4 ck))
end

Julian Kranz's avatar
Julian Kranz committed
477
val ck6 = do
Julian Kranz's avatar
Julian Kranz committed
478
 ck <- query $ck;
Axel Simon's avatar
Axel Simon committed
479
 update @{ck=''};
Julian Kranz's avatar
Julian Kranz committed
480
 return (IMM (IMM6 ck))
Julian Kranz's avatar
Julian Kranz committed
481
482
end

Julian Kranz's avatar
Julian Kranz committed
483
484
val ck7 = do
 ck <- query $ck;
Axel Simon's avatar
Axel Simon committed
485
 update @{ck=''};
Julian Kranz's avatar
Julian Kranz committed
486
487
488
 return (IMM (IMM7 ck))
end

Julian Kranz's avatar
Julian Kranz committed
489
490
val ck8 = do
 ck <- query $ck;
Axel Simon's avatar
Axel Simon committed
491
 update @{ck=''};
Julian Kranz's avatar
Julian Kranz committed
492
493
494
 return (IMM (IMM8 ck))
end

Julian Kranz's avatar
Julian Kranz committed
495
496
497
498
499
500
val ck12 = do
 ck <- query $ck;
 update @{ck=''};
 return (IMM (IMM12 ck))
end

Julian Kranz's avatar
Julian Kranz committed
501
502
503
504
505
506
val ck16 = do
 ck <- query $ck;
 update @{ck=''};
 return (IMM (IMM16 ck))
end

Julian Kranz's avatar
Julian Kranz committed
507
508
val ck22 = do
 ck <- query $ck;
Axel Simon's avatar
Axel Simon committed
509
 update @{ck=''};
Julian Kranz's avatar
Julian Kranz committed
510
511
512
 return (IMM (IMM22 ck))
end

Julian Kranz's avatar
Julian Kranz committed
513
514
val cs3 = do
 cs <- query $cs;
Axel Simon's avatar
Axel Simon committed
515
 update @{cs=''};
Julian Kranz's avatar
Julian Kranz committed
516
 return (IMM (IMM3 cs))
Julian Kranz's avatar
Julian Kranz committed
517
518
end

Julian Kranz's avatar
Julian Kranz committed
519
520
val cb3 = do
 cb <- query $cb;
Axel Simon's avatar
Axel Simon committed
521
 update @{cb=''};
Julian Kranz's avatar
Julian Kranz committed
522
523
524
 return (IMM (IMM3 cb))
end

Julian Kranz's avatar
Julian Kranz committed
525
526
527
528
529
530
531
val io5 = do
 io <- query $io;
 update @{io=''};
 return (IOREG (io-register-from-bits ('0' ^ io)))
end

val io6 = do
Julian Kranz's avatar
Julian Kranz committed
532
 io <- query $io;
Axel Simon's avatar
Axel Simon committed
533
 update @{io=''};
Julian Kranz's avatar
Julian Kranz committed
534
535
536
 return (IOREG (io-register-from-bits io))
end

Julian Kranz's avatar
Julian Kranz committed
537
538
539
540
541
542
val dq6 = do
 dq <- query $dq;
 update @{dq=''};
 return (IMM6 dq)
end

Julian Kranz's avatar
Julian Kranz committed
543
val rd2h-rd2l = do
Julian Kranz's avatar
Julian Kranz committed
544
 rd <- query $rd;
Axel Simon's avatar
Axel Simon committed
545
546
547
548
 rd-regl <- return (register-from-bits ('11' ^ rd ^ '0'));
 rd-regh <- return (register-from-bits ('11' ^ rd ^ '1'));
 update @{rd=''};
 return (REGHL {regh=rd-regh,regl=rd-regl})
Julian Kranz's avatar
Julian Kranz committed
549
550
end

Julian Kranz's avatar
Julian Kranz committed
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
val rd4h-rd4l = do
 rd <- query $rd;
 rd-regl <- return (register-from-bits (rd ^ '0'));
 rd-regh <- return (register-from-bits (rd ^ '1'));
 update @{rd=''};
 return (REGHL {regh=rd-regh,regl=rd-regl})
end

val rr4h-rr4l = do
 rr <- query $rr;
 rr-regl <- return (register-from-bits (rr ^ '0'));
 rr-regh <- return (register-from-bits (rr ^ '1'));
 update @{rr=''};
 return (REGHL {regh=rr-regh,regl=rr-regl})
end

Julian Kranz's avatar
Julian Kranz committed
567
568
569
val binop cons first second = do
 first <- first;
 second <- second;
Axel Simon's avatar
Axel Simon committed
570
 return (cons {first=first, second=second})
Julian Kranz's avatar
Julian Kranz committed
571
572
end

Julian Kranz's avatar
Julian Kranz committed
573
574
val unop cons operand = do
 operand <- operand;
Axel Simon's avatar
Axel Simon committed
575
 return (cons {operand=operand})
Julian Kranz's avatar
Julian Kranz committed
576
577
end

Julian Kranz's avatar
Julian Kranz committed
578
val nullop cons = do
Axel Simon's avatar
Axel Simon committed
579
 return cons
Julian Kranz's avatar
Julian Kranz committed
580
581
end

Julian Kranz's avatar
Julian Kranz committed
582
583
### ADC
###  - Add with Carry
Axel Simon's avatar
Axel Simon committed
584
val / ['000111 r d d d d d r r r r '] = binop ADC rd5 rr5
Julian Kranz's avatar
Julian Kranz committed
585
586
587

### ADD
###  - Add without Carry
Axel Simon's avatar
Axel Simon committed
588
val / ['000011 r d d d d d r r r r '] = binop ADD rd5 rr5
Julian Kranz's avatar
Julian Kranz committed
589
590
591

### ADIW
###  - Add Immediate to Word
Julian Kranz's avatar
Julian Kranz committed
592
val / ['10010110 k k d d k k k k '] = binop ADIW rd2h-rd2l ck6
Julian Kranz's avatar
Julian Kranz committed
593
594
595

### AND
###  - Logical AND
Axel Simon's avatar
Axel Simon committed
596
val / ['001000 r d d d d d r r r r '] = binop AND rd5 rr5
Julian Kranz's avatar
Julian Kranz committed
597
598
599

### ANDI
###  - Logical AND with Immediate
Axel Simon's avatar
Axel Simon committed
600
val / ['0111 k k k k d d d d k k k k '] = binop ANDI rd4 ck8
Julian Kranz's avatar
Julian Kranz committed
601
602
603

### ASR
###  - Arithmetic Shift Right
Axel Simon's avatar
Axel Simon committed
604
val / ['1001010 d d d d d 0101'] = unop ASR rd5
Julian Kranz's avatar
Julian Kranz committed
605
606
607

### BCLR
###  - Bit Clear in SREG
mb0's avatar
Up.    
mb0 committed
608
609
### => see CLC,CLZ,...
#val / ['100101001 s s s 1000'] = unop BCLR cs3
Julian Kranz's avatar
Julian Kranz committed
610
611
612

### BLD
###  - Bit Load from the T Flag in SREG to a Bit in Register
Axel Simon's avatar
Axel Simon committed
613
val / ['1111100 d d d d d 0 b b b '] = binop BLD rd5 cb3
Julian Kranz's avatar
Julian Kranz committed
614
615
616

### BRBC
###  - Branch if Bit in SREG is Cleared
Julian Kranz's avatar
Julian Kranz committed
617
618
###  => see below
#val / ['111101 k k k k k k k s s s '] = binop BRBC cs3 ck7
Julian Kranz's avatar
Julian Kranz committed
619
620
621

### BRBS
###  - Branch if Bit in SREG is Set
Julian Kranz's avatar
Julian Kranz committed
622
623
624
625
626
627
628
629
630
631
632
633
###  => see below
#val / ['111100 k k k k k k k s s s '] = binop BRBS cs3 ck7

### BRCC
###  - Branch if Carry Cleared
###  => see BRSH
#val / ['111101 k k k k k k k 000'] = unop BRCC ck7

### BRCS
###  - Branch if Carry Set
###  => see BRLO
#val / ['111100 k k k k k k k 000'] = unop BRCS ck7
Julian Kranz's avatar
Julian Kranz committed
634
635
636
637
638

### BREAK
###  - Break
val / ['1001010110011000'] = nullop BREAK

Julian Kranz's avatar
Julian Kranz committed
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
### BREQ
###  - Branch if Equal
val / ['111100 k k k k k k k 001'] = unop BREQ ck7

### BRGE
###  - Branch if Greater or Equal (Signed)
val / ['111101 k k k k k k k 100'] = unop BRGE ck7

### BRHC
###  - Branch if Half Carry Flag is Cleared
val / ['111101 k k k k k k k 101'] = unop BRHC ck7

### BRHS
###  - Branch if Half Carry Flag is Set
val / ['111100 k k k k k k k 101'] = unop BRHS ck7

### BRID
###  - Branch if Global Interrupt is Disabled
val / ['111101 k k k k k k k 111'] = unop BRID ck7

### BRIE
###  - Branch if Global Interrupt is Enabled
val / ['111100 k k k k k k k 111'] = unop BRIE ck7

### BRLO
###  - Branch if Lower (Unsigned)
val / ['111100 k k k k k k k 000'] = unop BRLO ck7

### BRLT
###  - Branch if Less Than (Signed)
val / ['111100 k k k k k k k 100'] = unop BRLT ck7

### BRMI
###  - Branch if Minus
val / ['111100 k k k k k k k 010'] = unop BRMI ck7

### BRNE
###  - Branch if Not Equal
val / ['111101 k k k k k k k 001'] = unop BRNE ck7

### BRPL
###  - Branch if Plus
val / ['111101 k k k k k k k 010'] = unop BRPL ck7

### BRSH
###  - Branch if Same or Higher (Unsigned)
val / ['111101 k k k k k k k 000'] = unop BRSH ck7

### BRTC
###  - Branch if the T Flag is Cleared
val / ['111101 k k k k k k k 110'] = unop BRTC ck7

### BRTS
###  - Branch if the T Flag is Set
val / ['111100 k k k k k k k 110'] = unop BRTS ck7

### BRVC
###  - Branch if Overflow Cleared
val / ['111101 k k k k k k k 011'] = unop BRVC ck7

### BRVS
###  - Branch if Overflow Set
val / ['111100 k k k k k k k 011'] = unop BRVS ck7

Julian Kranz's avatar
Julian Kranz committed
703
704
### BSET
###  - Bit Set in SREG
mb0's avatar
Up.    
mb0 committed
705
706
### => see SEC,SEZ,...
#val / ['100101000 s s s 1000'] = unop BSET cs3
Julian Kranz's avatar
Julian Kranz committed
707
708
709

### BST
###  - Bit Store from Bit in Register to T Flag in SREG
Axel Simon's avatar
Axel Simon committed
710
val / ['1111101 d d d d d 0 b b b '] = binop BST rd5 cb3
Julian Kranz's avatar
Julian Kranz committed
711
712
713

### CALL
###  - Long Call to a Subroutine
Axel Simon's avatar
Axel Simon committed
714
val / ['1001010 k k k k k 111 k ' 'k k k k k k k k k k k k k k k k '] = unop CALL ck22
Julian Kranz's avatar
Julian Kranz committed
715
716
717

### CBI
###  - Clear Bit in I/O Register
Julian Kranz's avatar
Julian Kranz committed
718
val / ['10011000 a a a a a b b b '] = binop CBI io5 cb3
Julian Kranz's avatar
Julian Kranz committed
719

Julian Kranz's avatar
Julian Kranz committed
720
721
722
723
### CBR
###  - Clear Bit in I/O Register
###  => see ANDI with K complemented

Julian Kranz's avatar
Julian Kranz committed
724
725
726
### CLC
###  - Clear Carry Flag
val / ['1001010010001000'] = nullop CLC
Julian Kranz's avatar
Julian Kranz committed
727
728
729
730
731
732
733
734
735
736
737
738
739

### CLH
###  - Clear Half Carry Flag
val / ['1001010011011000'] = nullop CLH

### CLI
###  - Clear Global Interrupt Flag
val / ['1001010011111000'] = nullop CLI

### CLN
###  - Clear Negative Flag
val / ['1001010010101000'] = nullop CLN

Julian Kranz's avatar
Julian Kranz committed
740
741
742
743
### CLR
###  - Clear Negative Flag
###  => see EOR Rd, Rd

Julian Kranz's avatar
Julian Kranz committed
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
### CLS
###  - Clear Signed Flag
val / ['1001010011001000'] = nullop CLS

### CLT
###  - Clear T Flag
val / ['1001010011101000'] = nullop CLT

### CLV
###  - Clear Overflow Flag
val / ['1001010010111000'] = nullop CLV

### CLZ
###  - Clear Zero Flag
val / ['1001010010011000'] = nullop CLZ

### COM
###  - Ones Complement
Axel Simon's avatar
Axel Simon committed
762
val / ['1001010 d d d d d 0000'] = unop COM rd5
Julian Kranz's avatar
Julian Kranz committed
763
764
765

### CP
###  - Compare
Axel Simon's avatar
Axel Simon committed
766
val / ['000101 r d d d d d r r r r '] = binop CP rd5 rr5
Julian Kranz's avatar
Julian Kranz committed
767
768
769

### CPC
###  - Compare with Carry
Axel Simon's avatar
Axel Simon committed
770
val / ['000001 r d d d d d r r r r '] = binop CPC rd5 rr5
Julian Kranz's avatar
Julian Kranz committed
771
772
773

### CPI
###  - Compare with Immediate
Axel Simon's avatar
Axel Simon committed
774
val / ['0011 k k k k d d d d k k k k '] = binop CPI rd4 ck8
Julian Kranz's avatar
Julian Kranz committed
775
776
777

### CPSE
###  - Compare Skip if Equal
Axel Simon's avatar
Axel Simon committed
778
val / ['000100 r d d d d d r r r r '] = binop CPSE rd5 rr5
Julian Kranz's avatar
Julian Kranz committed
779
780
781

### DEC
###  - Decrement
Axel Simon's avatar
Axel Simon committed
782
val / ['1001010 d d d d d 1010'] = unop DEC rd5
Julian Kranz's avatar
Julian Kranz committed
783
784
785

### DES
###  - Data Encryption Standard
Axel Simon's avatar
Axel Simon committed
786
val / ['10010100 k k k k 1011'] = unop DES ck4
Julian Kranz's avatar
Julian Kranz committed
787
788
789
790
791
792
793
794
795
796
797

### EICALL
###  - Extended Indirect Call to Subroutine
val / ['1001010100011001'] = nullop EICALL

### EIJMP
###  - Extended Indirect Jump
val / ['1001010000011001'] = nullop EIJMP

### ELPM
###  - Extended Load Program Memory
Julian Kranz's avatar
Julian Kranz committed
798
799
800
val / ['1001010111011000'] = binop ELPM r0 (//Z NONE)
val / ['1001000 d d d d d 0110'] = binop ELPM rd5 (//Z NONE)
val / ['1001000 d d d d d 0111'] = binop ELPM rd5 (//Z INCR)
Julian Kranz's avatar
Julian Kranz committed
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828

### EOR
###  - Exclusive OR
val / ['001001 r d d d d d r r r r '] = binop EOR rd5 rr5

### FMUL
###  - Fractional Multiply Unsigned
val / ['000000110 d d d 1 r r r '] = binop FMUL rd3 rr3

### FMULS
###  - Fractional Multiply Signed
val / ['000000111 d d d 0 r r r '] = binop FMULS rd3 rr3

### FMULSU
###  - Fractional Multiply Signed with Unsigned
val / ['000000111 d d d 1 r r r '] = binop FMULSU rd3 rr3

### ICALL
###  - Indirect Call to Subroutine
val / ['1001010100001001'] = nullop ICALL

### IJMP
###  - Indirect Jump
val / ['1001010000001001'] = nullop IJMP

### IN
###  - Load an I/O Location to Register
val / ['10110 a a d d d d d a a a a '] = binop IN rd5 io6
Julian Kranz's avatar
Julian Kranz committed
829
830
831
832
833
834
835
836
837
838
839

### INC
###  - Increment
val / ['1001010 d d d d d 0011'] = unop INC rd5

### JMP
###  - Jump
val / ['1001 010 k k k k k 110 k ' 'k k k k k k k k k k k k k k k k '] = unop JMP ck22

### LAC
###  - Load And Clear
Julian Kranz's avatar
Julian Kranz committed
840
val / ['1001001 d d d d d 0110'] = binop LAC /Z rd5
Julian Kranz's avatar
Julian Kranz committed
841
842
843

### LAS
###  - Load And Set
Julian Kranz's avatar
Julian Kranz committed
844
val / ['1001001 d d d d d 0101'] = binop LAS /Z rd5
Julian Kranz's avatar
Julian Kranz committed
845
846
847

### LAT
###  - Load And Toggle
Julian Kranz's avatar
Julian Kranz committed
848
val / ['1001001 d d d d d 0111'] = binop LAT /Z rd5
Julian Kranz's avatar
Julian Kranz committed
849
850
851

### LD
###  - Load Indirect from Data Space to Register using Index X
Julian Kranz's avatar
Julian Kranz committed
852
853
854
val / ['1001000 d d d d d 1100'] = binop LD rd5 (//X NONE)
val / ['1001000 d d d d d 1101'] = binop LD rd5 (//X INCR)
val / ['1001000 d d d d d 1110'] = binop LD rd5 (//X DECR)
Julian Kranz's avatar
Julian Kranz committed
855
856
857

### LD
###  - Load Indirect from Data Space to Register using Index Y
mb0's avatar
Up.    
mb0 committed
858
#val / ['1000000 d d d d d 1000'] = binop LD rd5 (//Y NONE)
Julian Kranz's avatar
Julian Kranz committed
859
860
861
val / ['1001000 d d d d d 1001'] = binop LD rd5 (//Y INCR)
val / ['1001000 d d d d d 1010'] = binop LD rd5 (//Y DECR)
val / ['10 q 0 q q 0 d d d d d 1 q q q '] = binop LD rd5 (///Y dq6)
Julian Kranz's avatar
Julian Kranz committed
862
863
864

### LD
###  - Load Indirect from Data Space to Register using Index Z
mb0's avatar
Up.    
mb0 committed
865
#val / ['1000000 d d d d d 0000'] = binop LD rd5 (//Z NONE)
Julian Kranz's avatar
Julian Kranz committed
866
867
868
869
870
871
872
873
874
875
876
val / ['1001000 d d d d d 0001'] = binop LD rd5 (//Z INCR)
val / ['1001000 d d d d d 0010'] = binop LD rd5 (//Z DECR)
val / ['10 q 0 q q 0 d d d d d 0 q q q '] = binop LD rd5 (///Z dq6)

### LDI
###  - Load Immediate
val / ['1110 k k k k d d d d k k k k '] = binop LDI rd4 ck8

### LDS
###  - Load Direct from Data Space
val / ['1001000 d d d d d 0000' 'k k k k k k k k k k k k k k k k '] = binop LDS rd5 ck16
mb0's avatar
Up.    
mb0 committed
877
#val / ['10100 k k k d d d d k k k k '] = binop LDS rd4 ck7
Julian Kranz's avatar
Julian Kranz committed
878
879
880
881
882
883
884

### LPM
###  - Load Program Memory
val / ['1001010111001000'] = binop LPM r0 (//Z NONE)
val / ['1001000 d d d d d 0100'] = binop LPM rd5 (//Z NONE)
val / ['1001000 d d d d d 0101'] = binop LPM rd5 (//Z INCR)

Julian Kranz's avatar
Julian Kranz committed
885
886
887
888
### LSL
###  - Logical Shift Left
###  => see ADD Rd, Rd

Julian Kranz's avatar
Julian Kranz committed
889
890
891
### LSR
###  - Logical Shift Right
val / ['1001010 d d d d d 0110'] = unop LSR rd5
Julian Kranz's avatar
Julian Kranz committed
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956

### MOV
###  - Copy Register
val / ['001011 r d d d d d r r r r '] = binop MOV rd5 rr5

### MOVW
###  - Copy Register Word
val / ['00000001 d d d d r r r r '] = binop MOVW rd4h-rd4l rr4h-rr4l

### MUL
###  - Multiply Unsigned
val / ['100111 r d d d d d r r r r '] = binop MUL rd5 rr5

### MULS
###  - Multiply Signed
val / ['00000010 d d d d r r r r '] = binop MULS rd4 rr4

### MULSU
###  - MULSU  Multiply Signed with Unsigned
val / ['000000110 d d d 0 r r r '] = binop MULSU rd3 rr3

### NEG
###  - Twos Complement
val / ['1001010 d d d d d 0001'] = unop NEG rd5

### NOP
###  - No Operation
val / ['0000000000000000'] = nullop NOP

### OR
###  - Logical OR
val / ['001010 r d d d d d r r r r '] = binop OR rd5 rr5

### ORI
###  - Logical OR with Immediate
val / ['0110 k k k k d d d d k k k k '] = binop ORI rd4 ck8

### OUT
###  - Store Register to I/O Location
val / ['10111 a a r r r r r a a a a '] = binop OUT io6 rr5

### POP
###  - Pop Register from Stack
val / ['1001000 d d d d d 1111'] = unop POP rd5

### PUSH
###  - Push Register on Stack
val / ['1001001 r r r r r 1111'] = unop PUSH rr5

### RCALL
###  - Relative Call to Subroutine
val / ['1101 k k k k k k k k k k k k '] = unop RCALL ck12

### RET
###  - Return from Subroutine
val / ['1001010100001000'] = nullop RET

### RETI
###  - Return from Interrupt
val / ['1001010100011000'] = nullop RETI

### RJMP
###  - Relative Jump
val / ['1100 k k k k k k k k k k k k '] = unop RJMP ck12

Julian Kranz's avatar
Julian Kranz committed
957
958
959
960
### ROL
###  - Rotate Left trough Carry
###  => see ADC Rd, Rd

Julian Kranz's avatar
Julian Kranz committed
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
### ROR
###  - Rotate Right through Carry
val / ['1001010 d d d d d 0111'] = unop ROR rd5

### SBC
###  - Subtract with Carry
val / ['000010 r d d d d d r r r r '] = binop SBC rd5 rr5

### SBCI
###  - Subtract Immediate with Carry
val / ['0100 k k k k d d d d k k k k '] = binop SBCI rd4 ck8

### SBI
###  - Set Bit in I/O Register
val / ['10011010 a a a a a b b b '] = binop SBI io5 cb3

### SBIC
###  - Skip if Bit in I/O Register is Cleared
val / ['10011001 a a a a a b b b '] = binop SBIC io5 cb3

### SBIS
###  - Skip if Bit in I/O Register is Set
val / ['10011011 a a a a a b b b '] = binop SBIS io5 cb3
Julian Kranz's avatar
Julian Kranz committed
984
985
986
987
988
989
990

### SBIW
###  - Subtract Immediate from Word
val / ['10010111 k k d d k k k k '] = binop SBIW rd2 ck6

### SBR
###  - Set Bits in Register
mb0's avatar
Up.    
mb0 committed
991
992
### => see ORI
#val / ['0110 k k k k d d d d k k k k '] = binop SBR rd4 ck8
Julian Kranz's avatar
Julian Kranz committed
993
994
995
996
997
998
999
1000

### SBRC
###  - Skip if Bit in Register is Cleared
val / ['1111110 r r r r r 0 b b b '] = binop SBRC rr5 cb3

### SBRS
###  - Skip if Bit in Register is Set
val / ['1111111 r r r r r 0 b b b '] = binop SBRS rr5 cb3