aboutsummaryrefslogtreecommitdiffstats
path: root/users/replicaJunction/readme.md
blob: 2a9cad2729eb4ec1d9bd20d38fc94adf89603378 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Copyright 2018 @<replicaJunction>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#include<stdio.h>
#include<assert.h>

int main()
{
    int rd, rs, rt;
    int dsp;
    int result;

    rs     = 0xFFFFFFFF;
    rt     = 0x10101010;
    result = 0x100F100F;
    __asm
        ("addq_s.ph   %0, %1, %2\n\t"
         : "=r"(rd)
         : "r"(rs), "r"(rt)
        );
    assert(result == rd);

    rs     = 0x3712847D;
    rt     = 0x0031AF2D;
    result = 0x37438000;
    __asm
        ("addq_s.ph   %0, %1, %2\n\t"
         : "=r"(rd)
         : "r"(rs), "r"(rt)
        );
    assert(result == rd);

    __asm
        ("rddsp %0\n\t"
         : "=r"(dsp)
        );
    assert(((dsp >> 20) & 0x01) == 1);

    rs     = 0x7fff847D;
    rt     = 0x0031AF2D;
    result = 0x7fff8000;
    __asm
        ("addq_s.ph   %0, %1, %2\n\t"
         : "=r"(rd)
         : "r"(rs), "r"(rt)
        );
    assert(result == rd);

    __asm
        ("rddsp %0\n\t"
         : "=r"(dsp)
        );
    assert(((dsp >> 20) & 0x01) == 1);

    rs     = 0x8030847D;
    rt     = 0x8a00AF2D;
    result = 0x80008000;
    __asm
        ("addq_s.ph   %0, %1, %2\n\t"
         : "=r"(rd)
         : "r"(rs), "r"(rt)
        );
    assert(result == rd);

    __asm
        ("rddsp %0\n\t"
         : "=r"(dsp)
        );
    assert(((dsp >> 20) & 0x01) == 1);

    return 0;
}