Searching \ for ' [PIC] tiny challenge ;)' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'tiny challenge ;)'.

No exact or substring matches. trying for part
PICList Thread
'[PICLIST] [PIC] tiny challenge ;)'
2000\08\10@171925 by Dmitry Kiryashov

flavicon
face
Hi guys. ;)

I got free minute and decided to drop this message. Anyone who
wants to refresh brain from coding and solve a small puzzle are
invited ;)

Well.

We have number in W register in 00ab00cd view, where 0's are
actually zeroes and abcd are some bits we are playing with.

The challenge is to convert 00ab00cd to aAbBcCdD view, where A
is not(a), B=not(b), etc.. In other words capital means negation.

For instance W=00100001 on input should result to W=10010110 on
output.

It should be done as tight as only possible. Everybody welcomes ;)

WBR Dmitry.

PS.  I'll also post my solution lately.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

2000\08\10@172922 by James Paul

flavicon
face
Whoa Dimitry,

Once again...slowly...

I understand everything up to your example, but that's where I get
lost.  Could you go through it again showing me how you got your
output from the input given?

                                           Thanks and Regards,

                                                  Jim



On Thu, 10 August 2000, Dmitry Kiryashov wrote:

{Quote hidden}

spam_OUTjimTakeThisOuTspamjpes.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

2000\08\10@175029 by Scott Dattalo

face
flavicon
face
On Fri, 11 Aug 2000, Dmitry Kiryashov wrote:

{Quote hidden}

  movwf   temp
  clrc
  rlf     temp,f
  iorwf   temp,w
  andlw   0x55
  movwf   temp     ; 0a0b0c0d
  rlf     temp,f
  xorlw   0x55
  iorwf   temp,w   ; or ,f

Less than 12 cycles!

maybe there's a trick or two though

Scott

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

2000\08\10@180455 by Dmitry Kiryashov

flavicon
face
Hi Scott. Good shot ;) Who shorter ?

WBR Dmitry.

Scott Dattalo wrote:

{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

2000\08\10@182329 by Don Hyde

flavicon
face
       movwf   temp    ;       temp =  00ab00cd
       andlw   0x22    ;       w =      00a000c0
       addwf   temp,w ;        w =      0a0b0c0d       (a+a = a0, b+0=b,
c+c=c0, d+0=d)
       addlw   0x55    ;       w =     aAbBcCdD        (a+1=aA, b+1=bB,
c+1=cC, d+1=dD)

> {Original Message removed}

2000\08\10@182809 by David VanHorn

flavicon
face
>
>For instance W=00100001 on input should result to W=10010110 on
>output.
>
>It should be done as tight as only possible. Everybody welcomes ;)


Interesting excersize, but what's the real-life purpose?

--
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

2000\08\10@182953 by Dmitry Kiryashov

flavicon
face
Hi Don.

Almost perfect ;)

WBR Dmitry.

Don Hyde wrote:
>
>         movwf   temp    ;       temp =  00ab00cd
>         andlw   0x22    ;       w =      00a000c0
>         addwf   temp,w ;        w =      0a0b0c0d       (a+a = a0, b+0=b,
> c+c=c0, d+0=d)
>         addlw   0x55    ;       w =     aAbBcCdD        (a+1=aA, b+1=bB,
> c+1=cC, d+1=dD)

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

2000\08\10@201819 by Bob Ammerman

picon face
How about this:

  00ab00cd
+00100010
---------------
 0aAb0cCd
&01010101
----------------
 0a0b0c0d
+01010101
----------------
aAbBcCdD


so, in code:

   ADDLW    B'00100010'
   ANDLW    B'01010101'
   ADDLW    B'01010101'

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

2000\08\10@205839 by Carl Ranson

flavicon
face
Bob....I hereby decree that you are the KING of binary.

all kneel and praise him.... :)

CR

{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

'[PICLIST] [EIT]: [PIC] tiny challenge ;)'
2000\08\10@221621 by Scott Dattalo

face
flavicon
face
On Thu, 10 Aug 2000, Bob Ammerman wrote:

> How about this:
>
>    00ab00cd
> +00100010
>  ---------------
>   0aAb0cCd
> &01010101
>  ----------------
>   0a0b0c0d
> +01010101
> ----------------
>  aAbBcCdD
>
>
> so, in code:
>
>     ADDLW    B'00100010'
>     ANDLW    B'01010101'
>     ADDLW    B'01010101'

Excellent! Now I know I've been doing too much C/C++
(Also, now I know why Dmitry posted the challenge - the solution is so elegant
who cares what problem it solves? :)

Scott

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

'[PICLIST] [PIC] tiny challenge ;)'
2000\08\11@053146 by WALSH, Scott

flavicon
face
I am sorry, but my head hurts in trying to understand this!

Bob, could you be so kind as to explain the logic and reason why this works,
rather than just stating the solution please?

tvm,
SW.

{Original Message removed}

2000\08\11@064610 by Bob Ammerman

picon face
Sure:

Here is the basic trick behind it:

Given the value (in binary)     0a,

where (a) is some bit, what happens when we add 01 (binary) to it?

Well, if 'a' is 0, then we get 01,  which is aA

And if 'a' is 1, then we get 10, which is aA

The rest of it is just applying this trick a total of 6 times:

00ab00cd + 00100010 = 0aAb0cCd    (2 times here)

0aAb0cCd & 01010101 = 0a0b0c0d    (get ready to do it again)

0a0b0c0d + 01010101 = aAbBcCdD    (4 more times)

Note that it works because there are zeros between the useful bits and
therefore carries won't happen from one to the other.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
sofftware)







----- Original Message -----
From: WALSH, Scott <.....scott.walshKILLspamspam.....PLANTRONICS.COM>
To: <EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU>
Sent: Friday, August 11, 2000 5:27 AM
Subject: Re: [PIC] tiny challenge ;)


> I am sorry, but my head hurts in trying to understand this!
>
> Bob, could you be so kind as to explain the logic and reason why this
works,
> rather than just stating the solution please?
>
> tvm,
> SW.
>
> {Original Message removed}

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