Re: [cc65] Label file

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2001-08-02 21:46:06


On Thu, Aug 02, 2001 at 02:06:02PM -0400, Keates, Mark wrote:
> Surely the fact the address < $100 identifies this?
> I think it can be left to the emulator import process
> to work this out.

The emulator is not able to make a difference between a label in the zero page
and a constant with a value less than $100, because symbols are not marked as
being labels or other constants. But this would be easy to add once it is
actually used by an emulator (see my notes about cleanup in the last mail).

> Whoa, how would that work? Map address ranges to filename/line pairs?
> Or even as far as statement start/end position within a line? E.g.

The current implementation is pretty similar to what you were describing. The
following C file (which does not make sense, it is just a relict from some
testing):

---------------------------------------------------------------------------
1: int main (void)
2: {
3:     unsigned char I, J = 0;
4:     for (I = 0; I < 10; ++I) {
5:         ++J;
6:     }
7:     return 0;
8: }
---------------------------------------------------------------------------

generates this line info file:

---------------------------------------------------------------------------
file	"crt0.s", 2790, 984062856
file	"c64.inc", 4163, 959521248
file	"../cbm/cbm.inc", 648, 959521248
file	"test.s", 1034, 996780975
file	"test.c", 114, 996780975
line	"test.c", 3, 000061-000068
line	"test.c", 4, 00007E-000087
line	"test.c", 4, 000069-000074
line	"test.c", 5, 000075-00007D
line	"test.c", 7, 000088-00008B
line	"test.c", 8, 00008C-00008E
file	"zerobss.s", 465, 975017720
file	"condes.s", 1947, 975367900
file	"decsp1.s", 206, 972502655
file	"incsp2.s", 691, 975367891
file	"pusha.s", 374, 975418377
file	"pushax.s", 568, 985451080
---------------------------------------------------------------------------

Each "file" statement identifies a source file, it's size and it's time of
last modification (the decimal value of a POSIX time_t). You can use this to
check if the file loaded by the emulator is really the one used to compile the
binary (and maybe display a warning to alert the user).

The "line" statement specifies a source line. As you can see, the for()
statement (line 4) needs actually two code ranges.

> This begs the question "What if I'm writing both C and assembler?"

Assembler code does not output line info for now. but this is not too
difficult to add, since it is already present in the object file.

> I would recommend that the C file generates the above syntax, but
> for assembler programming the .LINEPOS could be allowed to have
> no arguments, e.g. use the current line number (and pos=0).
> I think you'll might also need something to end a range.

It is really interesting to see that there are quite some similarities between
my implementation and your suggestions. Yes, there is something like .LINEPOS
and yes, there is a command to end a range.

> Is it overkill for the assembler to generate a range for each
> line of code? This clogs up emulator memory/serach time.
> (but then again this is running on a well spec'd PC).

When adding line info for assembler code, it is necessary to add line
information for each line. Anything else would be quite useless, and even
older DOS debuggers (Turbo Assembler for example) were able to handle this.

> Then, how do you determine whether the emulator should load the
> 'C' file or the 'S' file (as 'C' compiles to 'S' assembles to 'O')
> to highlight the code being executed? This would have to be
> specified in the assembler file's header, e.g. similar to
> '.debuginfo<tab>off' use '.sourcefile<tab>filename.c'

This is one of the reasons, the linker does not emit line info for assembler
code: It does not know which is more important and should be used.

Regards


        Uz


--						       
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:40 CET