Modding Use Function IF in PIC

Discussion in 'Modding' started by risingsun, 6 Oct 2007.

  1. risingsun

    risingsun What's a Dremel?

    Joined:
    6 Oct 2007
    Posts:
    1
    Likes Received:
    0
    I am using PIC16F873A. I am a pure noob of PIC. I am just a pure beginner. So to say noob question!
    My question is like this:

    Multiplier number A with number B, and give the result to C. Let the smaller number determine the loop.

    Num EQU 0x20 ; variable used for context saving
    Multiplier EQU 0x21 ; variable used for context saving
    Result EQU 0x22 ; variable used for context saving





    ;**********************************************************************
    ORG 0x000 ; processor reset vector

    nop ; nop required for icd
    goto main ; go to beginning of program


    ORG 0x004 ; interrupt vector location

    main MOVLW 0x00 ;
    MOVWF Num ;
    MOVWF Multiplier ;
    MOVWF Result ;
    MOVWF STATUS ;
    MOVLW 0x10 ;
    MOVWF Num ;
    MOVLW 0x12 ;Num - Multiplier
    MOVWF Multiplier ;
    SUBWF Num, 0 ;
    BTFSS STATUS, 1 ;
    GOTO leep ;
    loop MOVFW Num ;Multiplier control loop
    ADDWF Result, 1 ;
    DECFSZ Multiplier, 1 ;
    GOTO loop ;
    GOTO endi ;
    leep MOVFW Multiplier ;Num control loop
    ADDWF Result, 1 ;
    DECFSZ Num, 1 ;
    GOTO leep ;
    endi NOP ;
    END
    ******************************************
    is it correct? is there a better way to do this? Any useful reference of the PIC programming tutorial?
     
    Last edited: 6 Oct 2007
  2. jakenbake

    jakenbake full duplex

    Joined:
    5 Jun 2005
    Posts:
    495
    Likes Received:
    3
    Last edited: 8 Oct 2007

Share This Page