<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.12.3">
</HEAD>
<BODY>
On Fri, 2007-06-01 at 20:46 +0500, azeem ahmad wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">hi list</FONT>
<FONT COLOR="#000000">i am about to make a bootable floppy for test</FONT>
<FONT COLOR="#000000">but i am being unable to get it done</FONT>
<FONT COLOR="#000000">please review the code below and tell me if there is any problem with it</FONT>
<FONT COLOR="#000000">----------------------------------------------------------------------------------------------------------------------------------</FONT>
<FONT COLOR="#000000">.code16           #assembler directive to start 16-bit real mode for execution</FONT>
<FONT COLOR="#000000">.text             /*assembler directive to tell the start of 'read-only'</FONT>
<FONT COLOR="#000000">          code segment*/</FONT>
<FONT COLOR="#000000">.org 0x00 /*assembler directive to set the origon to sector 0</FONT>
<FONT COLOR="#000000">          needed to copy the program to the very first sector</FONT>
<FONT COLOR="#000000">          of the floppy disk*/</FONT>

<FONT COLOR="#000000">.global _start    /*assembler directive to export the start section to</FONT>
<FONT COLOR="#000000">          all other programs, i.e. to make it visible to programs</FONT>
<FONT COLOR="#000000">          like linker or other user programs*/</FONT>

<FONT COLOR="#000000">_start:                           #label of the start routine</FONT>
<FONT COLOR="#000000">  mov 0x07C0, %ax         /*move immidiate operand 07C0 to the</FONT>
<FONT COLOR="#000000">                          accumulator register ax, so that it can be</FONT>
<FONT COLOR="#000000">                          transfered to data segment register*/</FONT>
<FONT COLOR="#000000">  mov %ax, %ds            /*move contents of register ax to register ds*/</FONT>
<FONT COLOR="#000000">  call _boot              #call the boot section</FONT>
<FONT COLOR="#000000">  ret                     #return the control to the caller routine</FONT>

<FONT COLOR="#000000">_boot:                            #label of the boot section</FONT>
<FONT COLOR="#000000">  mov $msg, %si           /*move the address of the character string</FONT>
<FONT COLOR="#000000">                          constant 'msg' to the source index register*/</FONT>
<FONT COLOR="#000000">  call _disp              #call subroutine disp</FONT>
<FONT COLOR="#000000">  ret                     #return the control to the caller routine</FONT>

<FONT COLOR="#000000">_disp:                            #label of the disp routine</FONT>
<FONT COLOR="#000000">  cld                     /*clear direction flag, to permit string</FONT>
<FONT COLOR="#000000">                          instructions to increment index registers</FONT>
<FONT COLOR="#000000">                          by their own*/</FONT>
<FONT COLOR="#000000">  lodsb                   /*load the string pointed by ds:si in a</FONT>
<FONT COLOR="#000000">                          byte by byte manner into the accumulator*/</FONT>
<FONT COLOR="#000000">  or %al, %al             /*check if the entire string has been loaded</FONT>
<FONT COLOR="#000000">                          byte-wise by oring al to al, if the result is</FONT>
<FONT COLOR="#000000">                          zero, it shows there are no more byte to load*/</FONT>
<FONT COLOR="#000000">  jz ret                  #jump if al zero to return</FONT>
<FONT COLOR="#000000">  mov $0xE, %ah           /*else put code for 'write a character on the</FONT>
<FONT COLOR="#000000">                          screen and move forward' into the ah*/</FONT>
<FONT COLOR="#000000">  mov $7, %bh             /*enable normal attribute for all the blank</FONT>
<FONT COLOR="#000000">                          lines on the screen*/</FONT>
<FONT COLOR="#000000">  int $0x10               /*call interupt 0x10, which is responsible</FONT>
<FONT COLOR="#000000">                          for the video display, it will take codes</FONT>
<FONT COLOR="#000000">                          from ah and bh*/</FONT>
<FONT COLOR="#000000">  jmp _disp</FONT>

<FONT COLOR="#000000">msg:                              #label of the string definition</FONT>
<FONT COLOR="#000000">  .ascii "My Boot System"       #definition of the string</FONT>

<FONT COLOR="#000000">.org 510                  #set origon to 510</FONT>
<FONT COLOR="#000000">.word 0xAA55                      #</FONT>
<FONT COLOR="#000000">--------------------------------------------------------------------------------------------------------------------------------------</FONT>

<FONT COLOR="#000000">saved the file with the name myos.s</FONT>
<FONT COLOR="#000000">then</FONT>

<FONT COLOR="#000000">#as myos.s -o myos.o</FONT>
<FONT COLOR="#000000">#objcopy -O binary myos.o BOOT</FONT>
<FONT COLOR="#000000">#dd if=./BOOT of=/dev/fd0 bs=512 count=1</FONT>
<FONT COLOR="#000000">-------------------------------------------------------------------------------------------------------------------------------------</FONT>
<FONT COLOR="#000000">the system tries to boot from the floppy and it boots (as it doesnt give an </FONT>
<FONT COLOR="#000000">error or it doesnt go to the next boot device. but it doesnt display the </FONT>
<FONT COLOR="#000000">string that i had to show from the string</FONT>

<FONT COLOR="#000000">please check it and tell me about any possible errors in the code</FONT>

<FONT COLOR="#000000">Regards</FONT>
<FONT COLOR="#000000">Azeem</FONT>

<FONT COLOR="#000000">_________________________________________________________________</FONT>
<FONT COLOR="#000000">Express yourself instantly with MSN Messenger! Download today it's FREE! </FONT>
<FONT COLOR="#000000"><A HREF="http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/">http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/</A></FONT>

</PRE>
</BLOCKQUOTE>
Well, Does the BIOS actually contain the software interrupt code you are attempting to access.  That is question one.<BR>
Question 2 is what would your bootstrap return to?  At boot time, the system invokes a short reader that will read the first sector.  This program is built into the bios.  There is no IO available for this program, thus the system bio typically uses the system beep to give error messages which you have to interpret by counting the beeps and looking them up in the documenation on that particular bios.<BR>
<BR>
You cannot just debug a boot or bios routine, because the debugger already has been loaded with all the required tools, including all the IO routines.  You have set yourself quite a task to boot a system.  A good way to learn is to find an older CP/M reference manual.  In the early days, one sort of had to write their own bootstraps, BIOS package and then use patches to CP/M to get a working system.  Today the drivers are either in ROM on the boards and read during the boot process, or they are downloaded from a CD or the internet.  If you are doing this for a class project, you will need to look more closely at the references supplied for the class.  If this is something you are doing to learn, this is not the appropriate list.  You should google for developer mailing list.  Check some of the guys working on robotics or some such, where they are writing simple OS's (some not so simple) for embedded controllers.  These days, most people skip this part and go with a developer package which has a boot and bios package built in, like the Basic Stamp or the 8051 kits that are available.  Writing a bootable system for a modern PC would be difficult I think, and to fit it on a floppy would be very hard, unless you restricted it to something like DOS or CP/M.  In the early days, we had memory mapped displays, and serial I/O.  That was it.  the chips had 16 interrupts and most systems used about 12.  That is no longer true today.  <BR>
<BR>
    Good luck and I hope you can find some one to guide you on your quest.<BR>
<BR>
Regards,<BR>
Les H
</BODY>
</HTML>