88#include " regs.h"
99#include " custom.h"
1010#include " custom_hooks.h"
11+ #include " utils.h"
1112
1213#include " asm.h"
1314
@@ -499,133 +500,6 @@ void mycopy(db *d, db *s, size_t size, const char *name)
499500#endif
500501}
501502
502- // thanks to paxdiablo http://stackoverflow.com/users/14860/paxdiablo for the
503- // Function to print a hexadecimal dump of memory contents.
504- void hexDump (void *addr, int len)
505- {
506- int i;
507- unsigned char buff[17 ];
508- unsigned char *pc = (unsigned char *)addr;
509- (void )buff;
510- printf (" hexDump %p:\n " , addr);
511-
512- if (len == 0 ) {
513- printf (" ZERO LENGTH\n " );
514- return ;
515- }
516- if (len < 0 ) {
517- printf (" NEGATIVE LENGTH: %i\n " , len);
518- return ;
519- }
520-
521- // Process every byte in the data.
522- for (i = 0 ; i < len; i++) {
523- // Multiple of 16 means new line (with line offset).
524- if ((i % 16 ) == 0 ) {
525- // Just don't print ASCII for the zeroth line.
526- if (i != 0 )
527- printf (" %s\n " , buff);
528-
529- // Output the offset.
530- printf (" %04x " , i);
531- }
532-
533- // Now the hex code for the specific character.
534- printf (" %02x" , pc[i]);
535-
536- // And store a printable ASCII character for later.
537- if ((pc[i] < 0x20 ) || (pc[i] > 0x7e ))
538- buff[i % 16 ] = ' .' ;
539- else
540- buff[i % 16 ] = pc[i];
541- buff[(i % 16 ) + 1 ] = ' \0 ' ;
542- }
543-
544- // Pad out last line if not exactly 16 characters.
545- while ((i % 16 ) != 0 ) {
546- printf (" " );
547- i++;
548- }
549-
550- // And print the final ASCII bit.
551- printf (" %s\n " , buff);
552- }
553-
554- // Function to count the number of equal bytes between two memory regions.
555- size_t countEqual (const db *addr1, const db *addr2, int len)
556- {
557- size_t bytes = 0 ;
558- while (len && *(addr1++) == *(addr2++)) {
559- ++bytes;
560- }
561- return bytes;
562- }
563-
564- // Function to compare and print a hexadecimal dump of two memory regions.
565- void cmpHexDump (void *addr1, void *addr2, int len)
566- {
567- int i, j;
568- unsigned char buff1[17 ];
569- unsigned char buff2[17 ];
570- unsigned char *pc1 = (unsigned char *)addr1;
571- unsigned char *pc2 = (unsigned char *)addr2;
572-
573- printf (" cmpHexDump %p %p:\n " , pc1, pc2);
574-
575- if (len == 0 ) {
576- printf (" ZERO LENGTH\n " );
577- return ;
578- }
579- if (len < 0 ) {
580- printf (" NEGATIVE LENGTH: %i\n " , len);
581- return ;
582- }
583-
584- // Process every byte in the data.
585- for (i = 0 ; i < len; i++) {
586- // Multiple of 16 means new line (with line offset).
587- size_t size = i + 16 <= len ? 16 : len - i;
588-
589- // Compare memory contents and print differences.
590- if (memcmp (&pc1[i], &pc2[i], size) != 0 ) {
591- // Output the offset.
592- printf (" %04x " , i);
593-
594- // Print the first memory region.
595- for (j = 0 ; j < size; j++) {
596- // Now the hex code for the specific character.
597- printf (" %02x" , pc1[i + j]);
598-
599- // And store a printable ASCII character for later.
600- if ((pc1[i + j] < 0x20 ) || (pc1[i + j] > 0x7e ))
601- buff1[j] = ' .' ;
602- else
603- buff1[j] = pc1[i + j];
604- }
605- buff1[j] = ' \0 ' ;
606- printf (" %s\n " , buff1);
607-
608- // Print the second memory region.
609- printf (" " );
610- for (j = 0 ; j < size; j++) {
611- // Now the hex code for the specific character.
612- printf (" %02x" , pc2[i + j]);
613-
614- // And store a printable ASCII character for later.
615- if ((pc2[i + j] < 0x20 ) || (pc2[i + j] > 0x7e ))
616- buff2[j] = ' .' ;
617- else
618- buff2[j] = pc2[i + j];
619- }
620- buff2[j + 1 ] = ' \0 ' ;
621-
622- // And print the final ASCII bit.
623- printf (" %s\n " , buff2);
624- }
625-
626- i += size;
627- }
628- }
629503
630504// Function to dump the stack and shadow memory.
631505void stackDump (_STATE *_state)
@@ -644,7 +518,7 @@ void stackDump(_STATE *_state)
644518 shadow_stack.print (0 );
645519}
646520
647- // Function to log register values and other debug information.
521+ // Function to log dosbox register values
648522void log_regs_dbx_direct (size_t counter_,
649523 const char *file,
650524 int line,
0 commit comments