Greater than 0FFh Addresses!!

Status
Not open for further replies.

Suraj143

Active Member
I want to save a bank2 GP Register address ex: 110h in a register & later time i want to move that address to fsr.

Movlw 110h
movwf STORE

mplab says argument is out of range.
 
I want to save a bank2 GP Register address ex: 110h in a register & later time i want to move that address to fsr.

Movlw 110h
movwf STORE


mplab says argument is out of range.
hi,
110h is decimal 272d, so its too big for a BYTE. max 255.
 
I want to save a bank2 GP Register address ex: 110h in a register & later time i want to move that address to fsr.

Movlw 110h
movwf STORE

mplab says argument is out of range.

That's because the register address (in this case) is 0x10 and NOT 0x110 - the extra one is just added to signify that it's in a different bank.

As Eric said, you can't store values higher than 0xFF (255 dec) in a byte.
 
Hi Siraj143,

Storing a 9 bit GPR/SFR address will require two bytes. When you use that address value for setting up an indirect address you will copy the least significant 8 bits of the address to the FSR register and copy the 9th most significant bit of the address to the IRP bit of the STATUS register. The IRP bit specifies if the 8-bit address in FSR is located in bank 0-1 or in bank 2-3.

Regards, Mike
 
Last edited:
Hi thanks for the replies guys

Mike thats what I needed.

Here how I clear registers in B2 & 3.Is this ok?I use PIC16F877A.

Code:
		bsf	STATUS,IRP			; bit 7 of STATUS
Clear_RAM_B2	movlw	0x10		; 110h
		movwf	FSR
		movlw	.96
		movwf	Counter
		call	Clear_RAM_Loop
Clear_RAM_B3	movlw	0x90		; 190h
		movwf	FSR
		movlw	.96
		movwf	Counter
		call	Clear_RAM_Loop
		bcf	STATUS,IRP			; bit 7 of STATUS
		return

Clear_RAM_Loop	clrf	INDF
		incf	FSR,F
		decfsz	Counter,F
		goto	Clear_RAM_Loop
		return
 
Last edited:
That looks like it will work fine.

You could make it smaller by doing,
Code:
	bsf	STATUS,IRP	;banks 2 & 3
	movlw	0x10		;start at 0x110
	movwf	FSR
ClrLoop	clrf	INDF		;clear bank 2
	bsf	FSR,7		;move to back 3
	clrf	INDF		;clear bank 3
	bcf	FSR,7		;back to bank 2
	incf	FSR,f		;move to next location
	movlw	0x70		;end of bank 2 & 3
	xorwf	FSR,w		;reached end yet?
	btfss	STATUS,Z
	goto	ClrLoop		;no, so loop
Mike.
 
Hi Suraj143,

Would this work for you? Is it ok to clear 170..17F and 1F0..1FF ranges in your application?

Regards, Mike
Code:
        bsf     STATUS,IRP      ; banks 2-3
        movlw   0x90            ;
clr     movwf   FSR             ;
        clrf    INDF            ; clear 0x190..0x1FF
        bcf     FSR,7           ;
        clrf    INDF            ; clear 0x110..0x17F
        addlw   1               ;
        skpz                    ;
        goto    clr             ;
 
Last edited:

That's cheating, it clears the common are as well.

Mike.
 
Last edited:
Is there any reason not to clear the "common" RAM area? The routine is smaller and faster even though it's clearing more RAM.

If Suraj is using a 12-bit core device it won't work because there's no addlw instruction. It would have to be rewritten using one additional word (10 words instead of 9 words)...
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…