[Prev][Next][Index][Thread]

Re: I big question



Arturo Busleiman wrote:
> I was asked to program routines to call some BIOS functions like ah=$0x2
> (INT $10) [that's move cursor to x,y].
> I would like to know how do I make them work. This is the code I currently
> have (I have a .code16 version, so I can use ch,cl, etc and not cx)
[snip]
> Why doesn't this work?
> Is there any other way to use BIOS functions?

The OSKit works in protected mode.  You cannot execute realmode
code without any tricks, and the BIOS works in realmode. No
modern OS uses the BIOS, so you had better not either :)

If you're really desparate, you could try to install some
VM86 mode code in order to execute realmode stuff.  However,
this is really not worth the effort, IMO.  The OSKit has
a pretty complete set of drivers that'll replace the BIOS,
and will be at least 10x as fast for a PM OS than using
the BIOS (am I exaggerating here ?  don't think so.)
If you need an example of V86 anyway, there's one at 
http://www.erols.com/johnfine/ (AVIX.ZIP or something like
that.  It's not for the OSKit though.)

For this specific case, moving the hardware cursor is pretty
easy. (but I can't imagine that the OSKit doesn't have a text
driver :).  Still, if you want to do it manually, that's
possible.) Here's some code:

[base for gotoxy]
    videoMemOffs >>= 1;                 /* Set the new cursor position 
*/
    outportb(0x3d4, 0x0f);
    outportb(0x3d5, videoMemOffs & 0x0ff);
    outportw(0x3d4, 0x0e);
    outportb(0x3d5, videoMemOffs >> 8);

[base for getxy]
    outportb(0x3d4, 0x0e);              /* Get cursor Y position       
*/
    videoMemOffs = inportb(0x3d5);
    videoMemOffs <<= 8;
    outportb(0x3d4, 0x0f);              /* And add cursor X position   
*/
    videoMemOffs += inportb(0x3d5);
    videoMemOffs <<= 1;

videoMemOffs is the byte offset into the video memory.
Actually, this is part of a printf() routine, that's
why it looks so weird :)

Hope this helps,

-- Ramon

Follow-Ups: References: