flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Falling over at the first hurdle!

Author
Thread Post new topic Reply to topic
Just me



Joined: 10 Jun 2006
Posts: 14
Just me 07 Aug 2006, 15:15
Hi all Very Happy

Just trying ou some code that I have written, but it doesn't work.
Any idea's

Code:
org 0x7c00
use16
format binary

Begin:                  jmp Start
                        nop
GDTStart:
NULLDescriptor:         dd 0
                        dd 0
CODEDescriptor:         dd 0x0000ffff ;;;[+00]
                        dd 0x00cf9a00 ;;;[+04]
STACKDescriptor:
GDTEnd:

GDT_is:
GDTLimit:               dw GDTEnd - GDTStart - 1
                        dd GDTStart

Start:                  cli
                        xor ax,ax
                        mov ds,ax
                        lgdt [GDT_is]
                        mov eax,cr0
                        or al,1
                        mov cr0,eax
                        jmp 0x08:HereWeGo
use32
HereWeGo:               sti     ;;; Problem seems to be here
                        jmp $


BootSectorFinish:       times 510-($-Begin) db 0
                        dw 0xaa55
    

I 'am running it in vmware ver 5.0.
All I get is a stack fault from within vmware. Everything seems to work until, I put the sti instruction in. I cannot figure out what I'am doing wrong Exclamation
Any help would be appreciated Very Happy
Post 07 Aug 2006, 15:15
View user's profile Send private message Reply with quote
Artlav



Joined: 23 Dec 2004
Posts: 188
Location: Moscow, Russia
Artlav 07 Aug 2006, 15:24
My guess is that because IDT is not defined, first timer interrupt causes a triple fault.

Try reading tutorials about interrupts in PM.
Post 07 Aug 2006, 15:24
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 07 Aug 2006, 15:47
The first thing you need to do after switching to protected mode is set the ds,es and ss selectors and set esp for good measure. This means you will need a data descriptor in your GDT.

Code:
use32
HereWeGo:
mov ax,0x0010 ; offset of data selector in GDT
mov ds,ax ; setup selectors
mov es,ax ;
mov ss,ax ;
mov esp,0x00008000 ; location of stack    


The next problem is I don't think you can enable interrupts again until you have loaded an IDT with 32bit selectors and ISR handlers (this is where I am stuck at the moment, so I can't help any more than that Sad ).

HTH
Post 07 Aug 2006, 15:47
View user's profile Send private message Reply with quote
Just me



Joined: 10 Jun 2006
Posts: 14
Just me 07 Aug 2006, 16:30
Hi all,
Thanks for the quick reply's. I now see the error of my ways.
'codeb453' i was just look at the code you posted. I thought there was
a difference in the make up of a selector for data an the stack. You seem
to be using the 0x10 selector for the stack as well as data!
Post 07 Aug 2006, 16:30
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 07 Aug 2006, 18:31
Yes, you can define separate selectors for data and stack, if you want them to behave differently, if not, they can use the same selector because they both handle data and can have the same properties.[/code]
Post 07 Aug 2006, 18:31
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.