script of writing to boot sector not working

Started by zak100, August 12, 2009, 06:13:32 PM

Previous topic - Next topic

zak100

Hi,
I was helped by MichealW in providing a script for writing on bootsector.

It consists of two files c.bat and makeboot.txt
ml /c bpb_proc2.asm
pause
link16 /tiny bpb_proc2.obj,bpb_proc2.bin;
pause
:debug bpb_proc2.bin
:pause
debug < makeboot.txt
pause


and

N
N This is a DEBUG script that will copy
N bpb_proc2.bin to sector 0 of drive A.
N
N bpb_proc2.bin
L 0
W 0 0 0 1
Q

The output of script is given below:

D:\masm prog>c

D:\masm prog>ml /c bpb_proc2.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: bpb_proc2.asm

D:\masm prog>pause
Press any key to continue . . .

D:\masm prog>link16 /tiny bpb_proc2.obj,bpb_proc2.bin;

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.


D:\masm prog>pause
Press any key to continue . . .
D:\masm prog>debug 0<makeboot.txt
-N
-N This is a DEBUG script that will copy
-N bpb_proc2.bin to sector 0 of drive A.
-N
-N bpb_proc2.bin
-L 0
File not found
-W 0 0 0 0 1
Write protect error writing drive A
-Q


Yesterday, I got my h/d foratted unexpectedly. I have installed the masm32 again but I found that the script is not producing .com

file which it was doing previously. Kindly, somebody plz help me with this.

Zulfi.

dedndave

you probably need to get the 16-bit linker again
it does not come with the masm32 package, but is required for 16-bit code
i see that Michael named it "link16.exe"
the one i know of is named "lnk563.exe"
you may have to rename the file or edit the batch
http://www.masm32.com/board/index.php?topic=12056.msg91992#msg91992

FORTRANS

Hi,

   Looking at the version number, I think his LINK is okay.  zak100
add to the script to see what is going on.  (Uppercase to show
additions.)


DIR /OD
PAUSE
ml /c bpb_proc2.asm
DIR /OD
pause
link16 /tiny bpb_proc2.obj,bpb_proc2.bin;
DIR /OD
pause
:debug bpb_proc2.bin
:pause
debug < makeboot.txt
pause


Regards,

Steve N.

MichaelW

QuoteD:\masm prog>debug 0<makeboot.txt

What is the 0 following debug? Try:

debug < makeboot.txt

QuoteWrite protect error writing drive A

Unless the diskette is write protected, this probably means that the diskette does not have a valid format. Do a quick format of the diskette and try again.
eschew obfuscation

zak100

Hi myfriends,
Thanks for your attention.

Hi dedndave,
When I execute the Link563.exe, it produces LINK and CVPACK. I got LINK16
from masm32 folder.

D:\>dir masm32\bin
Volume in drive D is New Volume
Volume Serial Number is 405F-9423

Directory of D:\masm32\bin

08/12/2009  06:22 PM    <DIR>          .
08/12/2009  06:22 PM    <DIR>          ..
08/09/2008  01:36 PM               352 asmbl.txt
08/01/2007  01:49 PM               193 assmbl.bat
01/01/2007  05:01 PM               643 bldall.bat
01/01/2007  05:01 PM               643 bldallc.bat
01/01/2007  05:01 PM                88 bres.bat
01/01/2007  05:01 PM               542 build.bat
01/01/2007  05:01 PM               530 buildc.bat
01/21/1998  12:15 AM            15,632 cvtres.exe
01/01/2007  05:01 PM               408 dasm.bat
01/01/2007  05:01 PM               408 dasmd.bat
09/16/2002  02:58 AM            13,312 dbgwin.exe
03/29/2002  08:43 PM             2,048 dumpbin.exe
02/07/1999  11:24 AM           163,840 dumppe.exe
02/07/1999  11:24 AM             9,510 dumppe.txt
03/29/2002  08:43 PM             2,048 editbin.exe
09/27/2006  07:17 PM            44,984 imagedit.exe
10/17/1994  06:29 PM            82,134 imagedit.hlp
03/29/2002  08:43 PM             2,048 lib.exe
03/19/1998  11:28 AM           462,899 link.exe
01/13/1995  09:10 AM           364,544 link16.exe
08/01/2007  01:50 PM               341 lnk.bat
08/01/2007  01:50 PM               341 lnkc.bat
07/22/2001  12:31 AM             9,687 ml.err
03/29/1999  12:45 PM           372,736 ml.exe
09/19/1998  04:30 PM           117,520 msdis100.dll
03/19/1998  08:50 PM           164,112 msdis109.dll
06/10/1998  01:50 AM           157,456 mspdb50.dll
06/12/2007  07:01 AM             4,633 pelle.txt
05/31/2008  04:09 AM           653,488 poasm.exe
03/24/2008  08:30 PM            88,240 polib.exe
03/24/2008  08:30 PM           164,528 polink.exe
03/24/2008  09:41 PM           146,096 porc.dll
03/24/2008  09:41 PM            30,208 porc.exe
06/10/1998  01:50 AM             4,880 rc.exe
06/27/1995  11:03 AM           136,161 rc.hlp
06/10/1998  01:50 AM           105,744 rcdll.dll
09/27/2006  07:18 PM            19,188 zoomin.exe
              37 File(s)      3,342,165 bytes
               2 Dir(s)  25,864,237,056 bytes free

D:\>
---------------------------------------
Hi FORTRANS,

The result after adding your commands into script is given below:
Note when it executes debug, I cant copy/paste so I have just
written the stuff for yourself.

D:\masm prog>del *.obj

D:\masm prog>del *.bin

D:\masm prog>c

D:\masm prog>DIR /OD
Volume in drive D is New Volume
Volume Serial Number is 405F-9423

Directory of D:\masm prog

07/23/2009  11:02 AM                72 asm
07/28/2009  06:48 PM             1,181 str.asm
07/30/2009  10:43 PM               210 nasmB_1.asm
08/01/2009  10:44 PM             3,018 bpb.asm
08/06/2009  02:44 PM             3,472 bpb_proc.asm
08/09/2009  06:05 PM             2,575 bpb_str.asm
08/11/2009  06:56 PM               448 nasmB.asm
08/12/2009  06:12 PM    <DIR>          help
08/12/2009  06:48 PM             4,189 bpb_proc2.asm
08/12/2009  10:44 PM               122 makeboot.txt
08/13/2009  09:43 AM               171 c.bat
08/13/2009  09:49 AM    <DIR>          .
08/13/2009  09:49 AM    <DIR>          ..
              10 File(s)         15,458 bytes
               3 Dir(s)  25,864,241,152 bytes free

D:\masm prog>PAUSE
Press any key to continue . . .

D:\masm prog>ml /c bpb_proc2.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: bpb_proc2.asm

D:\masm prog>DIR /OD
Volume in drive D is New Volume
Volume Serial Number is 405F-9423

Directory of D:\masm prog

07/23/2009  11:02 AM                72 asm
07/28/2009  06:48 PM             1,181 str.asm
07/30/2009  10:43 PM               210 nasmB_1.asm
08/01/2009  10:44 PM             3,018 bpb.asm
08/06/2009  02:44 PM             3,472 bpb_proc.asm
08/09/2009  06:05 PM             2,575 bpb_str.asm
08/11/2009  06:56 PM               448 nasmB.asm
08/12/2009  06:48 PM             4,189 bpb_proc2.asm
08/12/2009  10:44 PM               122 makeboot.txt
08/13/2009  09:43 AM               171 c.bat
08/13/2009  09:51 AM    <DIR>          help
08/13/2009  09:51 AM    <DIR>          ..
08/13/2009  09:51 AM    <DIR>          .
08/13/2009  09:51 AM               363 bpb_proc2.obj
              11 File(s)         15,821 bytes
               3 Dir(s)  25,864,237,056 bytes free

D:\masm prog>pause
Press any key to continue . . .

D:\masm prog>link16 /tiny bpb_proc2.obj,bpb_proc2.bin;

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.


D:\masm prog>DIR /OD
Volume in drive D is New Volume
Volume Serial Number is 405F-9423

07/23/2009  11:02 AM                72 asm
07/28/2009  06:48 PM             1,181 str.asm
07/30/2009  10:43 PM               210 nasmB_1.asm
08/01/2009  10:44 PM             3,018 bpb.asm
08/06/2009  02:44 PM             3,472 bpb_proc.asm
08/09/2009  06:05 PM             2,575 bpb_str.asm
08/11/2009  06:56 PM               448 nasmB.asm
08/12/2009  06:48 PM             4,189 bpb_proc2.asm
08/12/2009  10:44 PM               122 makeboot.txt
08/13/2009  09:43 AM               171 c.bat
08/13/2009  09:51 AM    <DIR>          help
08/13/2009  09:51 AM               363 bpb_proc2.obj
08/13/2009  09:53 AM    <DIR>          ..
08/13/2009  09:53 AM    <DIR>          .
08/13/2009  09:53 AM               512 bpb_proc2.bin
              12 File(s)         16,333 bytes
               3 Dir(s)  25,864,237,056 bytes free
D:\masm prog>pause
Press any key to continue . . .

After this I cant copy/paste so I am writing this stuff:

D:\masm prog>debug 0<makeboot.txt
-N
-N This is a DEBUG script that will copy
-N bpb_proc2.bin to sector 0 of drive A.
-N
-N bpb_proc2.bin
-L 0
File not found
-W 0 0 0 0 1
Write protect error writing drive A
-Q

----------------------------------------
Hi MichaelW,


I am not putting this '0'. Its not in the script file:

D:\masm prog>type c.bat
DIR /OD
PAUSE
ml /c bpb_proc2.asm
DIR /OD
pause
link16 /tiny bpb_proc2.obj,bpb_proc2.bin;
DIR /OD
pause

and I am doing the format before execution. It was running fine but when I
got my h/d formatted during the course of running this script, its
giving me prob. In my opinion its not creating .com file so I am getting
this write protect as result of confusion of Debug program.

Zulfi.
:debug bpb_proc2.bin
:pause
debug < makeboot.txt
pause

D:\masm prog>

FORTRANS

Hi Zulfi.

   I see what you mean, I did in a floppy.  The DEBUG script
seems to work.

   You ban use EXE2BIN to convert an EXE to a COM or BIN.
I don't remember the 16-linker making other than EXE files.

Steve N.

FORTRANS

Hi,

   Well since the file is the right size, that was probably the wrong
thing to say.  Time to get better documentation.  Zero "0" is a
legal file name, and DEBUG will look for it, so that might be the
source of the "File not found" message.  And so harmless, though
I would be worried as to where the zero was coming from.  Add
an unassemble command to the makeboot.txt script to see if the
BIN file is loaded correctly, if you want.  Piques my curiosity.

   As a side note:  The floppy that got written to was unreadable
with Windows 2000, so I thought it was lost.  But I fired up a
different OS, and it was readable.  The recovery tools I tried
crashed due to whatever got written, and under a protected
mode OS, were painfully slow.  So I copied everything off, and
reformatted it.  Good ole' Windows, saving you from corrupted
disks.

Cheers,

Steve N.

zak100

Hi,
I am again going to check this thing today. Sorry, I dont understand whats your conclusion. How are we getting this 0? Should I use exe2bin? I feel there might be some thing wrong in the code. How this script was running before? It might not be a proper com file stuff. Thanks for your efforts.

Zulfi.

zak100

Hi,
I ran the script on my earlier program and it worked. No com file produced. But I saw the bin. I also saw that '0' with Debug. I am not able to copy and paste. Even Print Scrn didnt work. First time I ran I got write protect error. Then I formatted and ran again. This time no error comments. Program ran. This means my macro program is not in a com file format. I am now going to correct it.

Zulfi.

FORTRANS

Quote from: zak100 on August 15, 2009, 09:10:41 AM
Hi,
I am again going to check this thing today. Sorry, I dont understand whats your conclusion. How are we getting this 0?

   I concluded that I don't know how or why you are getting a zero.
But it should be "mostly hamless" in this case.  It would be nice if
you found out about the zero that you post your findings.

QuoteShould I use exe2bin?

   Not if the script is working.  I would check the BIN file to confirm
it contains what you expect.

Steve N.

zak100

Hi,
I dont know any way to store this at run time b/c I cant do copy. Scroll bars disappear when the Debug script starts execution.
Ok thanks for taking interest in my prob. I am now going back to work on macro prob.

Zulfi.

FORTRANS

Hi,

   To capture output from a BATch file, you can try the
following.


C:>COMMAND /C FILE.BAT > OUT.TXT


That works sometimes.

Regards,
Steve N.

zak100

Hi,
If it worked in this case, I would let you know.

Thanks again. I highly appreciate yours and others interest in solving prob of this forum.

Zulfi.