root / tests / test-i386-code16.S @ 0443eaf6
History | View | Annotate | Download (1.6 kB)
1 | e5918247 | bellard | .code16 |
---|---|---|---|
2 | e5918247 | bellard | .globl code16_start |
3 | e5918247 | bellard | .globl code16_end |
4 | e5918247 | bellard | |
5 | e5918247 | bellard | CS_SEG = 0xf |
6 | e5918247 | bellard | |
7 | e5918247 | bellard | code16_start: |
8 | e5918247 | bellard | |
9 | e5918247 | bellard | .globl code16_func1 |
10 | e5918247 | bellard | |
11 | e5918247 | bellard | /* basic test */ |
12 | e5918247 | bellard | code16_func1 = . - code16_start |
13 | e5918247 | bellard | mov $1, %eax |
14 | e5918247 | bellard | data32 lret |
15 | e5918247 | bellard | |
16 | e5918247 | bellard | /* test push/pop in 16 bit mode */ |
17 | e5918247 | bellard | .globl code16_func2 |
18 | e5918247 | bellard | code16_func2 = . - code16_start |
19 | e5918247 | bellard | xor %eax, %eax |
20 | e5918247 | bellard | mov $0x12345678, %ebx |
21 | e5918247 | bellard | movl %esp, %ecx |
22 | e5918247 | bellard | push %bx |
23 | e5918247 | bellard | subl %esp, %ecx |
24 | e5918247 | bellard | pop %ax |
25 | e5918247 | bellard | data32 lret |
26 | e5918247 | bellard | |
27 | e5918247 | bellard | /* test various jmp opcodes */ |
28 | e5918247 | bellard | .globl code16_func3 |
29 | e5918247 | bellard | code16_func3 = . - code16_start |
30 | e5918247 | bellard | jmp 1f |
31 | e5918247 | bellard | nop |
32 | e5918247 | bellard | 1: |
33 | e5918247 | bellard | mov $4, %eax |
34 | e5918247 | bellard | mov $0x12345678, %ebx |
35 | e5918247 | bellard | xor %bx, %bx |
36 | e5918247 | bellard | jz 2f |
37 | e5918247 | bellard | add $2, %ax |
38 | e5918247 | bellard | 2: |
39 | e5918247 | bellard | |
40 | e5918247 | bellard | call myfunc |
41 | e5918247 | bellard | |
42 | e5918247 | bellard | lcall $CS_SEG, $(myfunc2 - code16_start) |
43 | e5918247 | bellard | |
44 | e5918247 | bellard | ljmp $CS_SEG, $(myjmp1 - code16_start) |
45 | e5918247 | bellard | myjmp1_next: |
46 | e5918247 | bellard | |
47 | e5918247 | bellard | cs lcall myfunc2_addr - code16_start |
48 | e5918247 | bellard | |
49 | e5918247 | bellard | cs ljmp myjmp2_addr - code16_start |
50 | e5918247 | bellard | myjmp2_next: |
51 | e5918247 | bellard | |
52 | e5918247 | bellard | data32 lret |
53 | e5918247 | bellard | |
54 | e5918247 | bellard | myfunc2_addr: |
55 | e5918247 | bellard | .short myfunc2 - code16_start |
56 | e5918247 | bellard | .short CS_SEG |
57 | e5918247 | bellard | |
58 | e5918247 | bellard | myjmp2_addr: |
59 | e5918247 | bellard | .short myjmp2 - code16_start |
60 | e5918247 | bellard | .short CS_SEG |
61 | e5918247 | bellard | |
62 | e5918247 | bellard | myjmp1: |
63 | e5918247 | bellard | add $8, %ax |
64 | e5918247 | bellard | jmp myjmp1_next |
65 | e5918247 | bellard | |
66 | e5918247 | bellard | myjmp2: |
67 | e5918247 | bellard | add $16, %ax |
68 | e5918247 | bellard | jmp myjmp2_next |
69 | e5918247 | bellard | |
70 | e5918247 | bellard | myfunc: |
71 | e5918247 | bellard | add $1, %ax |
72 | e5918247 | bellard | ret |
73 | e5918247 | bellard | |
74 | e5918247 | bellard | myfunc2: |
75 | e5918247 | bellard | add $4, %ax |
76 | e5918247 | bellard | lret |
77 | e5918247 | bellard | |
78 | e5918247 | bellard | |
79 | e5918247 | bellard | code16_end: |
80 | dd3587f3 | bellard | |
81 | dd3587f3 | bellard | |
82 | dd3587f3 | bellard | /* other 32 bits tests */ |
83 | dd3587f3 | bellard | .code32 |
84 | dd3587f3 | bellard | |
85 | dd3587f3 | bellard | .globl func_lret32 |
86 | dd3587f3 | bellard | func_lret32: |
87 | dd3587f3 | bellard | movl $0x87654321, %eax |
88 | dd3587f3 | bellard | lret |
89 | dd3587f3 | bellard | |
90 | dd3587f3 | bellard | .globl func_iret32 |
91 | dd3587f3 | bellard | func_iret32: |
92 | dd3587f3 | bellard | movl $0xabcd4321, %eax |
93 | dd3587f3 | bellard | iret |
94 | dd3587f3 | bellard | |
95 | dd3587f3 | bellard | |
96 | dd3587f3 | bellard | |
97 | e5918247 | bellard |