iced_x86/formatter/fmt_opts.rs
1// SPDX-License-Identifier: MIT
2// Copyright (C) 2018-present iced project and contributors
3
4use crate::formatter::enums::*;
5use crate::formatter::enums_shared::MemorySizeOptions;
6use alloc::string::String;
7use core::hash::{Hash, Hasher};
8
9#[derive(Debug, Clone)]
10enum FormatterOptionString {
11 String(String),
12 Str(&'static str),
13}
14
15impl FormatterOptionString {
16 #[must_use]
17 #[inline]
18 pub fn as_str(&self) -> &str {
19 match self {
20 FormatterOptionString::String(s) => s.as_str(),
21 &FormatterOptionString::Str(s) => s,
22 }
23 }
24}
25
26impl Default for FormatterOptionString {
27 #[must_use]
28 #[inline]
29 fn default() -> Self {
30 FormatterOptionString::Str("")
31 }
32}
33
34impl Eq for FormatterOptionString {}
35impl PartialEq<FormatterOptionString> for FormatterOptionString {
36 #[must_use]
37 #[inline]
38 fn eq(&self, other: &FormatterOptionString) -> bool {
39 self.as_str().eq(other.as_str())
40 }
41}
42
43impl Hash for FormatterOptionString {
44 #[inline]
45 fn hash<H: Hasher>(&self, state: &mut H) {
46 self.as_str().hash(state);
47 }
48}
49
50struct Flags1;
51impl Flags1 {
52 const UPPERCASE_PREFIXES: u32 = 0x0000_0001;
53 const UPPERCASE_MNEMONICS: u32 = 0x0000_0002;
54 const UPPERCASE_REGISTERS: u32 = 0x0000_0004;
55 const UPPERCASE_KEYWORDS: u32 = 0x0000_0008;
56 const UPPERCASE_DECORATORS: u32 = 0x0000_0010;
57 const UPPERCASE_ALL: u32 = 0x0000_0020;
58 const SPACE_AFTER_OPERAND_SEPARATOR: u32 = 0x0000_0040;
59 const SPACE_AFTER_MEMORY_BRACKET: u32 = 0x0000_0080;
60 const SPACE_BETWEEN_MEMORY_ADD_OPERATORS: u32 = 0x0000_0100;
61 const SPACE_BETWEEN_MEMORY_MUL_OPERATORS: u32 = 0x0000_0200;
62 const SCALE_BEFORE_INDEX: u32 = 0x0000_0400;
63 const ALWAYS_SHOW_SCALE: u32 = 0x0000_0800;
64 const ALWAYS_SHOW_SEGMENT_REGISTER: u32 = 0x0000_1000;
65 const SHOW_ZERO_DISPLACEMENTS: u32 = 0x0000_2000;
66 const LEADING_ZEROS: u32 = 0x0000_4000;
67 const UPPERCASE_HEX: u32 = 0x0000_8000;
68 const SMALL_HEX_NUMBERS_IN_DECIMAL: u32 = 0x0001_0000;
69 const ADD_LEADING_ZERO_TO_HEX_NUMBERS: u32 = 0x0002_0000;
70 const BRANCH_LEADING_ZEROS: u32 = 0x0004_0000;
71 const SIGNED_IMMEDIATE_OPERANDS: u32 = 0x0008_0000;
72 const SIGNED_MEMORY_DISPLACEMENTS: u32 = 0x0010_0000;
73 const DISPLACEMENT_LEADING_ZEROS: u32 = 0x0020_0000;
74 const RIP_RELATIVE_ADDRESSES: u32 = 0x0040_0000;
75 const SHOW_BRANCH_SIZE: u32 = 0x0080_0000;
76 const USE_PSEUDO_OPS: u32 = 0x0100_0000;
77 const SHOW_SYMBOL_ADDRESS: u32 = 0x0200_0000;
78 const GAS_NAKED_REGISTERS: u32 = 0x0400_0000;
79 const GAS_SHOW_MNEMONIC_SIZE_SUFFIX: u32 = 0x0800_0000;
80 const GAS_SPACE_AFTER_MEMORY_OPERAND_COMMA: u32 = 0x1000_0000;
81 const MASM_ADD_DS_PREFIX32: u32 = 0x2000_0000;
82 const MASM_SYMBOL_DISPL_IN_BRACKETS: u32 = 0x4000_0000;
83 const MASM_DISPL_IN_BRACKETS: u32 = 0x8000_0000;
84}
85
86struct Flags2;
87impl Flags2 {
88 const NASM_SHOW_SIGN_EXTENDED_IMMEDIATE_SIZE: u32 = 0x0000_0001;
89 const PREFER_ST0: u32 = 0x0000_0002;
90 const SHOW_USELESS_PREFIXES: u32 = 0x0000_0004;
91}
92
93/// Formatter options
94#[derive(Debug, Clone, Eq, PartialEq, Hash)]
95pub struct FormatterOptions {
96 hex_prefix: FormatterOptionString,
97 hex_suffix: FormatterOptionString,
98 decimal_prefix: FormatterOptionString,
99 decimal_suffix: FormatterOptionString,
100 octal_prefix: FormatterOptionString,
101 octal_suffix: FormatterOptionString,
102 binary_prefix: FormatterOptionString,
103 binary_suffix: FormatterOptionString,
104 digit_separator: FormatterOptionString,
105 hex_digit_group_size: u32,
106 decimal_digit_group_size: u32,
107 octal_digit_group_size: u32,
108 binary_digit_group_size: u32,
109 options1: u32,
110 options2: u32,
111 first_operand_char_index: u32,
112 tab_size: u32,
113 number_base: NumberBase,
114 memory_size_options: MemorySizeOptions,
115 cc_b: CC_b,
116 cc_ae: CC_ae,
117 cc_e: CC_e,
118 cc_ne: CC_ne,
119 cc_be: CC_be,
120 cc_a: CC_a,
121 cc_p: CC_p,
122 cc_np: CC_np,
123 cc_l: CC_l,
124 cc_ge: CC_ge,
125 cc_le: CC_le,
126 cc_g: CC_g,
127}
128
129impl FormatterOptions {
130 /// Creates default formatter options
131 #[must_use]
132 #[allow(clippy::missing_inline_in_public_items)]
133 pub fn new() -> Self {
134 Self {
135 hex_prefix: FormatterOptionString::default(),
136 hex_suffix: FormatterOptionString::default(),
137 decimal_prefix: FormatterOptionString::default(),
138 decimal_suffix: FormatterOptionString::default(),
139 octal_prefix: FormatterOptionString::default(),
140 octal_suffix: FormatterOptionString::default(),
141 binary_prefix: FormatterOptionString::default(),
142 binary_suffix: FormatterOptionString::default(),
143 digit_separator: FormatterOptionString::default(),
144 hex_digit_group_size: 4,
145 decimal_digit_group_size: 3,
146 octal_digit_group_size: 4,
147 binary_digit_group_size: 4,
148 options1: Flags1::UPPERCASE_HEX
149 | Flags1::SMALL_HEX_NUMBERS_IN_DECIMAL
150 | Flags1::ADD_LEADING_ZERO_TO_HEX_NUMBERS
151 | Flags1::BRANCH_LEADING_ZEROS
152 | Flags1::SIGNED_MEMORY_DISPLACEMENTS
153 | Flags1::SHOW_BRANCH_SIZE
154 | Flags1::USE_PSEUDO_OPS
155 | Flags1::MASM_ADD_DS_PREFIX32
156 | Flags1::MASM_SYMBOL_DISPL_IN_BRACKETS
157 | Flags1::MASM_DISPL_IN_BRACKETS,
158 options2: 0,
159 first_operand_char_index: 0,
160 tab_size: 0,
161 number_base: NumberBase::Hexadecimal,
162 memory_size_options: MemorySizeOptions::Default,
163 cc_b: CC_b::b,
164 cc_ae: CC_ae::ae,
165 cc_e: CC_e::e,
166 cc_ne: CC_ne::ne,
167 cc_be: CC_be::be,
168 cc_a: CC_a::a,
169 cc_p: CC_p::p,
170 cc_np: CC_np::np,
171 cc_l: CC_l::l,
172 cc_ge: CC_ge::ge,
173 cc_le: CC_le::le,
174 cc_g: CC_g::g,
175 }
176 }
177
178 /// Creates default gas (AT&T) formatter options
179 #[cfg(feature = "gas")]
180 #[must_use]
181 #[inline]
182 pub fn with_gas() -> Self {
183 let mut options = FormatterOptions::new();
184 options.set_hex_prefix("0x");
185 options.set_octal_prefix("0");
186 options.set_binary_prefix("0b");
187 options
188 }
189
190 /// Creates default Intel (XED) formatter options
191 #[cfg(feature = "intel")]
192 #[must_use]
193 #[inline]
194 pub fn with_intel() -> Self {
195 let mut options = FormatterOptions::new();
196 options.set_hex_suffix("h");
197 options.set_octal_suffix("o");
198 options.set_binary_suffix("b");
199 options
200 }
201
202 /// Creates default masm formatter options
203 #[cfg(feature = "masm")]
204 #[must_use]
205 #[inline]
206 pub fn with_masm() -> Self {
207 let mut options = FormatterOptions::new();
208 options.set_hex_suffix("h");
209 options.set_octal_suffix("o");
210 options.set_binary_suffix("b");
211 options
212 }
213
214 /// Creates default nasm formatter options
215 #[cfg(feature = "nasm")]
216 #[must_use]
217 #[inline]
218 pub fn with_nasm() -> Self {
219 let mut options = FormatterOptions::new();
220 options.set_hex_suffix("h");
221 options.set_octal_suffix("o");
222 options.set_binary_suffix("b");
223 options
224 }
225
226 // NOTE: These tables must render correctly by `cargo doc` and inside of IDEs, eg. VSCode.
227
228 /// Prefixes are uppercased
229 ///
230 /// Default | Value | Example
231 /// --------|-------|--------
232 /// _ | `true` | `REP stosd`
233 /// 👍 | `false` | `rep stosd`
234 #[must_use]
235 #[inline]
236 pub const fn uppercase_prefixes(&self) -> bool {
237 (self.options1 & Flags1::UPPERCASE_PREFIXES) != 0
238 }
239
240 /// Prefixes are uppercased
241 ///
242 /// Default | Value | Example
243 /// --------|-------|--------
244 /// _ | `true` | `REP stosd`
245 /// 👍 | `false` | `rep stosd`
246 ///
247 /// # Arguments
248 ///
249 /// * `value`: New value
250 #[inline]
251 pub fn set_uppercase_prefixes(&mut self, value: bool) {
252 if value {
253 self.options1 |= Flags1::UPPERCASE_PREFIXES;
254 } else {
255 self.options1 &= !Flags1::UPPERCASE_PREFIXES;
256 }
257 }
258
259 /// Mnemonics are uppercased
260 ///
261 /// Default | Value | Example
262 /// --------|-------|--------
263 /// _ | `true` | `MOV rcx,rax`
264 /// 👍 | `false` | `mov rcx,rax`
265 #[must_use]
266 #[inline]
267 pub const fn uppercase_mnemonics(&self) -> bool {
268 (self.options1 & Flags1::UPPERCASE_MNEMONICS) != 0
269 }
270
271 /// Mnemonics are uppercased
272 ///
273 /// Default | Value | Example
274 /// --------|-------|--------
275 /// _ | `true` | `MOV rcx,rax`
276 /// 👍 | `false` | `mov rcx,rax`
277 ///
278 /// # Arguments
279 ///
280 /// * `value`: New value
281 #[inline]
282 pub fn set_uppercase_mnemonics(&mut self, value: bool) {
283 if value {
284 self.options1 |= Flags1::UPPERCASE_MNEMONICS;
285 } else {
286 self.options1 &= !Flags1::UPPERCASE_MNEMONICS;
287 }
288 }
289
290 /// Registers are uppercased
291 ///
292 /// Default | Value | Example
293 /// --------|-------|--------
294 /// _ | `true` | `mov RCX,[RAX+RDX*8]`
295 /// 👍 | `false` | `mov rcx,[rax+rdx*8]`
296 #[must_use]
297 #[inline]
298 pub const fn uppercase_registers(&self) -> bool {
299 (self.options1 & Flags1::UPPERCASE_REGISTERS) != 0
300 }
301
302 /// Registers are uppercased
303 ///
304 /// Default | Value | Example
305 /// --------|-------|--------
306 /// _ | `true` | `mov RCX,[RAX+RDX*8]`
307 /// 👍 | `false` | `mov rcx,[rax+rdx*8]`
308 ///
309 /// # Arguments
310 ///
311 /// * `value`: New value
312 #[inline]
313 pub fn set_uppercase_registers(&mut self, value: bool) {
314 if value {
315 self.options1 |= Flags1::UPPERCASE_REGISTERS;
316 } else {
317 self.options1 &= !Flags1::UPPERCASE_REGISTERS;
318 }
319 }
320
321 /// Keywords are uppercased (eg. `BYTE PTR`, `SHORT`)
322 ///
323 /// Default | Value | Example
324 /// --------|-------|--------
325 /// _ | `true` | `mov BYTE PTR [rcx],12h`
326 /// 👍 | `false` | `mov byte ptr [rcx],12h`
327 #[must_use]
328 #[inline]
329 pub const fn uppercase_keywords(&self) -> bool {
330 (self.options1 & Flags1::UPPERCASE_KEYWORDS) != 0
331 }
332
333 /// Keywords are uppercased (eg. `BYTE PTR`, `SHORT`)
334 ///
335 /// Default | Value | Example
336 /// --------|-------|--------
337 /// _ | `true` | `mov BYTE PTR [rcx],12h`
338 /// 👍 | `false` | `mov byte ptr [rcx],12h`
339 ///
340 /// # Arguments
341 ///
342 /// * `value`: New value
343 #[inline]
344 pub fn set_uppercase_keywords(&mut self, value: bool) {
345 if value {
346 self.options1 |= Flags1::UPPERCASE_KEYWORDS;
347 } else {
348 self.options1 &= !Flags1::UPPERCASE_KEYWORDS;
349 }
350 }
351
352 /// Uppercase decorators, eg. `{z}`, `{sae}`, `{rd-sae}` (but not opmask registers: `{k1}`)
353 ///
354 /// Default | Value | Example
355 /// --------|-------|--------
356 /// _ | `true` | `vunpcklps xmm2{k5}{Z},xmm6,dword bcst [rax+4]`
357 /// 👍 | `false` | `vunpcklps xmm2{k5}{z},xmm6,dword bcst [rax+4]`
358 #[must_use]
359 #[inline]
360 pub const fn uppercase_decorators(&self) -> bool {
361 (self.options1 & Flags1::UPPERCASE_DECORATORS) != 0
362 }
363
364 /// Uppercase decorators, eg. `{z}`, `{sae}`, `{rd-sae}` (but not opmask registers: `{k1}`)
365 ///
366 /// Default | Value | Example
367 /// --------|-------|--------
368 /// _ | `true` | `vunpcklps xmm2{k5}{Z},xmm6,dword bcst [rax+4]`
369 /// 👍 | `false` | `vunpcklps xmm2{k5}{z},xmm6,dword bcst [rax+4]`
370 ///
371 /// # Arguments
372 ///
373 /// * `value`: New value
374 #[inline]
375 pub fn set_uppercase_decorators(&mut self, value: bool) {
376 if value {
377 self.options1 |= Flags1::UPPERCASE_DECORATORS;
378 } else {
379 self.options1 &= !Flags1::UPPERCASE_DECORATORS;
380 }
381 }
382
383 /// Everything is uppercased, except numbers and their prefixes/suffixes
384 ///
385 /// Default | Value | Example
386 /// --------|-------|--------
387 /// _ | `true` | `MOV EAX,GS:[RCX*4+0ffh]`
388 /// 👍 | `false` | `mov eax,gs:[rcx*4+0ffh]`
389 #[must_use]
390 #[inline]
391 pub const fn uppercase_all(&self) -> bool {
392 (self.options1 & Flags1::UPPERCASE_ALL) != 0
393 }
394
395 /// Everything is uppercased, except numbers and their prefixes/suffixes
396 ///
397 /// Default | Value | Example
398 /// --------|-------|--------
399 /// _ | `true` | `MOV EAX,GS:[RCX*4+0ffh]`
400 /// 👍 | `false` | `mov eax,gs:[rcx*4+0ffh]`
401 ///
402 /// # Arguments
403 ///
404 /// * `value`: New value
405 #[inline]
406 pub fn set_uppercase_all(&mut self, value: bool) {
407 if value {
408 self.options1 |= Flags1::UPPERCASE_ALL;
409 } else {
410 self.options1 &= !Flags1::UPPERCASE_ALL;
411 }
412 }
413
414 /// Character index (0-based) where the first operand is formatted. Can be set to 0 to format it immediately after the mnemonic.
415 /// At least one space or tab is always added between the mnemonic and the first operand.
416 ///
417 /// Default | Value | Example
418 /// --------|-------|--------
419 /// 👍 | `0` | `mov•rcx,rbp`
420 /// _ | `8` | `mov•••••rcx,rbp`
421 #[must_use]
422 #[inline]
423 pub const fn first_operand_char_index(&self) -> u32 {
424 self.first_operand_char_index
425 }
426
427 /// Character index (0-based) where the first operand is formatted. Can be set to 0 to format it immediately after the mnemonic.
428 /// At least one space or tab is always added between the mnemonic and the first operand.
429 ///
430 /// Default | Value | Example
431 /// --------|-------|--------
432 /// 👍 | `0` | `mov•rcx,rbp`
433 /// _ | `8` | `mov•••••rcx,rbp`
434 ///
435 /// # Arguments
436 ///
437 /// * `value`: New value
438 #[inline]
439 pub fn set_first_operand_char_index(&mut self, value: u32) {
440 self.first_operand_char_index = value
441 }
442
443 /// Size of a tab character or 0 to use spaces
444 ///
445 /// - Default: `0`
446 #[must_use]
447 #[inline]
448 pub const fn tab_size(&self) -> u32 {
449 self.tab_size
450 }
451
452 /// Size of a tab character or 0 to use spaces
453 ///
454 /// - Default: `0`
455 ///
456 /// # Arguments
457 ///
458 /// * `value`: New value
459 #[inline]
460 pub fn set_tab_size(&mut self, value: u32) {
461 self.tab_size = value
462 }
463
464 /// Add a space after the operand separator
465 ///
466 /// Default | Value | Example
467 /// --------|-------|--------
468 /// _ | `true` | `mov rax, rcx`
469 /// 👍 | `false` | `mov rax,rcx`
470 #[must_use]
471 #[inline]
472 pub const fn space_after_operand_separator(&self) -> bool {
473 (self.options1 & Flags1::SPACE_AFTER_OPERAND_SEPARATOR) != 0
474 }
475
476 /// Add a space after the operand separator
477 ///
478 /// Default | Value | Example
479 /// --------|-------|--------
480 /// _ | `true` | `mov rax, rcx`
481 /// 👍 | `false` | `mov rax,rcx`
482 ///
483 /// # Arguments
484 ///
485 /// * `value`: New value
486 #[inline]
487 pub fn set_space_after_operand_separator(&mut self, value: bool) {
488 if value {
489 self.options1 |= Flags1::SPACE_AFTER_OPERAND_SEPARATOR;
490 } else {
491 self.options1 &= !Flags1::SPACE_AFTER_OPERAND_SEPARATOR;
492 }
493 }
494
495 /// Add a space between the memory expression and the brackets
496 ///
497 /// Default | Value | Example
498 /// --------|-------|--------
499 /// _ | `true` | `mov eax,[ rcx+rdx ]`
500 /// 👍 | `false` | `mov eax,[rcx+rdx]`
501 #[must_use]
502 #[inline]
503 pub const fn space_after_memory_bracket(&self) -> bool {
504 (self.options1 & Flags1::SPACE_AFTER_MEMORY_BRACKET) != 0
505 }
506
507 /// Add a space between the memory expression and the brackets
508 ///
509 /// Default | Value | Example
510 /// --------|-------|--------
511 /// _ | `true` | `mov eax,[ rcx+rdx ]`
512 /// 👍 | `false` | `mov eax,[rcx+rdx]`
513 ///
514 /// # Arguments
515 ///
516 /// * `value`: New value
517 #[inline]
518 pub fn set_space_after_memory_bracket(&mut self, value: bool) {
519 if value {
520 self.options1 |= Flags1::SPACE_AFTER_MEMORY_BRACKET;
521 } else {
522 self.options1 &= !Flags1::SPACE_AFTER_MEMORY_BRACKET;
523 }
524 }
525
526 /// Add spaces between memory operand `+` and `-` operators
527 ///
528 /// Default | Value | Example
529 /// --------|-------|--------
530 /// _ | `true` | `mov eax,[rcx + rdx*8 - 80h]`
531 /// 👍 | `false` | `mov eax,[rcx+rdx*8-80h]`
532 #[must_use]
533 #[inline]
534 pub const fn space_between_memory_add_operators(&self) -> bool {
535 (self.options1 & Flags1::SPACE_BETWEEN_MEMORY_ADD_OPERATORS) != 0
536 }
537
538 /// Add spaces between memory operand `+` and `-` operators
539 ///
540 /// Default | Value | Example
541 /// --------|-------|--------
542 /// _ | `true` | `mov eax,[rcx + rdx*8 - 80h]`
543 /// 👍 | `false` | `mov eax,[rcx+rdx*8-80h]`
544 ///
545 /// # Arguments
546 ///
547 /// * `value`: New value
548 #[inline]
549 pub fn set_space_between_memory_add_operators(&mut self, value: bool) {
550 if value {
551 self.options1 |= Flags1::SPACE_BETWEEN_MEMORY_ADD_OPERATORS;
552 } else {
553 self.options1 &= !Flags1::SPACE_BETWEEN_MEMORY_ADD_OPERATORS;
554 }
555 }
556
557 /// Add spaces between memory operand `*` operator
558 ///
559 /// Default | Value | Example
560 /// --------|-------|--------
561 /// _ | `true` | `mov eax,[rcx+rdx * 8-80h]`
562 /// 👍 | `false` | `mov eax,[rcx+rdx*8-80h]`
563 #[must_use]
564 #[inline]
565 pub const fn space_between_memory_mul_operators(&self) -> bool {
566 (self.options1 & Flags1::SPACE_BETWEEN_MEMORY_MUL_OPERATORS) != 0
567 }
568
569 /// Add spaces between memory operand `*` operator
570 ///
571 /// Default | Value | Example
572 /// --------|-------|--------
573 /// _ | `true` | `mov eax,[rcx+rdx * 8-80h]`
574 /// 👍 | `false` | `mov eax,[rcx+rdx*8-80h]`
575 ///
576 /// # Arguments
577 ///
578 /// * `value`: New value
579 #[inline]
580 pub fn set_space_between_memory_mul_operators(&mut self, value: bool) {
581 if value {
582 self.options1 |= Flags1::SPACE_BETWEEN_MEMORY_MUL_OPERATORS;
583 } else {
584 self.options1 &= !Flags1::SPACE_BETWEEN_MEMORY_MUL_OPERATORS;
585 }
586 }
587
588 /// Show memory operand scale value before the index register
589 ///
590 /// Default | Value | Example
591 /// --------|-------|--------
592 /// _ | `true` | `mov eax,[8*rdx]`
593 /// 👍 | `false` | `mov eax,[rdx*8]`
594 #[must_use]
595 #[inline]
596 pub const fn scale_before_index(&self) -> bool {
597 (self.options1 & Flags1::SCALE_BEFORE_INDEX) != 0
598 }
599
600 /// Show memory operand scale value before the index register
601 ///
602 /// Default | Value | Example
603 /// --------|-------|--------
604 /// _ | `true` | `mov eax,[8*rdx]`
605 /// 👍 | `false` | `mov eax,[rdx*8]`
606 ///
607 /// # Arguments
608 ///
609 /// * `value`: New value
610 #[inline]
611 pub fn set_scale_before_index(&mut self, value: bool) {
612 if value {
613 self.options1 |= Flags1::SCALE_BEFORE_INDEX;
614 } else {
615 self.options1 &= !Flags1::SCALE_BEFORE_INDEX;
616 }
617 }
618
619 /// Always show the scale value even if it's `*1`
620 ///
621 /// Default | Value | Example
622 /// --------|-------|--------
623 /// _ | `true` | `mov eax,[rbx+rcx*1]`
624 /// 👍 | `false` | `mov eax,[rbx+rcx]`
625 #[must_use]
626 #[inline]
627 pub const fn always_show_scale(&self) -> bool {
628 (self.options1 & Flags1::ALWAYS_SHOW_SCALE) != 0
629 }
630
631 /// Always show the scale value even if it's `*1`
632 ///
633 /// Default | Value | Example
634 /// --------|-------|--------
635 /// _ | `true` | `mov eax,[rbx+rcx*1]`
636 /// 👍 | `false` | `mov eax,[rbx+rcx]`
637 ///
638 /// # Arguments
639 ///
640 /// * `value`: New value
641 #[inline]
642 pub fn set_always_show_scale(&mut self, value: bool) {
643 if value {
644 self.options1 |= Flags1::ALWAYS_SHOW_SCALE;
645 } else {
646 self.options1 &= !Flags1::ALWAYS_SHOW_SCALE;
647 }
648 }
649
650 /// Always show the effective segment register. If the option is `false`, only show the segment register if
651 /// there's a segment override prefix.
652 ///
653 /// Default | Value | Example
654 /// --------|-------|--------
655 /// _ | `true` | `mov eax,ds:[ecx]`
656 /// 👍 | `false` | `mov eax,[ecx]`
657 #[must_use]
658 #[inline]
659 pub const fn always_show_segment_register(&self) -> bool {
660 (self.options1 & Flags1::ALWAYS_SHOW_SEGMENT_REGISTER) != 0
661 }
662
663 /// Always show the effective segment register. If the option is `false`, only show the segment register if
664 /// there's a segment override prefix.
665 ///
666 /// Default | Value | Example
667 /// --------|-------|--------
668 /// _ | `true` | `mov eax,ds:[ecx]`
669 /// 👍 | `false` | `mov eax,[ecx]`
670 ///
671 /// # Arguments
672 ///
673 /// * `value`: New value
674 #[inline]
675 pub fn set_always_show_segment_register(&mut self, value: bool) {
676 if value {
677 self.options1 |= Flags1::ALWAYS_SHOW_SEGMENT_REGISTER;
678 } else {
679 self.options1 &= !Flags1::ALWAYS_SHOW_SEGMENT_REGISTER;
680 }
681 }
682
683 /// Show zero displacements
684 ///
685 /// Default | Value | Example
686 /// --------|-------|--------
687 /// _ | `true` | `mov eax,[rcx*2+0]`
688 /// 👍 | `false` | `mov eax,[rcx*2]`
689 #[must_use]
690 #[inline]
691 pub const fn show_zero_displacements(&self) -> bool {
692 (self.options1 & Flags1::SHOW_ZERO_DISPLACEMENTS) != 0
693 }
694
695 /// Show zero displacements
696 ///
697 /// Default | Value | Example
698 /// --------|-------|--------
699 /// _ | `true` | `mov eax,[rcx*2+0]`
700 /// 👍 | `false` | `mov eax,[rcx*2]`
701 ///
702 /// # Arguments
703 ///
704 /// * `value`: New value
705 #[inline]
706 pub fn set_show_zero_displacements(&mut self, value: bool) {
707 if value {
708 self.options1 |= Flags1::SHOW_ZERO_DISPLACEMENTS;
709 } else {
710 self.options1 &= !Flags1::SHOW_ZERO_DISPLACEMENTS;
711 }
712 }
713
714 /// Hex number prefix or an empty string, eg. `"0x"`
715 ///
716 /// - Default: `""` (masm/nasm/intel), `"0x"` (gas)
717 #[must_use]
718 #[inline]
719 pub fn hex_prefix(&self) -> &str {
720 self.hex_prefix.as_str()
721 }
722
723 /// Hex number prefix or an empty string, eg. `"0x"`
724 ///
725 /// - Default: `""` (masm/nasm/intel), `"0x"` (gas)
726 ///
727 /// # Arguments
728 ///
729 /// * `value`: New value
730 #[inline]
731 pub fn set_hex_prefix(&mut self, value: &'static str) {
732 self.hex_prefix = FormatterOptionString::Str(value)
733 }
734
735 /// Hex number prefix or an empty string, eg. `"0x"`
736 ///
737 /// - Default: `""` (masm/nasm/intel), `"0x"` (gas)
738 ///
739 /// # Arguments
740 ///
741 /// * `value`: New value
742 #[inline]
743 pub fn set_hex_prefix_string(&mut self, value: String) {
744 self.hex_prefix = FormatterOptionString::String(value)
745 }
746
747 /// Hex number suffix or an empty string, eg. `"h"`
748 ///
749 /// - Default: `"h"` (masm/nasm/intel), `""` (gas)
750 #[must_use]
751 #[inline]
752 pub fn hex_suffix(&self) -> &str {
753 self.hex_suffix.as_str()
754 }
755
756 /// Hex number suffix or an empty string, eg. `"h"`
757 ///
758 /// - Default: `"h"` (masm/nasm/intel), `""` (gas)
759 ///
760 /// # Arguments
761 ///
762 /// * `value`: New value
763 #[inline]
764 pub fn set_hex_suffix(&mut self, value: &'static str) {
765 self.hex_suffix = FormatterOptionString::Str(value)
766 }
767
768 /// Hex number suffix or an empty string, eg. `"h"`
769 ///
770 /// - Default: `"h"` (masm/nasm/intel), `""` (gas)
771 ///
772 /// # Arguments
773 ///
774 /// * `value`: New value
775 #[inline]
776 pub fn set_hex_suffix_string(&mut self, value: String) {
777 self.hex_suffix = FormatterOptionString::String(value)
778 }
779
780 /// Size of a digit group, see also [`digit_separator()`]
781 ///
782 /// [`digit_separator()`]: #method.digit_separator
783 ///
784 /// Default | Value | Example
785 /// --------|-------|--------
786 /// _ | `0` | `0x12345678`
787 /// 👍 | `4` | `0x1234_5678`
788 #[must_use]
789 #[inline]
790 pub const fn hex_digit_group_size(&self) -> u32 {
791 self.hex_digit_group_size
792 }
793
794 /// Size of a digit group, see also [`digit_separator()`]
795 ///
796 /// [`digit_separator()`]: #method.digit_separator
797 ///
798 /// Default | Value | Example
799 /// --------|-------|--------
800 /// _ | `0` | `0x12345678`
801 /// 👍 | `4` | `0x1234_5678`
802 ///
803 /// # Arguments
804 ///
805 /// * `value`: New value
806 #[inline]
807 pub fn set_hex_digit_group_size(&mut self, value: u32) {
808 self.hex_digit_group_size = value
809 }
810
811 /// Decimal number prefix or an empty string
812 ///
813 /// - Default: `""`
814 #[must_use]
815 #[inline]
816 pub fn decimal_prefix(&self) -> &str {
817 self.decimal_prefix.as_str()
818 }
819
820 /// Decimal number prefix or an empty string
821 ///
822 /// - Default: `""`
823 ///
824 /// # Arguments
825 ///
826 /// * `value`: New value
827 #[inline]
828 pub fn set_decimal_prefix(&mut self, value: &'static str) {
829 self.decimal_prefix = FormatterOptionString::Str(value)
830 }
831
832 /// Decimal number prefix or an empty string
833 ///
834 /// - Default: `""`
835 ///
836 /// # Arguments
837 ///
838 /// * `value`: New value
839 #[inline]
840 pub fn set_decimal_prefix_string(&mut self, value: String) {
841 self.decimal_prefix = FormatterOptionString::String(value)
842 }
843
844 /// Decimal number suffix or an empty string
845 ///
846 /// - Default: `""`
847 #[must_use]
848 #[inline]
849 pub fn decimal_suffix(&self) -> &str {
850 self.decimal_suffix.as_str()
851 }
852
853 /// Decimal number suffix or an empty string
854 ///
855 /// - Default: `""`
856 ///
857 /// # Arguments
858 ///
859 /// * `value`: New value
860 #[inline]
861 pub fn set_decimal_suffix(&mut self, value: &'static str) {
862 self.decimal_suffix = FormatterOptionString::Str(value)
863 }
864
865 /// Decimal number suffix or an empty string
866 ///
867 /// - Default: `""`
868 ///
869 /// # Arguments
870 ///
871 /// * `value`: New value
872 #[inline]
873 pub fn set_decimal_suffix_string(&mut self, value: String) {
874 self.decimal_suffix = FormatterOptionString::String(value)
875 }
876
877 /// Size of a digit group, see also [`digit_separator()`]
878 ///
879 /// [`digit_separator()`]: #method.digit_separator
880 ///
881 /// Default | Value | Example
882 /// --------|-------|--------
883 /// _ | `0` | `12345678`
884 /// 👍 | `3` | `12_345_678`
885 #[must_use]
886 #[inline]
887 pub const fn decimal_digit_group_size(&self) -> u32 {
888 self.decimal_digit_group_size
889 }
890
891 /// Size of a digit group, see also [`digit_separator()`]
892 ///
893 /// [`digit_separator()`]: #method.digit_separator
894 ///
895 /// Default | Value | Example
896 /// --------|-------|--------
897 /// _ | `0` | `12345678`
898 /// 👍 | `3` | `12_345_678`
899 ///
900 /// # Arguments
901 ///
902 /// * `value`: New value
903 #[inline]
904 pub fn set_decimal_digit_group_size(&mut self, value: u32) {
905 self.decimal_digit_group_size = value
906 }
907
908 /// Octal number prefix or an empty string
909 ///
910 /// - Default: `""` (masm/nasm/intel), `"0"` (gas)
911 #[must_use]
912 #[inline]
913 pub fn octal_prefix(&self) -> &str {
914 self.octal_prefix.as_str()
915 }
916
917 /// Octal number prefix or an empty string
918 ///
919 /// - Default: `""` (masm/nasm/intel), `"0"` (gas)
920 ///
921 /// # Arguments
922 ///
923 /// * `value`: New value
924 #[inline]
925 pub fn set_octal_prefix(&mut self, value: &'static str) {
926 self.octal_prefix = FormatterOptionString::Str(value)
927 }
928
929 /// Octal number prefix or an empty string
930 ///
931 /// - Default: `""` (masm/nasm/intel), `"0"` (gas)
932 ///
933 /// # Arguments
934 ///
935 /// * `value`: New value
936 #[inline]
937 pub fn set_octal_prefix_string(&mut self, value: String) {
938 self.octal_prefix = FormatterOptionString::String(value)
939 }
940
941 /// Octal number suffix or an empty string
942 ///
943 /// - Default: `"o"` (masm/nasm/intel), `""` (gas)
944 #[must_use]
945 #[inline]
946 pub fn octal_suffix(&self) -> &str {
947 self.octal_suffix.as_str()
948 }
949
950 /// Octal number suffix or an empty string
951 ///
952 /// - Default: `"o"` (masm/nasm/intel), `""` (gas)
953 ///
954 /// # Arguments
955 ///
956 /// * `value`: New value
957 #[inline]
958 pub fn set_octal_suffix(&mut self, value: &'static str) {
959 self.octal_suffix = FormatterOptionString::Str(value)
960 }
961
962 /// Octal number suffix or an empty string
963 ///
964 /// - Default: `"o"` (masm/nasm/intel), `""` (gas)
965 ///
966 /// # Arguments
967 ///
968 /// * `value`: New value
969 #[inline]
970 pub fn set_octal_suffix_string(&mut self, value: String) {
971 self.octal_suffix = FormatterOptionString::String(value)
972 }
973
974 /// Size of a digit group, see also [`digit_separator()`]
975 ///
976 /// [`digit_separator()`]: #method.digit_separator
977 ///
978 /// Default | Value | Example
979 /// --------|-------|--------
980 /// _ | `0` | `12345670`
981 /// 👍 | `4` | `1234_5670`
982 #[must_use]
983 #[inline]
984 pub const fn octal_digit_group_size(&self) -> u32 {
985 self.octal_digit_group_size
986 }
987
988 /// Size of a digit group, see also [`digit_separator()`]
989 ///
990 /// [`digit_separator()`]: #method.digit_separator
991 ///
992 /// Default | Value | Example
993 /// --------|-------|--------
994 /// _ | `0` | `12345670`
995 /// 👍 | `4` | `1234_5670`
996 ///
997 /// # Arguments
998 ///
999 /// * `value`: New value
1000 #[inline]
1001 pub fn set_octal_digit_group_size(&mut self, value: u32) {
1002 self.octal_digit_group_size = value
1003 }
1004
1005 /// Binary number prefix or an empty string
1006 ///
1007 /// - Default: `""` (masm/nasm/intel), `"0b"` (gas)
1008 #[must_use]
1009 #[inline]
1010 pub fn binary_prefix(&self) -> &str {
1011 self.binary_prefix.as_str()
1012 }
1013
1014 /// Binary number prefix or an empty string
1015 ///
1016 /// - Default: `""` (masm/nasm/intel), `"0b"` (gas)
1017 ///
1018 /// # Arguments
1019 ///
1020 /// * `value`: New value
1021 #[inline]
1022 pub fn set_binary_prefix(&mut self, value: &'static str) {
1023 self.binary_prefix = FormatterOptionString::Str(value)
1024 }
1025
1026 /// Binary number prefix or an empty string
1027 ///
1028 /// - Default: `""` (masm/nasm/intel), `"0b"` (gas)
1029 ///
1030 /// # Arguments
1031 ///
1032 /// * `value`: New value
1033 #[inline]
1034 pub fn set_binary_prefix_string(&mut self, value: String) {
1035 self.binary_prefix = FormatterOptionString::String(value)
1036 }
1037
1038 /// Binary number suffix or an empty string
1039 ///
1040 /// - Default: `"b"` (masm/nasm/intel), `""` (gas)
1041 #[must_use]
1042 #[inline]
1043 pub fn binary_suffix(&self) -> &str {
1044 self.binary_suffix.as_str()
1045 }
1046
1047 /// Binary number suffix or an empty string
1048 ///
1049 /// - Default: `"b"` (masm/nasm/intel), `""` (gas)
1050 ///
1051 /// # Arguments
1052 ///
1053 /// * `value`: New value
1054 #[inline]
1055 pub fn set_binary_suffix(&mut self, value: &'static str) {
1056 self.binary_suffix = FormatterOptionString::Str(value)
1057 }
1058
1059 /// Binary number suffix or an empty string
1060 ///
1061 /// - Default: `"b"` (masm/nasm/intel), `""` (gas)
1062 ///
1063 /// # Arguments
1064 ///
1065 /// * `value`: New value
1066 #[inline]
1067 pub fn set_binary_suffix_string(&mut self, value: String) {
1068 self.binary_suffix = FormatterOptionString::String(value)
1069 }
1070
1071 /// Size of a digit group, see also [`digit_separator()`]
1072 ///
1073 /// [`digit_separator()`]: #method.digit_separator
1074 ///
1075 /// Default | Value | Example
1076 /// --------|-------|--------
1077 /// _ | `0` | `11010111`
1078 /// 👍 | `4` | `1101_0111`
1079 #[must_use]
1080 #[inline]
1081 pub const fn binary_digit_group_size(&self) -> u32 {
1082 self.binary_digit_group_size
1083 }
1084
1085 /// Size of a digit group, see also [`digit_separator()`]
1086 ///
1087 /// [`digit_separator()`]: #method.digit_separator
1088 ///
1089 /// Default | Value | Example
1090 /// --------|-------|--------
1091 /// _ | `0` | `11010111`
1092 /// 👍 | `4` | `1101_0111`
1093 ///
1094 /// # Arguments
1095 ///
1096 /// * `value`: New value
1097 #[inline]
1098 pub fn set_binary_digit_group_size(&mut self, value: u32) {
1099 self.binary_digit_group_size = value
1100 }
1101
1102 /// Digit separator or an empty string. See also eg. [`hex_digit_group_size()`]
1103 ///
1104 /// [`hex_digit_group_size()`]: #method.hex_digit_group_size
1105 ///
1106 /// Default | Value | Example
1107 /// --------|-------|--------
1108 /// 👍 | `""` | `0x12345678`
1109 /// _ | `"_"` | `0x1234_5678`
1110 #[must_use]
1111 #[inline]
1112 pub fn digit_separator(&self) -> &str {
1113 self.digit_separator.as_str()
1114 }
1115
1116 /// Digit separator or an empty string. See also eg. [`hex_digit_group_size()`]
1117 ///
1118 /// [`hex_digit_group_size()`]: #method.hex_digit_group_size
1119 ///
1120 /// Default | Value | Example
1121 /// --------|-------|--------
1122 /// 👍 | `""` | `0x12345678`
1123 /// _ | `"_"` | `0x1234_5678`
1124 ///
1125 /// # Arguments
1126 ///
1127 /// * `value`: New value
1128 #[inline]
1129 pub fn set_digit_separator(&mut self, value: &'static str) {
1130 self.digit_separator = FormatterOptionString::Str(value)
1131 }
1132
1133 /// Digit separator or an empty string. See also eg. [`hex_digit_group_size()`]
1134 ///
1135 /// [`hex_digit_group_size()`]: #method.hex_digit_group_size
1136 ///
1137 /// Default | Value | Example
1138 /// --------|-------|--------
1139 /// 👍 | `""` | `0x12345678`
1140 /// _ | `"_"` | `0x1234_5678`
1141 ///
1142 /// # Arguments
1143 ///
1144 /// * `value`: New value
1145 #[inline]
1146 pub fn set_digit_separator_string(&mut self, value: String) {
1147 self.digit_separator = FormatterOptionString::String(value)
1148 }
1149
1150 /// Add leading zeros to hexadecimal/octal/binary numbers.
1151 /// This option has no effect on branch targets and displacements, use [`branch_leading_zeros`]
1152 /// and [`displacement_leading_zeros`].
1153 ///
1154 /// Default | Value | Example
1155 /// --------|-------|--------
1156 /// _ | `true` | `0x0000000A`/`0000000Ah`
1157 /// 👍 | `false` | `0xA`/`0Ah`
1158 ///
1159 /// [`branch_leading_zeros`]: #method.branch_leading_zeros
1160 /// [`displacement_leading_zeros`]: #method.displacement_leading_zeros
1161 #[must_use]
1162 #[inline]
1163 pub const fn leading_zeros(&self) -> bool {
1164 (self.options1 & Flags1::LEADING_ZEROS) != 0
1165 }
1166
1167 /// Add leading zeros to hexadecimal/octal/binary numbers.
1168 /// This option has no effect on branch targets and displacements, use [`branch_leading_zeros`]
1169 /// and [`displacement_leading_zeros`].
1170 ///
1171 /// Default | Value | Example
1172 /// --------|-------|--------
1173 /// _ | `true` | `0x0000000A`/`0000000Ah`
1174 /// 👍 | `false` | `0xA`/`0Ah`
1175 ///
1176 /// [`branch_leading_zeros`]: #method.branch_leading_zeros
1177 /// [`displacement_leading_zeros`]: #method.displacement_leading_zeros
1178 ///
1179 /// # Arguments
1180 ///
1181 /// * `value`: New value
1182 #[inline]
1183 pub fn set_leading_zeros(&mut self, value: bool) {
1184 if value {
1185 self.options1 |= Flags1::LEADING_ZEROS;
1186 } else {
1187 self.options1 &= !Flags1::LEADING_ZEROS;
1188 }
1189 }
1190
1191 #[must_use]
1192 #[inline]
1193 #[doc(hidden)]
1194 pub const fn leading_zeroes(&self) -> bool {
1195 self.leading_zeros()
1196 }
1197
1198 #[inline]
1199 #[doc(hidden)]
1200 pub fn set_leading_zeroes(&mut self, value: bool) {
1201 self.set_leading_zeros(value);
1202 }
1203
1204 /// Use uppercase hex digits
1205 ///
1206 /// Default | Value | Example
1207 /// --------|-------|--------
1208 /// 👍 | `true` | `0xFF`
1209 /// _ | `false` | `0xff`
1210 #[must_use]
1211 #[inline]
1212 pub const fn uppercase_hex(&self) -> bool {
1213 (self.options1 & Flags1::UPPERCASE_HEX) != 0
1214 }
1215
1216 /// Use uppercase hex digits
1217 ///
1218 /// Default | Value | Example
1219 /// --------|-------|--------
1220 /// 👍 | `true` | `0xFF`
1221 /// _ | `false` | `0xff`
1222 ///
1223 /// # Arguments
1224 ///
1225 /// * `value`: New value
1226 #[inline]
1227 pub fn set_uppercase_hex(&mut self, value: bool) {
1228 if value {
1229 self.options1 |= Flags1::UPPERCASE_HEX;
1230 } else {
1231 self.options1 &= !Flags1::UPPERCASE_HEX;
1232 }
1233 }
1234
1235 /// Small hex numbers (-9 .. 9) are shown in decimal
1236 ///
1237 /// Default | Value | Example
1238 /// --------|-------|--------
1239 /// 👍 | `true` | `9`
1240 /// _ | `false` | `0x9`
1241 #[must_use]
1242 #[inline]
1243 pub const fn small_hex_numbers_in_decimal(&self) -> bool {
1244 (self.options1 & Flags1::SMALL_HEX_NUMBERS_IN_DECIMAL) != 0
1245 }
1246
1247 /// Small hex numbers (-9 .. 9) are shown in decimal
1248 ///
1249 /// Default | Value | Example
1250 /// --------|-------|--------
1251 /// 👍 | `true` | `9`
1252 /// _ | `false` | `0x9`
1253 ///
1254 /// # Arguments
1255 ///
1256 /// * `value`: New value
1257 #[inline]
1258 pub fn set_small_hex_numbers_in_decimal(&mut self, value: bool) {
1259 if value {
1260 self.options1 |= Flags1::SMALL_HEX_NUMBERS_IN_DECIMAL;
1261 } else {
1262 self.options1 &= !Flags1::SMALL_HEX_NUMBERS_IN_DECIMAL;
1263 }
1264 }
1265
1266 /// Add a leading zero to hex numbers if there's no prefix and the number starts with hex digits `A-F`
1267 ///
1268 /// Default | Value | Example
1269 /// --------|-------|--------
1270 /// 👍 | `true` | `0FFh`
1271 /// _ | `false` | `FFh`
1272 #[must_use]
1273 #[inline]
1274 pub const fn add_leading_zero_to_hex_numbers(&self) -> bool {
1275 (self.options1 & Flags1::ADD_LEADING_ZERO_TO_HEX_NUMBERS) != 0
1276 }
1277
1278 /// Add a leading zero to hex numbers if there's no prefix and the number starts with hex digits `A-F`
1279 ///
1280 /// Default | Value | Example
1281 /// --------|-------|--------
1282 /// 👍 | `true` | `0FFh`
1283 /// _ | `false` | `FFh`
1284 ///
1285 /// # Arguments
1286 ///
1287 /// * `value`: New value
1288 #[inline]
1289 pub fn set_add_leading_zero_to_hex_numbers(&mut self, value: bool) {
1290 if value {
1291 self.options1 |= Flags1::ADD_LEADING_ZERO_TO_HEX_NUMBERS;
1292 } else {
1293 self.options1 &= !Flags1::ADD_LEADING_ZERO_TO_HEX_NUMBERS;
1294 }
1295 }
1296
1297 /// Number base
1298 ///
1299 /// - Default: [`Hexadecimal`]
1300 ///
1301 /// [`Hexadecimal`]: enum.NumberBase.html#variant.Hexadecimal
1302 #[must_use]
1303 #[inline]
1304 pub const fn number_base(&self) -> NumberBase {
1305 self.number_base
1306 }
1307
1308 /// Number base
1309 ///
1310 /// - Default: [`Hexadecimal`]
1311 ///
1312 /// [`Hexadecimal`]: enum.NumberBase.html#variant.Hexadecimal
1313 ///
1314 /// # Arguments
1315 ///
1316 /// * `value`: New value
1317 #[inline]
1318 pub fn set_number_base(&mut self, value: NumberBase) {
1319 self.number_base = value
1320 }
1321
1322 /// Add leading zeros to branch offsets. Used by `CALL NEAR`, `CALL FAR`, `JMP NEAR`, `JMP FAR`, `Jcc`, `LOOP`, `LOOPcc`, `XBEGIN`
1323 ///
1324 /// Default | Value | Example
1325 /// --------|-------|--------
1326 /// 👍 | `true` | `je 00000123h`
1327 /// _ | `false` | `je 123h`
1328 #[must_use]
1329 #[inline]
1330 pub const fn branch_leading_zeros(&self) -> bool {
1331 (self.options1 & Flags1::BRANCH_LEADING_ZEROS) != 0
1332 }
1333
1334 /// Add leading zeros to branch offsets. Used by `CALL NEAR`, `CALL FAR`, `JMP NEAR`, `JMP FAR`, `Jcc`, `LOOP`, `LOOPcc`, `XBEGIN`
1335 ///
1336 /// Default | Value | Example
1337 /// --------|-------|--------
1338 /// 👍 | `true` | `je 00000123h`
1339 /// _ | `false` | `je 123h`
1340 ///
1341 /// # Arguments
1342 ///
1343 /// * `value`: New value
1344 #[inline]
1345 pub fn set_branch_leading_zeros(&mut self, value: bool) {
1346 if value {
1347 self.options1 |= Flags1::BRANCH_LEADING_ZEROS;
1348 } else {
1349 self.options1 &= !Flags1::BRANCH_LEADING_ZEROS;
1350 }
1351 }
1352
1353 #[must_use]
1354 #[inline]
1355 #[doc(hidden)]
1356 pub const fn branch_leading_zeroes(&self) -> bool {
1357 self.branch_leading_zeros()
1358 }
1359
1360 #[inline]
1361 #[doc(hidden)]
1362 pub fn set_branch_leading_zeroes(&mut self, value: bool) {
1363 self.set_branch_leading_zeros(value);
1364 }
1365
1366 /// Show immediate operands as signed numbers
1367 ///
1368 /// Default | Value | Example
1369 /// --------|-------|--------
1370 /// _ | `true` | `mov eax,-1`
1371 /// 👍 | `false` | `mov eax,FFFFFFFF`
1372 #[must_use]
1373 #[inline]
1374 pub const fn signed_immediate_operands(&self) -> bool {
1375 (self.options1 & Flags1::SIGNED_IMMEDIATE_OPERANDS) != 0
1376 }
1377
1378 /// Show immediate operands as signed numbers
1379 ///
1380 /// Default | Value | Example
1381 /// --------|-------|--------
1382 /// _ | `true` | `mov eax,-1`
1383 /// 👍 | `false` | `mov eax,FFFFFFFF`
1384 ///
1385 /// # Arguments
1386 ///
1387 /// * `value`: New value
1388 #[inline]
1389 pub fn set_signed_immediate_operands(&mut self, value: bool) {
1390 if value {
1391 self.options1 |= Flags1::SIGNED_IMMEDIATE_OPERANDS;
1392 } else {
1393 self.options1 &= !Flags1::SIGNED_IMMEDIATE_OPERANDS;
1394 }
1395 }
1396
1397 /// Displacements are signed numbers
1398 ///
1399 /// Default | Value | Example
1400 /// --------|-------|--------
1401 /// 👍 | `true` | `mov al,[eax-2000h]`
1402 /// _ | `false` | `mov al,[eax+0FFFFE000h]`
1403 #[must_use]
1404 #[inline]
1405 pub const fn signed_memory_displacements(&self) -> bool {
1406 (self.options1 & Flags1::SIGNED_MEMORY_DISPLACEMENTS) != 0
1407 }
1408
1409 /// Displacements are signed numbers
1410 ///
1411 /// Default | Value | Example
1412 /// --------|-------|--------
1413 /// 👍 | `true` | `mov al,[eax-2000h]`
1414 /// _ | `false` | `mov al,[eax+0FFFFE000h]`
1415 ///
1416 /// # Arguments
1417 ///
1418 /// * `value`: New value
1419 #[inline]
1420 pub fn set_signed_memory_displacements(&mut self, value: bool) {
1421 if value {
1422 self.options1 |= Flags1::SIGNED_MEMORY_DISPLACEMENTS;
1423 } else {
1424 self.options1 &= !Flags1::SIGNED_MEMORY_DISPLACEMENTS;
1425 }
1426 }
1427
1428 /// Add leading zeros to displacements
1429 ///
1430 /// Default | Value | Example
1431 /// --------|-------|--------
1432 /// _ | `true` | `mov al,[eax+00000012h]`
1433 /// 👍 | `false` | `mov al,[eax+12h]`
1434 #[must_use]
1435 #[inline]
1436 pub const fn displacement_leading_zeros(&self) -> bool {
1437 (self.options1 & Flags1::DISPLACEMENT_LEADING_ZEROS) != 0
1438 }
1439
1440 /// Add leading zeros to displacements
1441 ///
1442 /// Default | Value | Example
1443 /// --------|-------|--------
1444 /// _ | `true` | `mov al,[eax+00000012h]`
1445 /// 👍 | `false` | `mov al,[eax+12h]`
1446 ///
1447 /// # Arguments
1448 ///
1449 /// * `value`: New value
1450 #[inline]
1451 pub fn set_displacement_leading_zeros(&mut self, value: bool) {
1452 if value {
1453 self.options1 |= Flags1::DISPLACEMENT_LEADING_ZEROS;
1454 } else {
1455 self.options1 &= !Flags1::DISPLACEMENT_LEADING_ZEROS;
1456 }
1457 }
1458
1459 #[must_use]
1460 #[inline]
1461 #[doc(hidden)]
1462 pub const fn displacement_leading_zeroes(&self) -> bool {
1463 self.displacement_leading_zeros()
1464 }
1465
1466 #[inline]
1467 #[doc(hidden)]
1468 pub fn set_displacement_leading_zeroes(&mut self, value: bool) {
1469 self.set_displacement_leading_zeros(value);
1470 }
1471
1472 /// Options that control if the memory size (eg. `DWORD PTR`) is shown or not.
1473 /// This is ignored by the gas (AT&T) formatter.
1474 ///
1475 /// - Default: [`Default`]
1476 ///
1477 /// [`Default`]: enum.MemorySizeOptions.html#variant.Default
1478 #[must_use]
1479 #[inline]
1480 pub const fn memory_size_options(&self) -> MemorySizeOptions {
1481 self.memory_size_options
1482 }
1483
1484 /// Options that control if the memory size (eg. `DWORD PTR`) is shown or not.
1485 /// This is ignored by the gas (AT&T) formatter.
1486 ///
1487 /// - Default: [`Default`]
1488 ///
1489 /// [`Default`]: enum.MemorySizeOptions.html#variant.Default
1490 ///
1491 /// # Arguments
1492 ///
1493 /// * `value`: New value
1494 #[inline]
1495 pub fn set_memory_size_options(&mut self, value: MemorySizeOptions) {
1496 self.memory_size_options = value
1497 }
1498
1499 /// Show `RIP+displ` or the virtual address
1500 ///
1501 /// Default | Value | Example
1502 /// --------|-------|--------
1503 /// _ | `true` | `mov eax,[rip+12345678h]`
1504 /// 👍 | `false` | `mov eax,[1029384756AFBECDh]`
1505 #[must_use]
1506 #[inline]
1507 pub const fn rip_relative_addresses(&self) -> bool {
1508 (self.options1 & Flags1::RIP_RELATIVE_ADDRESSES) != 0
1509 }
1510
1511 /// Show `RIP+displ` or the virtual address
1512 ///
1513 /// Default | Value | Example
1514 /// --------|-------|--------
1515 /// _ | `true` | `mov eax,[rip+12345678h]`
1516 /// 👍 | `false` | `mov eax,[1029384756AFBECDh]`
1517 ///
1518 /// # Arguments
1519 ///
1520 /// * `value`: New value
1521 #[inline]
1522 pub fn set_rip_relative_addresses(&mut self, value: bool) {
1523 if value {
1524 self.options1 |= Flags1::RIP_RELATIVE_ADDRESSES;
1525 } else {
1526 self.options1 &= !Flags1::RIP_RELATIVE_ADDRESSES;
1527 }
1528 }
1529
1530 /// Show `NEAR`, `SHORT`, etc if it's a branch instruction
1531 ///
1532 /// Default | Value | Example
1533 /// --------|-------|--------
1534 /// 👍 | `true` | `je short 1234h`
1535 /// _ | `false` | `je 1234h`
1536 #[must_use]
1537 #[inline]
1538 pub const fn show_branch_size(&self) -> bool {
1539 (self.options1 & Flags1::SHOW_BRANCH_SIZE) != 0
1540 }
1541
1542 /// Show `NEAR`, `SHORT`, etc if it's a branch instruction
1543 ///
1544 /// Default | Value | Example
1545 /// --------|-------|--------
1546 /// 👍 | `true` | `je short 1234h`
1547 /// _ | `false` | `je 1234h`
1548 ///
1549 /// # Arguments
1550 ///
1551 /// * `value`: New value
1552 #[inline]
1553 pub fn set_show_branch_size(&mut self, value: bool) {
1554 if value {
1555 self.options1 |= Flags1::SHOW_BRANCH_SIZE;
1556 } else {
1557 self.options1 &= !Flags1::SHOW_BRANCH_SIZE;
1558 }
1559 }
1560
1561 /// Use pseudo instructions
1562 ///
1563 /// Default | Value | Example
1564 /// --------|-------|--------
1565 /// 👍 | `true` | `vcmpnltsd xmm2,xmm6,xmm3`
1566 /// _ | `false` | `vcmpsd xmm2,xmm6,xmm3,5`
1567 #[must_use]
1568 #[inline]
1569 pub const fn use_pseudo_ops(&self) -> bool {
1570 (self.options1 & Flags1::USE_PSEUDO_OPS) != 0
1571 }
1572
1573 /// Use pseudo instructions
1574 ///
1575 /// Default | Value | Example
1576 /// --------|-------|--------
1577 /// 👍 | `true` | `vcmpnltsd xmm2,xmm6,xmm3`
1578 /// _ | `false` | `vcmpsd xmm2,xmm6,xmm3,5`
1579 ///
1580 /// # Arguments
1581 ///
1582 /// * `value`: New value
1583 #[inline]
1584 pub fn set_use_pseudo_ops(&mut self, value: bool) {
1585 if value {
1586 self.options1 |= Flags1::USE_PSEUDO_OPS;
1587 } else {
1588 self.options1 &= !Flags1::USE_PSEUDO_OPS;
1589 }
1590 }
1591
1592 /// Show the original value after the symbol name
1593 ///
1594 /// Default | Value | Example
1595 /// --------|-------|--------
1596 /// _ | `true` | `mov eax,[myfield (12345678)]`
1597 /// 👍 | `false` | `mov eax,[myfield]`
1598 #[must_use]
1599 #[inline]
1600 pub const fn show_symbol_address(&self) -> bool {
1601 (self.options1 & Flags1::SHOW_SYMBOL_ADDRESS) != 0
1602 }
1603
1604 /// Show the original value after the symbol name
1605 ///
1606 /// Default | Value | Example
1607 /// --------|-------|--------
1608 /// _ | `true` | `mov eax,[myfield (12345678)]`
1609 /// 👍 | `false` | `mov eax,[myfield]`
1610 ///
1611 /// # Arguments
1612 ///
1613 /// * `value`: New value
1614 #[inline]
1615 pub fn set_show_symbol_address(&mut self, value: bool) {
1616 if value {
1617 self.options1 |= Flags1::SHOW_SYMBOL_ADDRESS;
1618 } else {
1619 self.options1 &= !Flags1::SHOW_SYMBOL_ADDRESS;
1620 }
1621 }
1622
1623 /// (gas only): If `true`, the formatter doesn't add `%` to registers
1624 ///
1625 /// Default | Value | Example
1626 /// --------|-------|--------
1627 /// _ | `true` | `mov eax,ecx`
1628 /// 👍 | `false` | `mov %eax,%ecx`
1629 #[must_use]
1630 #[inline]
1631 pub const fn gas_naked_registers(&self) -> bool {
1632 (self.options1 & Flags1::GAS_NAKED_REGISTERS) != 0
1633 }
1634
1635 /// (gas only): If `true`, the formatter doesn't add `%` to registers
1636 ///
1637 /// Default | Value | Example
1638 /// --------|-------|--------
1639 /// _ | `true` | `mov eax,ecx`
1640 /// 👍 | `false` | `mov %eax,%ecx`
1641 ///
1642 /// # Arguments
1643 ///
1644 /// * `value`: New value
1645 #[inline]
1646 pub fn set_gas_naked_registers(&mut self, value: bool) {
1647 if value {
1648 self.options1 |= Flags1::GAS_NAKED_REGISTERS;
1649 } else {
1650 self.options1 &= !Flags1::GAS_NAKED_REGISTERS;
1651 }
1652 }
1653
1654 /// (gas only): Shows the mnemonic size suffix even when not needed
1655 ///
1656 /// Default | Value | Example
1657 /// --------|-------|--------
1658 /// _ | `true` | `movl %eax,%ecx`
1659 /// 👍 | `false` | `mov %eax,%ecx`
1660 #[must_use]
1661 #[inline]
1662 pub const fn gas_show_mnemonic_size_suffix(&self) -> bool {
1663 (self.options1 & Flags1::GAS_SHOW_MNEMONIC_SIZE_SUFFIX) != 0
1664 }
1665
1666 /// (gas only): Shows the mnemonic size suffix even when not needed
1667 ///
1668 /// Default | Value | Example
1669 /// --------|-------|--------
1670 /// _ | `true` | `movl %eax,%ecx`
1671 /// 👍 | `false` | `mov %eax,%ecx`
1672 ///
1673 /// # Arguments
1674 ///
1675 /// * `value`: New value
1676 #[inline]
1677 pub fn set_gas_show_mnemonic_size_suffix(&mut self, value: bool) {
1678 if value {
1679 self.options1 |= Flags1::GAS_SHOW_MNEMONIC_SIZE_SUFFIX;
1680 } else {
1681 self.options1 &= !Flags1::GAS_SHOW_MNEMONIC_SIZE_SUFFIX;
1682 }
1683 }
1684
1685 /// (gas only): Add a space after the comma if it's a memory operand
1686 ///
1687 /// Default | Value | Example
1688 /// --------|-------|--------
1689 /// _ | `true` | `(%eax, %ecx, 2)`
1690 /// 👍 | `false` | `(%eax,%ecx,2)`
1691 #[must_use]
1692 #[inline]
1693 pub const fn gas_space_after_memory_operand_comma(&self) -> bool {
1694 (self.options1 & Flags1::GAS_SPACE_AFTER_MEMORY_OPERAND_COMMA) != 0
1695 }
1696
1697 /// (gas only): Add a space after the comma if it's a memory operand
1698 ///
1699 /// Default | Value | Example
1700 /// --------|-------|--------
1701 /// _ | `true` | `(%eax, %ecx, 2)`
1702 /// 👍 | `false` | `(%eax,%ecx,2)`
1703 ///
1704 /// # Arguments
1705 ///
1706 /// * `value`: New value
1707 #[inline]
1708 pub fn set_gas_space_after_memory_operand_comma(&mut self, value: bool) {
1709 if value {
1710 self.options1 |= Flags1::GAS_SPACE_AFTER_MEMORY_OPERAND_COMMA;
1711 } else {
1712 self.options1 &= !Flags1::GAS_SPACE_AFTER_MEMORY_OPERAND_COMMA;
1713 }
1714 }
1715
1716 /// (masm only): Add a `DS` segment override even if it's not present. Used if it's 16/32-bit code and mem op is a displ
1717 ///
1718 /// Default | Value | Example
1719 /// --------|-------|--------
1720 /// 👍 | `true` | `mov eax,ds:[12345678]`
1721 /// _ | `false` | `mov eax,[12345678]`
1722 #[must_use]
1723 #[inline]
1724 pub const fn masm_add_ds_prefix32(&self) -> bool {
1725 (self.options1 & Flags1::MASM_ADD_DS_PREFIX32) != 0
1726 }
1727
1728 /// (masm only): Add a `DS` segment override even if it's not present. Used if it's 16/32-bit code and mem op is a displ
1729 ///
1730 /// Default | Value | Example
1731 /// --------|-------|--------
1732 /// 👍 | `true` | `mov eax,ds:[12345678]`
1733 /// _ | `false` | `mov eax,[12345678]`
1734 ///
1735 /// # Arguments
1736 ///
1737 /// * `value`: New value
1738 #[inline]
1739 pub fn set_masm_add_ds_prefix32(&mut self, value: bool) {
1740 if value {
1741 self.options1 |= Flags1::MASM_ADD_DS_PREFIX32;
1742 } else {
1743 self.options1 &= !Flags1::MASM_ADD_DS_PREFIX32;
1744 }
1745 }
1746
1747 /// (masm only): Show symbols in brackets
1748 ///
1749 /// Default | Value | Example
1750 /// --------|-------|--------
1751 /// 👍 | `true` | `[ecx+symbol]` / `[symbol]`
1752 /// _ | `false` | `symbol[ecx]` / `symbol`
1753 #[must_use]
1754 #[inline]
1755 pub const fn masm_symbol_displ_in_brackets(&self) -> bool {
1756 (self.options1 & Flags1::MASM_SYMBOL_DISPL_IN_BRACKETS) != 0
1757 }
1758
1759 /// (masm only): Show symbols in brackets
1760 ///
1761 /// Default | Value | Example
1762 /// --------|-------|--------
1763 /// 👍 | `true` | `[ecx+symbol]` / `[symbol]`
1764 /// _ | `false` | `symbol[ecx]` / `symbol`
1765 ///
1766 /// # Arguments
1767 ///
1768 /// * `value`: New value
1769 #[inline]
1770 pub fn set_masm_symbol_displ_in_brackets(&mut self, value: bool) {
1771 if value {
1772 self.options1 |= Flags1::MASM_SYMBOL_DISPL_IN_BRACKETS;
1773 } else {
1774 self.options1 &= !Flags1::MASM_SYMBOL_DISPL_IN_BRACKETS;
1775 }
1776 }
1777
1778 /// (masm only): Show displacements in brackets
1779 ///
1780 /// Default | Value | Example
1781 /// --------|-------|--------
1782 /// 👍 | `true` | `[ecx+1234h]`
1783 /// _ | `false` | `1234h[ecx]`
1784 #[must_use]
1785 #[inline]
1786 pub const fn masm_displ_in_brackets(&self) -> bool {
1787 (self.options1 & Flags1::MASM_DISPL_IN_BRACKETS) != 0
1788 }
1789
1790 /// (masm only): Show displacements in brackets
1791 ///
1792 /// Default | Value | Example
1793 /// --------|-------|--------
1794 /// 👍 | `true` | `[ecx+1234h]`
1795 /// _ | `false` | `1234h[ecx]`
1796 ///
1797 /// # Arguments
1798 ///
1799 /// * `value`: New value
1800 #[inline]
1801 pub fn set_masm_displ_in_brackets(&mut self, value: bool) {
1802 if value {
1803 self.options1 |= Flags1::MASM_DISPL_IN_BRACKETS;
1804 } else {
1805 self.options1 &= !Flags1::MASM_DISPL_IN_BRACKETS;
1806 }
1807 }
1808
1809 /// (nasm only): Shows `BYTE`, `WORD`, `DWORD` or `QWORD` if it's a sign extended immediate operand value
1810 ///
1811 /// Default | Value | Example
1812 /// --------|-------|--------
1813 /// _ | `true` | `or rcx,byte -1`
1814 /// 👍 | `false` | `or rcx,-1`
1815 #[must_use]
1816 #[inline]
1817 pub const fn nasm_show_sign_extended_immediate_size(&self) -> bool {
1818 (self.options2 & Flags2::NASM_SHOW_SIGN_EXTENDED_IMMEDIATE_SIZE) != 0
1819 }
1820
1821 /// (nasm only): Shows `BYTE`, `WORD`, `DWORD` or `QWORD` if it's a sign extended immediate operand value
1822 ///
1823 /// Default | Value | Example
1824 /// --------|-------|--------
1825 /// _ | `true` | `or rcx,byte -1`
1826 /// 👍 | `false` | `or rcx,-1`
1827 ///
1828 /// # Arguments
1829 ///
1830 /// * `value`: New value
1831 #[inline]
1832 pub fn set_nasm_show_sign_extended_immediate_size(&mut self, value: bool) {
1833 if value {
1834 self.options2 |= Flags2::NASM_SHOW_SIGN_EXTENDED_IMMEDIATE_SIZE;
1835 } else {
1836 self.options2 &= !Flags2::NASM_SHOW_SIGN_EXTENDED_IMMEDIATE_SIZE;
1837 }
1838 }
1839
1840 /// Use `st(0)` instead of `st` if `st` can be used. Ignored by the nasm formatter.
1841 ///
1842 /// Default | Value | Example
1843 /// --------|-------|--------
1844 /// _ | `true` | `fadd st(0),st(3)`
1845 /// 👍 | `false` | `fadd st,st(3)`
1846 #[must_use]
1847 #[inline]
1848 pub const fn prefer_st0(&self) -> bool {
1849 (self.options2 & Flags2::PREFER_ST0) != 0
1850 }
1851
1852 /// Use `st(0)` instead of `st` if `st` can be used. Ignored by the nasm formatter.
1853 ///
1854 /// Default | Value | Example
1855 /// --------|-------|--------
1856 /// _ | `true` | `fadd st(0),st(3)`
1857 /// 👍 | `false` | `fadd st,st(3)`
1858 ///
1859 /// # Arguments
1860 ///
1861 /// * `value`: New value
1862 #[inline]
1863 pub fn set_prefer_st0(&mut self, value: bool) {
1864 if value {
1865 self.options2 |= Flags2::PREFER_ST0;
1866 } else {
1867 self.options2 &= !Flags2::PREFER_ST0;
1868 }
1869 }
1870
1871 /// Show useless prefixes. If it has useless prefixes, it could be data and not code.
1872 ///
1873 /// Default | Value | Example
1874 /// --------|-------|--------
1875 /// _ | `true` | `es rep add eax,ecx`
1876 /// 👍 | `false` | `add eax,ecx`
1877 #[must_use]
1878 #[inline]
1879 pub const fn show_useless_prefixes(&self) -> bool {
1880 (self.options2 & Flags2::SHOW_USELESS_PREFIXES) != 0
1881 }
1882
1883 /// Show useless prefixes. If it has useless prefixes, it could be data and not code.
1884 ///
1885 /// Default | Value | Example
1886 /// --------|-------|--------
1887 /// _ | `true` | `es rep add eax,ecx`
1888 /// 👍 | `false` | `add eax,ecx`
1889 ///
1890 /// # Arguments
1891 ///
1892 /// * `value`: New value
1893 #[inline]
1894 pub fn set_show_useless_prefixes(&mut self, value: bool) {
1895 if value {
1896 self.options2 |= Flags2::SHOW_USELESS_PREFIXES;
1897 } else {
1898 self.options2 &= !Flags2::SHOW_USELESS_PREFIXES;
1899 }
1900 }
1901
1902 /// Mnemonic condition code selector (eg. `JB` / `JC` / `JNAE`)
1903 ///
1904 /// Default: `JB`, `CMOVB`, `SETB`
1905 #[must_use]
1906 #[inline]
1907 pub const fn cc_b(&self) -> CC_b {
1908 self.cc_b
1909 }
1910
1911 /// Mnemonic condition code selector (eg. `JB` / `JC` / `JNAE`)
1912 ///
1913 /// Default: `JB`, `CMOVB`, `SETB`
1914 ///
1915 /// # Arguments
1916 ///
1917 /// * `value`: New value
1918 #[inline]
1919 pub fn set_cc_b(&mut self, value: CC_b) {
1920 self.cc_b = value;
1921 }
1922
1923 /// Mnemonic condition code selector (eg. `JAE` / `JNB` / `JNC`)
1924 ///
1925 /// Default: `JAE`, `CMOVAE`, `SETAE`
1926 #[must_use]
1927 #[inline]
1928 pub const fn cc_ae(&self) -> CC_ae {
1929 self.cc_ae
1930 }
1931
1932 /// Mnemonic condition code selector (eg. `JAE` / `JNB` / `JNC`)
1933 ///
1934 /// Default: `JAE`, `CMOVAE`, `SETAE`
1935 ///
1936 /// # Arguments
1937 ///
1938 /// * `value`: New value
1939 #[inline]
1940 pub fn set_cc_ae(&mut self, value: CC_ae) {
1941 self.cc_ae = value;
1942 }
1943
1944 /// Mnemonic condition code selector (eg. `JE` / `JZ`)
1945 ///
1946 /// Default: `JE`, `CMOVE`, `SETE`, `LOOPE`, `REPE`
1947 #[must_use]
1948 #[inline]
1949 pub const fn cc_e(&self) -> CC_e {
1950 self.cc_e
1951 }
1952
1953 /// Mnemonic condition code selector (eg. `JE` / `JZ`)
1954 ///
1955 /// Default: `JE`, `CMOVE`, `SETE`, `LOOPE`, `REPE`
1956 ///
1957 /// # Arguments
1958 ///
1959 /// * `value`: New value
1960 #[inline]
1961 pub fn set_cc_e(&mut self, value: CC_e) {
1962 self.cc_e = value;
1963 }
1964
1965 /// Mnemonic condition code selector (eg. `JNE` / `JNZ`)
1966 ///
1967 /// Default: `JNE`, `CMOVNE`, `SETNE`, `LOOPNE`, `REPNE`
1968 #[must_use]
1969 #[inline]
1970 pub const fn cc_ne(&self) -> CC_ne {
1971 self.cc_ne
1972 }
1973
1974 /// Mnemonic condition code selector (eg. `JNE` / `JNZ`)
1975 ///
1976 /// Default: `JNE`, `CMOVNE`, `SETNE`, `LOOPNE`, `REPNE`
1977 ///
1978 /// # Arguments
1979 ///
1980 /// * `value`: New value
1981 #[inline]
1982 pub fn set_cc_ne(&mut self, value: CC_ne) {
1983 self.cc_ne = value;
1984 }
1985
1986 /// Mnemonic condition code selector (eg. `JBE` / `JNA`)
1987 ///
1988 /// Default: `JBE`, `CMOVBE`, `SETBE`
1989 #[must_use]
1990 #[inline]
1991 pub const fn cc_be(&self) -> CC_be {
1992 self.cc_be
1993 }
1994
1995 /// Mnemonic condition code selector (eg. `JBE` / `JNA`)
1996 ///
1997 /// Default: `JBE`, `CMOVBE`, `SETBE`
1998 ///
1999 /// # Arguments
2000 ///
2001 /// * `value`: New value
2002 #[inline]
2003 pub fn set_cc_be(&mut self, value: CC_be) {
2004 self.cc_be = value;
2005 }
2006
2007 /// Mnemonic condition code selector (eg. `JA` / `JNBE`)
2008 ///
2009 /// Default: `JA`, `CMOVA`, `SETA`
2010 #[must_use]
2011 #[inline]
2012 pub const fn cc_a(&self) -> CC_a {
2013 self.cc_a
2014 }
2015
2016 /// Mnemonic condition code selector (eg. `JA` / `JNBE`)
2017 ///
2018 /// Default: `JA`, `CMOVA`, `SETA`
2019 ///
2020 /// # Arguments
2021 ///
2022 /// * `value`: New value
2023 #[inline]
2024 pub fn set_cc_a(&mut self, value: CC_a) {
2025 self.cc_a = value;
2026 }
2027
2028 /// Mnemonic condition code selector (eg. `JP` / `JPE`)
2029 ///
2030 /// Default: `JP`, `CMOVP`, `SETP`
2031 #[must_use]
2032 #[inline]
2033 pub const fn cc_p(&self) -> CC_p {
2034 self.cc_p
2035 }
2036
2037 /// Mnemonic condition code selector (eg. `JP` / `JPE`)
2038 ///
2039 /// Default: `JP`, `CMOVP`, `SETP`
2040 ///
2041 /// # Arguments
2042 ///
2043 /// * `value`: New value
2044 #[inline]
2045 pub fn set_cc_p(&mut self, value: CC_p) {
2046 self.cc_p = value;
2047 }
2048
2049 /// Mnemonic condition code selector (eg. `JNP` / `JPO`)
2050 ///
2051 /// Default: `JNP`, `CMOVNP`, `SETNP`
2052 #[must_use]
2053 #[inline]
2054 pub const fn cc_np(&self) -> CC_np {
2055 self.cc_np
2056 }
2057
2058 /// Mnemonic condition code selector (eg. `JNP` / `JPO`)
2059 ///
2060 /// Default: `JNP`, `CMOVNP`, `SETNP`
2061 ///
2062 /// # Arguments
2063 ///
2064 /// * `value`: New value
2065 #[inline]
2066 pub fn set_cc_np(&mut self, value: CC_np) {
2067 self.cc_np = value;
2068 }
2069
2070 /// Mnemonic condition code selector (eg. `JL` / `JNGE`)
2071 ///
2072 /// Default: `JL`, `CMOVL`, `SETL`
2073 #[must_use]
2074 #[inline]
2075 pub const fn cc_l(&self) -> CC_l {
2076 self.cc_l
2077 }
2078
2079 /// Mnemonic condition code selector (eg. `JL` / `JNGE`)
2080 ///
2081 /// Default: `JL`, `CMOVL`, `SETL`
2082 ///
2083 /// # Arguments
2084 ///
2085 /// * `value`: New value
2086 #[inline]
2087 pub fn set_cc_l(&mut self, value: CC_l) {
2088 self.cc_l = value;
2089 }
2090
2091 /// Mnemonic condition code selector (eg. `JGE` / `JNL`)
2092 ///
2093 /// Default: `JGE`, `CMOVGE`, `SETGE`
2094 #[must_use]
2095 #[inline]
2096 pub const fn cc_ge(&self) -> CC_ge {
2097 self.cc_ge
2098 }
2099
2100 /// Mnemonic condition code selector (eg. `JGE` / `JNL`)
2101 ///
2102 /// Default: `JGE`, `CMOVGE`, `SETGE`
2103 ///
2104 /// # Arguments
2105 ///
2106 /// * `value`: New value
2107 #[inline]
2108 pub fn set_cc_ge(&mut self, value: CC_ge) {
2109 self.cc_ge = value;
2110 }
2111
2112 /// Mnemonic condition code selector (eg. `JLE` / `JNG`)
2113 ///
2114 /// Default: `JLE`, `CMOVLE`, `SETLE`
2115 #[must_use]
2116 #[inline]
2117 pub const fn cc_le(&self) -> CC_le {
2118 self.cc_le
2119 }
2120
2121 /// Mnemonic condition code selector (eg. `JLE` / `JNG`)
2122 ///
2123 /// Default: `JLE`, `CMOVLE`, `SETLE`
2124 ///
2125 /// # Arguments
2126 ///
2127 /// * `value`: New value
2128 #[inline]
2129 pub fn set_cc_le(&mut self, value: CC_le) {
2130 self.cc_le = value;
2131 }
2132
2133 /// Mnemonic condition code selector (eg. `JG` / `JNLE`)
2134 ///
2135 /// Default: `JG`, `CMOVG`, `SETG`
2136 #[must_use]
2137 #[inline]
2138 pub const fn cc_g(&self) -> CC_g {
2139 self.cc_g
2140 }
2141
2142 /// Mnemonic condition code selector (eg. `JG` / `JNLE`)
2143 ///
2144 /// Default: `JG`, `CMOVG`, `SETG`
2145 ///
2146 /// # Arguments
2147 ///
2148 /// * `value`: New value
2149 #[inline]
2150 pub fn set_cc_g(&mut self, value: CC_g) {
2151 self.cc_g = value;
2152 }
2153}
2154
2155impl Default for FormatterOptions {
2156 #[must_use]
2157 #[inline]
2158 fn default() -> Self {
2159 FormatterOptions::new()
2160 }
2161}