summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/unidasm.cpp
diff options
context:
space:
mode:
author AJR <ariedlmayer@gmail.com>2026-05-17 16:13:12 -0400
committer AJR <ariedlmayer@gmail.com>2026-05-17 16:13:12 -0400
commita29ba2a5bd4860821f5a2dc34ab7f4adc73ca6bf (patch)
treeab429d6bc7853b4cf41a24855d6ae3bdf3f52d11 /src/tools/unidasm.cpp
parente277674de1ff9883750025242095590a0408cf78 (diff)
unidasm.cpp: Use C++20 bit functions
Diffstat (limited to 'src/tools/unidasm.cpp')
-rw-r--r--src/tools/unidasm.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/tools/unidasm.cpp b/src/tools/unidasm.cpp
index a6fd193ae05..2224bb04c98 100644
--- a/src/tools/unidasm.cpp
+++ b/src/tools/unidasm.cpp
@@ -227,13 +227,12 @@ using util::BIT;
#include "cpu/z8000/8000dasm.h"
#include "corestr.h"
-#include "eminline.h"
-#include "endianness.h"
#include "ioprocs.h"
#include "osdfile.h"
#include "strformat.h"
#include <algorithm>
+#include <bit>
#include <cctype>
#include <cstdio>
#include <cstdlib>
@@ -357,13 +356,13 @@ struct nec_unidasm_t : nec_disassembler::config
} nec_unidasm;
-static constexpr auto le = util::endianness::little;
-static constexpr auto be = util::endianness::big;
+static constexpr auto le = std::endian::little;
+static constexpr auto be = std::endian::big;
struct dasm_table_entry
{
const char * name;
- util::endianness endian;
+ std::endian endian;
int8_t pcshift;
std::function<util::disasm_interface *()> alloc;
};
@@ -1340,7 +1339,7 @@ int disasm_file(util::random_read &file, u64 length, options &opts)
// Compute the pc wraparound
offs_t pclength = opts.dasm->pcshift < 0 ? rounded_size >> -opts.dasm->pcshift : rounded_size << opts.dasm->pcshift;
offs_t limit = opts.basepc + pclength;
- offs_t pc_mask = limit ? util::make_bitmask<offs_t>(32 - count_leading_zeros_32(limit - 1)) : 0xffffffff;
+ offs_t pc_mask = limit ? util::make_bitmask<offs_t>(std::bit_width(limit - 1)) : 0xffffffff;
// Compute the page wraparound
offs_t page_mask = flags & util::disasm_interface::PAGED ? (1 << disasm->page_address_bits()) - 1 : 0;
@@ -1387,7 +1386,7 @@ int disasm_file(util::random_read &file, u64 length, options &opts)
}
// Compute the shift amount from pc delta to granularity-sized elements
- u32 granularity_shift = 31 - count_leading_zeros_32(disasm->opcode_alignment());
+ u32 granularity_shift = std::bit_width(disasm->opcode_alignment()) - 1;
// Number of pc steps to disassemble
u32 count = pclength;
@@ -1397,7 +1396,7 @@ int disasm_file(util::random_read &file, u64 length, options &opts)
// pc to string conversion
std::function<std::string (offs_t pc)> pc_to_string;
- int aw = 32 - count_leading_zeros_32(pc_mask);
+ int aw = std::bit_width(pc_mask);
bool is_octal = opts.octal; // Parameter? Per-cpu config?
if((flags & util::disasm_interface::PAGED2LEVEL) == util::disasm_interface::PAGED2LEVEL) {
int bits1 = disasm->page_address_bits();