1 | ; $Id: bs3-cpu-basic-2-asm.asm 96407 2022-08-22 17:43:14Z 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 | ;*********************************************************************************************************************************
|
---|
47 | BS3_BEGIN_DATA16
|
---|
48 | BS3_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 | ;
|
---|
56 | BS3_BEGIN_TEXT16
|
---|
57 |
|
---|
58 | BS3_PROC_BEGIN _bs3CpuBasic2_ud2
|
---|
59 | .again:
|
---|
60 | ud2
|
---|
61 | jmp .again
|
---|
62 | BS3_PROC_END _bs3CpuBasic2_ud2
|
---|
63 |
|
---|
64 |
|
---|
65 | BS3_PROC_BEGIN _bs3CpuBasic2_Int80
|
---|
66 | int 80h
|
---|
67 | .again: ud2
|
---|
68 | jmp .again
|
---|
69 | BS3_PROC_END _bs3CpuBasic2_Int80
|
---|
70 |
|
---|
71 |
|
---|
72 | BS3_PROC_BEGIN _bs3CpuBasic2_Int81
|
---|
73 | int 81h
|
---|
74 | .again: ud2
|
---|
75 | jmp .again
|
---|
76 | BS3_PROC_END _bs3CpuBasic2_Int81
|
---|
77 |
|
---|
78 |
|
---|
79 | BS3_PROC_BEGIN _bs3CpuBasic2_Int82
|
---|
80 | int 82h
|
---|
81 | .again: ud2
|
---|
82 | jmp .again
|
---|
83 | BS3_PROC_END _bs3CpuBasic2_Int82
|
---|
84 |
|
---|
85 |
|
---|
86 | BS3_PROC_BEGIN _bs3CpuBasic2_Int83
|
---|
87 | int 83h
|
---|
88 | .again: ud2
|
---|
89 | jmp .again
|
---|
90 | BS3_PROC_END _bs3CpuBasic2_Int83
|
---|
91 |
|
---|
92 |
|
---|
93 | BS3_PROC_BEGIN _bs3CpuBasic2_iret
|
---|
94 | iret
|
---|
95 | BS3_PROC_END _bs3CpuBasic2_iret
|
---|
96 | AssertCompile(_bs3CpuBasic2_iret_EndProc - _bs3CpuBasic2_iret == 1)
|
---|
97 |
|
---|
98 |
|
---|
99 | BS3_PROC_BEGIN _bs3CpuBasic2_iret_opsize
|
---|
100 | iretd
|
---|
101 | BS3_PROC_END _bs3CpuBasic2_iret_opsize
|
---|
102 | AssertCompile(_bs3CpuBasic2_iret_opsize_EndProc - _bs3CpuBasic2_iret_opsize == 2)
|
---|
103 |
|
---|
104 |
|
---|
105 | BS3_PROC_BEGIN _bs3CpuBasic2_iret_rexw
|
---|
106 | BS3_SET_BITS 64
|
---|
107 | iretq
|
---|
108 | BS3_SET_BITS 16
|
---|
109 | BS3_PROC_END _bs3CpuBasic2_iret_rexw
|
---|
110 | AssertCompile(_bs3CpuBasic2_iret_rexw_EndProc - _bs3CpuBasic2_iret_rexw == 2)
|
---|
111 |
|
---|
112 |
|
---|
113 | ;
|
---|
114 | ; CPU mode agnostic test code snippets.
|
---|
115 | ;
|
---|
116 | BS3_BEGIN_TEXT32
|
---|
117 |
|
---|
118 | ;;
|
---|
119 | ; @param [xBP + xCB*2] puDst
|
---|
120 | ; @param [xBP + xCB*3] uNewValue
|
---|
121 | BS3_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
|
---|
129 | BS3_PROC_END_CMN bs3CpuBasic2_Store_mov
|
---|
130 |
|
---|
131 | ;;
|
---|
132 | ; @param [xBP + xCB*2] puDst
|
---|
133 | ; @param [xBP + xCB*3] uNewValue
|
---|
134 | BS3_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
|
---|
142 | BS3_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
|
---|
148 | BS3_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
|
---|
159 | BS3_PROC_END_CMN bs3CpuBasic2_Store_cmpxchg
|
---|
160 |
|
---|
161 |
|
---|
162 | BS3_BEGIN_TEXT16
|
---|
163 |
|
---|
164 | ;
|
---|
165 | ; Instantiate code templates.
|
---|
166 | ;
|
---|
167 | BS3_INSTANTIATE_COMMON_TEMPLATE "bs3-cpu-basic-2-template.mac"
|
---|
168 | BS3_INSTANTIATE_TEMPLATE_WITH_WEIRD_ONES "bs3-cpu-basic-2-template.mac"
|
---|
169 |
|
---|