Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

debugdll.c File Reference


Detailed Description

Simple debugger & disassembler for emu6502

Definition in file debugdll.c.#include "../dllkit/dllkit.h"
#include "../usrmsgs.h"
#include "resource.h"
#include "instructions.h"
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  Regs
 Registers. More...


Defines

#define ADR(X, Y)   (((Y) << 8) + (X))
#define FN   0x80
#define FV   0x40
#define FB   0x10
#define FD   0x08
#define FI   0x04
#define FZ   0x02
#define FC   0x01
#define GETFLAG(FL)   ((regs->P & (FL)) == 0) ? 0 : 1

Functions

void StartDebug ()
 Starts debug.

void DisAsm (int lower, int upper, HANDLE fil, int act)
 Disassembler.

void DumpMemHex (HANDLE fil, UINT adr1, UINT adr2)
 Printer of memory in hex format.

void DumpMem (HANDLE fil, UINT adr1, UINT adr2)
 Printer of memory in raw format.

void printhelp ()
 Displays usage instructions.

HANDLE ofile ()
 Shows save dialog.

HANDLE orfile ()
 Shows open dialog.

void SetReg (Regs *regs, char *buf)
 Helper procedure for StartDebug.

void printregs (Regs *regs)
 Prints actual state of registers onto console.

void printfil (HANDLE fil, char *str)
 Prints message onto screen or into specified stream.

void rinterval (UINT *adr1, UINT *adr2)
 Reads an address interval and controls if it is correct.

UINT rhex (char *msg)
 Reads an hexadecimal integer and controls if it is correct.

void mklpstr (char *str)
 Converts strings read from console to null terminated strings.

void print (char *str)
 Prints given message onto the console.

void rline (char *str)
 Reads one command from console.

void printact (Regs *regs)
 Prints registers and dissassembled position in memory.

BOOL APIENTRY DllMain (HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
 Entry point of this dll.

DLLEXPORT void __cdecl InitDll (INITDLLSTRUCT *ids, INITDLLINFO *idi)
 Inits dll data structures.

DLLEXPORT void __cdecl OnMessage (MESSAGEDLLSTRUCT *mds)
 Recieves registered messages from emu6502 application.

DLLEXPORT void __cdecl IOFunc (UINT adr, unsigned char *data, iomode mode)
 IO function mapped into some adress in memory.


Variables

HANDLE hThisModule
MSGLIST Msgs
INITDLLSTRUCT info
HMENU hMenu
 Handle to the main menu bar.

HMENU hDebugMenu
 Handle to local debug menu which is appended to hMenu.


Define Documentation

#define FB   0x10
 

BRK flag

Definition at line 19 of file debugdll.c.

#define FC   0x01
 

Caryy flag

Definition at line 23 of file debugdll.c.

#define FD   0x08
 

Decimal flag

Definition at line 20 of file debugdll.c.

#define FI   0x04
 

Interrupt flag

Definition at line 21 of file debugdll.c.

#define FN   0x80
 

Negative flag

Definition at line 17 of file debugdll.c.

#define FV   0x40
 

Overflow flag

Definition at line 18 of file debugdll.c.

#define FZ   0x02
 

Zero flag

Definition at line 22 of file debugdll.c.


Function Documentation

void DisAsm int    lower,
int    upper,
HANDLE    fil,
int    act
 

Disassembler.

Disassembles given range of memory and writes it into the stream specified

Parameters:
lower, upper  Range of memory to be disassembled
fil  Handle to stream to write disassembled data into
act  Adress of instruction to be highlighted by adding >>> before it

Definition at line 510 of file debugdll.c.

BOOL APIENTRY DllMain HANDLE    hModule,
DWORD    ul_reason_for_call,
LPVOID    lpReserved
 

Entry point of this dll.

Definition at line 149 of file debugdll.c.

void DumpMem HANDLE    fil,
UINT    adr1,
UINT    adr2
 

Printer of memory in raw format.

Prints given range of memory into given stream in raw format

Parameters:
adr1, adr2  Range of memory to be printed
fil  Stream to write the memory into

Definition at line 639 of file debugdll.c.

void DumpMemHex HANDLE    fil,
UINT    adr1,
UINT    adr2
 

Printer of memory in hex format.

Prints given range of memory into given stream in hexadecimal format

Parameters:
adr1, adr2  Range of memory to be printed
fil  Stream to write the memory into

Definition at line 646 of file debugdll.c.

DLLEXPORT void __cdecl InitDll INITDLLSTRUCT   ids,
INITDLLINFO   idf
 

Inits dll data structures.

This function is called after dll is loaded. You have to implement this function. Useful informations are passed in its parameter. Also create, fill with messages to be catched and return MSGLIST structure.

Parameters:
ids  An INITDLLSTRUCT structure containig informations about calling emu6502 application.
idf  An INITDLLINFO structure which should be filled in this function
Note: if io memory boundaries to be reserved for this plugin are in conflict with some other plugin, previous settings will be overwritten!
Returns :
Filled MSGLIST of messages to be catched and forwarded to this plugin
See also:
OnMessage(MESSAGEDLLSTRUCT* mds) , INITDLLSTRUCT , INITDLLINFO

Definition at line 164 of file debugdll.c.

DLLEXPORT void __cdecl IOFunc UINT    adr,
unsigned char *    data,
iomode    mode
 

IO function mapped into some adress in memory.

Called directly when accesing adress to which is this function bound. Always write this function.

Parameters:
adr  Adress being accessed
data  Byte being read/written
mode  see iomode

Definition at line 238 of file debugdll.c.

void mklpstr char *    str
 

Converts strings read from console to null terminated strings.

Definition at line 775 of file debugdll.c.

HANDLE ofile  
 

Shows save dialog.

Shows save dialog and opens selected file.

Returns :
Handle to just opened stream of the selected file

Definition at line 693 of file debugdll.c.

DLLEXPORT void __cdecl OnMessage MESSAGEDLLSTRUCT   mds
 

Recieves registered messages from emu6502 application.

This function is called by emu6502 when some message event registered by InitDll occures. Implement this function even when you don't want to catch any messages.

Parameters:
mds  A MESSAGEDLLSTRUCT structure contaning informations about incoming message.
See also:
InitDll , MESSAGEDLLSTRUCT

Definition at line 210 of file debugdll.c.

HANDLE orfile  
 

Shows open dialog.

Shows open dialog and opens selected file.

Returns :
Handle to just opened stream of the selected file

Definition at line 660 of file debugdll.c.

void print char *    str
 

Prints given message onto the console.

Definition at line 793 of file debugdll.c.

void printact Regs   regs
 

Prints registers and dissassembled position in memory.

Definition at line 727 of file debugdll.c.

void printfil HANDLE    fil,
char *    str
 

Prints message onto screen or into specified stream.

If the fil stream is NULL, the message will be printed onto console

Parameters:
fil  Handle to a stream or NULL
str  Message to be printed

Definition at line 782 of file debugdll.c.

void printhelp  
 

Displays usage instructions.

Definition at line 614 of file debugdll.c.

void printregs Regs   regs
 

Prints actual state of registers onto console.

Definition at line 738 of file debugdll.c.

UINT rhex char *    msg
 

Reads an hexadecimal integer and controls if it is correct.

Definition at line 757 of file debugdll.c.

void rinterval UINT *    adr1,
UINT *    adr2
 

Reads an address interval and controls if it is correct.

Definition at line 749 of file debugdll.c.

void rline char *    str
 

Reads one command from console.

Definition at line 799 of file debugdll.c.

void SetReg Regs   regs,
char *    buf
 

Helper procedure for StartDebug.

Parses registers modifying commands.

Parameters:
regs  Pointer to the Regs structure used by the CPU plugin
buf  Pointer to the command user has entered

Definition at line 402 of file debugdll.c.

void StartDebug  
 

Starts debug.

Retrieves pointer to registers from the cpu plugin, if not present, shows an error message and stops debugging .

Definition at line 243 of file debugdll.c.


Variable Documentation

HMENU hDebugMenu
 

Handle to local debug menu which is appended to hMenu.

Definition at line 42 of file debugdll.c.

HMENU hMenu
 

Handle to the main menu bar.

Definition at line 40 of file debugdll.c.


Generated on Fri Sep 6 18:32:15 2002 for Emu6502 by doxygen1.2.17