View Full Version: Bios I/O calls and screen control

dex >>OS Dev >>Bios I/O calls and screen control


Pixelator- 06-02-2008
Bios I/O calls and screen control
Hi, i am getting ready to start making a simple "hello world" os but im not really sure how to use bios i/o functions that i read dex advised using in the fasm forum topic. as i am new to assembly coding, i don't really understand how bios calls work though i do have experiance with Dark Basic and some CPU design.

Dex- 06-02-2008

First i would start off by getting a bootloader, to make testing easier, i would suggest "bootprog" see here http://alexfru.chat.ru/epm.html Its is written with nasm, but DexOS and MiniDos comes with a fasm ver. Now you have your bootloader setup, start making simple com or exe for realmode that print to screen or display time etc Example of print string, using int 10h use16 ; 16bit addressing org 0x100 ; Com file stuff push cs ; Push CS on stack pop ds ; Move CS into DS push ds ; Push DS pop es ; Move DS into ES mov si,mes ; Point SI to string call print ; Call print function jmp $ ;just loop for now ;====================================================; ; print. ; ;====================================================; print: mov ah,0Eh ; Request display again1: lodsb ; load a byte into AL from DS:SI or al,al ; Or AL jz done1 ; Jump 0, to label done1 int 10h ; Call interrupt service jmp again1 ; Jump to label again1 done1: ret ; Return mes db 'Hello World!', 13, 10, 0 Assemble it as a com file eg: c:/fasm HelloTest.asm HelloTest.com <enter> You will need to mod bootprog to load a file called "HelloTest.com" see in its zip for instrutions on how to do this. Regards Dex. PS: Take a look at MiniDos for a good realmode example, it's on the fasm forum.

roboman- 06-03-2008

Call is nearly the same as gosub in basic. To get down to it int is also nearly the same as gosub. The section of code you jump to when you use call or int ends with a ret. The bios is just a section of program that is always in the computer and that you can call with an int. With asm there isn't really a good way to pass a varable, like you do in basic. For the most part, any info you need to send with an int call is stored in the registers of the cpu. The int function you want to call is defined by the number ( IE int 10h does a gosub to int number 10 ). To make things a bit more complex, most of the intrupt functions actualy do more then one thing. Most of the time you put a number in the cpu register al for what you want the function to do, but often you need to put numbers in other registers also.... http://ctyme.com/rbrown.htm has a list of int's and what info you need to put in registers (some of those are bios and some are dos intrupts, if dos isn't loaded you'll only have the bois ones...)

Pixelator- 06-03-2008

Thanks alot guys you both helped alot, now i can get it to print "hello world! over and over and over and it makes my eyes hurt.

Pixelator- 06-03-2008

Ok, i got the com file to run, but i can't find where i should change bootprog to make it load my file. i think i might be able to figure it out but i can't find the right file :? If you could tell me which one it would be most appriciated

Dex- 06-03-2008

Well you can get boot12.bin and the program "REN_PROG.EXE" and use it to change the name in the boot12.bin just type REN_PROG.EXE and see the lay but its something like REN_PROG FileName.com boot12.bin <enter> but you may have to use space's to make it 8 letters +3 ext Once you have changed the name, you would put boot12.bin on a floppy with BOOTABLE.EXE You could also get the fasm ver and change the asm code and re-assemble it. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Name of a program to be load and run ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ProgramName db "KERNEL32EXE" ; name and extension must be padded ; with spaces (11 bytes total) Rename name it to the name of your file (must be caps) and assemble it as boot12.bin and put it on the floppy as above. or you can for now, call your program minidos.com and use the floppy from minidos. Its up to you.

Pixelator- 06-04-2008

ok, i figured out my problem, Bootable.exe is quitting before i can tell it to make the floppy bootable. ill add a picture to make it easier for you to see whats going on: Btw, heres a pic of the computer im running most of this on (but it doesn't have internet and runs windows 98 ):

tonyMac- 06-04-2008

Hmmmm.... THat looks like you took everything in my box of spare parts and wired it together. :lol:

Dex- 06-04-2008

You will need to run it from a command prompt, At the prompt type something like bootable boot12.bin A: <enter> And make sure you have a formated floppy in the A: drive. PS: My box of bit is empty, as my friends keep asking me to fix there PC.

Pixelator- 06-04-2008

yea, it does sorta look like that doesn't it?. unfourtunately, the reason my mom let me take it apart was it was super slow(and it was just sitting dormate no use at all), but i figured out that the reason it the heat sync (the big meatley thing thats on the mother boaurd) is totally wimpy and doing nothing so it gets so hot you can see the heat waves off the top when its running. so im going to use the last open plug on the power supply to attatch a fan from an old amp from our churches sound system because it got hit by lightning (funny story really...) and so only the fan works. on the other hand now dos cant ever find bootable.exe so im going to bail on boot prog because its given me more trouble than its worth.

GhostXoP™- 07-08-2008
i fix pc's but thats of topic and not why im here
yes you need the bootloader to get the hello world program to start at boot, you will need to Mod BootProg.

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.