30 September 2022, 03:51 | #41 | |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,549
|
Quote:
Sometimes the only way to get exactly what you want is to write it in hex or create a macro for the instruction. For example the Barfly assembler 'optimizes' cmp to cmpi when the source is immediate, even with all optimizations turned off! Some compilers write word values into byte operands, which results in the (unused) upper byte being set to $ff when the signed byte value is negative. This becomes a problem if you are trying to create an identical executable from a disassembly, as the assembler may not do the same. |
|
30 September 2022, 08:28 | #42 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Assemblers aren't compilers, they don't do important stuff behind your back. If they do, then they are broken. Strictly identical exe is sometimes just impossible anyway, due to different ordering in reloc tables. Turning optimization on has the advantage of choosing best options for branch sizes. Doing that by hand is a pita and sometimes close to impossible when using macros. Resourcing code isn't that much different. First, reassemble with no opts. Then, compare with original exe and find out what the differences are. With PhxAss very few things can happen. So yeah, that $ff in negative byte immediates has disappeared. It's not a big deal, really. It won't prevent your program from working (and if it does, you know there is a checksum !). Then simply turning optimizations on can earn many kilobytes and your executable is already better than the original one ! |
|
30 September 2022, 23:39 | #43 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
|
As a reflection on the original discussion, you can know a few things that make instructions slower, without having to look up the cycle count for a specific CPU:
|
30 September 2022, 23:57 | #44 | ||||||||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,549
|
Quote:
Quote:
Quote:
Quote:
Of course I always have the option of getting the assembler to do optimization if I am too lazy (rarely) or to make the final release code tighter. Quote:
Quote:
Quote:
Quote:
|
||||||||
01 October 2022, 09:16 | #45 | ||||||||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Quote:
Quote:
Quote:
For branch tables you can turn optimizations off and on in the source itself, local to some code part (at least PhxAss can). I see turning opts off useful only for initial comparison when resourcing and faster assembly of large programs, the latter being much less important with uae-jit. Quote:
Quote:
Quote:
Quote:
Usually it's for making big alterations so you will have to check the code line by line. Actually i do all the code/data separation by hand. If it's just to generate labels, i fail to see the usefulness - these labels are for the most part number-based and are meaningless. Well, not only the branches are optimized. If, say, you use a structure and access the first member : by using name(An) (which is supposed to be recommended) the assembler will use 0(An) instead of (An) with optimizations off. Other zero constants may appear as well. |
||||||||
01 October 2022, 14:20 | #46 |
Alien Bleed
Join Date: Aug 2022
Location: UK
Posts: 4,150
|
Some really useful info guys. Manuals are one thing, real world examples sometimes another. Apologies for the nerd-snipe.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
32bit PC-relative LEA ?? | Nut | Coders. General | 22 | 18 March 2010 10:56 |
|
|