flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Protected Mode |
Author |
|
f0dder 01 Sep 2007, 08:34
It wouldn't be processor dependent but BIOS dependent... BIOS is 16bit realmode and usually extremely slow, so it's not much use for "real world" stuff. And you typically can't call BIOS from modern OS'es, unless you're actually writing DOS programs and the OS has 16-bit DOS emulation/support.
|
|||
01 Sep 2007, 08:34 |
|
DOS386 01 Sep 2007, 09:39
Quote: It wouldn't be processor dependent but BIOS dependent... BIOS is 16bit realmode and usually extremely slow, so it's not much use for "real world" stuff. And you typically can't call BIOS from modern OS'es NOT true. BIOS works pretty well and is less dead than some geeks would like to see it. It is not the fastest, but still useful, provides access to VGA, VESA, Floppy ( ), HD (IDE and SATA), partially even USB storage. But right, BIOS can't be called directly from PM, have to switch to RM for BIOS calls. _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
01 Sep 2007, 09:39 |
|
dosin 01 Sep 2007, 10:46
Well just to add I was looking for a good pmode example/tutorial-
This is what I am shooting for my first OS! writing DOS programs and the OS has 16-bit DOS emulation/support. and is for more of a learning environment... I have executed a pmode exe file written with this type of .clib and it worked - I was able to access the extended memory and exit pmode and return to the 16 bit os. My goal is to eventually learn pmode and have the real mode os launch the pmode kernel and have it take control from there Plus the clib will help write utilities like edit,copy, .......and I can still use the dos int.. that my os will support Thinking outside of the box: boot loader pmode jump to graphics wow an os! well for beginners this is were they want to begin..I know this was my first thought on building an os! Don't forget whats in the box - it started everything! bios.. dos.. ect! |
|||
01 Sep 2007, 10:46 |
|
f0dder 01 Sep 2007, 11:47
You can't depend on DOS if you're building an OS, really... and depending on the BIOS? Sure, if you want to have a very slow OS. But hey, the choice is yours
|
|||
01 Sep 2007, 11:47 |
|
Hayden 01 Sep 2007, 17:17
Many OS's use the bios's extensivly at the executive level...
_________________ New User.. Hayden McKay. |
|||
01 Sep 2007, 17:17 |
|
Dex4u 01 Sep 2007, 17:32
First i agree with NTOSKRNL_VXE, BIOS is not slow, anyone who thinks BIOS is slow, but Dos is not, does not know how Dos works ( not say you said that ).
But Dos is just wraps in most cases that call BIOS functions. @dosin, please post a link to the clib so we can help you more and remember C aim's to be portable. I have written a vesa demo to go to and from pmode for mode switching that may help, let me know if you want to see the fasm code . @f0dder, linux was fully dependent on "MINIX" in the first ver's of linux. http://kerneltrap.org/node/14002 |
|||
01 Sep 2007, 17:32 |
|
dosin 01 Sep 2007, 20:55
I will post the code and clib later tonight!
Bios - Some of the functions could be written with in/out :IO functions instead... I think this would be a great help developers.. Plus if you have Turbo C it is easy to configure with it! just go to your Lib folder and replace the COS.OBJ and CS.LIB then add the include files to either the bin or include folder if in the include folder use: #include <sdtio.h> if in the bin folder use: #include "stdio.h" Just remember to make back ups of the lib and include files you replace!!! This lib is still not fully tested!! You should not need to recompile it unless you add some functions/or change it! Also: Quote: I have written a vesa demo to go to and from pmode for mode switching that may help, let me know if you want to see the fasm code . Sure that would be great!!! I am still not real comfortable with PMODE yet! Thats why I was asking for a good tutorial/examples |
|||
01 Sep 2007, 20:55 |
|
Dex4u 02 Sep 2007, 00:21
http://www.dex4u.com/demos/DemoVesa.zip
NOTE: I was called ASHLEY4 when i coded it. |
|||
02 Sep 2007, 00:21 |
|
dosin 02 Sep 2007, 20:21
Dex4u: In your demovesa application I loose the keyboard and disk functions..ect I am guessing its because the IRQs need to reprogrammed
Great example very easy to follow!!!! could you list the steps for pmode: example: 1. Build the GDT 2. Enable A20 on the address bus 3. Enable protected mode in the CPU control register (CR0) 4. JUMP to clear the prefetch queue ect.. Thanks again!!! Here is that clib I found on the net! it does have a pmode sample that worked on my computer and I ran it from my os... Also it will run non dos .com and .exe files..
|
|||||||||||
02 Sep 2007, 20:21 |
|
Dex4u 03 Sep 2007, 01:57
Thanks for the lib code, as for why no keyboard etc, when entering pmode you need setup IDT and remap pic before you can use int, if not you need to disable them with cli in realmode before entering pmode, that means you can not use keyboard.
But as a temp measure, you can use poll to get keyboard input Example: Code: NoKey: xor eax,eax in AL,60h cmp al,0x50 jne NoKey1;do something here jmp NoKeyNoKey1: cmp al,0x48 jne NoKey2;do something here jmp NoKeyNoKey2: cmp al,0x1c jne NoKey ;do something here jmp NoKey Setting up GDT Quote:
The steps are the same as you put but i would add settingup IDT or disableing with cli This is the min thing you need, and remember this is for a single-tasking 32bit pmode OS, If you want a 32bit pmode multi-tasking OS, with uses using ring3 and paging etc there more. Note: also in pmode you can not use any bios ints, eg: int 13h, but you can goto and from pmode to realmode or write you own pmode driver. |
|||
03 Sep 2007, 01:57 |
|
dosin 03 Sep 2007, 04:38
Dex4u: Thank you, for all your help!
One thing I was wondering.. with that clib... it uses bios int 10h/16h ect and in pmode these don't work correct! Quote:
with this clib I was able to enter pmode and use them with the printf fucntion ect....... could it be that tc compiler sets up a virtual bus that points to those functions.. Since this virtual bus is running on windows? I read this is possible to program into pmode.. If so a clib like this would be worth using and building upon!.. if you want to see what I am talking about : boot the loader2.exe in the PM LOADER file |
|||
03 Sep 2007, 04:38 |
|
dosin 04 Sep 2007, 13:16
Dex4u would you mind taking a look at this example I uploaded!
Load the files on a floppy and boot- at the prompt type -dir and run the vm86.com/exe it uses the virtual real mode.... it seems to work!!! if you want to help to convert the nasm to FASM just let me know and I will up load it!!! It was an open source nasm/gcc program for virtual real mode I found..
|
|||||||||||
04 Sep 2007, 13:16 |
|
Dex4u 04 Sep 2007, 15:36
I have down loaded it, i will test it later and let you know how it runs, on some of my test PC.
PS: I think that demo2 users this for string out put, in pmode. Code: print_str:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Input : ESI = ASCIIZ string address ;;;; BH = Y coordinate (Y>=0) ;;;; BL = X coordinate ;;;; textattr = color attribute ;;;; Output: None, registers are preserved ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; push es pushad mov ax, 18h mov es, ax shl ebx, 1 ; y*=2, x*=2 movzx edi, bh ; edi = y*2 shl edi, 4 ; edi = (y*2)*16 mov eax, edi ; eax = (y*2)*16 shl edi, 2 ; edi = (y*2)*64 add edi, eax ; edi = (y*2)*80 movzx ebx, bl ; ebx = x*2 add edi, ebx ; edi = (y*80+x)*2 add edi, [video_addr] mov ah, [textattr] ; background color cld.1: lodsb or al, al jz .2 stosw jmp .1.2: popad pop es ret Last edited by Dex4u on 05 Sep 2007, 15:13; edited 1 time in total |
|||
04 Sep 2007, 15:36 |
|
DOS386 04 Sep 2007, 22:35
> it uses bios int 10h/16h ect and in pmode these don't work correct!
Char output: do-it-yourself in PM, it's trivial (see above) VGA: switch to RM or do it from PM via ports VESA: switch to RM (very difficult to do from PM via ports) FD/HD: switch to RM or do it from PM via ports |
|||
04 Sep 2007, 22:35 |
|
dosin 06 Sep 2007, 20:33
I think I have a good idea now on how to do it...
Thanks for all the help!!! |
|||
06 Sep 2007, 20:33 |
|
edfed 12 Oct 2007, 10:32
ok
but for vesa i prefer pm (via ports) and the rm possibility even it's very difficult |
|||
12 Oct 2007, 10:32 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.