Skip to main content

asmkit/x86/features/
686.rs

1use super::super::opcodes::*;
2use crate::core::emitter::*;
3use crate::core::operand::*;
4use crate::x86::assembler::*;
5use crate::x86::operands::*;
6
7/// A dummy operand that represents no register. Here just for simplicity.
8const NOREG: Operand = Operand::new();
9
10/// `FCMOVB`.
11///
12/// Supported operand variants:
13///
14/// ```text
15/// +---+----------+
16/// | # | Operands |
17/// +---+----------+
18/// | 1 | St       |
19/// +---+----------+
20/// ```
21pub trait FcmovbEmitter<A> {
22    fn fcmovb(&mut self, op0: A);
23}
24
25impl<'a> FcmovbEmitter<St> for Assembler<'a> {
26    fn fcmovb(&mut self, op0: St) {
27        self.emit(FCMOVBR, op0.as_operand(), &NOREG, &NOREG, &NOREG);
28    }
29}
30
31/// `FCMOVBE`.
32///
33/// Supported operand variants:
34///
35/// ```text
36/// +---+----------+
37/// | # | Operands |
38/// +---+----------+
39/// | 1 | St       |
40/// +---+----------+
41/// ```
42pub trait FcmovbeEmitter<A> {
43    fn fcmovbe(&mut self, op0: A);
44}
45
46impl<'a> FcmovbeEmitter<St> for Assembler<'a> {
47    fn fcmovbe(&mut self, op0: St) {
48        self.emit(FCMOVBER, op0.as_operand(), &NOREG, &NOREG, &NOREG);
49    }
50}
51
52/// `FCMOVE`.
53///
54/// Supported operand variants:
55///
56/// ```text
57/// +---+----------+
58/// | # | Operands |
59/// +---+----------+
60/// | 1 | St       |
61/// +---+----------+
62/// ```
63pub trait FcmoveEmitter<A> {
64    fn fcmove(&mut self, op0: A);
65}
66
67impl<'a> FcmoveEmitter<St> for Assembler<'a> {
68    fn fcmove(&mut self, op0: St) {
69        self.emit(FCMOVER, op0.as_operand(), &NOREG, &NOREG, &NOREG);
70    }
71}
72
73/// `FCMOVNB`.
74///
75/// Supported operand variants:
76///
77/// ```text
78/// +---+----------+
79/// | # | Operands |
80/// +---+----------+
81/// | 1 | St       |
82/// +---+----------+
83/// ```
84pub trait FcmovnbEmitter<A> {
85    fn fcmovnb(&mut self, op0: A);
86}
87
88impl<'a> FcmovnbEmitter<St> for Assembler<'a> {
89    fn fcmovnb(&mut self, op0: St) {
90        self.emit(FCMOVNBR, op0.as_operand(), &NOREG, &NOREG, &NOREG);
91    }
92}
93
94/// `FCMOVNBE`.
95///
96/// Supported operand variants:
97///
98/// ```text
99/// +---+----------+
100/// | # | Operands |
101/// +---+----------+
102/// | 1 | St       |
103/// +---+----------+
104/// ```
105pub trait FcmovnbeEmitter<A> {
106    fn fcmovnbe(&mut self, op0: A);
107}
108
109impl<'a> FcmovnbeEmitter<St> for Assembler<'a> {
110    fn fcmovnbe(&mut self, op0: St) {
111        self.emit(FCMOVNBER, op0.as_operand(), &NOREG, &NOREG, &NOREG);
112    }
113}
114
115/// `FCMOVNE`.
116///
117/// Supported operand variants:
118///
119/// ```text
120/// +---+----------+
121/// | # | Operands |
122/// +---+----------+
123/// | 1 | St       |
124/// +---+----------+
125/// ```
126pub trait FcmovneEmitter<A> {
127    fn fcmovne(&mut self, op0: A);
128}
129
130impl<'a> FcmovneEmitter<St> for Assembler<'a> {
131    fn fcmovne(&mut self, op0: St) {
132        self.emit(FCMOVNER, op0.as_operand(), &NOREG, &NOREG, &NOREG);
133    }
134}
135
136/// `FCMOVNU`.
137///
138/// Supported operand variants:
139///
140/// ```text
141/// +---+----------+
142/// | # | Operands |
143/// +---+----------+
144/// | 1 | St       |
145/// +---+----------+
146/// ```
147pub trait FcmovnuEmitter<A> {
148    fn fcmovnu(&mut self, op0: A);
149}
150
151impl<'a> FcmovnuEmitter<St> for Assembler<'a> {
152    fn fcmovnu(&mut self, op0: St) {
153        self.emit(FCMOVNUR, op0.as_operand(), &NOREG, &NOREG, &NOREG);
154    }
155}
156
157/// `FCMOVU`.
158///
159/// Supported operand variants:
160///
161/// ```text
162/// +---+----------+
163/// | # | Operands |
164/// +---+----------+
165/// | 1 | St       |
166/// +---+----------+
167/// ```
168pub trait FcmovuEmitter<A> {
169    fn fcmovu(&mut self, op0: A);
170}
171
172impl<'a> FcmovuEmitter<St> for Assembler<'a> {
173    fn fcmovu(&mut self, op0: St) {
174        self.emit(FCMOVUR, op0.as_operand(), &NOREG, &NOREG, &NOREG);
175    }
176}
177
178/// `FCOMI`.
179///
180/// Supported operand variants:
181///
182/// ```text
183/// +---+----------+
184/// | # | Operands |
185/// +---+----------+
186/// | 1 | St       |
187/// +---+----------+
188/// ```
189pub trait FcomiEmitter<A> {
190    fn fcomi(&mut self, op0: A);
191}
192
193impl<'a> FcomiEmitter<St> for Assembler<'a> {
194    fn fcomi(&mut self, op0: St) {
195        self.emit(FCOMIR, op0.as_operand(), &NOREG, &NOREG, &NOREG);
196    }
197}
198
199/// `FCOMIP`.
200///
201/// Supported operand variants:
202///
203/// ```text
204/// +---+----------+
205/// | # | Operands |
206/// +---+----------+
207/// | 1 | St, St   |
208/// +---+----------+
209/// ```
210pub trait FcomipEmitter<A, B> {
211    fn fcomip(&mut self, op0: A, op1: B);
212}
213
214impl<'a> FcomipEmitter<St, St> for Assembler<'a> {
215    fn fcomip(&mut self, op0: St, op1: St) {
216        self.emit(FCOMIPRR, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
217    }
218}
219
220/// `FUCOMI`.
221///
222/// Supported operand variants:
223///
224/// ```text
225/// +---+----------+
226/// | # | Operands |
227/// +---+----------+
228/// | 1 | St       |
229/// +---+----------+
230/// ```
231pub trait FucomiEmitter<A> {
232    fn fucomi(&mut self, op0: A);
233}
234
235impl<'a> FucomiEmitter<St> for Assembler<'a> {
236    fn fucomi(&mut self, op0: St) {
237        self.emit(FUCOMIR, op0.as_operand(), &NOREG, &NOREG, &NOREG);
238    }
239}
240
241/// `FUCOMIP`.
242///
243/// Supported operand variants:
244///
245/// ```text
246/// +---+----------+
247/// | # | Operands |
248/// +---+----------+
249/// | 1 | St, St   |
250/// +---+----------+
251/// ```
252pub trait FucomipEmitter<A, B> {
253    fn fucomip(&mut self, op0: A, op1: B);
254}
255
256impl<'a> FucomipEmitter<St, St> for Assembler<'a> {
257    fn fucomip(&mut self, op0: St, op1: St) {
258        self.emit(
259            FUCOMIPRR,
260            op0.as_operand(),
261            op1.as_operand(),
262            &NOREG,
263            &NOREG,
264        );
265    }
266}
267
268/// `RDPMC`.
269///
270/// Supported operand variants:
271///
272/// ```text
273/// +---+----------+
274/// | # | Operands |
275/// +---+----------+
276/// | 1 | (none)   |
277/// +---+----------+
278/// ```
279pub trait RdpmcEmitter {
280    fn rdpmc(&mut self);
281}
282
283impl<'a> RdpmcEmitter for Assembler<'a> {
284    fn rdpmc(&mut self) {
285        self.emit(RDPMC, &NOREG, &NOREG, &NOREG, &NOREG);
286    }
287}
288
289/// `SYSENTER`.
290///
291/// Supported operand variants:
292///
293/// ```text
294/// +---+----------+
295/// | # | Operands |
296/// +---+----------+
297/// | 1 | (none)   |
298/// +---+----------+
299/// ```
300pub trait SysenterEmitter {
301    fn sysenter(&mut self);
302}
303
304impl<'a> SysenterEmitter for Assembler<'a> {
305    fn sysenter(&mut self) {
306        self.emit(SYSENTER, &NOREG, &NOREG, &NOREG, &NOREG);
307    }
308}
309
310/// `SYSEXIT`.
311///
312/// Supported operand variants:
313///
314/// ```text
315/// +---+----------+
316/// | # | Operands |
317/// +---+----------+
318/// | 1 | (none)   |
319/// +---+----------+
320/// ```
321pub trait SysexitEmitter {
322    fn sysexit(&mut self);
323}
324
325impl<'a> SysexitEmitter for Assembler<'a> {
326    fn sysexit(&mut self) {
327        self.emit(SYSEXIT, &NOREG, &NOREG, &NOREG, &NOREG);
328    }
329}
330
331impl<'a> Assembler<'a> {
332    /// `FCMOVB`.
333    ///
334    /// Supported operand variants:
335    ///
336    /// ```text
337    /// +---+----------+
338    /// | # | Operands |
339    /// +---+----------+
340    /// | 1 | St       |
341    /// +---+----------+
342    /// ```
343    #[inline]
344    pub fn fcmovb<A>(&mut self, op0: A)
345    where
346        Assembler<'a>: FcmovbEmitter<A>,
347    {
348        <Self as FcmovbEmitter<A>>::fcmovb(self, op0);
349    }
350    /// `FCMOVBE`.
351    ///
352    /// Supported operand variants:
353    ///
354    /// ```text
355    /// +---+----------+
356    /// | # | Operands |
357    /// +---+----------+
358    /// | 1 | St       |
359    /// +---+----------+
360    /// ```
361    #[inline]
362    pub fn fcmovbe<A>(&mut self, op0: A)
363    where
364        Assembler<'a>: FcmovbeEmitter<A>,
365    {
366        <Self as FcmovbeEmitter<A>>::fcmovbe(self, op0);
367    }
368    /// `FCMOVE`.
369    ///
370    /// Supported operand variants:
371    ///
372    /// ```text
373    /// +---+----------+
374    /// | # | Operands |
375    /// +---+----------+
376    /// | 1 | St       |
377    /// +---+----------+
378    /// ```
379    #[inline]
380    pub fn fcmove<A>(&mut self, op0: A)
381    where
382        Assembler<'a>: FcmoveEmitter<A>,
383    {
384        <Self as FcmoveEmitter<A>>::fcmove(self, op0);
385    }
386    /// `FCMOVNB`.
387    ///
388    /// Supported operand variants:
389    ///
390    /// ```text
391    /// +---+----------+
392    /// | # | Operands |
393    /// +---+----------+
394    /// | 1 | St       |
395    /// +---+----------+
396    /// ```
397    #[inline]
398    pub fn fcmovnb<A>(&mut self, op0: A)
399    where
400        Assembler<'a>: FcmovnbEmitter<A>,
401    {
402        <Self as FcmovnbEmitter<A>>::fcmovnb(self, op0);
403    }
404    /// `FCMOVNBE`.
405    ///
406    /// Supported operand variants:
407    ///
408    /// ```text
409    /// +---+----------+
410    /// | # | Operands |
411    /// +---+----------+
412    /// | 1 | St       |
413    /// +---+----------+
414    /// ```
415    #[inline]
416    pub fn fcmovnbe<A>(&mut self, op0: A)
417    where
418        Assembler<'a>: FcmovnbeEmitter<A>,
419    {
420        <Self as FcmovnbeEmitter<A>>::fcmovnbe(self, op0);
421    }
422    /// `FCMOVNE`.
423    ///
424    /// Supported operand variants:
425    ///
426    /// ```text
427    /// +---+----------+
428    /// | # | Operands |
429    /// +---+----------+
430    /// | 1 | St       |
431    /// +---+----------+
432    /// ```
433    #[inline]
434    pub fn fcmovne<A>(&mut self, op0: A)
435    where
436        Assembler<'a>: FcmovneEmitter<A>,
437    {
438        <Self as FcmovneEmitter<A>>::fcmovne(self, op0);
439    }
440    /// `FCMOVNU`.
441    ///
442    /// Supported operand variants:
443    ///
444    /// ```text
445    /// +---+----------+
446    /// | # | Operands |
447    /// +---+----------+
448    /// | 1 | St       |
449    /// +---+----------+
450    /// ```
451    #[inline]
452    pub fn fcmovnu<A>(&mut self, op0: A)
453    where
454        Assembler<'a>: FcmovnuEmitter<A>,
455    {
456        <Self as FcmovnuEmitter<A>>::fcmovnu(self, op0);
457    }
458    /// `FCMOVU`.
459    ///
460    /// Supported operand variants:
461    ///
462    /// ```text
463    /// +---+----------+
464    /// | # | Operands |
465    /// +---+----------+
466    /// | 1 | St       |
467    /// +---+----------+
468    /// ```
469    #[inline]
470    pub fn fcmovu<A>(&mut self, op0: A)
471    where
472        Assembler<'a>: FcmovuEmitter<A>,
473    {
474        <Self as FcmovuEmitter<A>>::fcmovu(self, op0);
475    }
476    /// `FCOMI`.
477    ///
478    /// Supported operand variants:
479    ///
480    /// ```text
481    /// +---+----------+
482    /// | # | Operands |
483    /// +---+----------+
484    /// | 1 | St       |
485    /// +---+----------+
486    /// ```
487    #[inline]
488    pub fn fcomi<A>(&mut self, op0: A)
489    where
490        Assembler<'a>: FcomiEmitter<A>,
491    {
492        <Self as FcomiEmitter<A>>::fcomi(self, op0);
493    }
494    /// `FCOMIP`.
495    ///
496    /// Supported operand variants:
497    ///
498    /// ```text
499    /// +---+----------+
500    /// | # | Operands |
501    /// +---+----------+
502    /// | 1 | St, St   |
503    /// +---+----------+
504    /// ```
505    #[inline]
506    pub fn fcomip<A, B>(&mut self, op0: A, op1: B)
507    where
508        Assembler<'a>: FcomipEmitter<A, B>,
509    {
510        <Self as FcomipEmitter<A, B>>::fcomip(self, op0, op1);
511    }
512    /// `FUCOMI`.
513    ///
514    /// Supported operand variants:
515    ///
516    /// ```text
517    /// +---+----------+
518    /// | # | Operands |
519    /// +---+----------+
520    /// | 1 | St       |
521    /// +---+----------+
522    /// ```
523    #[inline]
524    pub fn fucomi<A>(&mut self, op0: A)
525    where
526        Assembler<'a>: FucomiEmitter<A>,
527    {
528        <Self as FucomiEmitter<A>>::fucomi(self, op0);
529    }
530    /// `FUCOMIP`.
531    ///
532    /// Supported operand variants:
533    ///
534    /// ```text
535    /// +---+----------+
536    /// | # | Operands |
537    /// +---+----------+
538    /// | 1 | St, St   |
539    /// +---+----------+
540    /// ```
541    #[inline]
542    pub fn fucomip<A, B>(&mut self, op0: A, op1: B)
543    where
544        Assembler<'a>: FucomipEmitter<A, B>,
545    {
546        <Self as FucomipEmitter<A, B>>::fucomip(self, op0, op1);
547    }
548    /// `RDPMC`.
549    ///
550    /// Supported operand variants:
551    ///
552    /// ```text
553    /// +---+----------+
554    /// | # | Operands |
555    /// +---+----------+
556    /// | 1 | (none)   |
557    /// +---+----------+
558    /// ```
559    #[inline]
560    pub fn rdpmc(&mut self)
561    where
562        Assembler<'a>: RdpmcEmitter,
563    {
564        <Self as RdpmcEmitter>::rdpmc(self);
565    }
566    /// `SYSENTER`.
567    ///
568    /// Supported operand variants:
569    ///
570    /// ```text
571    /// +---+----------+
572    /// | # | Operands |
573    /// +---+----------+
574    /// | 1 | (none)   |
575    /// +---+----------+
576    /// ```
577    #[inline]
578    pub fn sysenter(&mut self)
579    where
580        Assembler<'a>: SysenterEmitter,
581    {
582        <Self as SysenterEmitter>::sysenter(self);
583    }
584    /// `SYSEXIT`.
585    ///
586    /// Supported operand variants:
587    ///
588    /// ```text
589    /// +---+----------+
590    /// | # | Operands |
591    /// +---+----------+
592    /// | 1 | (none)   |
593    /// +---+----------+
594    /// ```
595    #[inline]
596    pub fn sysexit(&mut self)
597    where
598        Assembler<'a>: SysexitEmitter,
599    {
600        <Self as SysexitEmitter>::sysexit(self);
601    }
602}