News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Not able to jmp to kernel at sect2

Started by zak100, November 15, 2009, 03:23:52 PM

Previous topic - Next topic

dedndave

bootloader - we don't need to set DS for this one
this has to go on drive 0, side 0, cylinder 0, sector 2 for the bootstrap code to find it
a better way is to put this code in the first data sector of the floppy
then, use the BPB parameters to calculate the cylinder/head/sector number to find it
that way, you can read and write the disk with DOS
don't forget - after you see the "A", you have to press a key to continue (there is no message telling you that - lol)

        .MODEL  TINY
        .CODE

;----------------------------------------------------------------------------------

LoadOfs EQU     0               ;must match the value in the bootloader source file

;----------------------------------------------------------------------------------

;---------------------- initialize ES segment register

        ORG     0

Start:  push    cs
        pop     es
   
;---------------------- writing a message on screen at startup - we can't use int 21h

        mov     bp,offset Msg0+LoadOfs
        mov     cx,sizeof Msg0
        xor     dx,dx           ;row 0, column 0
        mov     bx,7            ;page 0, attribute = 7 (white on black)
        mov     ax,1301h        ;function 13 - cursor mode 1
        int     10h

;---------------------- done - halt

Halt0:  jmp     Halt0

;---------------------- data area in code segment

Msg0    db      "We be bootin2!"

;----------------------------------------------------------------------------------

        END     Start

zak100

Hi,
Thanks for your help. I have to ask some questions on your code. But right now I am facing another prob. I cant copy to sect2(the program which call bootloader) using partcopy.

D:\MASMPR~1>partcopy sect2_2.bin 0 200 -f0 200
Failed to read source at offset 22
D:\MASMPR~1>partcopy sect2_2.bin 0 2C -f0 200
Failed to read source at offset 22
D:\MASMPR~1>

Kindly help me in this regard.

Zulfi.

dedndave

lemme see - well - one way would be to use debug to perform the disk write
another way would be to write a small program to do it for you - it would be a simple program
be sure you start with a formatted floppy disk

as i said, the better way is to use the first real data sector
but, we should be able to test it as is
this machine has no floppy disk drive to test with
i suppose i could knock the dust off one of my older machines - lol

zak100

Hi,
I am using debug but I am getting write protect error. I have modified the srcipt provided by MichealW. First I formatted the floppy and then used his script to write bootsector. But when I am writing bootloader I am getting write protect error.

The modified script is given below:

PAUSE
ml /c sect2_2.asm
pause
link16 /tiny sect2_2.obj,sect2_2.bin;
pause
:debug sect2_2.bin
:pause
debug < makeboot1.txt
pause




and makeboot1.txt



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


Kindly help me in this regard.

Zulfi.

dedndave

it may be because the OS won't allow you to write to the FAT
write a small program
use BIOS INT 13h to write the file

FORTRANS

Hi Dave,

   I tried your code (after translating to 720 k format) and
am seeing errors in Windows 2000.  The first write of the
boot sector goes ahead and does write to the diskette.  The
second attempt to write the boot loader from debug says
write protected.  CHKDSK and my own disk format program
then report errors or a non-DOS disk.

   In my bastardized program the error code doesn't make
much sense.  (A variation of The Waite Group's READFMT
program if of interest.)  (Or maybe it makes sense and I
am using the wrong codes?)  Looking with Norton's DISKEDIT
does not show anything obviously wrong.  So, I will try with
a real MS-DOS system to see if your comment about writes
to the fat are correct.  And will try to track down the other
errors as time permits.

Regards,

Steve N.

Edit:  Yeah, wrong error code list.  "General failure" and
"Address mark not found"

SRN

dedndave

well - i think INT 13h could do it for you
however - why waste the time ?
the time might be better spent modifying the code so that it loads from the first real data sector
you are going to want to do that eventually, anyways
for that matter, just format the floppy with DOS
disassemble their boot sector
and write your loader code so that it works with their bootstrapper - lol
all the elements that are in their boot sector are good elements to have
they set the BPB table interrupt along with a few of the parameters and calculate the CHS for the first data sector i think
as i mentioned, i have no floppy drive to play with on this machine
i looked - they didn't even populate the connector on the motherboard to stick one in there - lol
i am guessing that means my BIOS won't support a floppy

FORTRANS

Hi,

   Yeah, off to the DOS machine to see what else I can screw
up.  Now that I found what the error messages are, I can
probaly do something very stupid.  Perhaps writing to the
wrong (second) sector in a cluster?

   You might check and see if your machine can boot from
USB?  Almost makes you wonder how much money is saved
by not supporting a floppy in the BIOS.  Not that that matters
if you have solder things anyway...

Cheers,

Steve

FORTRANS

Hi,

   Okay, quick and dirty results:  MS-DOS 6.2x, DEBUG
happily writes to the diskette.  Good old machine boots
from floppy, displays funny colored "A", and booting
message.  CHKDSK and my program still unhappy with
it.

   Now to fix up the error messages, and clean up my
utility program.

FWIW,

Steve N.

zak100

Hi all,
Based Fortrans work I am thinking to download debug 6.2x.

dedndave:
"the time might be better spent modifying the code so that it loads from the first real data sector
you are going to want to do that eventually, anyways
for that matter, just format the floppy with DOS
disassemble their boot sector
and write your loader code so that it works with their bootstrapper - lol
"
What I understood from your mesg that I have to format using:
format a:/s
and then overwrite the bootsector and then write the loader.
Am I write??
Zulfi.

dedndave

no Zulfi
the boot sector is always written onto floppies
the /s switch adds the files io.sys, msdos.sys, and command.com - we don't need those

Steve - attach the 512 binary for a 6.2 DOS floppy - i will disassemble it
we can see how they calculate the first data sector
i can't do it from memory - there is something about adding "hidden sectors" - i forget
we can also do the BPB block thing and make a proper boot disk
lol - i thought we did all this once before

zak100

Thanks for your quick response. Ok I would try the other option of writing the program. I am also looking for debug 6.2 links. Is it same as Dos 6.2 debug?

Zulfi.

dedndave

i use SymDeb for 16-bit code...
as for a linker, link16 or lnk563 should work
http://www.4shared.com/file/156081729/2ec76f0a/SymDeb.html

FORTRANS

Hello,

   I have been 'playing around' on the DOS machine.  To
cure the toxic response I changed the sectors per cluster
value.  Here are the changes to Dave's code I made.


bpbSectorsPerCluster DB 2 ; 1          Mods to dedndave's code: Cluster size
bpbReservedSectors   DW 1
bpbNumberOfFATs      DB 2
bpbRootEntries       DW 112 ; 224      Mods to dedndave's code: 720 K diskette
bpbTotalSectors      DW 1440 ; 2880
bpbMedia             DB 0F9H ; 0F0h
bpbSectorsPerFAT     DW 3 ; 9
bpbSectorsPerTrack   DW 9 ; 18


   The poor response of my utility, DISKEDIT, and CHKDSK
seem to be cured by that.  (Or not writing to the FAT a
bunch of stuff, not yet fully tested.)

   Attached is DOS boot sector in binary and hex.

HTH,

Steve

dedndave