www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/06/07:58:15

Xref: news2.mv.net comp.os.msdos.djgpp:2481
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Accessing a Memory Location
Message-ID: <4k1c21$fn@mack.rt66.com>
From: brennan AT mack DOT rt66 DOT com (Brennan "Mr. Wacko" Underwood)
Date: 4 Apr 1996 13:39:29 -0700
References: <4k00vi$dqb AT netnews DOT upenn DOT edu>
Organization: None, eh?
NNTP-Posting-Host: mack.rt66.com
Lines: 65
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <4k00vi$dqb AT netnews DOT upenn DOT edu>,
Michael C Hyzer <mchyzer AT red DOT seas DOT upenn DOT edu> wrote:
>Hello,
>I am running the same gcc for DOS on my pentium desktop and 386 laptop.  
>I am trying to write to the address of the parallel port (0x0378 on both 
>machines).  When i do it on the desktop, with a command such as:
>
>int *para = (char *)0x0378;
>
>This line causes a segmentation violation on the laptop.  When I use this 

I see your problem. IBM-PC/AT ports are not memory mapped. You have to
explicitly do an out or an in on them.

int para = 0x0378;
outportb(para, whatever);

Should do the trick.

>line on the desktop, it will complete the assignment, and I can read and  
>write to the address.  When I boot the desktop without drivers (hitting 
>F5 during startup), the C program will not run, and the segmentation 
>violation is identical to the laptop.  Another piece of information that 
>might help, is that the memory addresses for normal assignments on the 
>laptop consists of addresses such as: 0x7FFFFE58.  This is the same 
>magnitude of address that the desktop uses when it does not run 
>properly.  When the desktop does run properly, it uses addresses such as 
>0x51E54.  It seems that when C uses this block of memory, it can access 
>the memory address 0x0378.  But when C is using the high memory, it 
>cannot access the low memory, even to read it.  
>
>My question is:  Does anyone know how to load gcc so it uses low memory.  
>I am using the same memory manager on both machines, and trying to  
>duplicate the config.sys, but no luck.  

I think you're just coincidentally hitting unused mamory on one machine and not
on the other.

>Does anyone know how to write to an address that is locked out by C using
>usual commands.

See above.

>Is there another easy way to change the pins of the parallel port without 
>using C, if using C is unfeasable.  I want to change the voltage at 
>certain pins without start and stop bits, or however it normally 
>operates.   

Um.. I think if you just 'out' a byte to the base port it just changes the
pins in a binary way. My little[1] brother made a DAC that ran off the parallel
port and he just 'out'ed 22050 times a second. (With varying resistor values
per pin.)

And I've seen Linux load indicators outing a binary value to the parallel port
to make a bar graph, or to do the Knight-Rider swooshing light.

I don't know how long the pin stays that way, though.

Hope this helps!


--brennan
[1] Not. He's 6 foot something.
-- 
brennan AT rt66 DOT com  |  fsck /u

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019