<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Kernighan &amp; Ritchie Book &#8211; £20</title>
	<atom:link href="http://blog.james.walms.co.uk/2006/10/19/kernighan-ritchie-book/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.james.walms.co.uk/2006/10/19/kernighan-ritchie-book/</link>
	<description>James Walmsley&#039;s Blog</description>
	<lastBuildDate>Thu, 01 Apr 2010 09:15:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: James (me)</title>
		<link>http://blog.james.walms.co.uk/2006/10/19/kernighan-ritchie-book/comment-page-1/#comment-19</link>
		<dc:creator>James (me)</dc:creator>
		<pubDate>Mon, 23 Oct 2006 17:33:36 +0000</pubDate>
		<guid isPermaLink="false">http://worm.me.uk/2006/10/19/kernighan-ritchie-book-%c2%a320/#comment-19</guid>
		<description>; task3.asm
; by James Walmsley

	include&quot;P16F877.INC&quot;		;include the pic 16f877 assembly definitions

TIMREG	EQU	H&#039;0020&#039;		;set the timreg funtion to reside in register 20
TIMREG1	EQU	H&#039;0021&#039;		;set the timreg1 funtion to reside in register 21
CNTREG	EQU	H&#039;0022&#039;		;set counter to register 22


delval	EQU	H&#039;00FF&#039;		; set time delay value to 255
delval1	EQU	H&#039;00FF&#039;		; set time delay1 to 255

	banksel	TRISD		; change reagister bank
	clrf	PORTD		; make PORTD output
	banksel	PORTD		; select portd



start	movlw	0		; mov 0 value into Working register (w)
	movwf	CNTREG		; move 0 to Counter
	movwf	PORTD		;clear LEDs on PORTD

loop	movfw	CNTREG
	call	table		; update leds by incrementing them
	movwf	PORTD		; move W to Port D
	call	counter		; Call counter routine
	call	delay		; call delay subroutine
;	nop			; do nothign for a clock cycle
				; except increment the program counter by 1

	goto	loop		; go back to loop lable

delay	movlw	delval		; load w with the delay time value
	movwf	TIMREG		; put value into register
time	call	delay1		; goto next delay routine
	decfsz	TIMREG,f	; subtract 1 and skip to next instruction if is zero
	goto	time		; go back and take off another 1 till 0
	return

delay1	movlw	delval1		; load w with the delay time value
	movwf	TIMREG1		; put value into register
time1	decfsz	TIMREG1,f	; subtract 1 and skip to next instruction if is zero
	goto	time1		; go back and take off another 1 till 0
	return

table	addwf	PCL		;add the W to the Program counter to point to 1st item in table
	retlw	H&#039;0008&#039;		; Hex code to display a 0 shape
	retlw	H&#039;001B&#039;		; Hex code to display a 1 shape
	retlw	H&#039;0014&#039;		; Hex code to display a 2 shape
	retlw	H&#039;0004&#039;		; Hex code to display a 3 shape
	retlw	H&#039;0008&#039;		; Hex code to display a 4 shape
	retlw	H&#039;0010&#039;		; Hex code to display a 5 shape
	retlw	H&#039;0002&#039;		; Hex code to display a 6 shape
	retlw	H&#039;0040&#039;		; Hex code to display a 7 shape
	retlw	H&#039;0000&#039;		; Hex code to display a 8 shape
	retlw	H&#039;00F0&#039;		; Hex code to display a 9 shape
	

counter	movfw	CNTREG		; move current value of counter to W reg
	addlw	1		; add 1 to working reg
	movwf	CNTREG		; mov w to cntreg
	return			; return to main program

	end</description>
		<content:encoded><![CDATA[<p>; task3.asm<br />
; by James Walmsley</p>
<p>	include&#8221;P16F877.INC&#8221;		;include the pic 16f877 assembly definitions</p>
<p>TIMREG	EQU	H&#8217;0020&#8242;		;set the timreg funtion to reside in register 20<br />
TIMREG1	EQU	H&#8217;0021&#8242;		;set the timreg1 funtion to reside in register 21<br />
CNTREG	EQU	H&#8217;0022&#8242;		;set counter to register 22</p>
<p>delval	EQU	H&#8217;00FF&#8217;		; set time delay value to 255<br />
delval1	EQU	H&#8217;00FF&#8217;		; set time delay1 to 255</p>
<p>	banksel	TRISD		; change reagister bank<br />
	clrf	PORTD		; make PORTD output<br />
	banksel	PORTD		; select portd</p>
<p>start	movlw	0		; mov 0 value into Working register (w)<br />
	movwf	CNTREG		; move 0 to Counter<br />
	movwf	PORTD		;clear LEDs on PORTD</p>
<p>loop	movfw	CNTREG<br />
	call	table		; update leds by incrementing them<br />
	movwf	PORTD		; move W to Port D<br />
	call	counter		; Call counter routine<br />
	call	delay		; call delay subroutine<br />
;	nop			; do nothign for a clock cycle<br />
				; except increment the program counter by 1</p>
<p>	goto	loop		; go back to loop lable</p>
<p>delay	movlw	delval		; load w with the delay time value<br />
	movwf	TIMREG		; put value into register<br />
time	call	delay1		; goto next delay routine<br />
	decfsz	TIMREG,f	; subtract 1 and skip to next instruction if is zero<br />
	goto	time		; go back and take off another 1 till 0<br />
	return</p>
<p>delay1	movlw	delval1		; load w with the delay time value<br />
	movwf	TIMREG1		; put value into register<br />
time1	decfsz	TIMREG1,f	; subtract 1 and skip to next instruction if is zero<br />
	goto	time1		; go back and take off another 1 till 0<br />
	return</p>
<p>table	addwf	PCL		;add the W to the Program counter to point to 1st item in table<br />
	retlw	H&#8217;0008&#8242;		; Hex code to display a 0 shape<br />
	retlw	H&#8217;001B&#8217;		; Hex code to display a 1 shape<br />
	retlw	H&#8217;0014&#8242;		; Hex code to display a 2 shape<br />
	retlw	H&#8217;0004&#8242;		; Hex code to display a 3 shape<br />
	retlw	H&#8217;0008&#8242;		; Hex code to display a 4 shape<br />
	retlw	H&#8217;0010&#8242;		; Hex code to display a 5 shape<br />
	retlw	H&#8217;0002&#8242;		; Hex code to display a 6 shape<br />
	retlw	H&#8217;0040&#8242;		; Hex code to display a 7 shape<br />
	retlw	H&#8217;0000&#8242;		; Hex code to display a 8 shape<br />
	retlw	H&#8217;00F0&#8242;		; Hex code to display a 9 shape</p>
<p>counter	movfw	CNTREG		; move current value of counter to W reg<br />
	addlw	1		; add 1 to working reg<br />
	movwf	CNTREG		; mov w to cntreg<br />
	return			; return to main program</p>
<p>	end</p>
]]></content:encoded>
	</item>
</channel>
</rss>
