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?
there is no instruction MOVFW, you must use MOVF. read the datasheet for more info on this instruction. http://www.ece.vt.edu/cel/ece2504/PIC_Guide_v1.5.pdf page 8 goes into detail about a>b and if statements, but i think you're on the right track.