TWiki> CS385spring14 Web>Homeworks>Homework2 (revision 1)EditAttach

Homework 2

How the Operating System gets control of the machine

NOTE: This will be discussed further in class on Thursday. Reviewing some of the resources at the bottom of this page before the class on Thursday will help greatly.

Issued 1/21/14
Due Date 2/4/14 before class

The goal of this homework is to get a better understanding of what happens when a computer starts and how the operating system itself is loaded and activated. Your task is to write a floppy disk bootsector (in 8086 assembly code) which will be placed on a 1.44MB virtual floppy and attached to your virtual machine from homework 1.

Your bootsector needs to perform a number of tasks:

  1. Properly initialize screen, by outputting your name, indicating that the bootsector was loaded and executed.
  2. Show information about the system: how much low memory is available. What is the current time according to the machine.
  3. Perform 'chain loading'. Load the bootsector from the hard drive (which was installed there earlier when installing ubuntu) and execute it. This should result in loading Ubuntu as normal.
Optional:

  • Show the current time on the screen (and update!)

Some more detail

  • To create an empty floppy disk image, use the following command
    linux head -c 1474560 /dev/zero > myimage.vfd
    windows fsutil file createnew myimage.vfd 1474560

Evaluation

The homework will be evaluated using the following factors:

  • Correctness of assembler syntax -- The code should compile without error using nasm.
  • Documentation of the code -- The code is clearly documented, explaining what the intent is and how it is accomplished.
  • Correctness of execution -- The code performs the functions requested.
  • Creativity -- Your solution is different. Make sure to document your code or we might miss your special trick!
  • Optional tasks -- You implemented some or all of the optional requests, or went beyond what was requested in some other way.
You will be required to check in your assembly code in subversion. The state of the repository at the beginning of class on the due date will be used for evaluation.

Resources

The following links contain useful information:

Hints and advice

  • Pay attention to the number representation (in assembler and documentation): hexadecimal, octal, decimal?
  • nasm needs to know what mode the CPU will be in. Look for the 'BITS' directive. Likewise, a bootsector is self-contained (does not depend on external libraries). Pick the proper output format for nasm.
  • BIOS interrupt 0x12, function ax=0x00 can be useful in determining how much memory is available.
  • Do not alter memory under 0x500. This region is reserved for the interrupt table and bios data.
  • The BIOS loads your bootsector at address 0x7c00 and executes it. For the rest, you're on your own. This means you are responsible for setting correct values for the segment registers and setting up a stack.
  • Make sure that nasm and you (through segment registers) agree on what the origin of your code is (see 'org' directive)
  • For chain loading: since your bootsector code (currently executing) is located where the new bootsector needs to go (0x7c00), you might have to move your code out of the way...
  • Don't assume register values are preserved when invoking a service interrupt.
  • The 'ndisasm' command can be very helpful to verify the final layout and code of your bootsector.
  • Using a makefile can simplify compiling and testing your code.
  • Make sure to take backups; Even better would be to often check in your code using subversion.
  • The BIOS recognizes a valid bootsector by a signature (0xAA55) located at the end of the bootsector (offset 510 & 511). The following code is helpful to put the signature there:
; Convention: boot sector must have 0xAA55 in last 2 bytes
; See http://www.nasm.us/doc/nasmdoc3.html#section-3.5 for an
; explanation of $ and $$

   times 510-($-$$) db 0
   dw 0xAA55
Edit | Attach | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2014-01-22 - 04:43:53 - Main.driesk
 
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF