> YeYo wrote: > > I have a program coded for the PIC16C84/16F84, and at this point I > want to set a bit in a GRP PIC RAM Register. I have others 2 registers > declared at the start: > > ByteCounter EQU 0x2d ; Here I store the address I want to modify. > BitCounter EQU 0x2e ; Here I store the bit number I want to set. > Temporal EQU 0x2f ; Temp register. > Let's assume ByteCounter has the value 0x0c, and BitCounter has the > value 4. In this case all I want is to set to 1 the bit 4 of the > register located at address 0x0c. Please, can you tell me if the > following piece of code is correct? > > ; First I extract the content of the address pointed by ByteCounter to > Temporal, and set the bit. > First you declare Bytecounter and Bitcounter as registers, then you carry on using them as if they are literals. I take it you want to use the value in the register. Thus: > movlw ByteCounter ; W=0ch. Should be: movf Bytecounter,w > movwf FSR ; FSR=Point to the address of > W. > movfw INDF ; W=Store the content of the > pointed address. no such command, should be: movf INDF,w > movwf Temporal ; Temporal=W. > bsf Temporal,BitCounter ; Set the bit 4 of Temporal > register. Here you got another problem, BitCounter here stands for a literal as you cannot use a register in such a way. Rather 'OR' the two using IORWF. Replace the above two line with: iorwf BitCounter,w movwf Temporial > > ; Once the bit is set, let's store the content of Temporal to the > address pointed by ByteCounter (0x0c in this case) > > movlw ByteCounter ; W=0ch. Repair the same as above. > movwf FSR ; FSR=Point to the address of > W. > movfw Temporal ; W=Temporal. Repair the same as above. > movwf INDF ; Store W inside the address > pointed. Hope it helps Quentin