Commits

prabirshrestha committed d340d35

_start_stage1 text

Comments (0)

Files changed (1)

 # http://www.cs.cmu.edu/~410-s07/p4/p4-boot.pdf
 
-.code16
-.text
-	jmp .
+.code16                 # 16 bit code generation
+                        # Since all intel based start up with 16-bit instructions,
+                        # we won't be able to write 32 bit code yet.
+.text                   # code segment
 
-main:
+_start:
+    jmp _start_stage1   # this is the main entry point of our code which corresponds to the first byte
+    nop                 # of actual output when assembled The code under "_start" simply jumps over the
+                        # BPB and EBPB located at offset 0×3, resuming execution at the label _start_stage1.
+
+_start_stage1:
+    # Section 5.1 Boot:
+    # boot0 minimally must accomplish the following tasks:
+    #
+    # 1. Disable interrupts.
+    # 2. Canonicalize %CS:%EIP (see Section 6.1 below).
+    # 3. Load segment registers (%DS, %ES, %FS, %GS, %SS).
+    # 4. Set the stack pointer.
+    # 5. Enable interrupts.
+    # 6. Reset the floppy disk controller.
+    # 7. Read boot1 sectors from the floppy.
+    # 8. Jump to boot1 code.
+    #
+    # Should any of the above steps fail, boot0 should fail as follows:
+    # 1. Notify the user of a failure condition.
+    # 2. Disable interrupts.
+    # 3. Permanently suspend progress in execution.
+
+    # - Interrupts may not act now, so they are disabled.
+    cli                     # block all maskable interrupts (does not block NMI - non-maskable interrupts)
+    sti                     # enable interrupts
 
 .fill (510-(.-main)), 1, 0  # Pad with nulls up to 510 bytes (exclude boot magic)