LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 05-30-2008, 03:01 PM   #1
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Rep: Reputation: 49
C Program to write to the memory


I am trying to write a very simple C program in which I am trying to write to the memory on my computer in DOS. I have the following pseudo-code:

Code:
#include <stdio.h>

#define ADDRESSOFMEMORY 0xe0000 //address of memory
#define SIZEOFMEMORY 0x4000  //size of meory

int main(char** argv,int argc)
{ 
    int memoffset;
    short * memory;
    short data=0x1111;

<<SOME FUNCTION TO ACCESS THE MEMORY JUST LIKE MMAP fuction in Linux>>
memory=<<Access the memorymap>>


//Write fuction

   for(memoffset=0x0;memoffset<0x16;memoffset+=2)  
    {
	memory[memoffset]=data;   
    }
Any ideas how can I do this?
 
Old 05-30-2008, 03:59 PM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
I thought mmap() was part of the C standard library, but it turns out, it's only for POSIX-compliant systems.

Check out this link: http://guideme.itgo.com/atozofc/. I don't know if it will help you, but from glancing over the first page, it seems like it might answer your question.
 
Old 05-30-2008, 04:30 PM   #3
seraphim172
Member
 
Registered: May 2008
Posts: 101

Rep: Reputation: 15
What DOS version do you use? Most GNU tools are or have been available for DOS systems as well, so it shouldn't be a big deal to add GCC and a POSIX-compliant C library to your system.
(GCC for DOS was called DGCPP or something like that - it's been a long time...)

Linux Archive

Last edited by seraphim172; 06-25-2008 at 04:45 AM.
 
Old 05-30-2008, 05:11 PM   #4
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by seraphim172 View Post
What DOS version do you use? Most GNU tools are or have been available for DOS systems as well, so it shouldn't be a big deal to add GCC and a POSIX-compliant C library to your system.
(GCC for DOS was called DGCPP or something like that - it's been a long time...)
I am using DOs 6.22. ACtually I have the C program written in Linux (GNU C) and I need to convert the program so that it can run on DOS. Hence I posted this question to the forum.
 
  


Reply



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
Unable to read/write usb 256mb memory stick Aju Linux - Hardware 13 03-09-2009 03:24 AM
write a C++ program yewjingcho Programming 14 11-01-2007 06:05 PM
How to write code to detect a memory stick when it is pluged in? wanglinux2007 Programming 4 12-11-2006 10:44 AM
Write to port (C program) dummyagain Programming 8 10-24-2003 10:50 AM
Memory Leak when using memory debugging C program on SuSE SLES8 babalina Linux - Distributions 0 10-06-2003 09:39 AM

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

All times are GMT -5. The time now is 08:24 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