Stephen D. Barnes wrote: > Olin Lathrop Wrote: > > bss myvar, 2, 2 ;define 16 bit variable > > mov #myvar, w0 ;point W0 to start of MYVAR > > mov.b [w0++], w1 ;get low byte of MYVAR into W1 > > mov.b [w0], w2 ;get high byte of MYVAR into W2 > > I just want to be sure I really understand what happens here...please > correct me if I am wrong. > > > .bss myvar, 2, 2 ;defines variable, 2 bytes long, aligned > mov #myvar, w0 ;move the contents of myvar to w0 > mov.b [w0++], w1 ;move 1 byte of w0 to w1(low byte) and > ; post increment the the "effective address" > ; which means the w0 low byte will now > ; contain what was the high byte before the > ; increment? Not quite. ; This instruction places an immediate value that is the ; *address* of myvar into w0. In Olin's terminology, w0 is now ; a "pointer" to myvar where it resides in memory. mov #myvar, w0 ; This instruction uses w0 as an address, moves the memory byte at ; that address (the low byte of myvar) into w1, then increments w0 ; so that it contains the address of ("points to") the high byte ; of myvar. mov.b [w0++], w1 ; This instruction use w0 as an address again, moves the byte there ; (the high byte of myvar) into w2. No increment of w0 this time. mov.b [w0], w2 -- Dave Tweed -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist