xref: /qemu/target/avr/insn.decode (revision 865f3bb9e16365a27efaf3e5b4787fd402764484)
1*865f3bb9SMichael Rolnik#
2*865f3bb9SMichael Rolnik# AVR instruction decode definitions.
3*865f3bb9SMichael Rolnik#
4*865f3bb9SMichael Rolnik# Copyright (c) 2019-2020 Michael Rolnik <mrolnik@gmail.com>
5*865f3bb9SMichael Rolnik#
6*865f3bb9SMichael Rolnik# This library is free software; you can redistribute it and/or
7*865f3bb9SMichael Rolnik# modify it under the terms of the GNU Lesser General Public
8*865f3bb9SMichael Rolnik# License as published by the Free Software Foundation; either
9*865f3bb9SMichael Rolnik# version 2.1 of the License, or (at your option) any later version.
10*865f3bb9SMichael Rolnik#
11*865f3bb9SMichael Rolnik# This library is distributed in the hope that it will be useful,
12*865f3bb9SMichael Rolnik# but WITHOUT ANY WARRANTY; without even the implied warranty of
13*865f3bb9SMichael Rolnik# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14*865f3bb9SMichael Rolnik# Lesser General Public License for more details.
15*865f3bb9SMichael Rolnik#
16*865f3bb9SMichael Rolnik# You should have received a copy of the GNU Lesser General Public
17*865f3bb9SMichael Rolnik# License along with this library; if not, see <http://www.gnu.org/licenses/>.
18*865f3bb9SMichael Rolnik#
19*865f3bb9SMichael Rolnik
20*865f3bb9SMichael Rolnik#
21*865f3bb9SMichael Rolnik#   regs_16_31_by_one = [16 .. 31]
22*865f3bb9SMichael Rolnik#   regs_16_23_by_one = [16 .. 23]
23*865f3bb9SMichael Rolnik#   regs_24_30_by_two = [24, 26, 28, 30]
24*865f3bb9SMichael Rolnik#   regs_00_30_by_two = [0, 2, 4, 6, 8, .. 30]
25*865f3bb9SMichael Rolnik
26*865f3bb9SMichael Rolnik%rd             4:5
27*865f3bb9SMichael Rolnik%rr             9:1 0:4
28*865f3bb9SMichael Rolnik
29*865f3bb9SMichael Rolnik%rd_a           4:4                         !function=to_regs_16_31_by_one
30*865f3bb9SMichael Rolnik%rd_b           4:3                         !function=to_regs_16_23_by_one
31*865f3bb9SMichael Rolnik%rd_c           4:2                         !function=to_regs_24_30_by_two
32*865f3bb9SMichael Rolnik%rr_a           0:4                         !function=to_regs_16_31_by_one
33*865f3bb9SMichael Rolnik%rr_b           0:3                         !function=to_regs_16_23_by_one
34*865f3bb9SMichael Rolnik
35*865f3bb9SMichael Rolnik%imm6           6:2 0:4
36*865f3bb9SMichael Rolnik%imm8           8:4 0:4
37*865f3bb9SMichael Rolnik
38*865f3bb9SMichael Rolnik%io_imm         9:2 0:4
39*865f3bb9SMichael Rolnik%ldst_d_imm     13:1 10:2 0:3
40*865f3bb9SMichael Rolnik
41*865f3bb9SMichael Rolnik
42*865f3bb9SMichael Rolnik&rd_rr          rd rr
43*865f3bb9SMichael Rolnik&rd_imm         rd imm
44*865f3bb9SMichael Rolnik
45*865f3bb9SMichael Rolnik@op_rd_rr       .... .. . ..... ....        &rd_rr      rd=%rd rr=%rr
46*865f3bb9SMichael Rolnik@op_rd_imm6     .... .... .. .. ....        &rd_imm     rd=%rd_c imm=%imm6
47*865f3bb9SMichael Rolnik@op_rd_imm8     .... .... .... ....         &rd_imm     rd=%rd_a imm=%imm8
48*865f3bb9SMichael Rolnik@fmul           .... .... . ... . ...       &rd_rr      rd=%rd_b rr=%rr_b
49*865f3bb9SMichael Rolnik
50*865f3bb9SMichael Rolnik#
51*865f3bb9SMichael Rolnik# Arithmetic Instructions
52*865f3bb9SMichael Rolnik#
53*865f3bb9SMichael RolnikADD             0000 11 . ..... ....        @op_rd_rr
54*865f3bb9SMichael RolnikADC             0001 11 . ..... ....        @op_rd_rr
55*865f3bb9SMichael RolnikADIW            1001 0110 .. .. ....        @op_rd_imm6
56*865f3bb9SMichael RolnikSUB             0001 10 . ..... ....        @op_rd_rr
57*865f3bb9SMichael RolnikSUBI            0101 .... .... ....         @op_rd_imm8
58*865f3bb9SMichael RolnikSBC             0000 10 . ..... ....        @op_rd_rr
59*865f3bb9SMichael RolnikSBCI            0100 .... .... ....         @op_rd_imm8
60*865f3bb9SMichael RolnikSBIW            1001 0111 .. .. ....        @op_rd_imm6
61*865f3bb9SMichael RolnikAND             0010 00 . ..... ....        @op_rd_rr
62*865f3bb9SMichael RolnikANDI            0111 .... .... ....         @op_rd_imm8
63*865f3bb9SMichael RolnikOR              0010 10 . ..... ....        @op_rd_rr
64*865f3bb9SMichael RolnikORI             0110 .... .... ....         @op_rd_imm8
65*865f3bb9SMichael RolnikEOR             0010 01 . ..... ....        @op_rd_rr
66*865f3bb9SMichael RolnikCOM             1001 010 rd:5 0000
67*865f3bb9SMichael RolnikNEG             1001 010 rd:5 0001
68*865f3bb9SMichael RolnikINC             1001 010 rd:5 0011
69*865f3bb9SMichael RolnikDEC             1001 010 rd:5 1010
70*865f3bb9SMichael RolnikMUL             1001 11 . ..... ....        @op_rd_rr
71*865f3bb9SMichael RolnikMULS            0000 0010 .... ....         &rd_rr      rd=%rd_a rr=%rr_a
72*865f3bb9SMichael RolnikMULSU           0000 0011 0 ... 0 ...       @fmul
73*865f3bb9SMichael RolnikFMUL            0000 0011 0 ... 1 ...       @fmul
74*865f3bb9SMichael RolnikFMULS           0000 0011 1 ... 0 ...       @fmul
75*865f3bb9SMichael RolnikFMULSU          0000 0011 1 ... 1 ...       @fmul
76*865f3bb9SMichael RolnikDES             1001 0100 imm:4 1011
77