Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 13:20 07 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Left shifting bits in mmbasic on maximite

Author Message
steveizett
Newbie

Joined: 15/05/2012
Location: Australia
Posts: 21
Posted: 11:58pm 31 Aug 2016
Copy link to clipboard 
Print this post

Hi guys
I'm playing with a hx711 and need to implement the following code.

for (i=0;i<24;i++){
ADSK=1;
Count=Count<<1;
ADSK=0;
if(ADDO) Count++;
}
ADSK=1;
Count=Count^0x800000;
ADSK=0;
return(Count);

How do I shift left as in "Count<<1"
I see in the manual a reference to RShift = nbr\(2^bits)

Thanks very much.
Steve
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 01:32am 01 Sep 2016
Copy link to clipboard 
Print this post

Shifting one bit to the left is the same as multiplying by 2.

However the code you posted should work with a little modification as MMbasic does support shifting and XOR'ing.
From the manual page 49.
(Make sure the Count variable is an INTEGER!)
[code]
Shift operators:
x << y x >> y These operate in a special way.

<< means that the value returned will be the value
of x shifted by y bits to the left while

>> means the same only right shifted.
They are integer functions and any bits shifted
off are discarded and any bits introduced are set to zero.
[/code]
The ^ operator is called XOR in MMBasic.
(You can find that on the same page).

Edited by MicroBlocks 2016-09-02
Microblocks. Build with logic.
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1573
Posted: 01:40am 01 Sep 2016
Copy link to clipboard 
Print this post

@steveizett

LShift = nbr *(2^bits)


I think (AFAIK) the MMBasic (4.5) for Maximites has no shift operators.
... also no integers.

Regards
MichaelEdited by twofingers 2016-09-02
causality ≠ correlation ≠ coincidence
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 01:45am 01 Sep 2016
Copy link to clipboard 
Print this post

Oops, missed the Maximite reference in the topic.

Just use:
[code]
Count = Count * 2
[/code]

Microblocks. Build with logic.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 12:43pm 01 Sep 2016
Copy link to clipboard 
Print this post

Remember that you are limited to about 23 bits for integers in 32 bit floating point.

Jim
VK7JH
MMedit
 
steveizett
Newbie

Joined: 15/05/2012
Location: Australia
Posts: 21
Posted: 01:13pm 01 Sep 2016
Copy link to clipboard 
Print this post

Thanks guys for the help
Sounds like I need to use micromite for this app.
Cheers
Steve
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025