GIDForums  

Go Back   GIDForums > Computer Programming Forums > Assembly Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 16-Mar-2004, 11:10
mikhail mikhail is offline
Awaiting Email Confirmation
 
Join Date: Mar 2004
Location: Dublin, Ireland
Posts: 73
mikhail is on a distinguished road

Inline Assembly language


I'm trying to write a program which will have to read from the parallel port. I was given the following sample code which is supposed to clear the screen, access the parallel port and light eight LED lamps in sequence connected to data lines D0 - D7 of port 956 (LPT1).

CPP / C++ / C Code:
#pragma inline

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

void main(void)
{
	int i, temp;
	int port=956;

	/*Clear the text screen*/
	asm
	{
		mov	cx,0		//Upper corner of window
		mov	dx,2479H	//lower corner of window
		mov	bh,7		//Normal screen attributes
		mov	ax,0600H	//BIOS interrupt vaule
		int   10H		//Call interrupt
	}

	for(i=0; i<9; i++)
	{
		temp=(int) pow(2.0,(double) i);

		//Gain access to the double ports
		asm
		{
			mov	dx,port	//Place the parallel port number
			mov	ax,temp	//Value to be sent to port
			out	dx,a1	//Semd only lower eight bits
		}
		printf("%d\n", temp);
	}
}

The problem is that it my compilers demand a file called "TASM.exe" or "TASM32.exe" depending on the compiler. I downloaded TASM.exe from a website, but I'm still getting fatal errors in the linker.

Can anyone either tell me what's the problem, or suggest an alternative method for accessing the parallel port? Any help would be much appreciated.
Last edited by dsmith : 16-Mar-2004 at 12:50. Reason: Use the [c] and [/c] to highlight C syntax code
  #2  
Old 16-Mar-2004, 13:01
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Hi mikhail.

Is the tasm.exe in a folder that is in your search path? Also, are you programming in DOS? If you are programming in Windows 98 or higher, this is not going to work. Windows does not allow direct access to the ports in this manner. You are going to have to work more under the windows API. If you let us know what O/S you are doing this under we may be able to give you some more info.

Cheers,
d
  #3  
Old 16-Mar-2004, 23:43
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,435
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
TASM is the assembler program that comes with Turbo C. What you downloaded is probably not the TASM that goes with whatever compiler you're using
  #4  
Old 18-Mar-2004, 07:10
mikhail mikhail is offline
Awaiting Email Confirmation
 
Join Date: Mar 2004
Location: Dublin, Ireland
Posts: 73
mikhail is on a distinguished road
Quote:
Originally Posted by dsmith
Hi mikhail.

Is the tasm.exe in a folder that is in your search path? Also, are you programming in DOS? If you are programming in Windows 98 or higher, this is not going to work. Windows does not allow direct access to the ports in this manner. You are going to have to work more under the windows API. If you let us know what O/S you are doing this under we may be able to give you some more info.

Cheers,
d
I can't for the life of me remember the name of the folder, but I put it in a subfolder in the folder with the compiler, and the compiler stopped complaining - now it's the linker that's unhappy.

I'm programming on the college network here, which has in various places Windows 95,98 and even 2000. I've got XP at home, but the compiler I have there doesn't allow me to use the Borland Graphics interface, which I'm using in another part of the program. To get that to work, I'm right clicking on the text of the .cpp file, clicking "TargetExpert" then selecting "DOS (Standard)" from the menu under "platform" and checking the "BGI" box under "Libraries".

I imagine I can't use Windows API and BGI in the same program? I really don't want to have to start over on the graphics work, since I've got exams at the end of April and I'd prefer to have this whole thing done by then.

Thanks d.
Cheers,
Mik
  #5  
Old 18-Mar-2004, 07:13
mikhail mikhail is offline
Awaiting Email Confirmation
 
Join Date: Mar 2004
Location: Dublin, Ireland
Posts: 73
mikhail is on a distinguished road
Quote:
Originally Posted by WaltP
TASM is the assembler program that comes with Turbo C. What you downloaded is probably not the TASM that goes with whatever compiler you're using
Thanks, I'll try searching for a specific one.
  #6  
Old 18-Mar-2004, 08:37
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Quote:
Originally Posted by mikhail
I imagine I can't use Windows API and BGI in the same program? I really don't want to have to start over on the graphics work, since I've got exams at the end of April and I'd prefer to have this whole thing done by then.

Thanks d.
Cheers,
Mik

Here is a link that may help you out. If you do use this, read the PDF file very carefully as it cautions about security risks in using this. This will allow the direct access to the parports in NT and above like you are looking for. Otherwise, you will need to look into the Windows sdk or api's.

I haven't compiled inline assembler for several years now. I agree with Walt. Make sure that you are using the Turbo Assembler. I don't think that this is something that you can just download - I may be mistaken, but this is something that you would have to buy from Borland. In any case, make sure it is in your search path and you may even need to specify something in your compile command to get it to work.

Good luck!
d
  #7  
Old 19-Mar-2004, 12:03
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 570
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
Quote:
Originally Posted by mikhail
I imagine I can't use Windows API and BGI in the same program?
Hey, Mikhail. I use Borland's Graphics environment to do stuff too, and I have tried to lace API code into it at no success. But hey, just because I failed doesn't mean it's not possible.
__________________
-Aaron
  #8  
Old 22-Mar-2004, 10:06
mikhail mikhail is offline
Awaiting Email Confirmation
 
Join Date: Mar 2004
Location: Dublin, Ireland
Posts: 73
mikhail is on a distinguished road
Quote:
Originally Posted by aaroncohn
Hey, Mikhail. I use Borland's Graphics environment to do stuff too, and I have tried to lace API code into it at no success. But hey, just because I failed doesn't mean it's not possible.

I'm under the impression now that it's not possible. I'm having a look at www.geekhideout.com which looks ideal, but I got the following linking error when I tried to compile the io.cpp file included with it:

Error: Unresolved external '_main' referanced from Y:\Nalapps\W95\Devsuite\lib\cox32.obj

Any ideas fellows?
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
.htaccess language / rewrite problem spinflip Apache Web Server Forum 5 15-Dec-2003 15:14

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 12:55.


vBulletin, Copyright © 2000 - 2017, Jelsoft Enterprises Ltd.