LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-25-2011, 01:35 PM   #1
ramzaher
LQ Newbie
 
Registered: Nov 2010
Posts: 25

Rep: Reputation: 0
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);
}
 
Old 01-25-2011, 01:51 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
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++.

Last edited by dugan; 01-25-2011 at 02:13 PM.
 
Old 01-25-2011, 01:53 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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.
 
Old 01-25-2011, 02:02 PM   #4
ramzaher
LQ Newbie
 
Registered: Nov 2010
Posts: 25

Original Poster
Rep: Reputation: 0
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
 
Old 01-25-2011, 02:03 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Quote:
Originally Posted by ramzaher View Post
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.

Last edited by dugan; 01-25-2011 at 02:07 PM.
 
Old 01-25-2011, 02:17 PM   #6
ramzaher
LQ Newbie
 
Registered: Nov 2010
Posts: 25

Original Poster
Rep: Reputation: 0
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)
 
Old 01-25-2011, 02:20 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
What colour in which register? There's no such thing in newer versions
of Windows OR in Linux.
 
Old 01-25-2011, 02:22 PM   #8
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Quote:
Originally Posted by ramzaher View Post
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.

Last edited by dugan; 01-25-2011 at 02:27 PM.
 
Old 01-25-2011, 02:24 PM   #9
ramzaher
LQ Newbie
 
Registered: Nov 2010
Posts: 25

Original Poster
Rep: Reputation: 0
http://gd.tuwien.ac.at/languages/c/p...own/advcw1.htm
here is an examples
 
Old 01-25-2011, 02:24 PM   #10
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by dugan View Post
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.
 
Old 01-25-2011, 02:38 PM   #11
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 01-25-2011, 02:47 PM   #12
ramzaher
LQ Newbie
 
Registered: Nov 2010
Posts: 25

Original Poster
Rep: Reputation: 0
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())
 
Old 01-25-2011, 02:51 PM   #13
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Are you aware that DOS and Windows 7 are different operating systems?

Last edited by dugan; 01-25-2011 at 02:53 PM.
 
Old 01-25-2011, 02:53 PM   #14
ramzaher
LQ Newbie
 
Registered: Nov 2010
Posts: 25

Original Poster
Rep: Reputation: 0
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!
 
Old 01-25-2011, 02:54 PM   #15
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Quote:
Originally Posted by ramzaher View Post
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.

Last edited by dugan; 01-25-2011 at 03:05 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Recording Music with Linuc sjoerd222 Linux - Software 3 10-29-2007 10:41 AM
Linuc Translation gongjiao Linux - Newbie 1 09-24-2007 04:39 AM
understanding DOS vs Linux assembly language shortname Programming 10 03-07-2007 10:04 PM
Some linuc issues vm_devadas Linux - General 2 12-01-2006 09:47 AM
Linuc Testing Center irish rebel Linux - Software 1 06-08-2004 08:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration