Re: A89: dumb question


[Prev][Next][Index][Thread]

Re: A89: dumb question




clr.w would clear that byte, and whatever byte is stored after.


so if you have 

whatever dc.b xx
foo      dc.b yy

then clr.w whatever would clear both whatever and foo.

clr.l would clear the byte, and the 3 bytes after..

You see.. it is like this..  a label is nothing more (or less) than a name of an
address.
dc.b does no more (or less) then to put in a  byte of that value in your
compiled program at that point.

so what you do, with 
whatever dc.b xx
is that you put in a byte with the value xx an address that you name "whatever".

then when you write clr.w whatever, the compiler first translates "whatever" to
the memoryaddress it is equal to, and puts it with the clr.w opcode.

to take another example.. the compiled code for 

move.w d0,d1 
rts

is $32004e75

so it is perfectly leagal to write

pointless_sub: dc.w $3200,4e75

and then anywhere in your code do a "bsr pointless_sub"
it will work just perfectly.

the fun thing with this is that you in you program then can write "move.w
#3210,pointless_sub"
and suddenly your little subroutine has morfed itself into

move.w (a0),d1
rts

!!

It is that simple..  no magic at all.. :)

//Olle
Hope I cleared it up for someone at least.

S43R80@aol.com wrote:
> 
> This is really a dumb question.  However, here it goes: If I for example do
> something like:
>  whatever dc.b xx
> 
> ...then what would happen if i did something like:
>  clr.w whatever
>         or
>  clr.l whatever...
> 
> would the compiler go crazy? or just ignore it?


Follow-Ups: References: