mkdbg Tool

Whenever you create com files that can be assembled with debug, you can also make a batch file that creates a debug script to run with debug and create the file. This program automatically reads the specified file and creates a batch file to automatically rebuild it with debug.
Example:
You have A.com:

mov ah,02
mov dl,41h
int 21h
int 20h

“mkdbg A.com” gives an output of:

@echo off
(
echo e 0100 B4 02 B2 41 CD 21 CD 20
echo r cx
echo 0008
echo n a.com
echo w
echo q
)>temp.dbg
debug<temp.dbg>nul
del temp.dbg
echo a.com has been created in the current directory
pause

You can output that to a batch file. The purpose of this program is that you can post batch file code which will create the com file, without actually attaching an executable com file.

Source:

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
void help();

int main(int argc,char *argv[]) {
   if (argc<2) { help(); return 0; }
   char *infile=argv[1];
   FILE *fp;
   fp=fopen(infile,"rb");
   if (fp==NULL) {
      printf("Failed to open file\n");
      return 1;
   }
   printf(
      "@echo off\n"
      "(\n"
   );
   int c;
   int len=0;
   int ten=0;
   int addr=0x100;
   printf("echo e %04X ",addr);
   while ((c=getc(fp))!=EOF) {
      len++;
      if (ten==16) {
         ten=0;
         addr+=0x10;
         printf("\necho e %04X ",addr);
      }
      printf("%02X ",c);
      ten++;
   }
   char *name=strstr(infile,"\\");
   if (name==0) {
      name=infile;
   } else {
      name=strrchr(infile,92)+1;
   }
   printf(
      "\necho r cx\necho %04X\n"
      "echo n %s\necho w\necho q\n"
   ,len,name);
   printf(
      ")>temp.dbg\n"
      "debug<temp.dbg>nul\n"
      "del temp.dbg\n"
      "echo %s has been created in the current directory\n"
      "pause\n",name);
   return 0;
}

void help() {
   printf(
      "mkdbg - By Jakash3\n"
      "Usage: mkdbg file.com\n"
   );
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: