We can't help much without more information about how it is failing, in any case. I can give a few pieces of advice though (pardon any mistakes I may make, I haven't been doing this for a while):
[*] I don't know much about Flat Assembler, but as far as I know, it takes a syntax that is almost the same as
Netwide Assembler. If you can't get FASM to work, you might want to try NASM. If you do, you may want to get
NASM-IDE or NASMEdit (also on the same web page, though I don't think it works with the current version of JVM) to make working with it easier.
Yasm is also another option to consider using.
[*] There's a typo on either line 3 or line 8 (counting only actual lines of code): on the former, a label is given as [tt]tripos[/tt], while on the latter, it is given as [tt]tripsos[/tt]. One of the two must be changed; as it is, it probably won't assemble at all. (BTW, there's has already been at least one other operating system called Tripos - in fact, it was the basis for AmigaExec back in the 1980s. While you don't have to change the name, you should be aware of the fact in case there's any confusion. I ran into the same problem when I was calling mine 'Janos'.)
[*] The code never sets the segment registers. You never use the stack in this part of the code, but you
do use a data offset, which could be a problem; while most BIOSes do set the code and data segments to 0000, you cannot rely on it. I would add some code just before [tt]mbr_ch_loop[/tt] to the effect of:
Code: Select all
start:
mov ax, 0x9000 ; select some arbitrarily high point in memory
cli
mov ss, ax ; and set the stack segment to it
mov sp, 0xFFFF ; put the stack pointer to the top of SS
sti ; reset interrupts so BIOS calls can be used
mov ax, cs
mov ds, ax ; set DS == CS
Even if this is not the cause of the current problem, it will help you avoid others in the future.
[*] In the existing code, the very first instruction given is 'lodsb', which is supposed to load the first byte of a string which is pointed to by the SI register in the AH register. The problem is, the SI register hasn't been set yet. you need something like
before that in order to make it work.
[*] You need to issue a disk reset interrupt call (
int 0x13, AH=0x00) before you try reading from the disk.
[*] The BIOS interrupt for reading a sector from a disk is
Int 0x13, AH=0x02, not
int 0x13, AH=0x32 (which isn't even a standard BIOS call). I'm guessing that this was another typo.
BTW, I'm attaching a copy of my own boot loader, which may be helpful. It's for NASM (which as I said is similar but not quite the same as FASM), and uses several macros and a lot of defined constants, but it's well commented and may prove useful to you as a reference point. The
OS-DEV Wiki has several links to other
example boot loaders to look at as well, and a detailed explanation of the
boot-up sequence and how to
design a boot loader.