VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-asm.asm@ 97441

Last change on this file since 97441 was 97431, checked in by vboxsync, 2 years ago

ValKit/bs3-cpu-basic-2: Working a JMP test... bugref:9898

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 KB
Line 
1; $Id: bs3-cpu-basic-2-asm.asm 97431 2022-11-07 13:53:24Z vboxsync $
2;; @file
3; BS3Kit - bs3-cpu-basic-2
4;
5
6;
7; Copyright (C) 2007-2022 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
27; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28; in the VirtualBox distribution, in which case the provisions of the
29; CDDL are applicable instead of those of the GPL.
30;
31; You may elect to license modified versions of this file under the
32; terms and conditions of either the GPL or the CDDL or both.
33;
34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
36
37
38;*********************************************************************************************************************************
39;* Header Files *
40;*********************************************************************************************************************************
41%include "bs3kit.mac"
42
43
44;*********************************************************************************************************************************
45;* Global Variables *
46;*********************************************************************************************************************************
47BS3_BEGIN_DATA16
48BS3_GLOBAL_DATA g_bs3CpuBasic2_ud2_FlatAddr, 4
49 dd _bs3CpuBasic2_ud2 wrt FLAT
50
51
52
53;
54; CPU mode agnostic test code snippets.
55;
56BS3_BEGIN_TEXT16
57
58BS3_PROC_BEGIN _bs3CpuBasic2_ud2
59.again:
60 ud2
61 jmp .again
62BS3_PROC_END _bs3CpuBasic2_ud2
63
64
65BS3_PROC_BEGIN _bs3CpuBasic2_Int80
66 int 80h
67.again: ud2
68 jmp .again
69BS3_PROC_END _bs3CpuBasic2_Int80
70
71
72BS3_PROC_BEGIN _bs3CpuBasic2_Int81
73 int 81h
74.again: ud2
75 jmp .again
76BS3_PROC_END _bs3CpuBasic2_Int81
77
78
79BS3_PROC_BEGIN _bs3CpuBasic2_Int82
80 int 82h
81.again: ud2
82 jmp .again
83BS3_PROC_END _bs3CpuBasic2_Int82
84
85
86BS3_PROC_BEGIN _bs3CpuBasic2_Int83
87 int 83h
88.again: ud2
89 jmp .again
90BS3_PROC_END _bs3CpuBasic2_Int83
91
92
93BS3_PROC_BEGIN _bs3CpuBasic2_iret
94 iret
95BS3_PROC_END _bs3CpuBasic2_iret
96AssertCompile(_bs3CpuBasic2_iret_EndProc - _bs3CpuBasic2_iret == 1)
97
98
99BS3_PROC_BEGIN _bs3CpuBasic2_iret_opsize
100 iretd
101BS3_PROC_END _bs3CpuBasic2_iret_opsize
102AssertCompile(_bs3CpuBasic2_iret_opsize_EndProc - _bs3CpuBasic2_iret_opsize == 2)
103
104
105BS3_PROC_BEGIN _bs3CpuBasic2_iret_rexw
106 BS3_SET_BITS 64
107 iretq
108 BS3_SET_BITS 16
109BS3_PROC_END _bs3CpuBasic2_iret_rexw
110AssertCompile(_bs3CpuBasic2_iret_rexw_EndProc - _bs3CpuBasic2_iret_rexw == 2)
111
112
113;
114; CPU mode agnostic test code snippets.
115;
116BS3_BEGIN_TEXT32
117
118;;
119; @param [xBP + xCB*2] puDst
120; @param [xBP + xCB*3] uNewValue
121BS3_PROC_BEGIN_CMN bs3CpuBasic2_Store_mov, BS3_PBC_NEAR
122 push xBP
123 mov xBP, xSP
124 mov xCX, [xBP + xCB*2]
125 mov xAX, [xBP + xCB*3]
126 mov [xCX], xAX
127 leave
128 ret
129BS3_PROC_END_CMN bs3CpuBasic2_Store_mov
130
131;;
132; @param [xBP + xCB*2] puDst
133; @param [xBP + xCB*3] uNewValue
134BS3_PROC_BEGIN_CMN bs3CpuBasic2_Store_xchg, BS3_PBC_NEAR
135 push xBP
136 mov xBP, xSP
137 mov xCX, [xBP + xCB*2]
138 mov xAX, [xBP + xCB*3]
139 xchg [xCX], xAX
140 leave
141 ret
142BS3_PROC_END_CMN bs3CpuBasic2_Store_xchg
143
144;;
145; @param [xBP + xCB*2] puDst
146; @param [xBP + xCB*3] uNewValue
147; @param [xBP + xCB*4] uOldValue
148BS3_PROC_BEGIN_CMN bs3CpuBasic2_Store_cmpxchg, BS3_PBC_NEAR
149 push xBP
150 mov xBP, xSP
151 mov xCX, [xBP + xCB*2]
152 mov xDX, [xBP + xCB*3]
153 mov xAX, [xBP + xCB*4]
154.again:
155 cmpxchg [xCX], xDX
156 jnz .again
157 leave
158 ret
159BS3_PROC_END_CMN bs3CpuBasic2_Store_cmpxchg
160
161
162;
163; Jump code segment 64KB.
164;
165; There is no ORG directive in OMF mode of course. :-(
166;
167section BS3JMPTEXT16 align=16 CLASS=BS3CLASS16JMPCODE PRIVATE USE16
168 GROUP BS3GROUPJMPTEXT16 BS3JMPTEXT16
169 BS3_SET_BITS 16
170
171; 0000: Start with two int3 filler instructions.
172BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmptext16_start), function, 2
173 int3
174 int3
175
176; 0002: This is the target for forward wrap around jumps, should they succeed.
177BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_target_wrap_forward), function, 2
178 ud2
179 align 8, int3
180
181; 0008
182BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jb_wrap_backward__ud2), function, 2
183 db 0ebh, -012h ; jmp (0x0008 + 2 - 0x12 = 0xFFFFFFF8 (-8))
184 int3
185
186; 000b
187BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jb_opsize_wrap_backward__ud2), function, 3
188 db 066h, 0ebh, -016h ; jmp (0x000b + 3 - 0x16 = 0xFFFFFFF8 (-8))
189 int3
190
191 align 0x80, int3
192; 0080
193BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jv16_wrap_backward__ud2), function, 3
194 db 0e9h ; jmp (0x0080 + 3 - 0x8b = 0xFFFFFFF8 (-8))
195 dw -08bh
196 int3
197
198; 0084
199BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jv16_opsize_wrap_backward__ud2), function, 3
200 db 066h, 0e9h ; jmp (0x0084 + 6 - 0x92 = 0xFFFFFFF8 (-8))
201 dd -092h
202 int3
203
204
205 align 0x100, int3 ; Note! Doesn't work correctly for higher values.
206 times (0xff76 - 0x100) int3
207
208
209; ff76
210BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jv16_wrap_forward__ud2), function, 5
211 db 0e9h ; jmp (0xff76+4 + 0x88 = 0x10002 (65538))
212 dw 089h
213 int3
214
215; ff7a
216BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jv16_opsize_wrap_forward__ud2), function, 7
217 db 066h, 0e9h ; o32 jmp (0xff7a+6 + 0x82 = 0x10002 (65538))
218 dd 082h
219 int3
220
221; ff81
222BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jb_wrap_forward__ud2), function, 2
223 db 0ebh, 07fh ; jmp (0xff81+2 + 0x7f = 0x10002 (65538))
224 int3
225
226; ff84
227BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_jb_opsize_wrap_forward__ud2), function, 3
228 db 066h, 0ebh, 07bh ; o32 jmp (0xff84+3 + 0x7b = 0x10002 (65538))
229; ff87
230
231 times (0xfff8 - 0xff87) int3
232
233; fff8: This is the target for backward wrap around jumps, should they succeed.
234BS3_GLOBAL_NAME_EX NAME(bs3CpuBasic2_jmp_target_wrap_backward), function, 2
235 ud2
236 times 6 int3
237; End of segment.
238
239BS3_BEGIN_TEXT16
240
241;
242; Instantiate code templates.
243;
244BS3_INSTANTIATE_COMMON_TEMPLATE "bs3-cpu-basic-2-template.mac"
245BS3_INSTANTIATE_TEMPLATE_WITH_WEIRD_ONES "bs3-cpu-basic-2-template.mac"
246
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette