Searching \ for 'MPASM accessing middle bytes...' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/language/index.htm?key=asm
Search entire site for: 'MPASM accessing middle bytes...'.

Truncated match.
PICList Thread
'MPASM accessing middle bytes...'
1997\03\25@093918 by mike

flavicon
picon face
Hi,

In MPASM, I can declare a constant value of two byte
and access the high and low bytes using 'HIGH' and 'LOW'.

Example:

MyConst  equ  h'ABCD'

   movlw   high(MyConst)   ; will move $AB into w


If I declare a constant with more than 2 bytes, is it possible
to access the middle bytes?

Example:

MyConst  equ  h'01020304'

  movlw   ???? (MyConst)    ;how do I access the 3rd byte???

Regards,

Mike Watson

1997\03\25@150058 by Andrew Warren

face
flavicon
face
Mayes uk <spam_OUTmikeTakeThisOuTspamd-m-g.demon.co.uk> wrote:

> If I declare a constant with more than 2 bytes, is it possible
> to access the middle bytes?
>
> Example:
>
> MyConst  equ  h'01020304'
>
>    movlw   ???? (MyConst)    ;how do I access the 3rd byte???

Mike:

   MOVLW ((MYCONST) >> 8) & 0xFF

It's probably easiest if you use parameterized #DEFINEs to define
the shift-and-AND operations for each byte-position... Then you can
just say:

   MOVLW LSB2(MYCONT)

or whatever.

By the way, it's best to use shift-and-AND macros instead of LOW and
HIGH... In at least some versions of M

1997\03\26@040621 by mike

flavicon
picon face
In message  <.....199703251959.NAA23125KILLspamspam@spam@dfw-ix5.ix.netcom.com> PICLISTspamKILLspamMITVMA.MIT.EDU
writes:
{Quote hidden}

Thanks for the reply, Andy.

One phrase I didn't understand was "parameterized #DEFINEs". Can
you give me an example?

Regards,


Mike

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...