473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

FILE Access

Hello,

This might be a tad off topic. The c-programming groups
I found appear to be unused...

The problem is simple...

I need to create a listing file from an assembler source file.
The listing file is just a copy of the source file with line numbers
along with a list of syntax errors (e.g. multiply or undefined symbols).

I'm not really sure how to approach this. I figure I can
create an error file and put errors there until the entire source
is processed then copy that into the end of the listing. That doesn't
seem like a great way and I haven't thought of anything better.

Any suggestions are greatly appreciated.

Thanks,
Grant
Nov 14 '05 #1
4 1517
Grant Austin <ga*****@foo.foo.bar.net> writes:
I need to create a listing file from an assembler source file.
The listing file is just a copy of the source file with line numbers
along with a list of syntax errors (e.g. multiply or undefined symbols).


Your question is outside the domain of comp.lang.c, which discusses
only the standard C programming language, including the standard C
library. This is a remarkably narrow topic compared to what many
people expect.

For your convenience, the list below contains topics that are not
on-topic for comp.lang.c, and suggests newsgroups for you to explore
if you have questions about these topics. Please do observe proper
netiquette before posting to any of these newsgroups. In particular,
you should read the group's charter and FAQ, if any (FAQs are
available from www.faqs.org and other sources). If those fail to
answer your question then you should browse through at least two weeks
of recent articles to make sure that your question has not already
been answered.

* OS-specific questions, such as how to clear the screen,
access the network, list the files in a directory, or read
"piped" output from a subprocess. These questions should be
directed to OS-specific newsgroups, such as
comp.os.ms-windows.programmer.misc, comp.unix.programmer, or
comp.os.linux.development.apps.

* Compiler-specific questions, such as installation issues and
locations of header files. Ask about these in
compiler-specific newsgroups, such as gnu.gcc.help or
comp.os.ms-windows.programmer.misc. Questions about writing
compilers are appropriate in comp.compilers.

* Processor-specific questions, such as questions about
assembly and machine code. x86 questions are appropriate in
comp.lang.asm.x86, embedded system processor questions may
be appropriate in comp.arch.embedded.

* ABI-specific questions, such as how to interface assembly
code to C. These questions are both processor- and
OS-specific and should typically be asked in OS-specific
newsgroups.

* Algorithms, except questions about C implementations of
algorithms. "How do I implement algorithm X in C?" is not a
question about a C implementation of an algorithm, it is a
request for source code. Newsgroups comp.programming and
comp.theory may be appropriate.

* Making C interoperate with other languages. C has no
facilities for such interoperation. These questions should
be directed to system- or compiler-specific newsgroups. C++
has features for interoperating with C, so consider
comp.lang.c++ for such questions.

* The C standard, as opposed to standard C. Questions about
the C standard are best asked in comp.std.c.

* C++. Please do not post or cross-post questions about C++
to comp.lang.c. Ask C++ questions in C++ newsgroups, such
as comp.lang.c++ or comp.lang.c++.moderated.

* Test posts. Please test in a newsgroup meant for testing,
such as alt.test.

news.groups.questions is a good place to ask about the appropriate
newsgroup for a given topic.

--
Ben Pfaff
email: bl*@cs.stanford.edu
web: http://benpfaff.org
Nov 14 '05 #2

"Grant Austin" <ga*****@foo.foo.bar.net> wrote in message
I need to create a listing file from an assembler source file.
The listing file is just a copy of the source file with line numbers
along with a list of syntax errors (e.g. multiply or undefined
symbols).

It's more a programming issue than a C one. C is a reasonable choice of
language to write this program in.
Presumably you already have an assembler. You can evoke it using the
system() function, and direct the output somewhere appropriate (this is
rather platform-specific).
Then you need to run through the assembly listing line by line adding line
numbers and errors. Just call fgets() to read a line, keep a counter going
for the line number, and write a function to change the line into a tagged
line. Presumably the error file contains line numbers and is in numerical
order, so you need to keep track of the topmost error line.

The difficult bit might come if you have several different error formats,
for instance "syntax error line 1" but "line 2, jump label out of range"
Nov 14 '05 #3
# I need to create a listing file from an assembler source file.
# The listing file is just a copy of the source file with line numbers
# along with a list of syntax errors (e.g. multiply or undefined symbols).
#
# I'm not really sure how to approach this. I figure I can
# create an error file and put errors there until the entire source
# is processed then copy that into the end of the listing. That doesn't
# seem like a great way and I haven't thought of anything better.

It's a perfectly satisfactory solution, and the norm for many years. You can
probably use tmpname or its variants to get the file name.

Most modern computers you are likely to use have large virtual memories. It's
likely that you can also store the entire listing in memory, either as a
linked list or a reallocced string (or string array).

Assuming you have enough memory, which you choose is a style question.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
The whole world's against us.
Nov 14 '05 #4
Grant Austin <ga*****@foo.foo.bar.net> wrote:
I need to create a listing file from an assembler source file.
The listing file is just a copy of the source file with line numbers
along with a list of syntax errors (e.g. multiply or undefined symbols).

I'm not really sure how to approach this. I figure I can
create an error file and put errors there until the entire source
is processed then copy that into the end of the listing. That doesn't
seem like a great way and I haven't thought of anything better.


Well, the one thing about this problem that _is_ relevant to C is that,
like most other languages, C doesn't have any features for inserting a
line in the middle of a file, only for appending lines or overwriting,
and perhaps not even the latter for text files.
So if you do want to insert the error message at the first significant
line, then no matter what you do, you will end up reading the file
twice, once to find the errors, once to insert messages about them in
the proper place.

Richard
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the...
2
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
3
by: Joe Costa | last post by:
I have written the following code to search for the right file depending on the startup file for "Client Access". The menu database that I made will load the correct config file specific for each...
4
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup)...
1
by: raydelex | last post by:
I am new to securing a database with logins. My questions is: I want only one database to use a new Workgroup file that I have created, not all the Access databases that I bring up under my...
11
by: sur | last post by:
Hello, My problem is that File.Exists works fine if my file is on my local drive but returns false if its on any other drive. I think that the issue is probably file permissions and so I have...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
13
by: George | last post by:
Hi, I am re-writing part of my application using C#. This application starts another process which execute a "legacy" program. This legacy program writes to a log file and before it ends, it...
16
by: Eran.Yasso | last post by:
Hi, I have a mdb file shared in the LAN. I want to write app that verifies if it's open. If the file is not open, then my app can open the file. if the file is used, then the app won't open it....
5
by: =?Utf-8?B?QWRyaWFuTW9ycmlz?= | last post by:
Hello! I'm trying to copy a file from another computer on the network that I do not have permission with my current logon details to access. If I open the folder using the Windows file manager...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.