LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   dos.h using int86() with linuc C language ! (https://www.linuxquestions.org/questions/programming-9/dos-h-using-int86-with-linuc-c-language-858609/)

ramzaher 01-25-2011 01:35 PM

dos.h using int86() with linuc C language !
 
hey i am working on a small project and i have to use the int86 and the union REGS i got the dos.h and inter this code
Code:

#include<stdio.h>
#include<dos.h>

int main()


{
  union REG g;

  printf("ok");
  g.h.dh=0x10;
int86(0x10,&g,&g);
}


dugan 01-25-2011 01:51 PM

You have to? Why?

If this is for school, then I hope it's early enough that you can still drop the course and get a full refund.

The only way to get this working is to actually build and run it in DOS. Use a virtual machine running FreeDOS and a copy of Turbo C++.

Tinkster 01-25-2011 01:53 PM

There's no "equivalent" or "direct replacement". Linux handles OS
and hardware internals quite differently. What are you trying to
achieve? Try finding the Linux equivalent.



Cheers,
Tink

P.S.: Better off in PROGRAMMING, moved accordingly.

ramzaher 01-25-2011 02:02 PM

aha i have windows 7 version i know that i should work on windows 7 actually i did and i get the same error which is
undefined reference int86() ....even i include the proper library dos.h that have the function int86 !!!
another thing i am sure that there is a replacement for dos.h specially for accessing the register but i want to know what is to know what is the replacement thanks anyway

dugan 01-25-2011 02:03 PM

Quote:

Originally Posted by ramzaher (Post 4237420)
Code:

.h.dh=0x10;
int86(0x10,&g,&g);


Can anyone decipher this couplet, which the OP very unwisely decided not to comment? I looked up the interrupt on Wikipedia and I can't find a matching call.

Furthemore, as you have already been told twice, there is no way to get this working in anything other than DOS. Not Windows 7. DOS.

ramzaher 01-25-2011 02:17 PM

int86( 0x10, &regs, &regs );
its mean to call interrupt 10 to get the color in specific register i know what the code means ! and i know its work,i search the internet and i found other have the same code i copy it but i got just one problem
int86 is udefined is that mean the problem is from the header dos.h ( i speak now as i tried it in windows version)

Tinkster 01-25-2011 02:20 PM

What colour in which register? There's no such thing in newer versions
of Windows OR in Linux.

dugan 01-25-2011 02:22 PM

Quote:

Originally Posted by ramzaher (Post 4237477)
int86 is udefined

The link library containing the function definition is missing.

Here's what you need to set up a build environment for this:

http://www.virtualbox.org/
http://www.freedos.org/
http://www.delorie.com/djgpp/

You install VirtualBox on your host system (works in both Linux and Windows), you install FreeDOS in VirtualBox, and you install djgpp in FreeDOS. Then you use djgpp to build the program.

No, there is no other way.

You have your solution. Now mark the thread as solved.

ramzaher 01-25-2011 02:24 PM

http://gd.tuwien.ac.at/languages/c/p...own/advcw1.htm
here is an examples

theNbomr 01-25-2011 02:24 PM

Quote:

Originally Posted by dugan (Post 4237462)
Can anyone decipher this couplet, which the OP very unwisely decided not to comment? I looked up the interrupt on Wikipedia and I can't find a matching call.

Furthemore, as you have already been told twice, there is no way to get this working in anything other than DOS. Not Windows 7. DOS.

As I recall, a union REG is a union that describes the arrangement of 16-bit registers in X86 real-mode. Each 16-bit register can be addressed as either the 16-bit register or either of its 8-bit high/low components. In this case, the OP seem to be referring to the 16-bit DX register, which can be addressed as the 8-bit DH and 8-bit DL registers. The BIOS Int 10h takes its principle argument(s) in AH:AL, with DX sometimes being used to specify row/column coordinates for text-mode screen writing. The posted code is not sufficiently complete to decipher what it should do.
--- rod.

theNbomr 01-25-2011 02:38 PM

The use of int86() is a MS &/or Borland method of accessing X86 real-mode BIOS interrupts. There is no way these are going to work from any protected-mode OS. There is probably a way to emulate such a real-mode configuration, such as Qemu. The code can probably be compiled with gcc, but will not link, due to the absence of any working library containing the int86() function. The error message 'undefined reference int86()' seems to support this.
In general terms, the BIOS Int 10h is used to control the video susbsytem, including both text-mode and some graphics modes. In practice, the BIOS calls were rarely used to actually perform graphics functionality (poor speed). If the OP wants to simply write text to character cells in a text-mode screen, there are the ncurses calls that are probably the closest approximations in Linux of the the Int 10h BIOS calls.
--- rod.

ramzaher 01-25-2011 02:47 PM

thanks theNbmor but even when i used it on MS OS system i got an error undefined ref and i use a header (dos.h) that contains int86() ...can be another error not related to the header ! mm actually i have a dos.h that dont contains the int86() but i downloaded new one contains int86() and then i got that erro ( undefined reference int86())

dugan 01-25-2011 02:51 PM

Are you aware that DOS and Windows 7 are different operating systems?

ramzaher 01-25-2011 02:53 PM

aha i know that but still u can use the CMD in any windows version to reach to the interrupt 10 !! so it should work!

dugan 01-25-2011 02:54 PM

Quote:

Originally Posted by ramzaher (Post 4237518)
aha i know that but still u can use the CMD in any windows version to reach to the interrupt 10 !! so it should work!

Sorry, but it doesn't work that way. Cmd.exe is just a Windows application. It doesn't give you any special privileges. It also doesn't provide development libraries, such as those needed to link with dos.h.

If you want to continue following DOS-specific tutorials that don't work in Windows 7 (certainly not in cmd.exe), then follow my instructions in post #8 to get them working.


All times are GMT -5. The time now is 08:20 PM.