Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.electronics.design > #380481

Re: OT: programming problem

From Martin Brown <|||newspam|||@nezumi.demon.co.uk>
Newsgroups sci.electronics.design
Subject Re: OT: programming problem
Date 2015-10-06 10:51 +0100
Organization Aioe.org NNTP Server
Message-ID <mv05ie$66b$1@speranza.aioe.org> (permalink)
References <dAJQx.52004$P21.14655@fx09.iad>

Show all headers | View raw


On 06/10/2015 07:09, Robert Baer wrote:
 >    Yes, the same old PIC16F648A..
 >
 > DELAY   MOVWF   sW     ; save W
 > ; following gives Warning: Argument out of range.  Least significant
 > bits used.
 >          MOVF    sSTATUS,STATUS  ;assy: d=1;sSTATUS@25 == save STATUS
 >          CLRF    COUNT1
 >          CLRF    COUNT2
 >          MOVLW   d'16'  ; fudge for about 1 Sec delay
 >          MOVWF   COUNT3
 >
 > LOOPIE  DECFSZ  COUNT3
 >          GOTO    LUPOTR
 >          GOTO    DEXIT
 >
 > LUPOTR  DECFSZ  COUNT2
 >          GOTO    LUPINR  ; COUNTed once,do inner loop
 >          GOTO    LOOPIE
 >
 > LUPINR  INCFSZ  COUNT1  ; race inside inner loop
 >          GOTO    LUPINR  ; high speed count
 >          GOTO    LUPOTR  ; go for another outer count
 >
 > DEXIT:  MOVF    sW      ; restore W
 > ; following gives Warning: Argument out of range.  Least significant
 > bits used.
 >          MOVF    STATUS,sSTATUS  ;assy: d=0;STATUS@03  == restore STATUS
 >          RETURN
 >    Using this shows that W is NOT restored, that it set to the delay 
value.
 >    Therefore, i can assume ditto for STATUS.
 >    Comments in listing derived from compiled code; "d" stands for the
 > direction bit.
 >
 >    Help?

Learning how to program in PIC assembler might help. RTFM

http://tutor.al-williams.com/pic-inst.html

MOVF sW,W

MOVF sW,F merely tests if sW==0

Is this some sort of competition to maximise the number of GOTOs and 
random flow of control? Heaven help the maintenance programmers.

If you reorder the code sensibly half of the GOTOs vanish.
COUNT3 needs to be one less due to dropping through the loop code.

LUPINR INCFSZ COUNT1
        GOTO   LUPINR
        DECFSZ COUNT2
        GOTO   LUPINR
        DECFSZ COUNT3
        GOTO   LUPINR
DEXIT

I prefer to have a single delay routine that accepts W on input as the 
exact number of cycles to delay by as a separate routine. It makes doing 
variable precision delays in software so much easier. YMMV

-- 
Regards,
Martin Brown

Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-05 23:09 -0700
  Re: OT: programming problem piglet <erichpwagner@hotmail.com> - 2015-10-06 09:48 +0100
    Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-06 09:58 -0700
  Re: OT: programming problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-06 10:51 +0100
    Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-06 10:11 -0700
      Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-06 13:40 -0700
        Re: OT: programming problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-07 09:14 +0100
          Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-07 19:50 -0700
  Re: OT: programming problem "P E Schoen" <paul@pstech-inc.com> - 2015-10-06 21:01 -0400
    Re: OT: programming problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-07 09:16 +0100
      Re: OT: programming problem Lasse Langwadt Christensen <langwadt@fonz.dk> - 2015-10-07 02:00 -0700
        Re: OT: programming problem, NASTY Robert Baer <robertbaer@localnet.com> - 2015-10-07 22:23 -0700
          Re: OT: programming problem, NASTY Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-08 12:05 +0100
          Re: OT: programming problem, NASTY piglet <erichpwagner@hotmail.com> - 2015-10-08 16:31 +0100
      Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-07 20:10 -0700
        Re: OT: programming problem new_ibm <randy.day@sasktel.netx> - 2015-10-08 08:33 -0600
    Re: OT: programming problem Robert Baer <robertbaer@localnet.com> - 2015-10-07 19:33 -0700

csiph-web