Searching \ for 'Commands for 16c54 ??' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=16C
Search entire site for: 'Commands for 16c54 ??'.

Truncated match.
PICList Thread
'Commands for 16c54 ??'
1997\06\29@070333 by genie

flavicon
face
part 0 758 bytes
!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN">

What is the best and quickest way to implement the following types of commands on a pic micro ??

IF w = f then , IF w<>f then , IF w > f then , IF w < f then

I am new to PIC chips and your help would be well appreciated...Are there any good internet sources of info on programming code (such as a tutor) ??

Paul (Thanks)

1997\06\29@152839 by Terry

flavicon
face
<x-rich>At 08:55 PM 6/29/97 +1000, you wrote:


<excerpt>

<bigger>What is the best and quickest way to implement the  following
types of commands on a pic micro
??</bigger><fontfamily><param>Arial</param><color><param>0606,0000,0000</param>


<bigger>IF w = f then , IF w<<>f then , IF w > f then  , IF w << f
then</bigger>


<bigger>I am new to PIC chips and your help would be well
appreciated...Are there any good internet sources of info on programming
code  (such as a tutor) ??</bigger>


</color></fontfamily></excerpt><fontfamily><param>Arial</param><color><param>060
6,0000,0000</param>

You may think about picking up the Square One electronics book "Easy
PIC'n"  It mainly deals with the 16c84, but it does have a section on the
16c54.  Good into book.</color></fontfamily>
</x-rich>

1997\06\29@171254 by gtham

flavicon
face
>
> At 08:55 PM 6/29/97 +1000, you wrote:
>
>      What is the best and quickest way to implement the following
>      types of commands on a pic micro ??
>
>      IF w = f then , IF w<>f then , IF w > f then , IF w < f then
>

Check Beginner's PIC page at

http://hobbes.king.ac.uk/matt/pic/

under Hints and tips, logical commands, you will find
just what you are looking for.

Gus

1997\06\30@170027 by Steve Smith

picon face
You wrote
Snip
<IF w = f then , IF w<>f then , IF w > f then , IF w < f then>

I think this might work
firstly check if w=f by subtraction and checking Z and testing returning a 1
in the w register for the first result. secondly test for a carry (w>f)
(2)else the result is (w<f) (3) and by default w<>f and does not need
computing.

Call        Choice

Choice
SUBWF    f,w                ;subtract w from file
BTFSC     STATUS,Z     ; test for zero (w=f)
RETLW     1                  ; exit sub w=1 (w=f)
BCF         STATUS,C     ; clear carry before starting
SUBWF     f,w               ; do again and check for borrow
BTFSS     STATUS,C     ; test for carry (w>f)
RETLW     2                  ; exit sub w=2 (w<f)
RETLW     3                  ; exit sub w=3 (w>f) by default

minor fracture in the thaught process cant remember if Ive got the bit test
in the correct polarity but try it and see (Its close)...

Steve.....

1997\06\30@233022 by Bob Fehrenbach

picon face
Steve Smith <spam_OUTXYGAXTakeThisOuTspamAOL.COM> wrote:
>You wrote
>Snip
><IF w = f then , IF w<>f then , IF w > f then , IF w < f then>
>
>I think this might work
>firstly check if w=f by subtraction and checking Z and testing returning a 1
>in the w register for the first result. secondly test for a carry (w>f)
>(2)else the result is (w<f) (3) and by default w<>f and does not need
>computing.
>
>Call        Choice
>
>Choice
>SUBWF    f,w                ;subtract w from file
>BTFSC     STATUS,Z     ; test for zero (w=f)
>RETLW     1                  ; exit sub w=1 (w=f)

      *** It is unclear what is intended by the next two lines.
      *** Clearing the carry destroys valuable information and
      *** the second subtract ???  w = f-(f-w) ??

{Quote hidden}

  Simpler:

  SUBWF     f,w                   ; subtract w from file
  BTFSC     STATUS,Z              ; test for zero (w=f)
  RETLW     1                     ; exit with w=1
  BTFSS     STATUS,C              ; If f>w, C = 1
  RETLW     2                     ; exit with w=2 (f<w)
  RETLW     3                     ; exit with w=3 (f>w)

  Since the calling routine would then have to test for the value in
  w, it would seem that an inline test would be faster and take less
  code space:

  SUBWF   f, w
  BTFSC   STATUS, Z
  GOTO    f_equals_w
  BTFSS   STATUS, C
  GOTO    f_ltn_w
  GOTO    f_gtn_w                 ;If the f_gtn_w routine followed,
                                  ;this jump is eliminated, doing
                                  ;the whole thing in 5 instructions.

--
Bob Fehrenbach    Wauwatosa, WI     .....bfehrenbKILLspamspam@spam@execpc.com


'Commands for 16c54 ??'
1997\07\01@040550 by Mike Harrison
picon face
At 16:59 30/6/1997 -0400, you wrote:

>Call        Choice
>
>Choice
>SUBWF    f,w                ;subtract w from file
>BTFSC     STATUS,Z     ; test for zero (w=f)
>RETLW     1                  ; exit sub w=1 (w=f)
>BCF         STATUS,C     ; clear carry before starting
>SUBWF     f,w               ; do again and check for borrow
>BTFSS     STATUS,C     ; test for carry (w>f)
>RETLW     2                  ; exit sub w=2 (w<f)
>RETLW     3                  ; exit sub w=3 (w>f) by default
>
For the sake of confirming something I do on a regular basis I would use:
>SUBWF    f,w                ;subtract w from file
>BTFSC     STATUS,Z     ; test for zero (w=f)
>RETLW     1            ; exit sub w=1 (w=f)
>BTFSS     STATUS,C     ; test for carry (w>f), C preserved from first
;       subtraction
>RETLW     2            ; exit sub w=2 (w<f)
>RETLW     3            ; exit sub w=3 (w>f) by default
I just want to confim this is ok, and saves those three instructions.
Mike
***************************************************************************
M. Harrison                                     TEL 44 1235 445288
Space Science division                          Fax 44 1235 445848
Rutherford Appleton Lab                         email m.c.harrisonspamKILLspamrl.ac.uk
Building R25 Room 2.124                         .....mikeKILLspamspam.....leyenda.demon.co.uk
Chilton
Oxon OX11 0QX UK
***************************************************************************

1997\07\01@172644 by Steve Smith

picon face
I wrote the following and got it corrected

>Call        Choice
>
>Choice
>SUBWF    f,w                ;subtract w from file
>BTFSC     STATUS,Z     ; test for zero (w=f)
>RETLW     1                  ; exit sub w=1 (w=f)
>BCF         STATUS,C     ; clear carry before starting
>SUBWF     f,w               ; do again and check for borrow
>BTFSS     STATUS,C     ; test for carry (w>f)
>RETLW     2                  ; exit sub w=2 (w<f)
>RETLW     3                  ; exit sub w=3 (w>f) by default
>
For the sake of confirming something I do on a regular basis I would use:
>SUBWF    f,w                ;subtract w from file
>BTFSC     STATUS,Z     ; test for zero (w=f)
>RETLW     1            ; exit sub w=1 (w=f)
>BTFSS     STATUS,C     ; test for carry (w>f), C preserved from first
;       subtraction
>RETLW     2            ; exit sub w=2 (w<f)
>RETLW     3            ; exit sub w=3 (w>f) by default
I just want to confim this is ok, and saves those three instructions.
Mike

Thanks Mike cause I had forgot I had to save the contents of w first in temp
store before attempting to subtracting it again.....

      *** It is unclear what is intended by the next two lines.
      *** Clearing the carry destroys valuable information and
      *** the second subtract ???  w = f-(f-w) ??

Thaugt about it after I had sent is (must engage brain before using fingers)
I had a feeling this could be done but never tried it so couldnt confirm it.
Is it not critical to clear C before starting else some leftovers may cause a
bad result ?

  Since the calling routine would then have to test for the value in
  w, it would seem that an inline test would be faster and take less
  code space:

  SUBWF   f, w
  BTFSC   STATUS, Z
  GOTO    f_equals_w
  BTFSS   STATUS, C
  GOTO    f_ltn_w
  GOTO    f_gtn_w                 ;If the f_gtn_w routine followed,
                                  ;this jump is eliminated, doing
                                  ;the whole thing in 5 instructions.

--
Thanks also Bob Fehrenbach
Cheers Steve.....

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