problem loading sectors

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
protonix

problem loading sectors

Post by protonix »

Hi all,


I am (finally) implementing the ability to load sectors in my OS. Since my os is only 512 bytes, I have decided to save space and instead of having the user type what sector they want loaded, they press keys F1-F3 to load sectors 1-3 respectively (I am adding F4-F12 later...).

The problem is that when loading a sector, the OS crashes in bochs with the message "00068675875p[CPU0 ] >>PANIC<< prefetch: RIP > CS.limit"

Sectors are loaded to 0x2000:0x0000

The source code is located at http://protonix.asmhackers.net/protonix ... NEWPRO.ASM
(Sorry for the long URL, I have a weird way of organizing my stuff on my webspace)

The relevant sector loading code is at these labels:
sectcomp:
intload2:
intload3:
loadsect:


Here is the Bochs log: http://protonix.asmhackers.net/protonix ... el/log.txt


This is all in FASM, and realmode.
What is causing this PANIC?

-Anthony
DennisCGc

Re:problem loading sectors

Post by DennisCGc »

Hi,

Your code seems to be okay, but what are you loading at 0x2000:0000 (in other words, what's at sector 2 ?)

I think the code, which is at sector 2, is actually causing the problem. (you're jumping to it.)

HTH,

DennisCGc.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:problem loading sectors

Post by Pype.Clicker »

it looks like your code ran straight forward through 0x2000:xxxx until it attemps to execute instruction at cs=0x2000, eip=0x00010000, which is forbidden in realmode ...

Chances are that you've loaded a bunch of zeroes instead of the code you expected to have (wrong sector nr or something alike).
protonix

Re:problem loading sectors

Post by protonix »

Here's the test program:

Code: Select all

;Protonix sector loading test program
;Just prints a string, waits for a key, and returns to the OS
;Also demonstrates Protonix interrupts in user programs

use16 
org 0x0000

mov ax, 0x2000
mov ds, ax
mov es, ax

mov si, string   ;load and print string
mov si, pakmsg
int 0x21

int 0x22      ;wait for key

int 0x19      ;give control back to OS

string db 'If you can read this, you have successfully run the Protonix test program',13,10,0
pakmsg db 'Press any key to return to Protonix',13,10,0


times 512-($-$$) db 0   ;make file 512 bytes
And to write everything to disk:

Code: Select all

@echo off
echo Installer Script for Protonix 0.2-1   
echo Insert a blank floppy disk in drive A (it need not be formatted)
fasm newpro.asm 
fasm test.asm
copy /b newpro.bin+test.bin protonix.img
echo.
pause
partcopy protonix.img 0 400 -f0
echo Done! 

-Anthony
protonix

Re:problem loading sectors

Post by protonix »

Any ideas?
B.E

Re:problem loading sectors

Post by B.E »

Question:

Is it ment to start in DOS?

if it is not then int 21h and 22h is only for dos, you have to write your own ISR.

if it is then [org 7c00h] statement is wrong.

even with support for int 21h

Code: Select all

mov ax, 0x2000
mov ds, ax
mov es, ax

mov si, string   ;load and print string
mov si, pakmsg
int 0x21
is going to execute function 20h (a NULL function);
protonix

Re:problem loading sectors

Post by protonix »

Interrupt 0x21 and 0x22 are valid in my OS (I set up a custom IVT). 0x21 is string output and 0x22 is character input.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:problem loading sectors

Post by Pype.Clicker »

what about setting a breakpoint in the bochs at 0x20000 so that you can make sure what's there is your code and that it executes as expected ?
protonix

Re:problem loading sectors

Post by protonix »

BOCHSDBG seems to not be working for me, unfortunately.
Post Reply