about summary refs log tree commit diff stats
path: root/test/arch/x86/unit/mn_stack.py
blob: f9cfc60a76d8515248fd577b1172e86acc4ce127 (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
57
58
59
60
61
62
63
#! /usr/bin/env python2

import sys

from asm_test import Asm_Test_32


class Test_PUSHPOP(Asm_Test_32):
    TXT = '''
    main:
       MOV     EBP, ESP
       PUSH    0x11223344
       POP     EAX
       CMP     EBP, ESP
       JNZ     BAD

       PUSHW   0x1122
       POPW    AX
       CMP     EBP, ESP
       JNZ     BAD

       PUSH    SS
       POP     EAX
       CMP     EBP, ESP
       JNZ     BAD

       PUSHW   SS
       POPW    AX
       CMP     EBP, ESP
       JNZ     BAD

       PUSHFD
       POP     EAX
       CMP     EBP, ESP
       JNZ     BAD

       PUSHFW
       POPW    AX
       CMP     EBP, ESP
       JNZ     BAD

       PUSH    EAX
       POPFD
       CMP     EBP, ESP
       JNZ     BAD

       PUSHW   AX
       POPFW
       CMP     EBP, ESP
       JNZ     BAD

       RET

BAD:
       INT     0x3
       RET
    '''
    def check(self):
        assert(self.myjit.cpu.ESP-4 == self.myjit.cpu.EBP)


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