openMSX
Dasm.hh
Go to the documentation of this file.
1#ifndef DASM_HH
2#define DASM_HH
3
4#include "EmuTime.hh"
5
6#include "function_ref.hh"
7
8#include <cstdint>
9#include <functional>
10#include <span>
11#include <string>
12
13namespace openmsx {
14
15class MSXCPUInterface;
16
17void appendAddrAsHex(std::string& output, uint16_t addr);
18
26std::optional<unsigned> instructionLength(std::span<const uint8_t> bin);
27
28std::span<uint8_t> fetchInstruction(const MSXCPUInterface& interface, uint16_t addr,
29 std::span<uint8_t, 4> buffer, EmuTime::param time);
30
40unsigned dasm(std::span<const uint8_t> opcode, uint16_t pc, std::string& dest,
41 function_ref<void(std::string&, uint16_t)> appendAddr = &appendAddrAsHex);
42
52unsigned dasm(const MSXCPUInterface& interface, uint16_t pc, std::span<uint8_t, 4> buf,
53 std::string& dest, EmuTime::param time,
54 function_ref<void(std::string&, uint16_t)> appendAddr = &appendAddrAsHex);
55
74uint16_t instructionBoundary(const MSXCPUInterface& interface, uint16_t addr,
75 EmuTime::param time);
76
85uint16_t nInstructionsBefore(const MSXCPUInterface& interface, uint16_t addr,
86 EmuTime::param time, int n);
87
88} // namespace openmsx
89
90#endif
This file implemented 3 utility functions:
Definition Autofire.cc:11
std::span< uint8_t > fetchInstruction(const MSXCPUInterface &interface, uint16_t addr, std::span< uint8_t, 4 > buffer, EmuTime::param time)
Definition Dasm.cc:109
std::optional< unsigned > instructionLength(std::span< const uint8_t > bin)
Calculate the length of the instruction at the given address.
Definition Dasm.cc:26
uint16_t instructionBoundary(const MSXCPUInterface &interface, uint16_t addr, EmuTime::param time)
This is only an heuristic to display instructions in a debugger disassembly view.
Definition Dasm.cc:196
uint16_t nInstructionsBefore(const MSXCPUInterface &interface, uint16_t addr, EmuTime::param time, int n)
Get the start address of the 'n'th instruction before the instruction containing the byte at the give...
Definition Dasm.cc:203
void appendAddrAsHex(std::string &output, uint16_t addr)
Definition Dasm.cc:21
unsigned dasm(std::span< const uint8_t > opcode, uint16_t pc, std::string &dest, function_ref< void(std::string &, uint16_t)> appendAddr)
Disassemble.
Definition Dasm.cc:38