about summary refs log tree commit diff stats
path: root/test/arch/x86/unit/mn_psrl_psll.py
blob: 7d9572b0e07ace4dca569d83e5acf21c6001c380 (plain) (blame)
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
#! /usr/bin/env python2
import sys

from asm_test import Asm_Test_32

class Test_PSRL(Asm_Test_32):
    TXT = '''
    main:
       CALL   next
       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
       .byte 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
    next:
       POP    EBP
       MOVQ   MM0, QWORD PTR [EBP]
       MOVQ   MM1, MM0
       MOVQ   MM2, MM0
       MOVQ   MM3, MM0
       PSRLW  MM1, QWORD PTR [EBP+0x8]
       PSRLD  MM2, QWORD PTR [EBP+0x8]
       PSRLQ  MM3, QWORD PTR [EBP+0x8]
       RET
    '''

    def check(self):
        assert self.myjit.cpu.MM0 == 0x1122334455667788
        assert self.myjit.cpu.MM1 == 0x0112033405560778
        assert self.myjit.cpu.MM2 == 0x0112233405566778
        assert self.myjit.cpu.MM3 == 0x0112233445566778

class Test_PSLL(Asm_Test_32):
    TXT = '''
    main:
       CALL   next
       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
       .byte 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
    next:
       POP    EBP
       MOVQ   MM0, QWORD PTR [EBP]
       MOVQ   MM1, MM0
       MOVQ   MM2, MM0
       MOVQ   MM3, MM0
       PSLLW  MM1, QWORD PTR [EBP+0x8]
       PSLLD  MM2, QWORD PTR [EBP+0x8]
       PSLLQ  MM3, QWORD PTR [EBP+0x8]
       RET
    '''

    def check(self):
        assert self.myjit.cpu.MM0 == 0x1122334455667788
        assert self.myjit.cpu.MM1 == 0x1220344056607880
        assert self.myjit.cpu.MM2 == 0x1223344056677880
        assert self.myjit.cpu.MM3 == 0x1223344556677880


if __name__ == "__main__":
    [test(*sys.argv[1:])() for test in [Test_PSRL, Test_PSLL]]