Hi All,
Is there a way to set multiple bit in a single instruction line?
Example:
dim TEMP as Byte
dim X as sbit at temp.b0
dim Y as sbit at temp.b1
dim Z as sbit at temp.b2
dim A as sbit at temp.b3
now, if i want to set four bits, i have to do that:
X = 1
Y = 1
Z = 1
A = 1
Then the assember output will address the RAM four times wasting a lot of time and space.
I wonder if there is a possibility to do something like that:
X+Y+Z+A = 1
or
X.Y.Z.A = 1
that would even mean that the assembler will put a single calculated value during the compiling phase.
Thank You
Alessandro
Bits manipulation
Re: Bits manipulation
Hi,
You can do it like that:
Temp = Temp and %1111
Sergiu
You can do it like that:
Temp = Temp and %1111
Sergiu
-
- Posts: 101
- Joined: 04 Nov 2016 13:09
Re: Bits manipulation
Thank you Sergiu
I know that.
My problem is about readibility of the code. That why i putted alias to the bits...
I would like to read the names of the bits
Thank you,
Alex
I know that.
My problem is about readibility of the code. That why i putted alias to the bits...
I would like to read the names of the bits
Thank you,
Alex
-
- Posts: 27
- Joined: 21 Jan 2017 10:44
- Location: Lahore
- Contact:
Re: Bits manipulation
did you try this?Alessandro Fulignani wrote:Hi All,
Is there a way to set multiple bit in a single instruction line?
Example:
dim TEMP as Byte
dim X as sbit at temp.b0
dim Y as sbit at temp.b1
dim Z as sbit at temp.b2
dim A as sbit at temp.b3
now, if i want to set four bits, i have to do that:
X = 1
Y = 1
Z = 1
A = 1
Then the assember output will address the RAM four times wasting a lot of time and space.
Otherwise I need to use Arduino Mega 2560. So, I wonder if there is a possibility to do something like that:
X+Y+Z+A = 1
or
X.Y.Z.A = 1
that would even mean that the assembler will put a single calculated value during the compiling phase.
Thank You
Alessandro
X=Y=Z=A=1;
-
- Posts: 101
- Joined: 04 Nov 2016 13:09
Re: Bits manipulation
Good Morning,
Thank you for your suggestion. Yes i did. Does not work.
Alex
Thank you for your suggestion. Yes i did. Does not work.
Alex