[comp.sys.amiga.programmer] Assembly Lang Help Again

Charlie_Gibbs@mindlink.UUCP (Charlie Gibbs) (02/12/91)

In article <91042.210040GHGAEA8@cc1.kuleuven.ac.be>
GHGAEA8@cc1.kuleuven.ac.be writes:

>    I've read the reply that came to the questions about CNOP, but still
>there's something not clear ... If the CNOP command fills the memory with
>NOP's i.e. an opcode with a length of TWO bytes, how the hell can it be used
>to word-align ?  Do you get my point ? No, well let's make it clear ...
>Imagine I use a CNOP 0,2.  Two things can be possible :
>
>    1. My code is already word-aligned : CNOP shouldn't do anything at all
>    2. My code is not word-aligned : CNOP should add a byte.
>
>The question is : what byte is CNOP going to add ?  It can't add a complete
>NOP command 'cause that would take two bytes ...

     If necessary, CNOP will indeed add an extra byte to get onto a
word boundary before doing anything else.  In this respect it is no
different from any other executable instruction.  The assembler must
make sure than any executable instruction begins on a word boundary,
and will add a byte of padding if necessary.

     This single byte will most likely be a null (0x00), but I'd
consider it bad programming practice to count on this, just as I'd
never make assumptions as to the contents of uninitialized storage.
Why is it so important that you know that that byte is?  Perhaps
one of us could suggest another way of doing whatever you're trying.

     Another way to get onto a word boundary, especially appropriate
if you're in a BSS hunk, is to say

        DS.W    0

Of course, you can't do all the fancy tricks that CNOP can do, but
it'll cover a large percentage of cases anyway.

Charlie_Gibbs@mindlink.UUCP
Elevator music brings me down.  

GHGAEA8@cc1.kuleuven.ac.be (02/12/91)

    I've read the reply that came to the questions about CNOP, but still
there's something not clear ... If the CNOP command fills the memory with
NOP's i.e. an opcode with a length of TWO bytes, how the hell can it be used
to word-align ?  Do you get my point ? No, well let's make it clear ...
Imagine I use a CNOP 0,2.  Two things can be possible :

    1. My code is already word-aligned : CNOP shouldn't do anything at all
    2. My code is not word-aligned : CNOP should add a byte.

The question is : what byte is CNOP going to add ?  It can't add a complete
NOP command 'cause that would take two bytes ...

                                                 Another Amiga Freak

---------------------------------------------------------------------------