<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>6502 &#8211; Retro Computing</title>
	<atom:link href="http://retro.hansotten.nl/tag/6502/feed/" rel="self" type="application/rss+xml" />
	<link>http://retro.hansotten.nl</link>
	<description>About small SBC systems</description>
	<lastBuildDate>Wed, 26 Aug 2020 07:11:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>http://retro.hansotten.nl/wp-content/uploads/2020/10/cropped-kim1-as-32x32.jpg</url>
	<title>6502 &#8211; Retro Computing</title>
	<link>http://retro.hansotten.nl</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Enhanced 6502 BASIC</title>
		<link>http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/enhanced-6502-basic/</link>
		
		<dc:creator><![CDATA[hanso]]></dc:creator>
		<pubDate>Sat, 08 Jul 2017 12:11:30 +0000</pubDate>
				<category><![CDATA[6502]]></category>
		<guid isPermaLink="false">http://retro.hansotten.nl/?page_id=2474</guid>

					<description><![CDATA[Enhanced BASIC is a BASIC interpreter for the 6502 and compatible microprocessors. It is constructed to be quick and powerful and easily ported to most 6502 systems. It requires few resources to run and includes instructions to facilitate easy low level handling of hardware devices. It also retains most of the powerful high level instructions [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a href="http://retro.hansotten.nl/wp-content/uploads/2017/07/startup.png" data-wpel-link="internal"><img fetchpriority="high" decoding="async" class="alignright size-medium wp-image-2481" src="http://retro.hansotten.nl/wp-content/uploads/2017/07/startup-300x225.png" alt="" width="300" height="225" srcset="http://retro.hansotten.nl/wp-content/uploads/2017/07/startup-300x225.png 300w, http://retro.hansotten.nl/wp-content/uploads/2017/07/startup-1x1.png 1w, http://retro.hansotten.nl/wp-content/uploads/2017/07/startup.png 320w" sizes="(max-width: 300px) 100vw, 300px" /></a>Enhanced BASIC is a BASIC interpreter for the 6502 and compatible microprocessors. It is constructed to be quick and powerful and easily ported to most 6502 systems. It requires few resources to run and includes instructions to facilitate easy low level handling of hardware devices. It also retains most of the powerful high level instructions from similar BASICs.</p>
<p>EhBASIC represents hundreds of hours work over nearly three years, lots of frustration, lots of joy and the occasional twinge from RSI induced tendonitis.</p>
<p>EhBASIC is free but not copyright free. For non commercial use there is only one restriction, any derivative work should include, in any binary image distributed, the string &#8220;Derived from EhBASIC&#8221; and in any distribution that includes human readable files a file that includes the above string in a human readable form e.g. not as a comment in</p>
<ul>
<li><a href="http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/enhanced-6502-basic/update-ehbasic/" data-wpel-link="internal">Update</a></li>
<li><a href="http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/enhanced-6502-basic/ehbasic-requirements/" data-wpel-link="internal">Requirements</a></li>
<li><a href="http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/enhanced-6502-basic/ehbasic-language-reference/" data-wpel-link="internal">Language reference</a></li>
<li><a href="http://retro.hansotten.nl/uploads/leedavison/Enhanced_6502_BASIC_reference_manual.pdf" data-wpel-link="internal">EhBASIC reference manual in PDF format</a></li>
<li><a href="http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/enhanced-6502-basic/how-to-use-ehbasic/" data-wpel-link="internal">How to use</a></li>
<li><a href="http://retro.hansotten.nl/6502-sbc/starting-ehbasic/" data-wpel-link="internal">Starting BASIC</a></li>
<li><a href="http://retro.hansotten.nl/6502-sbc/advanced-ehbasic-techniques/" data-wpel-link="internal">Advanced techniques</a></li>
<li><a href="http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/enhanced-6502-basic/ehbasic-extending-call/" data-wpel-link="internal">Extending CALL</a></li>
<li><a href="http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/enhanced-6502-basic/ehbasic-using-usr/" data-wpel-link="internal">Using USR()</a></li>
<li><a href="http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/enhanced-6502-basic/ehbasic-useful-routines/" data-wpel-link="internal">Useful routines</a></li>
<li><a href="http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/enhanced-6502-basic/ehbasic-internals/" data-wpel-link="internal">Internals</a></li>
<li><a href="http://retro.hansotten.nl/uploads/leedavison/ehbasicsourc209e.zip" data-wpel-link="internal">Download version 2.09</a></li>
<li><a href="http://retro.hansotten.nl/uploads/leedavison/6502_EhBASIC_V2.22-master.zip" data-wpel-link="internal">Download the latest original version 2.22, with some extra information by Klaus Dormann, fixing bugs </a></li>
<li><a href="http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/enhanced-6502-basic/ehbasic-bug-ibuffs-location/" data-wpel-link="internal">EhBASIC bug Ibuffs location</a></li>
<li><a href="https://github.com/jefftranter/6502/tree/master/asm/ehbasic" data-wpel-link="external">Jeff trantor made a CC65 assemblerversion of EhBASIC 2.22 for the Apple 1 and OSI 1P</a></li>
<li><a href="http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/enhanced-6502-basic/ehbasic-load-and-save-notes/" data-wpel-link="internal">Notes on LOAD and SAVE</a></li>
</ul>
<p>With the change to v2.xx a lot of the details for the use and internal working of EhBASIC have changed!</p>
<!-- relpost-thumb-wrapper --><div class="relpost-thumb-wrapper"><!-- filter-class --><div class="relpost-thumb-container"><style>.relpost-block-single-image, .relpost-post-image { margin-bottom: 10px; }</style><h3>See also:</h3><div style="clear: both"></div><div style="clear: both"></div><!-- relpost-block-container --><div class="relpost-block-container relpost-block-column-layout" style="--relposth-columns: 3;--relposth-columns_t: 2; --relposth-columns_m: 2"><a href="http://retro.hansotten.nl/6502-sbc/kim-1-manuals-and-software/kim-1-related-hardware/terc-kim-1-interface-set/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2026/05/20260524_150837-scaled.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">TERC KIM-1 Interface set</h2><div class="relpost_card_exerpt">A recent acquisition, the TERC (Technical Education Research Centers) KIM-1 Interface set. An educational tool to work w...</div></div></div></a><a href="http://retro.hansotten.nl/what-cpu-is-this-6502-and-other-component-testers/6502-tester-nmos-cmos-1-8mhz/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2026/05/6502testers1.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">6502 tester NMOS CMOS 1-8MHz</h2><div class="relpost_card_exerpt">The 6502 W65C02 6502C CPU tester NMOS / CMOS 1-8MHz is a CPU tester for 40 pin 6502/65C02 and WD65C02 and Sally. 

The...</div></div></div></a><a href="http://retro.hansotten.nl/what-cpu-is-this-6502-and-other-component-testers/20901-2/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2026/05/mc6800mcs6502.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">680x/650x Test system</h2><div class="relpost_card_exerpt">The 680x/650x Test system allows to test, with the CPU itself performing the test, the MC680X and MCS650X families.

T...</div></div></div></a><a href="http://retro.hansotten.nl/what-cpu-is-this-6502-and-other-component-testers/backbit-chip-tester-pro-v2/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2025/11/chip-tester-pro-6530.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">Backbit Chip Tester PRO V2</h2><div class="relpost_card_exerpt">A simple tio use and effective component test and ROM dump can be done with the wonderful Backbit Chiptester Pro V2.

...</div></div></div></a></div><!-- close relpost-block-container --><div style="clear: both"></div></div><!-- close filter class --></div><!-- close relpost-thumb-wrapper -->]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Some code bits</title>
		<link>http://retro.hansotten.nl/6502-sbc/lee-davison-web-site/some-code-bits/</link>
		
		<dc:creator><![CDATA[hanso]]></dc:creator>
		<pubDate>Wed, 31 Aug 2016 18:03:51 +0000</pubDate>
				<category><![CDATA[6502]]></category>
		<guid isPermaLink="false">http://retro.hansotten.nl/?page_id=1855</guid>

					<description><![CDATA[So you have a need, a need for a particular routine. Well it just may be here. Square calculator Calculates a 16-bit unsigned integer square Root calculator Calculates the 8-bit root of a 16-bit integer Ring buffer Setting up an interrupt serviced buffer Pseudo random Generating 8-bit pseudo random numbers Square Calculator This routine calculates [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>So you have a need, a need for a particular routine. Well it just may be here.</p>
<ul>
<li><a href="#square">Square calculator</a> Calculates a 16-bit unsigned integer square</li>
<li><a href="#root">Root calculator</a> Calculates the 8-bit root of a 16-bit integer</li>
<li><a href="#buffer">Ring buffer</a> Setting up an interrupt serviced buffer</li>
<li><a href="#prng">Pseudo random</a> Generating 8-bit pseudo random numbers</li>
</ul>
<p><a name="square"></a></p>
<h3>Square Calculator</h3>
<p>This routine calculates the 16-bit unsigned integer square of a signed 16-bit integer in the range +/-255 (decimal).</p>
<pre class="brush: plain; title: ; notranslate">
; by Lee Davison; Calculates the 16 bit unsigned integer square of the signed 
; 16 bit integer in Numberl/Numberh.
; The result is always in the range 0 to 65025 and is held in Squarel/Squareh
;
; The maximum input range is only +/-255 and no checking is done to ensure that
; this is so.
;
; This routine is useful if you are trying to draw circles as for any circle
;
; x^2+y^2=r^2 where x and y are the co-ordinates of any point on the circle and
; r is the circle radius
;
; Destroys all registers

	.ORG	8000		; these must be in RAM

Numberl				; number to square low byte
Numberh	= Numberl+		; number to square high byte
	.word $FFFF

Squarel				; square low byte
Squareh	= Squarel+1		; square high byte
	.word $FFFF

Tempsq				; temp byte for intermediate result
	.byte $00

	.ORG	8192		; any address will do

Square
	LDA	#$00		; clear A
	STA	Squarel		; clear square low byte
				; (the high byte gets shifted out)
	LDA	Numberl		; get number low byte
	LDX	Numberh		; get number high byte
	BPL	NoNneg		; if +ve don't negate it
				; else do a two's complement
	EOR	#$FF		; invert
	SEC			; +1
	ADC	#$00		; and add it

NoNneg:
	STA	Tempsq		; save ABS(number)
	LDX	#$08		; set bit count

Nextr2bit:
	ASL	Squarel		; low byte *2
	ROL	Squareh		; high byte *2+carry from low
	ASL	A		; shift number byte
	BCC	NoSqadd		; don't do add if C = 0
	TAY			; save A
	CLC			; clear carry for add
	LDA	Tempsq		; get number
	ADC	Squarel		; add number^2 low byte
	STA	Squarel		; save number^2 low byte
	LDA	#$00		; clear A
	ADC	Squareh		; add number^2 high byte
	STA	Squareh		; save number^2 high byte
	TYA			; get A back

NoSqadd:
	DEX			; decrement bit count
	BNE	Nextr2bit	; go do next bit
	RTS
</pre>
<p><a name="root"></a></p>
<h3>Square Root Calculator</h3>
<p>This routine calculates the 8-bit integer square root and 9 bit integer remainder of an unsigned 16-bit integer.</p>
<pre class="brush: plain; title: ; notranslate">
; by Lee Davison
; Calculates the 8 bit root and 9 bit remainder of a 16 bit unsigned integer in	
; Numberl/Numberh. The result is always in the range 0 to 255 and is held in
; Root, the remainder is in the range 0 to 511 and is held in Reml/Remh
;
; partial results are held in templ/temph
;
; This routine is the complement to the integer square program.
;
; Destroys A, X registers.

; variables - must be in RAM

Numberl		= $F0		; number to find square root of low byte
Numberh		= Numberl+1	; number to find square root of high byte
Reml		= $F2		; remainder low byte
Remh		= Reml+1	; remainder high byte
templ		= $F4		; temp partial low byte
temph		= templ+1	; temp partial high byte
Root		= $F6		; square root

	*= $8000		; can be anywhere, ROM or RAM

SqRoot
	LDA	#$00		; clear A
	STA	Reml		; clear remainder low byte
	STA	Remh		; clear remainder high byte
	STA	Root		; clear Root
	LDX	#$08		; 8 pairs of bits to do
Loop
	ASL	Root		; Root = Root * 2

	ASL	Numberl		; shift highest bit of number ..
	ROL	Numberh		;
	ROL	Reml		; .. into remainder
	ROL	Remh		;

	ASL	Numberl		; shift highest bit of number ..
	ROL	Numberh		;
	ROL	Reml		; .. into remainder
	ROL	Remh		;

	LDA	Root		; copy Root ..
	STA	templ		; .. to templ
	LDA	#$00		; clear byte
	STA	temph		; clear temp high byte

	SEC			; +1
	ROL	templ		; temp = temp * 2 + 1
	ROL	temph		;

	LDA	Remh		; get remainder high byte
	CMP	temph		; comapre with partial high byte
	BCC	Next		; skip sub if remainder high byte smaller

	BNE	Subtr		; do sub if &amp;amp;lt;&amp;amp;gt; (must be remainder&amp;amp;gt;partial !)

	LDA	Reml		; get remainder low byte
	CMP	templ		; comapre with partial low byte
	BCC	Next		; skip sub if remainder low byte smaller

				; else remainder&amp;amp;gt;=partial so subtract then
				; and add 1 to root. carry is always set here
Subtr
	LDA	Reml		; get remainder low byte
	SBC	templ		; subtract partial low byte
	STA	Reml		; save remainder low byte
	LDA	Remh		; get remainder high byte
	SBC	temph		; subtract partial high byte
	STA	Remh		; save remainder high byte

	INC	Root		; increment Root
Next
	DEX			; decrement bit pair count
	BNE	Loop		; loop if not all done

	RTS
</pre>
<p><a name="buffer"></a></p>
<h3>256-Byte Data Buffer</h3>
<p>This routine is an interrupt serviced 256 byte data buffer for serial ports and the like.<br />
Very similar code was used to supply the stepper motor driver routine with line co-ordinate pairs.<br />
This is not a finished solution, you will need to add your own code to drive the target of the buffer.</p>
<pre class="brush: plain; title: ; notranslate">
; By Lee Davison
; code for an interrupt serviced data buffer. similar code is used to drive
; the XY stepper motors on a plotter with new position information every 5mS
; and also to allow pen up/down movement time of 70mS

; buffer and variables must be in RAM

Buffer				; 256 byte buffer (must start at page edge)
	.ds	$100

BRindx				; buffer read index
	.byte	$00

BWindx				; buffer write index
	.byte	$00

Sendf				; am sending flag
	.byte	$00

WByte				; temp store for the byte to be sent
	.byte	$00

; write the data to the buffer a byte at a time and increment the pointer.
; the routine is called with the byte to write in A. If the interrupt
; device is idle when this routine is called it will wake it up by doing
; a BRK before it exits

; destroys the Y register

; can be ROM or RAM

Incwritb
	STA	WByte		; save byte to write
	LDA	BRindx		; get read index
	SEC			; set carry for subtract
	SBC	BWindx		; subtract write index
	BEQ	Dowrite		; if equal then buffer empty so do write
	CMP	#$02		; need at least n+1 bytes to avoid rollover
	BCC	Incwritb	; loop if no space


				; construct and write data to buffer
Dowrite
	LDY	BWindx		; get write index
	LDA	WByte		; get byte to write
	STA	Buffer,Y	; save it
	INY			; increment index to next byte
	STY	BWindx		; save new write index byte

; now see if the interrupt service routine is already running or if it's
; idle

	LDA	Sendf		; get the sending flag
	BNE	Doingit		; skip call if running
	BRK			; software call to interrupt routine
	NOP			; need this as return from BRK is +1 byte!
	CLI			; enable the interrupts

Doingit
	RTS				

; this is the interrupt service routine. takes a byte a time from the
; buffer and does some thing with it. also sets up the device(s) for
; the next interrupt

; no registers altered

BuffIRQ
	PHA			; save A
	TXA			; copy X
	PHA			; save X
	TYA			; copy Y
	PHA			; save Y

; insert code here to ensure this is the interrupt you want. if it
; isn't then just exit quietly via ResExit the end of the routine

Getnext
	JSR	Increadb	; increment pointer and read byte from buffer
	BCS	ExitIRQ		; branch if no byte to do

; here would be the guts of the routine such as sending the byte to
; the ACIA or a printer port or some other byte device. it will also
; ensure the device is set to generate an interrupt when it's completed
; it's task

	LDA	#$FF		; set byte
	STA	Sendf		; set sending flag
	JMP	ResExit		; restore the registers &amp;amp;amp;amp; exit

				; all done, clear the flag restore the
				; registers &amp;amp;amp;amp; exit
ExitIRQ
	LDA	#$00		; clear byte
	STA	Sendf		; clear sending flag

ResExit
	PLA			; pull Y
	TAY			; restore it
	PLA			; pull X
	TAX			; restore it
	PLA			; restore A
	RTI			; this was an interrupt service request
				; so exit properly

; get byte from the buffer and increment the pointer. If the buffer is empty
; then exit with the carry flag set else exit with carry clear and the byte
; in A

Increadb
	LDY	BRindx		; get buffer read index
	CPY	BWindx		; compare write index
	BEQ	NOktoread	; branch if empty (= sets carry)
	LDA	Buffer,Y	; get byte from buffer
	INY			; increment pointer
	STY	BRindx		; save buffer read index
	CLC			; clear not ok flag

NOktoread
	RTS
</pre>
<p><a name="prng"></a></p>
<h3>6502 8 bit PRNG</h3>
<p>This is a short piece of code that generates a maximal length, 8 bit, pseudo random<br />
number sequence. This routine is no great shakes in the speed stakes, it&#8217;s just a demo of a usefull<br />
technique.</p>
<pre class="brush: plain; title: ; notranslate">
; by Lee Davison
; returns pseudo random 8 bit number in A. Affects A, X and Y.
; (r_seed) is the byte from which the number is generated and MUST be
; initialised to a non zero value or this function will always return
; zero. Also r_seed must be in RAM, you can see why......

rand_8
	LDA	r_seed		; get seed
	AND	#$B8		; mask non feedback bits
				; for maximal length run with 8 bits we need
				; taps at b7, b5, b4 and b3
	LDX	#$05		; bit count (shift top 5 bits)
	LDY	#$00		; clear feedback count
F_loop
	ASL	A		; shift bit into carry
	BCC	bit_clr		; branch if bit = 0

	INY			; increment feedback count (b0 is XOR all the	
				; shifted bits from A)
bit_clr
	DEX			; decrement count
	BNE	F_loop		; loop if not all done

no_clr
	TYA			; copy feedback count
	LSR	A		; bit 0 into Cb
	LDA	r_seed		; get seed back
	ROL	A		; rotate carry into byte
	STA	r_seed		; save number as next seed
	RTS			; done

r_seed
	.byte	1		; prng seed byte (must not be zero)
</pre>
<p><b>Other number lengths</b><br />
A maximal length pseudo random number generator is basically just a shif register with feedback from the later stages to generate the next input bit. The form for a generator of length <i>n</i> with feedback from <i>t</i> is shown below.<br />
<b>Pseudo random sequence generator</b></p>
<p><img decoding="async" title="n length pseudo random sequence generator" src="http://retro.hansotten.nl/wp-content/uploads/2016/08/shift.png" border="1" /></p>
<p>You don&#8217;t have to limit the length to only 8 bits, any number of bits from two upwards will work if you chose the right feedback tap(s). Here is a table of some values.</p>
<table border=1>
<tbody>
<tr>
<td align="CENTER"><b><i>Bits [n]</i></b></td>
<td align="CENTER"><b><i>Tap(s) [t]</i></b></td>
<td align="CENTER"><b><i>Length</i></b></td>
<td align="CENTER"><b><i>Bits [n]</i></b></td>
<td align="CENTER"><b><i>Tap(s) [t]</i></b></td>
<td align="CENTER"><b><i>Length</i></b></td>
</tr>
<tr>
<td align="CENTER">2</td>
<td align="CENTER">1</td>
<td align="RIGHT">3</td>
<td align="CENTER">3</td>
<td align="CENTER">2</td>
<td align="RIGHT">7</td>
</tr>
<tr>
<td align="CENTER">4</td>
<td align="CENTER">3</td>
<td align="RIGHT">15</td>
<td align="CENTER">5</td>
<td align="CENTER">3</td>
<td align="RIGHT">31</td>
</tr>
<tr>
<td align="CENTER">6</td>
<td align="CENTER">5</td>
<td align="RIGHT">63</td>
<td align="CENTER">7</td>
<td align="CENTER">6</td>
<td align="RIGHT">127</td>
</tr>
<tr>
<td align="CENTER"><b>8</b></td>
<td align="CENTER"><b>6,5,4</b></td>
<td align="RIGHT"><b>255 </b></td>
<td align="CENTER">9</td>
<td align="CENTER">5</td>
<td align="RIGHT">511</td>
</tr>
<tr>
<td align="CENTER">10</td>
<td align="CENTER">7</td>
<td align="RIGHT">1023</td>
<td align="CENTER">11</td>
<td align="CENTER">9</td>
<td align="RIGHT">2047</td>
</tr>
<tr>
<td align="CENTER">15</td>
<td align="CENTER">14</td>
<td align="RIGHT">32767</td>
<td align="CENTER"><b>16</b></td>
<td align="CENTER"><b>15,13,4</b></td>
<td align="RIGHT"><b>65535 </b></td>
</tr>
<tr>
<td align="CENTER">17</td>
<td align="CENTER">14</td>
<td align="RIGHT">131071</td>
<td align="CENTER">18</td>
<td align="CENTER">11</td>
<td align="RIGHT">262143</td>
</tr>
<tr>
<td align="CENTER">20</td>
<td align="CENTER">17</td>
<td align="RIGHT">1048575</td>
<td align="CENTER">21</td>
<td align="CENTER">19</td>
<td align="RIGHT">2097151</td>
</tr>
<tr>
<td align="CENTER">22</td>
<td align="CENTER">21</td>
<td align="RIGHT">4194303</td>
<td align="CENTER">23</td>
<td align="CENTER">18</td>
<td align="RIGHT">8388607</td>
</tr>
<tr>
<td align="CENTER"><b>24</b></td>
<td align="CENTER"><b>23,22,17</b></td>
<td align="RIGHT"><b>16777215 </b></td>
<td align="CENTER">25</td>
<td align="CENTER">22</td>
<td align="RIGHT">33554431</td>
</tr>
<tr>
<td align="CENTER">28</td>
<td align="CENTER">25</td>
<td align="RIGHT">268435455</td>
<td align="CENTER">29</td>
<td align="CENTER">27</td>
<td align="RIGHT">536870911</td>
</tr>
<tr>
<td align="CENTER">31</td>
<td align="CENTER">28</td>
<td align="RIGHT">2147483647</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>In the last case, with 31 bits, if you took a new value once a second the sequence<br />
wouldn&#8217;t repeat for over sixty eight years. Even clocked at 1MHz it would still take<br />
over thirty five minutes to cycle through every state.<br />
<b>Faster, shorter method</b><br />
The above pseudo random number generator is known as a Fibonacci generator and, while it works, it turns out there is a much better generator to implement with a microprocessor.</p>
<p><b>Galois pseudo random sequence generator.</b><br />
<img decoding="async" title="n length pseudo random sequence generator" src="http://retro.hansotten.nl/wp-content/uploads/2016/08/tfihs.png" border="1" /></p>
<p>The Galois generator needs only to test the state of one bit and that can be tested after<br />
the shift has been performed. The state of this bit determines whether the feedback term<br />
is exclusive ORed with the result. This single bit test and multiple bit feedback is<br />
easily done as can be seen from the code below.</p>
<pre class="brush: plain; title: ; notranslate">
; returns pseudo random 8 bit number in A. Affects A. (r_seed) is the
; byte from which the number is generated and MUST be initialised to a
; non zero value or this function will always return zero. Also r_seed		
; must be in RAM, you can see why......

rand_8
	LDA	r_seed		; get seed
	ASL			; shift byte
	BCC	no_eor		; branch if no carry

	EOR	#$CF		; else EOR with $CF
no_eor
	STA	r_seed		; save number as next seed
	RTS			; done

r_seed
	.byte	1		; prng seed byte, must not be zero
</pre>
<p>You don&#8217;t have to limit the length to only 8 bits, any number of bits from three upwards will work if you chose the right feedback value. Here is a table of some values that have been chosen to give a feedback value that fits in a byte, this makes implementation on an 8 bit micro as short as possible. For these values bit n is the least significant bit in the value and the tested bit is the bit shifted out from bit 1.</p>
<table>
<tbody>
<tr>
<td align="CENTER" width="10%"><b><i>Bits [n]</i></b></td>
<td align="CENTER" width="20%"><b><i>Feedback</i></b></td>
<td align="CENTER" width="20%"><b><i>Length</i></b></td>
<td align="CENTER" width="10%"><b><i>Bits [n]</i></b></td>
<td align="CENTER" width="20%"><b><i>Feedback</i></b></td>
<td align="CENTER" width="20%"><b><i>Length</i></b></td>
</tr>
<tr>
<td align="CENTER">3</td>
<td align="CENTER">$03</td>
<td align="RIGHT">7</td>
<td align="CENTER">4</td>
<td align="CENTER">$03</td>
<td align="RIGHT">15</td>
</tr>
<tr>
<td align="CENTER">5</td>
<td align="CENTER">$17</td>
<td align="RIGHT">31</td>
<td align="CENTER">6</td>
<td align="CENTER">$27</td>
<td align="RIGHT">63</td>
</tr>
<tr>
<td align="CENTER">7</td>
<td align="CENTER">$4B</td>
<td align="RIGHT">127</td>
<td align="CENTER"><b>8</b></td>
<td align="CENTER"><b>$CF</b></td>
<td align="RIGHT"><b>255 </b></td>
</tr>
<tr>
<td align="CENTER">9</td>
<td align="CENTER">$B7</td>
<td align="RIGHT">511</td>
<td align="CENTER">10</td>
<td align="CENTER">$E7</td>
<td align="RIGHT">1023</td>
</tr>
<tr>
<td align="CENTER">11</td>
<td align="CENTER">$EB</td>
<td align="RIGHT">2047</td>
<td align="CENTER">12</td>
<td align="CENTER">$EB</td>
<td align="RIGHT">4095</td>
</tr>
<tr>
<td align="CENTER">13</td>
<td align="CENTER">$BB</td>
<td align="RIGHT">8191</td>
<td align="CENTER">14</td>
<td align="CENTER">$BB</td>
<td align="RIGHT">16383</td>
</tr>
<tr>
<td align="CENTER">15</td>
<td align="CENTER">$DD</td>
<td align="RIGHT">32767</td>
<td align="CENTER"><b>16</b></td>
<td align="CENTER"><b>$D7</b></td>
<td align="RIGHT"><b>65535 </b></td>
</tr>
<tr>
<td align="CENTER">17</td>
<td align="CENTER">$AF</td>
<td align="RIGHT">131071</td>
<td align="CENTER">18</td>
<td align="CENTER">$E7</td>
<td align="RIGHT">262143</td>
</tr>
<tr>
<td align="CENTER">19</td>
<td align="CENTER">$AF</td>
<td align="RIGHT">524287</td>
<td align="CENTER">20</td>
<td align="CENTER">$F3</td>
<td align="RIGHT">1048575</td>
</tr>
<tr>
<td align="CENTER">21</td>
<td align="CENTER">$B7</td>
<td align="RIGHT">2097151</td>
<td align="CENTER">22</td>
<td align="CENTER">$BB</td>
<td align="RIGHT">4194303</td>
</tr>
<tr>
<td align="CENTER">23</td>
<td align="CENTER">$F3</td>
<td align="RIGHT">8388607</td>
<td align="CENTER"><b>24</b></td>
<td align="CENTER"><b>$DB</b></td>
<td align="RIGHT"><b>16777215 </b></td>
</tr>
<tr>
<td align="CENTER">25</td>
<td align="CENTER">$93</td>
<td align="RIGHT">33554431</td>
<td align="CENTER">26</td>
<td align="CENTER">$B1</td>
<td align="RIGHT">67108863</td>
</tr>
<tr>
<td align="CENTER">27</td>
<td align="CENTER">$B1</td>
<td align="RIGHT">134217727</td>
<td align="CENTER">28</td>
<td align="CENTER">$E1</td>
<td align="RIGHT">268435455</td>
</tr>
<tr>
<td align="CENTER">29</td>
<td align="CENTER">$C3</td>
<td align="RIGHT">536870911</td>
<td align="CENTER">30</td>
<td align="CENTER">$AF</td>
<td align="RIGHT">1073741823</td>
</tr>
<tr>
<td align="CENTER">31</td>
<td align="CENTER">$8B</td>
<td align="RIGHT">2147483647</td>
<td align="CENTER"><b>32</b></td>
<td align="CENTER"><b>$AF</b></td>
<td align="RIGHT"><b>4294967295 </b></td>
</tr>
</tbody>
</table>
<p>This is now the form of sequence generator used to generate values for the RND() function in EhBASIC.</p>
<p><center><i><b>&#8220;The generation of random numbers is too important to be left to chance.&#8221;<br />
</b></i><br />
Robert R. Coveyou.</center></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>65C21, 65C52 IC photos added</title>
		<link>http://retro.hansotten.nl/65c21-65c52-ic-photos-added/</link>
		
		<dc:creator><![CDATA[hanso]]></dc:creator>
		<pubDate>Wed, 09 Sep 2015 11:21:14 +0000</pubDate>
				<category><![CDATA[6502]]></category>
		<guid isPermaLink="false">http://retro.hansotten.nl/65c21-65c52-ic-photos-added</guid>

					<description><![CDATA[Three IC&#8217;s photos added to the gallery of 65XX photo collection: 6C52 two dates and 65C21, all Rockwell. See also:A demo of the new facilities in the KIM-1 Simulator 2.2.1A demo of the new facilities in the KIM-1 Simulator 2.2.1 Scroll, copy paste of the console. New versions of KIM-...KIM-1 connectors: beware the Chinese cheap variants!The [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Three IC&#8217;s photos added to the <a href="http://retro.hansotten.nl/6502-sbc/65xx-ics/" data-wpel-link="internal">gallery of 65XX photo collection</a>: 6C52 two dates and 65C21, all Rockwell.</p>
<p><a href="http://retro.hansotten.nl/wp-content/uploads/2015/05/65c52p3-9304.jpg" data-wpel-link="internal"><img decoding="async" class="alignnone size-full wp-image-1081" src="http://retro.hansotten.nl/wp-content/uploads/2015/05/65c52p3-9304.jpg" alt="65c52p3 9304" width="600" height="182" srcset="http://retro.hansotten.nl/wp-content/uploads/2015/05/65c52p3-9304.jpg 600w, http://retro.hansotten.nl/wp-content/uploads/2015/05/65c52p3-9304-300x91.jpg 300w, http://retro.hansotten.nl/wp-content/uploads/2015/05/65c52p3-9304-3x1.jpg 3w" sizes="(max-width: 600px) 100vw, 600px" /></a><br />
<span id="more-1088"></span><br />
<a href="http://retro.hansotten.nl/wp-content/uploads/2015/05/65c52p3-9334.jpg" data-wpel-link="internal"><img decoding="async" class="alignnone size-full wp-image-1082" src="http://retro.hansotten.nl/wp-content/uploads/2015/05/65c52p3-9334.jpg" alt="65c52p3 9334" width="600" height="186" srcset="http://retro.hansotten.nl/wp-content/uploads/2015/05/65c52p3-9334.jpg 600w, http://retro.hansotten.nl/wp-content/uploads/2015/05/65c52p3-9334-300x93.jpg 300w, http://retro.hansotten.nl/wp-content/uploads/2015/05/65c52p3-9334-3x1.jpg 3w" sizes="(max-width: 600px) 100vw, 600px" /></a></p>
<p><a href="http://retro.hansotten.nl/wp-content/uploads/2015/05/65c21p2-0721.jpg" data-wpel-link="internal"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1084" src="http://retro.hansotten.nl/wp-content/uploads/2015/05/65c21p2-0721.jpg" alt="65c21p2 0721" width="600" height="178" srcset="http://retro.hansotten.nl/wp-content/uploads/2015/05/65c21p2-0721.jpg 600w, http://retro.hansotten.nl/wp-content/uploads/2015/05/65c21p2-0721-300x89.jpg 300w, http://retro.hansotten.nl/wp-content/uploads/2015/05/65c21p2-0721-3x1.jpg 3w"  sizes="(max-width: 600px) 100vw, 600px" /></a></p>
<!-- relpost-thumb-wrapper --><div class="relpost-thumb-wrapper"><!-- filter-class --><div class="relpost-thumb-container"><style>.relpost-block-single-image, .relpost-post-image { margin-bottom: 10px; }</style><h3>See also:</h3><div style="clear: both"></div><div style="clear: both"></div><!-- relpost-block-container --><div class="relpost-block-container relpost-block-column-layout" style="--relposth-columns: 3;--relposth-columns_t: 2; --relposth-columns_m: 2"><a href="http://retro.hansotten.nl/kim-1-simulator-2-2-0/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2026/05/pastescroll.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">A demo of the new facilities in the KIM-1 Simulator 2.2.1</h2><div class="relpost_card_exerpt">A demo of the new facilities in the KIM-1 Simulator 2.2.1 

Scroll, copy paste of the console.

New versions of KIM-...</div></div></div></a><a href="http://retro.hansotten.nl/kim-1-connectors-beware-the-chinese-cheap-variants/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2025/09/307-044-500-202.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">KIM-1 connectors: beware the Chinese cheap variants!</h2><div class="relpost_card_exerpt">The KIM-1 needs 2 edge connectors.

The specifications are: card edge; PIN: 44; 3.96mm 

When you search for those, ...</div></div></div></a><a href="http://retro.hansotten.nl/magazines-compute-and-compute-ii/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2025/09/best-of-micro2-front.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">Magazines: Compute! and Compute II</h2><div class="relpost_card_exerpt">The pages om Magazines had an update.

MICRO has its own page with all Best of MICRO pfds.
Compute! and Compute II ar...</div></div></div></a><a href="http://retro.hansotten.nl/mtu-documents-update/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2025/07/k10085c2025-07-06-0001s.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">All documents in the MTU pages are now clean and higher quality, about 50 new PDFs.</h2><div class="relpost_card_exerpt">I got hold a about 10 cm of MTU documents. Several I already had in PDF format, some not available yet.
I took the oppo...</div></div></div></a></div><!-- close relpost-block-container --><div style="clear: both"></div></div><!-- close filter class --></div><!-- close relpost-thumb-wrapper -->]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Gallery of 65XX IC photos</title>
		<link>http://retro.hansotten.nl/gallery-of-65xx-ic-photos/</link>
		
		<dc:creator><![CDATA[hanso]]></dc:creator>
		<pubDate>Mon, 01 Jun 2015 12:16:47 +0000</pubDate>
				<category><![CDATA[6502]]></category>
		<guid isPermaLink="false">http://retro.hansotten.nl/gallery-of-65xx-ic-photos</guid>

					<description><![CDATA[My drawer is full with a supply of 65XX IC&#8217;s. Some bought, some donated, some salvaged. From old to quite recent. See also:A demo of the new facilities in the KIM-1 Simulator 2.2.1A demo of the new facilities in the KIM-1 Simulator 2.2.1 Scroll, copy paste of the console. New versions of KIM-...KIM-1 connectors: beware [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>My drawer is full with a supply of <a href="http://retro.hansotten.nl/6502-sbc/65xx-ics/" data-wpel-link="internal">65XX IC&#8217;</a>s. Some bought, some donated, some salvaged. From old to quite recent.</p>
<p><a href="http://retro.hansotten.nl/6502-sbc/65xx-ics/" data-wpel-link="internal"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-832" src="http://retro.hansotten.nl/wp-content/uploads/2015/05/6520-7715.jpg" alt="6520 7715" width="600" height="194" srcset="http://retro.hansotten.nl/wp-content/uploads/2015/05/6520-7715.jpg 600w, http://retro.hansotten.nl/wp-content/uploads/2015/05/6520-7715-300x97.jpg 300w, http://retro.hansotten.nl/wp-content/uploads/2015/05/6520-7715-3x1.jpg 3w"  sizes="(max-width: 600px) 100vw, 600px" /></a></p>
<!-- relpost-thumb-wrapper --><div class="relpost-thumb-wrapper"><!-- filter-class --><div class="relpost-thumb-container"><style>.relpost-block-single-image, .relpost-post-image { margin-bottom: 10px; }</style><h3>See also:</h3><div style="clear: both"></div><div style="clear: both"></div><!-- relpost-block-container --><div class="relpost-block-container relpost-block-column-layout" style="--relposth-columns: 3;--relposth-columns_t: 2; --relposth-columns_m: 2"><a href="http://retro.hansotten.nl/kim-1-simulator-2-2-0/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2026/05/pastescroll.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">A demo of the new facilities in the KIM-1 Simulator 2.2.1</h2><div class="relpost_card_exerpt">A demo of the new facilities in the KIM-1 Simulator 2.2.1 

Scroll, copy paste of the console.

New versions of KIM-...</div></div></div></a><a href="http://retro.hansotten.nl/kim-1-connectors-beware-the-chinese-cheap-variants/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2025/09/307-044-500-202.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">KIM-1 connectors: beware the Chinese cheap variants!</h2><div class="relpost_card_exerpt">The KIM-1 needs 2 edge connectors.

The specifications are: card edge; PIN: 44; 3.96mm 

When you search for those, ...</div></div></div></a><a href="http://retro.hansotten.nl/magazines-compute-and-compute-ii/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2025/09/best-of-micro2-front.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">Magazines: Compute! and Compute II</h2><div class="relpost_card_exerpt">The pages om Magazines had an update.

MICRO has its own page with all Best of MICRO pfds.
Compute! and Compute II ar...</div></div></div></a><a href="http://retro.hansotten.nl/mtu-documents-update/" class="relpost-block-single" data-wpel-link="internal"><div class="relpost-custom-block-single"><div class="relpost-block-single-image rpt-lazyload" aria-hidden="true" role="img" data-bg="http://retro.hansotten.nl/wp-content/uploads/2025/07/k10085c2025-07-06-0001s.jpg" style="background: transparent no-repeat scroll 0% 0%; width: 150px; height: 150px; aspect-ratio: 1/1;"></div><div class="relpost-block-single-text"  style="height: 125px;font-family: Arial;  font-size: 12px;  color: #333333;"><h2 class="relpost_card_title">All documents in the MTU pages are now clean and higher quality, about 50 new PDFs.</h2><div class="relpost_card_exerpt">I got hold a about 10 cm of MTU documents. Several I already had in PDF format, some not available yet.
I took the oppo...</div></div></div></a></div><!-- close relpost-block-container --><div style="clear: both"></div></div><!-- close filter class --></div><!-- close relpost-thumb-wrapper -->]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
