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
;************************************************* *****************************
Bookmarks