Changed disassembler overrides to use 'std::ostream &' internally

This commit is contained in:
Nathan Woods 2016-10-30 10:49:25 -04:00
parent 894c6320a0
commit 9d0f2ae21c
10 changed files with 136 additions and 288 deletions

View File

@ -70,7 +70,12 @@ offs_t device_disasm_interface::disassemble(char *buffer, offs_t pc, const uint8
// check for disassembler override
if (!m_dasm_override.isnull())
result = m_dasm_override(device(), buffer, pc, oprom, opram, options);
{
std::ostringstream stream;
result = m_dasm_override(device(), stream, pc, oprom, opram, options);
std::string stream_str = stream.str();
strcpy(buffer, stream_str.c_str());
}
if (result == 0)
result = disasm_disassemble(buffer, pc, oprom, opram, options);

View File

@ -53,7 +53,7 @@ const uint32_t DASMFLAG_LENGTHMASK = 0x0000ffff; // the low 16-bits contain
// TYPE DEFINITIONS
//**************************************************************************
typedef device_delegate<offs_t (device_t &device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)> dasm_override_delegate;
typedef device_delegate<offs_t (device_t &device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)> dasm_override_delegate;
// ======================> device_disasm_interface

View File

@ -56,7 +56,7 @@ public:
required_ioport m_io_penb;
required_ioport m_io_portd;
offs_t palm_dasm_override(device_t &device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options);
offs_t palm_dasm_override(device_t &device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options);
};

View File

@ -1162,7 +1162,7 @@ static const char *lookup_trap(uint16_t opcode)
return nullptr;
}
offs_t palm_state::palm_dasm_override(device_t &device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
offs_t palm_state::palm_dasm_override(device_t &device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
{
uint16_t opcode;
unsigned result = 0;
@ -1176,18 +1176,11 @@ offs_t palm_state::palm_dasm_override(device_t &device, char *buffer, offs_t pc,
callnum = ((callnum >> 8) & 0x00ff) | ((callnum << 8) & 0xff00);
trap = lookup_trap(callnum);
result = 2;
if (trap)
{
strcpy(buffer, trap);
}
else
{
sprintf(buffer, "trap #$f");
}
stream << (trap ? trap : "trap #$f");
}
else if ((opcode & 0xF000) == 0xA000)
{
sprintf(buffer, "Call Index: %04x", opcode);
util::stream_format(stream, "Call Index: %04x", opcode);
result = 2;
}
return result;

View File

@ -141,7 +141,8 @@ public:
DECLARE_WRITE_LINE_MEMBER( cart_w ) { cart_w((bool) state); }
// disassembly override
offs_t dasm_override(device_t &device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options);
static offs_t os9_dasm_override(device_t &device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options);
offs_t dasm_override(device_t &device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options);
protected:
// device-level overrides

View File

@ -221,7 +221,7 @@ public:
required_device<floppy_connector> m_floppy3;
required_device<palette_device> m_palette;
offs_t dgnbeta_dasm_override(device_t &device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options);
offs_t dgnbeta_dasm_override(device_t &device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options);
private:
void execute_beta_key_dump(int ref, int params, const char *param[]);

View File

@ -521,7 +521,7 @@ public:
void mac_driver_init(model_t model);
void mac_install_memory(offs_t memory_begin, offs_t memory_end,
offs_t memory_size, void *memory_data, int is_rom, const char *bank);
offs_t mac_dasm_override(device_t &device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options);
offs_t mac_dasm_override(device_t &device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options);
};
#endif /* MAC_H_ */

View File

@ -1206,90 +1206,90 @@ void coco_state::cart_w(bool state)
static const char *const os9syscalls[] =
{
"F$Link", /* Link to Module */
"F$Load", /* Load Module from File */
"F$UnLink", /* Unlink Module */
"F$Fork", /* Start New Process */
"F$Wait", /* Wait for Child Process to Die */
"F$Chain", /* Chain Process to New Module */
"F$Exit", /* Terminate Process */
"F$Mem", /* Set Memory Size */
"F$Send", /* Send Signal to Process */
"F$Icpt", /* Set Signal Intercept */
"F$Sleep", /* Suspend Process */
"F$SSpd", /* Suspend Process */
"F$ID", /* Return Process ID */
"F$SPrior", /* Set Process Priority */
"F$SSWI", /* Set Software Interrupt */
"F$PErr", /* Print Error */
"F$PrsNam", /* Parse Pathlist Name */
"F$CmpNam", /* Compare Two Names */
"F$SchBit", /* Search Bit Map */
"F$AllBit", /* Allocate in Bit Map */
"F$DelBit", /* Deallocate in Bit Map */
"F$Time", /* Get Current Time */
"F$STime", /* Set Current Time */
"F$CRC", /* Generate CRC */
"F$GPrDsc", /* get Process Descriptor copy */
"F$GBlkMp", /* get System Block Map copy */
"F$GModDr", /* get Module Directory copy */
"F$CpyMem", /* Copy External Memory */
"F$SUser", /* Set User ID number */
"F$UnLoad", /* Unlink Module by name */
"F$Alarm", /* Color Computer Alarm Call (system wide) */
"F$Link", // Link to Module
"F$Load", // Load Module from File
"F$UnLink", // Unlink Module
"F$Fork", // Start New Process
"F$Wait", // Wait for Child Process to Die
"F$Chain", // Chain Process to New Module
"F$Exit", // Terminate Process
"F$Mem", // Set Memory Size
"F$Send", // Send Signal to Process
"F$Icpt", // Set Signal Intercept
"F$Sleep", // Suspend Process
"F$SSpd", // Suspend Process
"F$ID", // Return Process ID
"F$SPrior", // Set Process Priority
"F$SSWI", // Set Software Interrupt
"F$PErr", // Print Error
"F$PrsNam", // Parse Pathlist Name
"F$CmpNam", // Compare Two Names
"F$SchBit", // Search Bit Map
"F$AllBit", // Allocate in Bit Map
"F$DelBit", // Deallocate in Bit Map
"F$Time", // Get Current Time
"F$STime", // Set Current Time
"F$CRC", // Generate CRC
"F$GPrDsc", // get Process Descriptor copy
"F$GBlkMp", // get System Block Map copy
"F$GModDr", // get Module Directory copy
"F$CpyMem", // Copy External Memory
"F$SUser", // Set User ID number
"F$UnLoad", // Unlink Module by name
"F$Alarm", // Color Computer Alarm Call (system wide)
nullptr,
nullptr,
"F$NMLink", /* Color Computer NonMapping Link */
"F$NMLoad", /* Color Computer NonMapping Load */
"F$NMLink", // Color Computer NonMapping Link
"F$NMLoad", // Color Computer NonMapping Load
nullptr,
nullptr,
"F$TPS", /* Return System's Ticks Per Second */
"F$TimAlm", /* COCO individual process alarm call */
"F$VIRQ", /* Install/Delete Virtual IRQ */
"F$SRqMem", /* System Memory Request */
"F$SRtMem", /* System Memory Return */
"F$IRQ", /* Enter IRQ Polling Table */
"F$IOQu", /* Enter I/O Queue */
"F$AProc", /* Enter Active Process Queue */
"F$NProc", /* Start Next Process */
"F$VModul", /* Validate Module */
"F$Find64", /* Find Process/Path Descriptor */
"F$All64", /* Allocate Process/Path Descriptor */
"F$Ret64", /* Return Process/Path Descriptor */
"F$SSvc", /* Service Request Table Initialization */
"F$IODel", /* Delete I/O Module */
"F$SLink", /* System Link */
"F$Boot", /* Bootstrap System */
"F$BtMem", /* Bootstrap Memory Request */
"F$GProcP", /* Get Process ptr */
"F$Move", /* Move Data (low bound first) */
"F$AllRAM", /* Allocate RAM blocks */
"F$AllImg", /* Allocate Image RAM blocks */
"F$DelImg", /* Deallocate Image RAM blocks */
"F$SetImg", /* Set Process DAT Image */
"F$FreeLB", /* Get Free Low Block */
"F$FreeHB", /* Get Free High Block */
"F$AllTsk", /* Allocate Process Task number */
"F$DelTsk", /* Deallocate Process Task number */
"F$SetTsk", /* Set Process Task DAT registers */
"F$ResTsk", /* Reserve Task number */
"F$RelTsk", /* Release Task number */
"F$DATLog", /* Convert DAT Block/Offset to Logical */
"F$DATTmp", /* Make temporary DAT image (Obsolete) */
"F$LDAXY", /* Load A [X,[Y]] */
"F$LDAXYP", /* Load A [X+,[Y]] */
"F$LDDDXY", /* Load D [D+X,[Y]] */
"F$LDABX", /* Load A from 0,X in task B */
"F$STABX", /* Store A at 0,X in task B */
"F$AllPrc", /* Allocate Process Descriptor */
"F$DelPrc", /* Deallocate Process Descriptor */
"F$ELink", /* Link using Module Directory Entry */
"F$FModul", /* Find Module Directory Entry */
"F$MapBlk", /* Map Specific Block */
"F$ClrBlk", /* Clear Specific Block */
"F$DelRAM", /* Deallocate RAM blocks */
"F$GCMDir", /* Pack module directory */
"F$AlHRam", /* Allocate HIGH RAM Blocks */
"F$TPS", // Return System's Ticks Per Second
"F$TimAlm", // COCO individual process alarm call
"F$VIRQ", // Install/Delete Virtual IRQ
"F$SRqMem", // System Memory Request
"F$SRtMem", // System Memory Return
"F$IRQ", // Enter IRQ Polling Table
"F$IOQu", // Enter I/O Queue
"F$AProc", // Enter Active Process Queue
"F$NProc", // Start Next Process
"F$VModul", // Validate Module
"F$Find64", // Find Process/Path Descriptor
"F$All64", // Allocate Process/Path Descriptor
"F$Ret64", // Return Process/Path Descriptor
"F$SSvc", // Service Request Table Initialization
"F$IODel", // Delete I/O Module
"F$SLink", // System Link
"F$Boot", // Bootstrap System
"F$BtMem", // Bootstrap Memory Request
"F$GProcP", // Get Process ptr
"F$Move", // Move Data (low bound first)
"F$AllRAM", // Allocate RAM blocks
"F$AllImg", // Allocate Image RAM blocks
"F$DelImg", // Deallocate Image RAM blocks
"F$SetImg", // Set Process DAT Image
"F$FreeLB", // Get Free Low Block
"F$FreeHB", // Get Free High Block
"F$AllTsk", // Allocate Process Task number
"F$DelTsk", // Deallocate Process Task number
"F$SetTsk", // Set Process Task DAT registers
"F$ResTsk", // Reserve Task number
"F$RelTsk", // Release Task number
"F$DATLog", // Convert DAT Block/Offset to Logical
"F$DATTmp", // Make temporary DAT image (Obsolete)
"F$LDAXY", // Load A [X,[Y]]
"F$LDAXYP", // Load A [X+,[Y]]
"F$LDDDXY", // Load D [D+X,[Y]]
"F$LDABX", // Load A from 0,X in task B
"F$STABX", // Store A at 0,X in task B
"F$AllPrc", // Allocate Process Descriptor
"F$DelPrc", // Deallocate Process Descriptor
"F$ELink", // Link using Module Directory Entry
"F$FModul", // Find Module Directory Entry
"F$MapBlk", // Map Specific Block
"F$ClrBlk", // Clear Specific Block
"F$DelRAM", // Deallocate RAM blocks
"F$GCMDir", // Pack module directory
"F$AlHRam", // Allocate HIGH RAM Blocks
nullptr,
nullptr,
nullptr,
@ -1318,8 +1318,8 @@ static const char *const os9syscalls[] =
nullptr,
nullptr,
nullptr,
"F$RegDmp", /* Ron Lammardo's debugging register dump call */
"F$NVRAM", /* Non Volatile RAM (RTC battery backed static) read/write */
"F$RegDmp", // Ron Lammardo's debugging register dump call
"F$NVRAM", // Non Volatile RAM (RTC battery backed static) read/write
nullptr,
nullptr,
nullptr,
@ -1334,40 +1334,51 @@ static const char *const os9syscalls[] =
nullptr,
nullptr,
nullptr,
"I$Attach", /* Attach I/O Device */
"I$Detach", /* Detach I/O Device */
"I$Dup", /* Duplicate Path */
"I$Create", /* Create New File */
"I$Open", /* Open Existing File */
"I$MakDir", /* Make Directory File */
"I$ChgDir", /* Change Default Directory */
"I$Delete", /* Delete File */
"I$Seek", /* Change Current Position */
"I$Read", /* Read Data */
"I$Write", /* Write Data */
"I$ReadLn", /* Read Line of ASCII Data */
"I$WritLn", /* Write Line of ASCII Data */
"I$GetStt", /* Get Path Status */
"I$SetStt", /* Set Path Status */
"I$Close", /* Close Path */
"I$DeletX" /* Delete from current exec dir */
"I$Attach", // Attach I/O Device
"I$Detach", // Detach I/O Device
"I$Dup", // Duplicate Path
"I$Create", // Create New File
"I$Open", // Open Existing File
"I$MakDir", // Make Directory File
"I$ChgDir", // Change Default Directory
"I$Delete", // Delete File
"I$Seek", // Change Current Position
"I$Read", // Read Data
"I$Write", // Write Data
"I$ReadLn", // Read Line of ASCII Data
"I$WritLn", // Write Line of ASCII Data
"I$GetStt", // Get Path Status
"I$SetStt", // Set Path Status
"I$Close", // Close Path
"I$DeletX" // Delete from current exec dir
};
offs_t coco_state::dasm_override(device_t &device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
//-------------------------------------------------
// os9_dasm_override
//-------------------------------------------------
offs_t coco_state::os9_dasm_override(device_t &device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
{
unsigned call;
unsigned result = 0;
offs_t result = 0;
/* check for SWI2 instruction */
// Microware OS-9 (on the CoCo) and a number of other 6x09 based systems used the SWI2
// instruction for syscalls. This checks for a SWI2 and looks up the syscall as appropriate
if ((oprom[0] == 0x10) && (oprom[1] == 0x3F))
{
call = oprom[2];
if ((call < ARRAY_LENGTH(os9syscalls)) && os9syscalls[call])
if ((call < ARRAY_LENGTH(os9syscalls)) && (os9syscalls[call] != nullptr))
{
sprintf(buffer, "OS9 %s", os9syscalls[call]);
util::stream_format(stream, "OS9 %s", os9syscalls[call]);
result = 3;
}
}
return result;
}
offs_t coco_state::dasm_override(device_t &device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
{
return os9_dasm_override(device, stream, pc, oprom, opram, options);
}

View File

@ -65,6 +65,7 @@
#include "cpu/m6809/m6809.h"
#include "machine/6821pia.h"
#include "includes/dgn_beta.h"
#include "includes/coco.h"
#include "machine/mos6551.h"
#include "imagedev/flopdrv.h"
@ -950,172 +951,9 @@ void dgn_beta_state::machine_start()
OS9 Syscalls for disassembly
****************************************************************************/
static const char *const os9syscalls[] =
offs_t dgn_beta_state::dgnbeta_dasm_override(device_t &device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
{
"F$Link", /* Link to Module */
"F$Load", /* Load Module from File */
"F$UnLink", /* Unlink Module */
"F$Fork", /* Start New Process */
"F$Wait", /* Wait for Child Process to Die */
"F$Chain", /* Chain Process to New Module */
"F$Exit", /* Terminate Process */
"F$Mem", /* Set Memory Size */
"F$Send", /* Send Signal to Process */
"F$Icpt", /* Set Signal Intercept */
"F$Sleep", /* Suspend Process */
"F$SSpd", /* Suspend Process */
"F$ID", /* Return Process ID */
"F$SPrior", /* Set Process Priority */
"F$SSWI", /* Set Software Interrupt */
"F$PErr", /* Print Error */
"F$PrsNam", /* Parse Pathlist Name */
"F$CmpNam", /* Compare Two Names */
"F$SchBit", /* Search Bit Map */
"F$AllBit", /* Allocate in Bit Map */
"F$DelBit", /* Deallocate in Bit Map */
"F$Time", /* Get Current Time */
"F$STime", /* Set Current Time */
"F$CRC", /* Generate CRC */
"F$GPrDsc", /* get Process Descriptor copy */
"F$GBlkMp", /* get System Block Map copy */
"F$GModDr", /* get Module Directory copy */
"F$CpyMem", /* Copy External Memory */
"F$SUser", /* Set User ID number */
"F$UnLoad", /* Unlink Module by name */
"F$Alarm", /* Color Computer Alarm Call (system wide) */
nullptr,
nullptr,
"F$NMLink", /* Color Computer NonMapping Link */
"F$NMLoad", /* Color Computer NonMapping Load */
nullptr,
nullptr,
"F$TPS", /* Return System's Ticks Per Second */
"F$TimAlm", /* COCO individual process alarm call */
"F$VIRQ", /* Install/Delete Virtual IRQ */
"F$SRqMem", /* System Memory Request */
"F$SRtMem", /* System Memory Return */
"F$IRQ", /* Enter IRQ Polling Table */
"F$IOQu", /* Enter I/O Queue */
"F$AProc", /* Enter Active Process Queue */
"F$NProc", /* Start Next Process */
"F$VModul", /* Validate Module */
"F$Find64", /* Find Process/Path Descriptor */
"F$All64", /* Allocate Process/Path Descriptor */
"F$Ret64", /* Return Process/Path Descriptor */
"F$SSvc", /* Service Request Table Initialization */
"F$IODel", /* Delete I/O Module */
"F$SLink", /* System Link */
"F$Boot", /* Bootstrap System */
"F$BtMem", /* Bootstrap Memory Request */
"F$GProcP", /* Get Process ptr */
"F$Move", /* Move Data (low bound first) */
"F$AllRAM", /* Allocate RAM blocks */
"F$AllImg", /* Allocate Image RAM blocks */
"F$DelImg", /* Deallocate Image RAM blocks */
"F$SetImg", /* Set Process DAT Image */
"F$FreeLB", /* Get Free Low Block */
"F$FreeHB", /* Get Free High Block */
"F$AllTsk", /* Allocate Process Task number */
"F$DelTsk", /* Deallocate Process Task number */
"F$SetTsk", /* Set Process Task DAT registers */
"F$ResTsk", /* Reserve Task number */
"F$RelTsk", /* Release Task number */
"F$DATLog", /* Convert DAT Block/Offset to Logical */
"F$DATTmp", /* Make temporary DAT image (Obsolete) */
"F$LDAXY", /* Load A [X,[Y]] */
"F$LDAXYP", /* Load A [X+,[Y]] */
"F$LDDDXY", /* Load D [D+X,[Y]] */
"F$LDABX", /* Load A from 0,X in task B */
"F$STABX", /* Store A at 0,X in task B */
"F$AllPrc", /* Allocate Process Descriptor */
"F$DelPrc", /* Deallocate Process Descriptor */
"F$ELink", /* Link using Module Directory Entry */
"F$FModul", /* Find Module Directory Entry */
"F$MapBlk", /* Map Specific Block */
"F$ClrBlk", /* Clear Specific Block */
"F$DelRAM", /* Deallocate RAM blocks */
"F$GCMDir", /* Pack module directory */
"F$AlHRam", /* Allocate HIGH RAM Blocks */
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
"F$RegDmp", /* Ron Lammardo's debugging register dump call */
"F$NVRAM", /* Non Volatile RAM (RTC battery backed static) read/write */
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
"I$Attach", /* Attach I/O Device */
"I$Detach", /* Detach I/O Device */
"I$Dup", /* Duplicate Path */
"I$Create", /* Create New File */
"I$Open", /* Open Existing File */
"I$MakDir", /* Make Directory File */
"I$ChgDir", /* Change Default Directory */
"I$Delete", /* Delete File */
"I$Seek", /* Change Current Position */
"I$Read", /* Read Data */
"I$Write", /* Write Data */
"I$ReadLn", /* Read Line of ASCII Data */
"I$WritLn", /* Write Line of ASCII Data */
"I$GetStt", /* Get Path Status */
"I$SetStt", /* Set Path Status */
"I$Close", /* Close Path */
"I$DeletX" /* Delete from current exec dir */
};
offs_t dgn_beta_state::dgnbeta_dasm_override(device_t &device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
{
unsigned call;
unsigned result = 0;
if ((oprom[0] == 0x10) && (oprom[1] == 0x3F))
{
call = oprom[2];
if ((call < ARRAY_LENGTH(os9syscalls)) && os9syscalls[call])
{
sprintf(buffer, "OS9 %s", os9syscalls[call]);
result = 3;
}
}
return result;
return coco_state::os9_dasm_override(device, stream, pc, oprom, opram, options);
}
void dgn_beta_state::execute_beta_dat_log(int ref, int params, const char *param[])

View File

@ -3181,7 +3181,7 @@ const char *lookup_trap(uint16_t opcode)
offs_t mac_state::mac_dasm_override(device_t &device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
offs_t mac_state::mac_dasm_override(device_t &device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
{
uint16_t opcode;
unsigned result = 0;
@ -3191,9 +3191,9 @@ offs_t mac_state::mac_dasm_override(device_t &device, char *buffer, offs_t pc, c
if ((opcode & 0xF000) == 0xA000)
{
trap = lookup_trap(opcode);
if (trap)
if (trap != nullptr)
{
strcpy(buffer, trap);
stream << trap;
result = 2;
}
}