24 September 2013, 21:00 | #1 |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
vasm dead code removal
Does anybody know if there is a way to tell vasm what code belongs to a specific routine? So that routines that are never called don't get included in the compiled exe.
|
26 September 2013, 10:50 | #2 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Unfortunately vasm cannot help you here. Is there a solution for that on other assemblers?
I would suggest to put your routines into a static linker library, so the linker (vlink) will only include those which are really needed. Use a separate object module for each routine to make it work. |
26 September 2013, 12:35 | #3 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
gcc has features (-ffunction-sections/-fdata-sections/-gc-sections) where it puts each function/data item in its own section and then the linker automatically discards unreferenced sections.. I know it's not vasm, but maybe of interest anyway..
|
26 September 2013, 13:06 | #4 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
The assembler doesn't know where a function starts or ends, unless there is a directive which defines that. |
|
26 September 2013, 16:53 | #5 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
|
27 September 2013, 08:01 | #6 |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
Thanks for your replies!
Haven't seen any assembler which can do this. It would be a useful feature to have, as you could spend less time organizing routines into different files. Perhaps not applicable to all types of code. But in most cases a function is just a function with a start and an end so syntactically it could be implemented with some kind of begin/end directives. Last edited by dalton; 27 September 2013 at 08:22. Reason: manners |
27 September 2013, 10:59 | #7 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
EDIT: Maybe not that easy as I wrote first: References to labels between start and end from a location between the same start and end directives should not be counted, of course. Last edited by phx; 27 September 2013 at 11:04. Reason: Thought about it again |
|
27 September 2013, 15:16 | #8 |
Registered User
Join Date: Sep 2008
Location: Germany
Age: 49
Posts: 137
|
Does an assembler have an understanding of the program flow? For me this the difference with a higher languages compiler.
|
30 September 2013, 11:33 | #9 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
|
30 September 2013, 11:44 | #10 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Easily is relative I guess.
lea START-4(pc),a0 bsr GetHunk ; code to store hunk starts follows ... ; lots of other code ; a2: hunk starts move.l (a2)+,d0 add.l #SOMECODE-STARTOFFSET,d0 ; label access, trivial? etc. There are so many ways to disguise label referencing that I would not call it an easy task to detect any references. |
30 September 2013, 12:40 | #11 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Hm... you're right of course. Maybe I would have realized that when I started working on it.
It probably makes no sense to implement something like that into an assembler. |
30 September 2013, 17:32 | #12 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
In my opinion this is stuff for a HLL compiler anyway and neither needed nor required for assembler code as for asm the coder should take care of the code on his own.
|
01 October 2013, 08:12 | #13 | |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
Quote:
For me it could be as simple as declaring that some asm-code should be left out if a specific label is never referenced. Could look like this: Code:
draw_line: IFREFERENCED draw_line ; awesome line drawing routine goes here rts ENDC |
|
01 October 2013, 10:23 | #14 |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
Of course it would be good also to have a directive for explicitly referencing a label too. That can be used if you want to explicitly tell the assembler that you've referenced a label but the reference itself is hidden in trickery.
|
01 October 2013, 11:49 | #15 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
|
01 October 2013, 12:23 | #16 |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
As far as I understand, the linker cannot remove parts of an included asm source. To remove code you need to put each routine in a separate file and compile an object for each of them. Then only the objects that are used will be included.
|
01 October 2013, 12:40 | #17 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Your example to link with a C program looks like the ideal case for putting your assembler routines as separate objects into a static link library.
Why can't you do that? Maybe because your huge assembler source is already written and it is much work to divide it into small pieces? |
01 October 2013, 14:31 | #18 |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
Yes, this is typically how my legacy sources are organized. It is not incredibly hard to split them into many different files. But it's not much fun, and I guess that a feature like this could be useful also when coding pure asm.
I don't think there are any really convenient ways of maintaining function libraries in asm, and in the end the purpose of the assembler is to make life easier for us. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Latest Win32 VASM Build? | bodhi | Coders. Asm / Hardware | 89 | 25 August 2017 01:27 |
vasm and word alignment | Den | Coders. Asm / Hardware | 9 | 07 February 2014 11:25 |
Help linking VASM object code | clenched | Coders. Asm / Hardware | 2 | 24 May 2013 22:32 |
vasm fsincos | dalton | Coders. Asm / Hardware | 4 | 03 September 2012 10:35 |
vasm 1.5 RFC | phx | Coders. General | 30 | 11 December 2010 02:08 |
|
|