Multiplying with 11 using PIC


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Sep 2015
    Posts
    23


    Did you find this post helpful? Yes | No

    Default Re: Multiplying with 11 using PIC

    Hi
    Please look at the code for MPLAB.Please look if you can help about.My knowledge in MPLAB programming is very low.

    Here is a CODE for multiply.Please could you make a correction that MUX_24X24 routine will work when
    multiplier h'225C18' is over 6 digits – for instance in this example – multiplier should be h'179F508'
    Below code works fine with multiplier h'225C18'
    ;************************************************* **************************************
    SPREMI_MEM ; input data are FREQ_NO i MEM_NO and according to them
    ; location for saving to FLASH are defined
    ;data which are saved are saved in registers BIN_H,BIN_M i BIN_L and that are data
    ;for display frequencies on the address h'05', h'06', h'07'
    ;-calculating the word which have to be sent to AD9850:
    movf BIN_H,W ;move values for multiply KEYB
    movwf MULCND_H
    movf BIN_M,W
    movwf MULCND_M
    movf BIN_L,W
    movwf MULCND_L
    ;What if multiplier is h'179F508'
    ;Please make correction in code if multiplier is 7 digits long hex number
    movlw h'22' ;set multiplier h'225C18' KEYB
    movwf MULPLR_H
    movlw h'5C'
    movwf MULPLR_M
    movlw h'18'
    movwf MULPLR_L

    call MUX_24X24 ;multiply

    movf REZ_5,W ;registar 4 for AD9850 KEYB
    movwf RAM_0
    movf REZ_4,W ;registar 3 for AD9850 KEYB
    movwf RAM_1
    movf REZ_3,W ;registar 2 for AD9850
    movwf RAM_2
    movf REZ_2,W ;registar 1 for AD9850 KEYB
    movwf RAM_3
    movlw h'00'
    movwf RAM_4

    movf BIN_H,W ;value for diplay KEYB
    movwf RAM_5
    movf BIN_M,W ;value for display KEYB
    movwf RAM_6
    movf BIN_L,W ;value for display KEYB
    movwf RAM_7
    UPIS_U_FLASH
    call FLASH_WRITE
    return
    ;************************************************* *****************************
    ;************************************************* *****************************
    MUX_24X24 ; multiply tree bytes :MULPLR_H, MULPLR_M i MULPLR_L
    ;with MULCND_H, MULCND_M i MULCND_L
    ; 48 bit result saved in REZ_5 to REZ_0
    clrf REZ_5
    clrf REZ_4
    clrf REZ_3 ; MUX
    clrf REZ_2
    clrf REZ_1
    clrf REZ_0
    movlw d'24' ;count for 24 bit
    movwf BROJAČ_T3
    bcf STATUS,C ;Clear the carry bit in the status Reg.
    LOOP24
    rrcf MULPLR_H,F ; MUX
    rrcf MULPLR_M,F ;
    rrcf MULPLR_L,F ; MUX
    btfss STATUS,C
    goto ROTATE_R
    ADD_3_BYTES
    movf MULCND_L,W
    addwf REZ_3,F
    btfsc STATUS,C ;check carry bit
    incf REZ_4,F
    btfsc STATUS,C ;check carry bit MUX
    incf REZ_5,F

    movf MULCND_M,W
    addwf REZ_4,F
    btfsc STATUS,C ;check carry bit MUX
    incf REZ_5,F

    movf MULCND_H,W
    addwf REZ_5,F

    ROTATE_R
    rrcf REZ_5,F
    rrcf REZ_4,F
    rrcf REZ_3,F
    rrcf REZ_2,F
    rrcf REZ_1,F
    rrcf REZ_0,F
    decfsz BROJAČ_T3,F ; MUX
    goto LOOP24
    return
    ;************************************************* *****************************

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,721


    Did you find this post helpful? Yes | No

    Default Re: Multiplying with 11 using PIC

    a 32 bit number cannot be represented in 24 bits , you need 32bit multiplier code

    look at n-bit math
    Warning I'm not a teacher

Similar Threads

  1. pass pic basic pro pic from pic 16f877a to pic 16f887
    By joseluisatmega8 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 12th February 2020, 16:17
  2. High Speed Serial Comm PC - PIC and PIC - PIC
    By manumenzella in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 16th January 2007, 21:55
  3. Multiplying large numbers
    By jhonea1 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 14th April 2006, 17:41

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts