At 3/6/01 01:34 PM , john maushammer wrote:
>
> developer@... wrote:
>
> > 1-What is .cnop? (pad to an even number of blocks? What is it?)
>
> Yep - the .cnop instruction pads out to an even number of blocks. The
> first argument is the byte to pad it with, and the second argument is
> the multiple of bytes to pad to (i.e. $200= pad to $200, $400, $600,
> etc.)
Well, actually the value of the emitted byte is always zero (ie: a NOP
instruction). The first parameter is for emitting an arbitrary number of
bytes (NOP's) up to but less than the second parameter. The second
parameter is, of course, for specifying a byte boundary to pad too, but it
must be a power of two. Thus, $600 wouldn't work.
I can't say I understand the rationale behind '.cnop' but that seems to be
it's modus operandi. ;-)
BTW, here is the actual code that is called in the assembler. I looked
this up when I was trying to understand it myself:
void smach_cnop (numtype offs, numtype modulo)
{
if (modulo <= 0 || (modulo & (modulo - 1)) != 0)
errormsg ("second argument to cnop must be a positive power of two");
else if (offs < 0 || offs >= modulo)
errormsg ("first argument to cnop out of range");
else {
emit_prefix (modulo | offs);
EMIT (OP_CNOP);
}
}