1 | ; $Id: bs3-cpu-instr-2-gen-asm.asm 103602 2024-02-29 02:10:17Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - bs3-cpu-instr-2-gen - assembly helpers for test data generator.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2024 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 "iprt/asmdefs.mac"
|
---|
42 |
|
---|
43 | BEGINCODE
|
---|
44 |
|
---|
45 | %ifdef ASM_CALL64_MSC
|
---|
46 | %define EFLAGS_PARAM_REG r8d
|
---|
47 | %else
|
---|
48 | %define EFLAGS_PARAM_REG ecx
|
---|
49 | %endif
|
---|
50 |
|
---|
51 |
|
---|
52 | ;;
|
---|
53 | ; @param 1 instruction
|
---|
54 | ; @param 2 Whether it takes carry in.
|
---|
55 | ; @param 3 Whether it has an 8-bit form.
|
---|
56 | %macro DO_BINARY 3
|
---|
57 |
|
---|
58 | %if %3 != 0
|
---|
59 | BEGINPROC GenU8_ %+ %1
|
---|
60 | %if %2 != 0
|
---|
61 | lahf
|
---|
62 | and ah, 0xfe
|
---|
63 | shl EFLAGS_PARAM_REG, 8
|
---|
64 | or eax, EFLAGS_PARAM_REG
|
---|
65 | sahf
|
---|
66 | %endif
|
---|
67 | %ifdef ASM_CALL64_MSC
|
---|
68 | %1 cl, dl
|
---|
69 | mov [r9], cl
|
---|
70 | %else
|
---|
71 | %1 sil, dil
|
---|
72 | mov [rdx], sil
|
---|
73 | %endif
|
---|
74 | pushf
|
---|
75 | pop rax
|
---|
76 | ret
|
---|
77 | ENDPROC GenU8_ %+ %1
|
---|
78 | %endif
|
---|
79 |
|
---|
80 | BEGINPROC GenU16_ %+ %1
|
---|
81 | %if %2 != 0
|
---|
82 | lahf
|
---|
83 | and ah, 0xfe
|
---|
84 | shl EFLAGS_PARAM_REG, 8
|
---|
85 | or eax, EFLAGS_PARAM_REG
|
---|
86 | sahf
|
---|
87 | %endif
|
---|
88 | %ifdef ASM_CALL64_MSC
|
---|
89 | %1 cx, dx
|
---|
90 | mov [r9], cx
|
---|
91 | %else
|
---|
92 | %1 si, di
|
---|
93 | mov [rdx], si
|
---|
94 | %endif
|
---|
95 | pushf
|
---|
96 | pop rax
|
---|
97 | ret
|
---|
98 | ENDPROC GenU16_ %+ %1
|
---|
99 |
|
---|
100 | BEGINPROC GenU32_ %+ %1
|
---|
101 | %if %2 != 0
|
---|
102 | lahf
|
---|
103 | and ah, 0xfe
|
---|
104 | shl EFLAGS_PARAM_REG, 8
|
---|
105 | or eax, EFLAGS_PARAM_REG
|
---|
106 | sahf
|
---|
107 | %endif
|
---|
108 | %ifdef ASM_CALL64_MSC
|
---|
109 | %1 ecx, edx
|
---|
110 | mov [r9], ecx
|
---|
111 | %else
|
---|
112 | %1 esi, edi
|
---|
113 | mov [rdx], esi
|
---|
114 | %endif
|
---|
115 | pushf
|
---|
116 | pop rax
|
---|
117 | ret
|
---|
118 | ENDPROC GenU32_ %+ %1
|
---|
119 |
|
---|
120 | BEGINPROC GenU64_ %+ %1
|
---|
121 | %if %2 != 0
|
---|
122 | lahf
|
---|
123 | and ah, 0xfe
|
---|
124 | shl EFLAGS_PARAM_REG, 8
|
---|
125 | or eax, EFLAGS_PARAM_REG
|
---|
126 | sahf
|
---|
127 | %endif
|
---|
128 | %ifdef ASM_CALL64_MSC
|
---|
129 | %1 rcx, rdx
|
---|
130 | mov [r9], rcx
|
---|
131 | %else
|
---|
132 | %1 rsi, rdi
|
---|
133 | mov [rdx], rsi
|
---|
134 | %endif
|
---|
135 | pushf
|
---|
136 | pop rax
|
---|
137 | ret
|
---|
138 | ENDPROC GenU64_ %+ %1
|
---|
139 |
|
---|
140 | %endmacro
|
---|
141 |
|
---|
142 | DO_BINARY and, 0, 1
|
---|
143 | DO_BINARY or, 0, 1
|
---|
144 | DO_BINARY xor, 0, 1
|
---|
145 | DO_BINARY test, 0, 1
|
---|
146 |
|
---|
147 | DO_BINARY add, 0, 1
|
---|
148 | DO_BINARY adc, 1, 1
|
---|
149 | DO_BINARY sub, 0, 1
|
---|
150 | DO_BINARY sbb, 1, 1
|
---|
151 | DO_BINARY cmp, 0, 1
|
---|
152 |
|
---|
153 | DO_BINARY bt, 0, 0
|
---|
154 | DO_BINARY btc, 0, 0
|
---|
155 | DO_BINARY btr, 0, 0
|
---|
156 | DO_BINARY bts, 0, 0
|
---|
157 |
|
---|