Jump to content

16f88 asm question


mess
 Share

Recommended Posts

Hi,

I'm working on a small 16f88 project in assembler

using the speakjet code as template...

*Can someone explain the use of SWITCHBANK_...?

I understand the banked system with pic18f... with BANKSEL variable

but I don't know when to switch banks with a 16f88

my variable declarations:

shared_ram		udata_shr
W_TMP			res	1
STATUS_TMP		res	1
FSR_TMP			res	1

gpr0			udata
NOISE			res 3
TMP1			res 1
...and the code without switches
IRQ_Handler_NoiseInt
	;; noise generator
	;; new bit = b18 exor b13
	;; shift NOISE one to the left, insert new bit as LSB
	; TMP1 = NOISE >> 2
	rrf		NOISE, W
	rrf		WREG, W
	movwf	TMP1
	; WREG = NOISE+1 >> 4
	rrf		(NOISE+1), W
	swapf	WREG, W
	; WREG = WREG exor TMP1
	xorwf	TMP1, W
	; carry = LSB of WREG
	rrf		WREG, W
	; three byte shift register
	rlf		(NOISE+2), f
	rlf		(NOISE+1), f
	rlf		NOISE, f

	; ouput new shift register value to RA2
        ; the output value is in the carry flag from last shift
	bc		IRQ_Handler_NoiseInt_Out_1
        bcf		PORTA, 2
	goto	IRQ_Handler_NoiseInt_End
IRQ_Handler_NoiseInt_Out_1
	bsf		PORTA, 2
IRQ_Handler_NoiseInt_End
	goto IRQ_End

*I also get a assembler error on WREG (symbol not defined)

does anybody knows how to solve this?

  Michaël

Link to comment
Share on other sites

I'm not 100% sure how/why it works, but I know the 16F8* doesn't have a W register SFR. Hopefully someone can explain wtf that's all about, obviously the W register exists, but F&^ if I know why it can't be directly addressed....

In short you'll have to MOVWF your data to a variable and do the bitshift there.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...