I need to write to the screen for my OS, and I can't find a good way to do it. I have seen several assembly codes, but I can't find one that will do the job. One in C++ would be even better! I'm running Red Hat 9, if that helps.
I need to write to the screen for my OS, and I can't find a good way to do it. I have seen several assembly codes, but I can't find one that will do the job. One in C++ would be even better! I'm running Red Hat 9, if that helps.
Are you writing an OS from scratch and you want to access the screen, and RH9 is your development platform?
Or are you just using RH9 and want to access the screen from within RH9
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I am using Red Hat 9, and I'm writing the OS from scratch.
Compuboy over at flashdaddee has a tutorial about making an OS, and his bootloader development tutorial has what you need. Basically...
Get it from http://electrichamster.net/lucie/Code:mov ah, 0x0E ;set teletype mode mov al, 'A' ;the char we want to print mov bh, 0x00 ;set the page number int 0x10 ;call the video function.
SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
I say what I say, I mean what I mean.
IDE: emacs + make + gcc and proud of it.
Thanks, it's a great tuturial. Only one problem. I'm using the GRUB bootloader, and I have my multiboot header. I must compile this with as, and the code in the tuturial must be compiled with NASM. Is it possible to link these together, or do I need one in AT&T Syntax?
The syntax you use or the assembler doesn't really matter, the binary will be the same. You don't need a boot loader, just put the floppy you're using before in the boot order and GRUB won't have to worry about it.
Translating the asm syntax should prove too hard. Good luck!
SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
I say what I say, I mean what I mean.
IDE: emacs + make + gcc and proud of it.
You can access text-mode video memory directly at 0xb8000. Each character is composed of two bytes. The first byte is the character and the second byte is the foreground-background color. The screen is 80 characters wide, 25 characters high, and I believe up to 7 "virtual screens" which are basically extra storage space you can scroll.
With this you can make a putch function, some color functions, and you're on your way to making the printf function.
Just search google for more information about the colors. I believe the first 8 values were full colors and the next 8 were light shaded versions. That would make 16 possibilities. You do this for the color byte twice using upper and lower nibbles for the foreground and background color.Code:char *videoText = (char *)0xb8000;
EDIT: Color chart found here: http://my.execpc.com/~geezer/osd/cons/
Speedy5 you can't access memory like that in linux
>>Speedy5 you can't access memory like that in linux
He's not trying to access it in Linux, he's using bios functions.
SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
I say what I say, I mean what I mean.
IDE: emacs + make + gcc and proud of it.
No those are not BIOS functions. Those are memory that maps to the screen when you initialy boot up. Use them until you switch to graphics resolutions. Works in real or protected mode after you boot the kernel.
>>No those are not BIOS functions
True, I was thinking of something else.
Anyhow, what's the limit for that video memory and how standard is that memory location?
SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
I say what I say, I mean what I mean.
IDE: emacs + make + gcc and proud of it.
That memory location is pretty standard and is supported by all VGA adapters. Its been around since a long, long time. It possibly dates back to 1970's or 1980's. Its 80 characters wide, 25 characters high (per screen), 2 bytes per character, and 8 virtual screens (memory lower than the first screen). It ranges 32767 bytes (note some aren't used) from 0xB8000 to 0xBFFFF.