06 December 2014, 23:11 | #1 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
cnop
I'm wondering if I should change the way how the CNOP directive currently works in vasm. Its name implies that a NOP instruction might be used for padding, but the most important Amiga assemblers, like Devpac, AsmOne and even PhxAss and vasm always pad with zero-bytes. I remember only A68k and the SNMA assembler which used NOP ($4e71). The latter even has a CNUL directive to pad with zeros.
Does anybody think it makes sense to use NOP instead of zeros? Only for code sections, of course... |
06 December 2014, 23:43 | #2 |
Moderator
Join Date: Nov 2001
Location: Germany
Posts: 866
|
basm also uses NOPs but in my practice I never needed CNOP producing NOPs. it anyway is only possible if the skip is a multiple of words and the addresses are even.
|
06 December 2014, 23:45 | #3 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,365
|
PhxAss can use both, NOP = $4e71 or zeros, AFAIK. But you should know better
(It's the PhxAss option Z = zeropadding) Usually I've configured PhxAssGUI to use zeros for all my projects, but in case you want to align something, like a loop for example, in the middle of a code sequence then you need a real NOP to do that. You can only align with zeros after a gap in the code (after a BRA or a RTS). Edited: The zeros are like heroes, but their spelling is different. Last edited by PeterK; 08 December 2014 at 23:44. |
07 December 2014, 01:51 | #4 | |
Registered User
Join Date: Aug 2012
Location: Australia
Posts: 651
|
Quote:
Bloody hell after reading a few of your threads on optimisations etc do you fellas sleep with your 68k Programmer's Reference Manual under your pillows |
|
07 December 2014, 20:24 | #5 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
Quote:
I think it doesn't hurt any existing code to implement it... |
|||
08 December 2014, 23:43 | #6 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,365
|
No, just enable some optimization options in PhxAss and it will do most parts of this job by using the best possible instructions. The coders, of course, still have to find the optimal programming strategy, which is not explained in any manual.
|
06 February 2015, 22:38 | #7 | |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
|
Quote:
|
|
09 February 2015, 09:50 | #8 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
|
15 February 2015, 04:48 | #9 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
|
(copy/paste CNOP is just a way of aligning data, a replacement for modifying "*" (program counter) as allowed by older assemblers. In a BSS section, it should become a DS and in code or data sections, it should become a DC of the appropriate size. Or the assembler should just skip a few bytes in memory in all cases, it should not matter to the developer.
It's a silly directive name, anyway. There's no real condition and certainly no CPU NOP instruction involved anywhere. There are no arguments that I can see for adding support for insertion of NOP statements in code sections when a CNOP is encountered. What would CNOP 1,2 do except cause code corruption? And if you pad a piece of code with n NOP instructions, what's the use case? Without an RTS, you would only make a very slow replacement for a jump table that executes every single branch point in the table if you happen to jump to the first entry. Convince me. But I think there's just some confusion as to what the directive is supposed to do here. Caused by the silly name in the first place. |
15 February 2015, 07:16 | #10 | |||
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
This is different than skipping over unitialized data in a code or data hunk which wouldn't be any better if it was possible. Quote:
Quote:
The Devpac manual which vasm sort of used to follow doesn't give the padding used or tell what would be done in this case. My good old Cape 68k with it's excellent manual covers it though: "CNOP - Places a series of 2-byte NOP instructions, with any odd filler byte set to 0 in the object file to reach the desired alignment." It would crash but the manual is clear . It's not about use or abuse, which has and will happen, but about compatibility and predictability. Generating NOP in code sections is the most compatible padding for CNOP. |
|||
15 February 2015, 14:58 | #11 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
I agree with matthey. I can't think of any sensible reasons at all for padding with zeroes or random data, whereas padding with NOPs is actually useful and backwards compatible.
The name of the directive clearly suggests what it does, and with A68K and CAPE doing exactly this, and being some of the earliest available assemblers for Amiga, I would consider these to be predicates for how to implement the CNOP directive. But I would actually insert something like move.l A7, A7, which is a true no-op, whereas a NOP can actually incur long unexpected delays. The point of CNOP after all isn't to insert NOPs or some other specific values, but to allow convenient aligning of both code and data. |
15 February 2015, 17:13 | #12 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
|
|
17 February 2015, 21:53 | #13 | |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
|
Quote:
Anyway, it should be a quick job to test out how the assemblers you want to be compatible with do it. |
|
19 February 2015, 21:33 | #14 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,335
|
I think CNOP should with zeros, not NOPs. The reason being, the official/canonical Amiga Macro Assembler by Metacomco works that way.
That's not to say that the ability to pad with some other value isn't useful, but the default behaviour should IMHO match the Metacomco assembler. Also, in cases where CNOP adds only a single padding byte, half a NOP opcode doesn't make much sense. An assembler could have a directive to either change which word CNOP uses for padding, or implement another directive to pad with NOPs or anything else. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|