Please clarify the syntax of SHIFTOUT command inPBASIC
Archiver
Posts: 46,084
I am wondering if there is an error in the manual for the PBASIC
command description "SHIFOUT". I quote below the manual (obtained
from help menu in the PBASIC editor 2.0 beta 2.1).
"
By default, SHIFTOUT transmits eight bits, but you can set it to
shift any number of bits from 1 to 16 with the Bits argument. For
example:
SHIFTOUT 0, 1, MSBFIRST, [noparse][[/noparse]250\4]
Will only output the lowest 4 bits (%1010 in this case).
Some devices require more than 16 bits. To solve this, you can use a
single SHIFTOUT command with multiple values. Each value can be
assigned a particular number of bits with the Bits argument. As in:
SHIFTOUT 0, 1, MSBFIRST, [noparse][[/noparse]250\4, 1045\16]
The above code will first shift out four bits of the number 250 (%
1111) and then 16 bits of the number 1045 (%0000010000010101). The
two values together make up a 20 bit value.
"
command description "SHIFOUT". I quote below the manual (obtained
from help menu in the PBASIC editor 2.0 beta 2.1).
"
By default, SHIFTOUT transmits eight bits, but you can set it to
shift any number of bits from 1 to 16 with the Bits argument. For
example:
SHIFTOUT 0, 1, MSBFIRST, [noparse][[/noparse]250\4]
Will only output the lowest 4 bits (%1010 in this case).
Some devices require more than 16 bits. To solve this, you can use a
single SHIFTOUT command with multiple values. Each value can be
assigned a particular number of bits with the Bits argument. As in:
SHIFTOUT 0, 1, MSBFIRST, [noparse][[/noparse]250\4, 1045\16]
The above code will first shift out four bits of the number 250 (%
1111) and then 16 bits of the number 1045 (%0000010000010101). The
two values together make up a 20 bit value.
"
Comments
shiftout 0,1,msbfirst,[noparse][[/noparse]250\4]
will shift out the "lowest 4 bits (%1010 in this
case)", that is correct. (The previous version of the manual said
%0000 there, which was incorrect!) In the next paragraph, it states
that [noparse][[/noparse]250\4] will shift out
"four bits of the number 250 (%1111)..."
Which is wrong. What it shifts out is in fact the lowest 4 bits, "1010".
Here is what happens with,
shiftout 0,1,msbfirst,[noparse][[/noparse]variable\n]
...the Stamp grabs the lowest n bits of the variable and pads it to
the left with zeros if necessary. Then it sends
the n bits, most significant bit first. For example
x var word
x = 250 ' = %0000000011111010 in binary
shiftout 0,1,msbfirst,[noparse][[/noparse]x\4]
*sends %1010
shiftout 0,1,msbfirst,[noparse][[/noparse]x\11] ' <-MSB first
*sends %00011111010
shiftout 0,1,lsbfirst,[noparse][[/noparse]x\11] '<--LSB first!
*sends %01011111000
I hope that clarifies it for you.
-- Tracy
>I am wondering if there is an error in the manual for the PBASIC
>command description "SHIFOUT". I quote below the manual (obtained
>from help menu in the PBASIC editor 2.0 beta 2.1).
>
>"
>By default, SHIFTOUT transmits eight bits, but you can set it to
>shift any number of bits from 1 to 16 with the Bits argument. For
>example:
>
> SHIFTOUT 0, 1, MSBFIRST, [noparse][[/noparse]250\4]
>
>Will only output the lowest 4 bits (%1010 in this case).
>
>Some devices require more than 16 bits. To solve this, you can use a
>single SHIFTOUT command with multiple values. Each value can be
>assigned a particular number of bits with the Bits argument. As in:
>
> SHIFTOUT 0, 1, MSBFIRST, [noparse][[/noparse]250\4, 1045\16]
>
>The above code will first shift out four bits of the number 250 (%
>1111) and then 16 bits of the number 1045 (%0000010000010101). The
>two values together make up a 20 bit value.
>"
>
it very easy to understand. I appreciate it very much.I hope the
parallax team is aware of this mistake and has taken steps to correct
it.
--- In basicstamps@yahoogroups.com, Tracy Allen <tracy@e...> wrote:
> When the manual says,
> shiftout 0,1,msbfirst,[noparse][[/noparse]250\4]
> will shift out the "lowest 4 bits (%1010 in this
> case)", that is correct. (The previous version of the manual said
> %0000 there, which was incorrect!) In the next paragraph, it
states
> that [noparse][[/noparse]250\4] will shift out
> "four bits of the number 250 (%1111)..."
>
> Which is wrong. What it shifts out is in fact the lowest 4
bits, "1010".
>
> Here is what happens with,
> shiftout 0,1,msbfirst,[noparse][[/noparse]variable\n]
>
> ...the Stamp grabs the lowest n bits of the variable and pads it to
> the left with zeros if necessary. Then it sends
> the n bits, most significant bit first. For example
> x var word
> x = 250 ' = %0000000011111010 in binary
> shiftout 0,1,msbfirst,[noparse][[/noparse]x\4]
> *sends %1010
>
> shiftout 0,1,msbfirst,[noparse][[/noparse]x\11] ' <-MSB first
> *sends %00011111010
>
> shiftout 0,1,lsbfirst,[noparse][[/noparse]x\11] '<--LSB first!
> *sends %01011111000
>
> I hope that clarifies it for you.
>
> -- Tracy
>
>
>
> >I am wondering if there is an error in the manual for the PBASIC
> >command description "SHIFOUT". I quote below the manual (obtained
> >from help menu in the PBASIC editor 2.0 beta 2.1).
> >
> >"
> >By default, SHIFTOUT transmits eight bits, but you can set it to
> >shift any number of bits from 1 to 16 with the Bits argument. For
> >example:
> >
> > SHIFTOUT 0, 1, MSBFIRST, [noparse][[/noparse]250\4]
> >
> >Will only output the lowest 4 bits (%1010 in this case).
> >
> >Some devices require more than 16 bits. To solve this, you can use
a
> >single SHIFTOUT command with multiple values. Each value can be
> >assigned a particular number of bits with the Bits argument. As in:
> >
> > SHIFTOUT 0, 1, MSBFIRST, [noparse][[/noparse]250\4, 1045\16]
> >
> >The above code will first shift out four bits of the number 250 (%
> >1111) and then 16 bits of the number 1045 (%0000010000010101). The
> >two values together make up a 20 bit value.
> >"
> >
update, I'll make sure it gets taken care of. The help file source is
already fixed and will be recompiled for the next compiler release.
-- Jon Williams
-- Parallax
Original Message
From: mohammedrasiq [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=w_E0VAAhCdiCSpjjPaZBS90yvZOeyfaOEzcMS85DoRnsjoW8hSCMdKMj1nj5zSbwmDbii1CM2oeH-EBX5BlvDXM]mohammedrasiq@y...[/url
Sent: Tuesday, July 29, 2003 5:35 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Re: Please clarify the syntax of SHIFTOUT command
inPBASIC
Thanks a lot, Tracy! Your explanation, as always, is lucid and makes
it very easy to understand. I appreciate it very much.I hope the
parallax team is aware of this mistake and has taken steps to correct
it.
--- In basicstamps@yahoogroups.com, Tracy Allen <tracy@e...> wrote:
> When the manual says,
> shiftout 0,1,msbfirst,[noparse][[/noparse]250\4]
> will shift out the "lowest 4 bits (%1010 in this
> case)", that is correct. (The previous version of the manual said
> %0000 there, which was incorrect!) In the next paragraph, it
states
> that [noparse][[/noparse]250\4] will shift out
> "four bits of the number 250 (%1111)..."
>
> Which is wrong. What it shifts out is in fact the lowest 4
bits, "1010".
>
> Here is what happens with,
> shiftout 0,1,msbfirst,[noparse][[/noparse]variable\n]
>
> ...the Stamp grabs the lowest n bits of the variable and pads it to
> the left with zeros if necessary. Then it sends
> the n bits, most significant bit first. For example
> x var word
> x = 250 ' = %0000000011111010 in binary
> shiftout 0,1,msbfirst,[noparse][[/noparse]x\4]
> *sends %1010
>
> shiftout 0,1,msbfirst,[noparse][[/noparse]x\11] ' <-MSB first
> *sends %00011111010
>
> shiftout 0,1,lsbfirst,[noparse][[/noparse]x\11] '<--LSB first!
> *sends %01011111000
>
> I hope that clarifies it for you.
>
> -- Tracy
>
>
>
> >I am wondering if there is an error in the manual for the PBASIC
> >command description "SHIFOUT". I quote below the manual (obtained
> >from help menu in the PBASIC editor 2.0 beta 2.1).
> >
> >"
> >By default, SHIFTOUT transmits eight bits, but you can set it to
> >shift any number of bits from 1 to 16 with the Bits argument. For
> >example:
> >
> > SHIFTOUT 0, 1, MSBFIRST, [noparse][[/noparse]250\4]
> >
> >Will only output the lowest 4 bits (%1010 in this case).
> >
> >Some devices require more than 16 bits. To solve this, you can use
a
> >single SHIFTOUT command with multiple values. Each value can be
> >assigned a particular number of bits with the Bits argument. As in:
> >
> > SHIFTOUT 0, 1, MSBFIRST, [noparse][[/noparse]250\4, 1045\16]
> >
> >The above code will first shift out four bits of the number 250 (%
> >1111) and then 16 bits of the number 1045 (%0000010000010101). The
> >two values together make up a 20 bit value. "
> >
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....