Page 1 of 1

V86 a wise choise?

Posted: Fri Jul 21, 2006 11:46 am
by aryan_illusion
Hello again...
so far i have set up a GDT,IDT and routine services...and a keyboard handler...
well what i want to do next is load some files from the floppy disk in pmode...the bootloader do so using ints (while loading my kernel in real mode)....
so do i need to setup v86 in order to do so..?

and i also want to switch to grapic mode....for that i'm pretty sure i'll need to use V86..but would i'll able to output text on the screen using my printf?

secondly as of now i don't want to implement multitasking...so would that make setting up v86 difficult?
and i also would like my keyboard handler to handle the keyboard I\O..would V86 let me to do?

well.... having a GDT,IDT and ISRs in place ..how hard would implementing V86 be?...

please answer
thnx

Posted: Fri Jul 21, 2006 12:39 pm
by Dex
First i think your best off going to realmode and back to pmode, for doing bios int, this work great for mode changing and floppy loading, and its not too slow, + you can load from USB key fobs too.
I have made a demo that goes to and from realmode, for vesa mode change (you can easy make it do int 13h functions), let me know if you want me to post a link.

Also if you want to see how good this meford work for floppy load, you can down load my OS and try it: http://www.dex4u.com/

Posted: Fri Jul 21, 2006 1:25 pm
by aryan_illusion
yeah sure please post the link that will be really helpful....
thnx

Posted: Fri Jul 21, 2006 3:29 pm
by Dex
http://www.dex4u.com/demos/DemoVesa.zip
You need vesa2 to use the demo, as it displays 640x480 32bpp, faded screen, waits 10 seconds and than switch's to realmode changes to text mode, back to pmode, prints message, waits 10seconds and keeps loop until you turn PC off.

Note: i was called "ASHLEY4" when i made this, but in some country's its a girls name so i changed to Dex.

Posted: Fri Jul 21, 2006 8:30 pm
by aryan_illusion
well can n u post or link examples regarding mode switching?
i mean i tried getting back to real mode from pmode but it generated "gerneral protection fault"...which was expected since i didn't change the IDT pointer for real mode(i guess thats what it was)

i'm okay in C but new to asm...so any help would be great

btw Ashley how are the English doin now? any chance at the worldcup this time around? lol

Posted: Sat Jul 22, 2006 6:25 am
by Dex
The code is in the above link.
But quick example for changing to text mode:

Code: Select all

;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;                         Back to realmode for textmode int's.                            ;
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Real_TextMode_int:
        pushad

        jmp   20h:do_16t
use16

do_16t:

        mov   ax,28H
	mov   ds,ax
	mov   ss,ax
	nop


	mov   bx,[RealModeCS]                  ; push real-mode CS:IP
	push  bx
	lea   bx,[do_rm2]
	push  bx
                                               ; clear PE [protected mode enable] bit and return to real mode

        mov   eax,cr0
	and   al,0xFE
	mov   cr0,eax
	retf		                       ; jumps to do_rm

;''''''''''''''''''''''''';
; 16-bit real mode again  ;
;.........................;

do_rm2:
        mov   ax,cs                            ; restore real-mode segment register values
	mov   ds,ax
	mov   ss,ax
	nop
	mov   es,ax
	mov   fs,ax
	mov   gs,ax

	lidt  [ridtr]                          ; point to real-mode IDTR

        push  cs
	pop   ds
        push  ds
        pop   es
        mov   ax,0xB800
	mov   es,ax


        sti                                    ; re-enable interrupts
;''''''''''''''''''''''''''';
;  16-bit real mode int's   ;
;...........................;
        mov   ax,0x0003
        int   10h
;''''''''''''''''''''''''''';
;  real mode int's end      ;
;...........................;
        cli                                   ; Disable interrupts,
        lgdt  [gdtr]                          ; Load the GDTR with the base address and limit of the GDT

	mov   eax,cr0                         ; Set the PE [protected mode enable] bit in register CR0
	or    al,1
	mov   cr0,eax


	jmp   sys_code:do_pm111               ; jumps to do_pm


;''''''''''''''''''''''''''';
;  32-bit protected  mode   ;
;...........................;
use32
do_pm111:

      	mov   ax,sys_data
        mov   ds,ax
        mov   ss,ax
        nop
	mov   es,ax
	mov   fs,ax
	mov   gs,ax

        mov   ax,8h
	mov   es,ax

        popad

        ret
Note: when you boot you need to save some realmode settings, see in the above link.
PS: Worldcup is well gone, only winner remember it :wink:

Posted: Sat Jul 22, 2006 8:56 am
by aryan_illusion
thnx this should clear things alot,i'll try it out

and btw i meant the cricket worldcup silly

Posted: Sat Jul 22, 2006 11:09 am
by Dex
Cricket i see :lol:, we have about the same chance of doing well, as we have at football worldcup :cry:.

Posted: Sun Jul 23, 2006 10:34 pm
by aryan_illusion
i think you guys had better chance at football :P
anyways thnx for the help