Code: Select all
void printchar(char c){
union REGS regs;
regs.h.ah=0x00; //print character function
regs.h.al=c; //character to print
regs.x.dx=0x00; //print port to print to (LPT1)
int86(0x17,®s,®s); //interrupt
}
Code: Select all
void printchar(char c){
union REGS regs;
regs.h.ah=0x00; //print character function
regs.h.al=c; //character to print
regs.x.dx=0x00; //print port to print to (LPT1)
int86(0x17,®s,®s); //interrupt
}
And have a BIOS interface (or CSM in UEFI mode).kzinti wrote:Well you can if you implement int86()
Code: Select all
void printchar(char c){
REGS regs;
_ah (regs.eax) = 0x00;
_al (regs.eax) = c;
_dx (regs.edx) = 0x00;
io_services (0x17,®s,®s);
}
Under special circumstances, yes. But even when you could, I wouldn't recommend it, as it would be extremely slow, plus you probably won't have Teletype video mode anyway, only pixel-based graphics on modern machines (only a few BIOS implements that and only for some video modes. Chances are that that BIOS int won't work). Check out PC Screen Font or consider using a minimalistic library such as Scalable Screen Font instead.PavelCheckov wrote:Can I use the following to print to my printer on an Intel64 system?
Not really, you could switch modes temporarily.Thomas wrote:That looks like legacy code and makes only sense when using real mode.
Also in Minix (see source line 8861). It switches to real mode, does the BIOS call and then switches back to protmode. The caller of int86() is none the wiser. You could implement something like that in long mode too, but BIOS must exists in the first place of course (and the machine must have an LPT peripheral which is unlikely these days).Thomas wrote:int86 is part of the old dos turbo C++ library if I remember correctly
I like looking through old C programming books, and trying to follow the tutorials today.Thomas wrote:Hi Pavel,
int86 is part of the old dos turbo C++ library if I remember correctly