# pic maths - how to enforce 8 bits?

Status
Not open for further replies.

#### kardzzz

##### New Member
My project requires 5 modes. {0-4}, using a 12F683.

I increment a register using ADDWF by 0x34 (dec 52).
My problem is I don't understand what the PIC is doing once it encounter 'dec 260' hence see a 9 bit binary.

52 110100
104 1101000
156 10011100
208 11010000
260 100000100 (9bit)

I don't have a simulator, does, it simply do a 260-255 = 5 and store b'101' ?
How can I force the processor to store a '0' if above 255?

Thanks

#### be80be

##### Well-Known Member
It rolls over once it gets to 255 and starts back at 0. Don't you have Mplab It's free and can simulate your chip.

#### Pommie

##### Well-Known Member
The simplest way to do it is to check the Carry flag.

Code:
		movlw	.52		;add 52 decimal
btfsc	STATUS,C	;gone past 255?
clrf	Var		;yes so variable = 0
Mike.

#### kardzzz

##### New Member
Thanks for your replies, I manage to solve my problem.