Page 1 of 1

BootLoader Problem???

Posted: Sun Jan 25, 2009 2:04 pm
by Sam111
Ok I don't know why this is failing. I am using boches to test and it seems like it is resting over
and over again (triple faulting) whenever I issue the jmp 0000:8000 command.

What I am trying to do is load the second sector of the floppy and then jump to it.

This is my bootloader sector 1 code that the bios loads.

Code: Select all

org 0x7C00
BITS 16
jmp start
greetings	    db	'Greetings and welcome ',13d,10d,'$' 
BOOTLOADER_NAME db 'Nates BootLoader Stage 1' ,13d,10d,'$'
STARTSECTOR     db  2            ;start sector to load
LOADADDRESS     dw  8000h       ; where to load the sectors into memory
NUMBEROFSECTORS db  1           ; number of bytes to load begining at STARTSECTOR

clear_screen:
mov ax , 600h      ; clear screen scroll up function
mov bh , 7h        ; white on black background
mov ch , 0h        ;upper line (top)
mov cl , 0h        ;left col (far left)
mov dh , 18h       ;bottom 
mov dl , 4Fh       ;far right
int 10h  ;                          do the clearing 
ret


readsectors_into_memory:
mov ah , 02h                    ; read function
mov al , NUMBEROFSECTORS        ; number  of sectors to read
mov ch , 0h                     ; cylinder number
mov cl , STARTSECTOR            ; starting sector to begin reading from
mov dh , 0h                     ; head number
mov dl , 00h                    ;drive for floppy
mov bx , LOADADDRESS            ; es:ds-> buffer for where the sectors will be loaded in this case 0000:8000h

int 13                          ; execute the interrupt for reading into memory
ret


start:
mov ax , 0x9100 ;set the stack to some random address
mov ss , ax
mov sp , 0x9000 ; set the stack pointer to some random address
xor ax , ax
mov ds , ax     ;data segment is at segment zero 
mov es , ax     ; exta segment is at segment zero now.

call clear_screen

mov ah , 13h
mov al , 01h 
mov bh , 0h
mov bl , 0Fh
mov dh , 5h
mov dl , 3h
mov cx , greetings
mov bp , cx
mov cx , 22d
int 10h


mov cx , BOOTLOADER_NAME
mov bp , cx
mov cx , 24d
mov dh , 10h
mov dl , 0h
int 10h

readData:
call readsectors_into_memory
jc readData


;It get's here because I put a display string out to the screen and it wrote it out fine.
;I think it is loading the sector because the carry is never set but when it tries the jmp 0000:8000 it doesn't work??????? jmp 0000:8000





This is my sector 2 code that I want to load into memory 0000:8000 then jump to it

Code: Select all

org 0x8000
BITS 16
jmp main
hello	db	'This is sector 2!',13d,10d,'$' ;Put any data here!

main:
mov ax , 0
mov ds , ax 
mov es , ax
mov ax , 0x1110
mov ss , ax
mov sp , ax


mov ax , 600h       ; clear screen scroll up function
mov bh , 7h         ; white on black background
mov ch , 0h         ;upper line (top)
mov cl , 0h         ;left col (far left)
mov dh , 18h        ;bottom 
mov dl , 4Fh        ;far right
int 10h             ;do the clearing 

; display the string This is sector 2 on the screen
;mov ax , 0
;mov es , ax

mov ah , 13h
mov al , 01h 
mov bh , 0h
mov bl , 0Fh
mov dh , 5h
mov dl , 3h
mov cx , hello
mov bp , cx
mov cx , 16d
int 10h
; loop forever
endsss:
jmp endsss


This is what the bochesout.txt has in it

Code: Select all

00000000000i[     ] Bochs x86 Emulator 2.3.6
00000000000i[     ]   Build from CVS snapshot, on December 24, 2007
00000000000i[     ] System configuration
00000000000i[     ]   processors: 1 (cores=1, HT threads=1)
00000000000i[     ]   A20 line support: yes
00000000000i[     ]   APIC support: yes
00000000000i[     ] CPU configuration
00000000000i[     ]   level: 6
00000000000i[     ]   TLB enabled: yes
00000000000i[     ]   SMP support: no
00000000000i[     ]   FPU support: yes
00000000000i[     ]   MMX support: yes
00000000000i[     ]   SSE support: 2
00000000000i[     ]   CLFLUSH support: yes
00000000000i[     ]   VME support: yes
00000000000i[     ]   3dnow! support: no
00000000000i[     ]   PAE support: yes
00000000000i[     ]   PGE support: yes
00000000000i[     ]   PSE support: yes
00000000000i[     ]   x86-64 support: yes
00000000000i[     ]   SEP support: yes
00000000000i[     ]   MWAIT support: no
00000000000i[     ] Optimization configuration
00000000000i[     ]   Guest2HostTLB support: yes
00000000000i[     ]   RepeatSpeedups support: yes
00000000000i[     ]   Icache support: yes
00000000000i[     ]   Trace cache support: yes
00000000000i[     ]   Fast function calls: yes
00000000000i[     ] Devices configuration
00000000000i[     ]   ACPI support: yes
00000000000i[     ]   NE2000 support: yes
00000000000i[     ]   PCI support: yes
00000000000i[     ]   SB16 support: yes
00000000000i[     ]   USB support: yes
00000000000i[     ]   VGA extension support: vbe cirrus
00000000000i[MEM0 ] allocated memory at 01D30020. after alignment, vector=01D31000
00000000000i[MEM0 ] 512.00MB
00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('BIOS-bochs-latest')
00000000000i[MEM0 ] rom at 0xc0000/38400 ('../VGABIOS-lgpl-latest')
00000000000i[APIC?] set APIC ID to 0
00000000000i[APIC0] 80686
00000000000i[APIC0] local apic in CPU apicid=00 initializing
00000000000i[IOAP ] initializing I/O APIC
00000000000i[IOAP ] set APIC ID to 1
00000000000i[MEM0 ] Register memory access handlers: fec00000-fec00fff
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Sun Jan 25 14:54:52 2009 (time0=1232913292)
00000000000i[DMA  ] channel 4 used by cascade
00000000000i[DMA  ] channel 2 used by Floppy Drive
00000000000i[FDD  ] fd0: 'myfloppy2.img' ro=0, h=2,t=80,spt=18
00000000000i[PCI  ] 440FX Host bridge present at device 0, function 0
00000000000i[PCI  ] PIIX3 PCI-to-ISA bridge present at device 1, function 0
00000000000i[MEM0 ] Register memory access handlers: 000a0000-000bffff
00000000000i[WGUI ] Desktop Window dimensions: 1152 x 864
00000000000i[WGUI ] Number of Mouse Buttons = 3
00000000000i[WGUI ] IME disabled
00000000000i[MEM0 ] Register memory access handlers: e0000000-e07fffff
00000000000i[CLVGA] VBE Bochs Display Extension Enabled
00000000000i[CLVGA] interval=40000
00000000000i[     ] init_mem of 'harddrv' plugin device by virtual method
00000000000i[     ] init_mem of 'keyboard' plugin device by virtual method
00000000000i[     ] init_mem of 'serial' plugin device by virtual method
00000000000i[     ] init_mem of 'parallel' plugin device by virtual method
00000000000i[     ] init_mem of 'extfpuirq' plugin device by virtual method
00000000000i[     ] init_mem of 'gameport' plugin device by virtual method
00000000000i[     ] init_mem of 'speaker' plugin device by virtual method
00000000000i[     ] init_mem of 'pci_ide' plugin device by virtual method
00000000000i[     ] init_mem of 'acpi' plugin device by virtual method
00000000000i[     ] init_dev of 'harddrv' plugin device by virtual method
00000000000i[HD   ] Using boot sequence floppy, cdrom, disk
00000000000i[HD   ] Floppy boot signature check is enabled
00000000000i[     ] init_dev of 'keyboard' plugin device by virtual method
00000000000i[KBD  ] will paste characters every 1000 keyboard ticks
00000000000i[     ] init_dev of 'serial' plugin device by virtual method
00000000000i[SER  ] com1 at 0x03f8 irq 4
00000000000i[     ] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR  ] parallel port 1 at 0x0378 irq 7
00000000000i[     ] init_dev of 'extfpuirq' plugin device by virtual method
00000000000i[     ] init_dev of 'gameport' plugin device by virtual method
00000000000i[     ] init_dev of 'speaker' plugin device by virtual method
00000000000i[     ] init_dev of 'pci_ide' plugin device by virtual method
00000000000i[PCI  ] PIIX3 PCI IDE controller present at device 1, function 1
00000000000i[     ] init_dev of 'acpi' plugin device by virtual method
00000000000i[PCI  ] ACPI Controller present at device 1, function 3
00000000000i[     ] register state of 'harddrv' plugin device by virtual method
00000000000i[     ] register state of 'keyboard' plugin device by virtual method
00000000000i[     ] register state of 'serial' plugin device by virtual method
00000000000i[     ] register state of 'parallel' plugin device by virtual method
00000000000i[     ] register state of 'extfpuirq' plugin device by virtual method
00000000000i[     ] register state of 'gameport' plugin device by virtual method
00000000000i[     ] register state of 'speaker' plugin device by virtual method
00000000000i[     ] register state of 'pci_ide' plugin device by virtual method
00000000000i[     ] register state of 'acpi' plugin device by virtual method
00000000000i[SYS  ] bx_pc_system_c::Reset(HARDWARE) called
00000000000i[CPU0 ] cpu hardware reset
00000000000i[APIC0] local apic in CPU 0 initializing
00000000000i[     ] reset of 'harddrv' plugin device by virtual method
00000000000i[     ] reset of 'keyboard' plugin device by virtual method
00000000000i[     ] reset of 'serial' plugin device by virtual method
00000000000i[     ] reset of 'parallel' plugin device by virtual method
00000000000i[     ] reset of 'extfpuirq' plugin device by virtual method
00000000000i[     ] reset of 'gameport' plugin device by virtual method
00000000000i[     ] reset of 'speaker' plugin device by virtual method
00000000000i[     ] reset of 'pci_ide' plugin device by virtual method
00000000000i[     ] reset of 'acpi' plugin device by virtual method
00000003445i[BIOS ] $Revision: 1.193 $ $Date: 2007/12/20 18:12:11 $
00000317060i[KBD  ] reset-disable command received
00000335566i[BIOS ] Starting rombios32
00000336288i[BIOS ] ram_size=0x20000000
00000356698i[BIOS ] Found 1 cpu(s)
00000372170i[BIOS ] bios_table_addr: 0x000faff8 end=0x000fe05b
00000372244i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00000699979i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00001028426i[P2I  ] PCI IRQ routing: PIRQA# set to 0x0b
00001028475i[P2I  ] PCI IRQ routing: PIRQB# set to 0x09
00001028524i[P2I  ] PCI IRQ routing: PIRQC# set to 0x0b
00001028573i[P2I  ] PCI IRQ routing: PIRQD# set to 0x09
00001028588i[P2I  ] write: ELCR2 = 0x0a
00001029389i[BIOS ] PIIX3 init: elcr=00 0a
00001050302i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237
00001053275i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000
00001055716i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010
00001056198i[PIDE ] new BM-DMA address: 0xc000
00001056952i[BIOS ] region 4: 0x0000c000
00001059227i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113
00001059758i[ACPI ] new irq line = 11
00001059794i[ACPI ] new PM base address: 0xb000
00001059861i[ACPI ] new SM base address: 0xb100
00001060246i[CPU0 ] Enter to System Management Mode
00001060256i[CPU0 ] RSM: Resuming from System Management Mode
00001060290i[PCI  ] setting SMRAM control register to 0x4a
00001060508i[PCI  ] setting SMRAM control register to 0x0a
00001084183i[BIOS ] MP table addr=0x000fb0d0 MPC table addr=0x000fb000 size=0xd0
00001086126i[BIOS ] ACPI tables: RSDP addr=0x000fb0e0 ACPI DATA addr=0x1fff0000 size=0x978
00001098996i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00001349337i[VBIOS] VGABios $Id: vgabios.c,v 1.66 2006/07/10 07:47:51 vruppert Exp $

00001349408i[CLVGA] VBE known Display Interface b0c0
00001349440i[CLVGA] VBE known Display Interface b0c4
00001352365i[VBIOS] VBE Bios $Id: vbe.c,v 1.58 2006/08/19 09:39:43 vruppert Exp $
00001440000i[WGUI ] dimension update x=720 y=400 fontheight=16 fontwidth=9 bpp=8
00001796627i[BIOS ] Booting from 0000:7c00
00122798000i[WGUI ] system RESET callback
00122798000i[SYS  ] bx_pc_system_c::Reset(HARDWARE) called
00122798000i[CPU0 ] cpu hardware reset
00122798000i[APIC0] local apic in CPU 0 initializing
00122798000i[     ] reset of 'harddrv' plugin device by virtual method
00122798000i[     ] reset of 'keyboard' plugin device by virtual method
00122798000i[     ] reset of 'serial' plugin device by virtual method
00122798000i[     ] reset of 'parallel' plugin device by virtual method
00122798000i[     ] reset of 'extfpuirq' plugin device by virtual method
00122798000i[     ] reset of 'gameport' plugin device by virtual method
00122798000i[     ] reset of 'speaker' plugin device by virtual method
00122798000i[     ] reset of 'pci_ide' plugin device by virtual method
00122798000i[     ] reset of 'acpi' plugin device by virtual method
00122801572i[BIOS ] $Revision: 1.193 $ $Date: 2007/12/20 18:12:11 $
00123115073i[KBD  ] reset-disable command received
00123133467i[BIOS ] Starting rombios32
00123134189i[BIOS ] ram_size=0x20000000
00123154621i[BIOS ] Found 1 cpu(s)
00123170093i[BIOS ] bios_table_addr: 0x000faff8 end=0x000fe05b
00123170167i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00123497902i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00123826349i[P2I  ] PCI IRQ routing: PIRQA# set to 0x0b
00123826398i[P2I  ] PCI IRQ routing: PIRQB# set to 0x09
00123826447i[P2I  ] PCI IRQ routing: PIRQC# set to 0x0b
00123826496i[P2I  ] PCI IRQ routing: PIRQD# set to 0x09
00123826511i[P2I  ] write: ELCR2 = 0x0a
00123827312i[BIOS ] PIIX3 init: elcr=00 0a
00123848225i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237
00123851198i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000
00123853639i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010
00123854875i[BIOS ] region 4: 0x0000c000
00123857150i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113
00123857681i[ACPI ] new irq line = 11
00123881553i[BIOS ] MP table addr=0x000fb0d0 MPC table addr=0x000fb000 size=0xd0
00123883496i[BIOS ] ACPI tables: RSDP addr=0x000fb0e0 ACPI DATA addr=0x1fff0000 size=0x978
00123896366i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00124146707i[VBIOS] 
VGABios $Id: vgabios.c,v 1.66 2006/07/10 07:47:51 vruppert Exp $

00124146778i[CLVGA] VBE known Display Interface b0c0
00124146810i[CLVGA] VBE known Display Interface b0c4
00124149735i[VBIOS] VBE Bios $Id: vbe.c,v 1.58 2006/08/19 09:39:43 vruppert Exp $
00124593997i[BIOS ] Booting from 0000:7c00
00131752000i[WGUI ] system RESET callback
00131752000i[SYS  ] bx_pc_system_c::Reset(HARDWARE) called
00131752000i[CPU0 ] cpu hardware reset
00131752000i[APIC0] local apic in CPU 0 initializing
00131752000i[     ] reset of 'harddrv' plugin device by virtual method
00131752000i[     ] reset of 'keyboard' plugin device by virtual method
00131752000i[     ] reset of 'serial' plugin device by virtual method
00131752000i[     ] reset of 'parallel' plugin device by virtual method
00131752000i[     ] reset of 'extfpuirq' plugin device by virtual method
00131752000i[     ] reset of 'gameport' plugin device by virtual method
00131752000i[     ] reset of 'speaker' plugin device by virtual method
00131752000i[     ] reset of 'pci_ide' plugin device by virtual method
00131752000i[     ] reset of 'acpi' plugin device by virtual method
00131755572i[BIOS ] $Revision: 1.193 $ $Date: 2007/12/20 18:12:11 $
00132069073i[KBD  ] reset-disable command received
00132087465i[BIOS ] Starting rombios32
00132088187i[BIOS ] ram_size=0x20000000
00132108597i[BIOS ] Found 1 cpu(s)
00132124069i[BIOS ] bios_table_addr: 0x000faff8 end=0x000fe05b
00132124143i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00132451878i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00132780325i[P2I  ] PCI IRQ routing: PIRQA# set to 0x0b
00132780374i[P2I  ] PCI IRQ routing: PIRQB# set to 0x09
00132780423i[P2I  ] PCI IRQ routing: PIRQC# set to 0x0b
00132780472i[P2I  ] PCI IRQ routing: PIRQD# set to 0x09
00132780487i[P2I  ] write: ELCR2 = 0x0a
00132781288i[BIOS ] PIIX3 init: elcr=00 0a
00132802201i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237
00132805174i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000
00132807615i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010
00132808851i[BIOS ] region 4: 0x0000c000
00132811126i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113
00132811657i[ACPI ] new irq line = 11
00132835529i[BIOS ] MP table addr=0x000fb0d0 MPC table addr=0x000fb000 size=0xd0
00132837472i[BIOS ] ACPI tables: RSDP addr=0x000fb0e0 ACPI DATA addr=0x1fff0000 size=0x978
00132850342i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00133100683i[VBIOS] 
VGABios $Id: vgabios.c,v 1.66 2006/07/10 07:47:51 vruppert Exp $

00133100754i[CLVGA] VBE known Display Interface b0c0
00133100786i[CLVGA] VBE known Display Interface b0c4
00133103711i[VBIOS] VBE Bios $Id: vbe.c,v 1.58 2006/08/19 09:39:43 vruppert Exp $
00133547973i[BIOS ] Booting from 0000:7c00
00136930000p[WGUI ] >>PANIC<< POWER button turned off.
00136930000i[CPU0 ] CPU is in real mode (active)
00136930000i[CPU0 ] CS.d_b = 16 bit
00136930000i[CPU0 ] SS.d_b = 16 bit
00136930000i[CPU0 ] EFER   = 0x00000000
00136930000i[CPU0 ] | RAX=000000000000023a  RBX=0000000000007c38
00136930000i[CPU0 ] | RCX=0000000000000037  RDX=0000000000000000
00136930000i[CPU0 ] | RSP=0000000000009000  RBP=0000000000007c1c
00136930000i[CPU0 ] | RSI=00000000ffff88ca  RDI=0000000000080000
00136930000i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00136930000i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00136930000i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00136930000i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00136930000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df if tf sf zf AF PF CF
00136930000i[CPU0 ] | SEG selector     base    limit G D
00136930000i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00136930000i[CPU0 ] |  CS:0000( 0004| 0|  0) 00000000 0000ffff 0 0
00136930000i[CPU0 ] |  DS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00136930000i[CPU0 ] |  SS:9100( 0005| 0|  0) 00091000 0000ffff 0 0
00136930000i[CPU0 ] |  ES:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00136930000i[CPU0 ] |  FS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00136930000i[CPU0 ] |  GS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00136930000i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00136930000i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00136930000i[CPU0 ] | RIP=00000000000064ce (00000000000064ce)
00136930000i[CPU0 ] | CR0=0x00000010 CR1=0x0 CR2=0x0000000000000000
00136930000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00136930000i[CPU0 ] >> add byte ptr ds:[bx+si], al : 0000
00136930000i[CMOS ] Last time is 1232913359 (Sun Jan 25 14:55:59 2009)
00136930000i[     ] restoring default signal behavior
00136930000i[CTRL ] quit_sim called with exit code 1

I don't know how to fix this. I know it is falling at the jmp 0000:8000 not before or after.
I don't know what the hell add byte ptr ds:[bx +si], al : 0000. Maybe it is not jumping to where I want it to.

Thanks for any help.
I have tried everything.

Re: BootLoader Problem???

Posted: Sun Jan 25, 2009 2:19 pm
by stephenj
Should "int 13" be "int 13h"?

Also, this topic should probably be moved to OS Dev.

Re: BootLoader Problem???

Posted: Sun Jan 25, 2009 2:47 pm
by Sam111
Yes now it doesn't keep resetting it displays my sector 1 display but it doesn't jmp to my second sector because I think it is having trouble reading/writing from the floppy drive?

In the bochesout.txt file I have a **** load of lines like this

Code: Select all

00002901224i[FDD  ] attempt to read/write sector 55 past last sector 18
So do you see a problem in my readsectors_into_memory: function? Because I cann't see anything wrong with it? It should be just reading the second sector ?

Thanks for your help.
I posted this question a while back in the os section but nobody seemed to spot any problems.
But I am still at a loss on how I fix this new problem. At least I have a clue on what is going wrong. But the CHS seems to be correct format for the int 13h call to read/write to floppy?

Code: Select all

sector 55 past last sector 18
<-- Where is this coming from I never said anything about sector 55 uh? #-o

Re: BootLoader Problem???

Posted: Sun Jan 25, 2009 3:29 pm
by Troy Martin
Hint: the sectors per track of a 1.44MB floppy is 18.
I have tried everything.
Apparently not.

Re: BootLoader Problem???

Posted: Sun Jan 25, 2009 4:12 pm
by Sam111
Ya , but where in my code do I screw that up ?
These are the varibles

Code: Select all

STARTSECTOR     db  2            ;start sector to load
LOADADDRESS     dw  8000h       ; where to load the sectors into memory
NUMBEROFSECTORS db  1           ; number of bytes to load begining at STARTSECTOR
; I don't specify > 18 any where in startsector ?

Code: Select all

readsectors_into_memory:
mov ah , 02h                    ; read function
mov al , NUMBEROFSECTORS        ; number  of sectors to read
mov ch , 0h                     ; cylinder number
mov cl , STARTSECTOR            ; starting sector to begin reading from
mov dh , 0h                     ; head number
mov dl , 00h                    ;drive for floppy
mov bx , LOADADDRESS            ; es:bx-> buffer for where the sectors will be loaded in this case 0000:8000h

int 13h                          ; execute the interrupt for reading into memory
ret

I have even tried putting [] around the 3 varibles ?

but then I get this in the error log

Code: Select all

00093813090e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093813347e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093813604e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093813861e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093814118e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093814375e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093814632e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093814889e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093815146e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093815403e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093815660e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093815917e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093816174e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093816431e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093816688e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093816945e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093817201e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093817457e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093817713e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093817969e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093818225e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093818481e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093818737e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093818993e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093819249e[CPU0 ] prefetch: EIP [00010000] > CS.limit [0000ffff]
00093819249i[CPU0 ] CPU is in real mode (active)
00093819249i[CPU0 ] CS.d_b = 16 bit
00093819249i[CPU0 ] SS.d_b = 16 bit
00093819249i[CPU0 ] EFER   = 0x00000000
00093819249i[CPU0 ] | RAX=000000000000fdfd  RBX=0000000000000000
00093819249i[CPU0 ] | RCX=000000000000fdfd  RDX=000000000000e320
00093819249i[CPU0 ] | RSP=0000000000000003  RBP=000000000000fdfd
00093819249i[CPU0 ] | RSI=00000000000065bf  RDI=000000000000fdfd
00093819249i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00093819249i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00093819249i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00093819249i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00093819249i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf AF PF CF
00093819249i[CPU0 ] | SEG selector     base    limit G D
00093819249i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00093819249i[CPU0 ] |  CS:17fd( 1e00| 0|  0) 00017fd0 0000ffff 0 0
00093819249i[CPU0 ] |  DS:0000( 0000| 0|  0) 00000000 0000ffff 0 0
00093819249i[CPU0 ] |  SS:0000( 0000| 0|  0) 00000000 0000ffff 0 0
00093819249i[CPU0 ] |  ES:fdfd( 0000| 0|  0) 000fdfd0 0000ffff 0 0
00093819249i[CPU0 ] |  FS:0000( 0000| 0|  0) 00000000 0000ffff 0 0
00093819249i[CPU0 ] |  GS:0000( 0000| 0|  0) 00000000 0000ffff 0 0
00093819249i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00093819249i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00093819249i[CPU0 ] | RIP=000000000000ffff (000000000000ffff)
00093819249i[CPU0 ] | CR0=0x00000010 CR1=0x0 CR2=0x0000000000000000
00093819249i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00093819249i[CPU0 ] (instruction unavailable) page split instruction
00093819249e[CPU0 ] exception(): 3rd (12) exception with no resolution, shutdown status is 00h, resetting
00093819249i[SYS  ] bx_pc_system_c::Reset(SOFTWARE) called
00093819249i[CPU0 ] cpu software reset
00093819249i[APIC0] local apic in CPU 0 initializing
00093822821i[BIOS ] $Revision: 1.193 $ $Date: 2007/12/20 18:12:11 $
00094136550i[KBD  ] reset-disable command received
00094155172i[BIOS ] Starting rombios32
00094155894i[BIOS ] ram_size=0x20000000
00094176326i[BIOS ] Found 1 cpu(s)
00094191798i[BIOS ] bios_table_addr: 0x000faff8 end=0x000fe05b
00094191872i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00094519607i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00094848054i[P2I  ] PCI IRQ routing: PIRQA# set to 0x0b
00094848103i[P2I  ] PCI IRQ routing: PIRQB# set to 0x09
00094848152i[P2I  ] PCI IRQ routing: PIRQC# set to 0x0b
00094848201i[P2I  ] PCI IRQ routing: PIRQD# set to 0x09
00094848216i[P2I  ] write: ELCR2 = 0x0a
00094849017i[BIOS ] PIIX3 init: elcr=00 0a
00094869930i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237
00094872903i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000
00094875344i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010
00094876580i[BIOS ] region 4: 0x0000c000
00094878855i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113
00094879386i[ACPI ] new irq line = 11
00094903258i[BIOS ] MP table addr=0x000fb0d0 MPC table addr=0x000fb000 size=0xd0
00094905201i[BIOS ] ACPI tables: RSDP addr=0x000fb0e0 ACPI DATA addr=0x1fff0000 size=0x978
00094918071i[PCI  ] 440FX PMC write to PAM register 59 (TLB Flush)
00095168412i[VBIOS] 
VGABios $Id: vgabios.c,v 1.66 2006/07/10 07:47:51 vruppert Exp $

00095168483i[CLVGA] VBE known Display Interface b0c0
00095168515i[CLVGA] VBE known Display Interface b0c4
00095171440i[VBIOS] VBE Bios $Id: vbe.c,v 1.58 2006/08/19 09:39:43 vruppert Exp $
00095615702i[BIOS ] Booting from 0000:7c00
00101614000p[WGUI ] >>PANIC<< POWER button turned off.
00101614000i[CPU0 ] CPU is in real mode (active)
00101614000i[CPU0 ] CS.d_b = 16 bit
00101614000i[CPU0 ] SS.d_b = 16 bit
00101614000i[CPU0 ] EFER   = 0x00000000
00101614000i[CPU0 ] | RAX=0000000000000001  RBX=0000000000000000
00101614000i[CPU0 ] | RCX=0000000000000002  RDX=0000000000000000
00101614000i[CPU0 ] | RSP=0000000000009000  RBP=0000000000007c1c
00101614000i[CPU0 ] | RSI=00000000ffff88ca  RDI=0000000000080000
00101614000i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00101614000i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00101614000i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00101614000i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00101614000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df if tf sf ZF af PF cf
00101614000i[CPU0 ] | SEG selector     base    limit G D
00101614000i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00101614000i[CPU0 ] |  CS:0000( 0004| 0|  0) 00000000 0000ffff 0 0
00101614000i[CPU0 ] |  DS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00101614000i[CPU0 ] |  SS:9100( 0005| 0|  0) 00091000 0000ffff 0 0
00101614000i[CPU0 ] |  ES:8000( 0005| 0|  0) 00080000 0000ffff 0 0
00101614000i[CPU0 ] |  FS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00101614000i[CPU0 ] |  GS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00101614000i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00101614000i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00101614000i[CPU0 ] | RIP=0000000000001f42 (0000000000001f42)
00101614000i[CPU0 ] | CR0=0x00000010 CR1=0x0 CR2=0x0000000000000000
00101614000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00101614000i[CPU0 ] >> (invalid)  : FFFD
00101614000i[CMOS ] Last time is 1232921144 (Sun Jan 25 17:05:44 2009)

Re: BootLoader Problem???

Posted: Sun Jan 25, 2009 4:17 pm
by M-Saunders
You seem to be confusing decimal and hexadecimal -- on the one hand loading the kernel at 8000h, but then jmping to 8000. Where did you get that code?

M

Re: BootLoader Problem???

Posted: Sun Jan 25, 2009 4:30 pm
by Sam111
Ok I tried changing jmp 0000:8000 to jmp 0000:8000h but I get this

Code: Select all

vruppert Exp $
00087721986i[BIOS ] Booting from 0000:7c00
00114662000p[WGUI ] >>PANIC<< POWER button turned off.
00114662000i[CPU0 ] CPU is in real mode (active)
00114662000i[CPU0 ] CS.d_b = 16 bit
00114662000i[CPU0 ] SS.d_b = 16 bit
00114662000i[CPU0 ] EFER   = 0x00000000
00114662000i[CPU0 ] | RAX=0000000000001301  RBX=000000000000000f
00114662000i[CPU0 ] | RCX=0000000000000010  RDX=0000000000000503
00114662000i[CPU0 ] | RSP=0000000000001110  RBP=0000000000007c03
00114662000i[CPU0 ] | RSI=00000000ffff88ca  RDI=0000000000080000
00114662000i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00114662000i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00114662000i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00114662000i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00114662000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df if tf sf ZF af PF cf
00114662000i[CPU0 ] | SEG selector     base    limit G D
00114662000i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00114662000i[CPU0 ] |  CS:0000( 0004| 0|  0) 00000000 0000ffff 0 0
00114662000i[CPU0 ] |  DS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00114662000i[CPU0 ] |  SS:1110( 0005| 0|  0) 00011100 0000ffff 0 0
00114662000i[CPU0 ] |  ES:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00114662000i[CPU0 ] |  FS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00114662000i[CPU0 ] |  GS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00114662000i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00114662000i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00114662000i[CPU0 ] | RIP=000000000000804a (000000000000804a)
00114662000i[CPU0 ] | CR0=0x00000010 CR1=0x0 CR2=0x0000000000000000
00114662000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00114662000i[CPU0 ] >> jmp .+0xfffe (0x0000804a) : EBFE
00114662000i[CMOS ] Last time is 1232922235 (Sun Jan 25 17:23:55 2009)
00114662000i[     ] restoring default signal behavior
00114662000i[CTRL ] quit_sim called with exit code 1
When I look at my disk image with a hex editor. Sector 2 contains

Code: Select all

E9 14 00 54 68 69 73 20 69 73 20 73 65 63 74 6F 72 20 32 21 0D 0A 24 B8 00 00 8E D8 8E C0 B8 10 11 8E D0 89 C4 B8 00 06 B7 07 B5 00 B1 00 B6 18 B2 4F CD 10 B4 13 B0 01 B7 00 B3 0F B6 05 B2 03 B9 03 7C 89 CD B9 10 00 CD 10 EB FE 00 00 00 00 ...on and on

Code: Select all

00114662000i[CPU0 ] >> jmp .+0xfffe (0x0000804a) : EBFE
So it seems like it is jumping to the EB FE code on the second sector so I would think it is suppose to display my string but it doesn't. It just freezes the screen because I think EB FE is the

Code: Select all

endsss:
jmp endsss
code. So then it is failing somewhere on sector's 2 code?

I original copied my programs with a hex editor on to sector 1 and 2 respectfully.
It seems like it is jumping to the second sector but it is crashing. Do I jump to the wrong piece of code on the 2 sector ?


This is sector 2 code

Code: Select all

org 0x8000
BITS 16
jmp main
hello	db	'This is sector 2!',13d,10d,'$' ;Put any data here!

main:
mov ax , 0
mov ds , ax 
mov es , ax
mov ax , 0x1110
mov ss , ax
mov sp , ax


mov ax , 600h       ; clear screen scroll up function
mov bh , 7h         ; white on black background
mov ch , 0h         ;upper line (top)
mov cl , 0h         ;left col (far left)
mov dh , 18h        ;bottom 
mov dl , 4Fh        ;far right
int 10h             ;do the clearing 

; display the string This is sector 2 on the screen
;mov ax , 0
;mov es , ax

mov ah , 13h
mov al , 01h 
mov bh , 0h
mov bl , 0Fh
mov dh , 5h
mov dl , 3h
mov cx , hello
mov bp , cx
mov cx , 16d
int 10h
; loop forever
endsss:
jmp endsss


Re: BootLoader Problem???

Posted: Sun Jan 25, 2009 4:59 pm
by Sam111
Sorry I had a old version of the sector 2 program on my disk image.
It was doing everything correct after I made the 0000:8000h change
Once I asemblied the sector 2 program and copied it to sector 2 it works.

Thank you for all your help the problem's where

Code: Select all

int 13 to int 13h
and
jmp 0000:8000 to jmp 0000:8000h
Stupid me I sort of lost track of this in coding in a few places.
Good luck with your OS. =D>