<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.intellivision.us/index.php?action=history&amp;feed=atom&amp;title=Sqrt.asm</id>
		<title>Sqrt.asm - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.intellivision.us/index.php?action=history&amp;feed=atom&amp;title=Sqrt.asm"/>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Sqrt.asm&amp;action=history"/>
		<updated>2026-04-17T19:53:32Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://wiki.intellivision.us/index.php?title=Sqrt.asm&amp;diff=14907&amp;oldid=prev</id>
		<title>Mr z: Protected &quot;Sqrt.asm&quot; ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite))</title>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Sqrt.asm&amp;diff=14907&amp;oldid=prev"/>
				<updated>2010-12-04T09:26:14Z</updated>
		
		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/index.php/Sqrt.asm&quot; title=&quot;Sqrt.asm&quot;&gt;Sqrt.asm&lt;/a&gt;&amp;quot; ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite))&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 09:26, 4 December 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Mr z</name></author>	</entry>

	<entry>
		<id>http://wiki.intellivision.us/index.php?title=Sqrt.asm&amp;diff=2949&amp;oldid=prev</id>
		<title>Mr z: /* Notes */</title>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Sqrt.asm&amp;diff=2949&amp;oldid=prev"/>
				<updated>2008-09-06T21:02:18Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Notes&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 21:02, 6 September 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l16&quot; &gt;Line 16:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 16:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Notes =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Notes =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Unlike the square-root code in the EXEC, this code works over the entire range $0000 to $FFFF.&amp;#160; It is also an order of magnitude faster:&amp;#160; Taking the square root of an integer takes between 600 and 700 cycles, whereas the EXEC's routine has a much wider range, taking nearly 10,000 cycles in some cases.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Unlike the square-root code in the EXEC, this code works over the entire range $0000 to $FFFF.&amp;#160; It is also an order of magnitude faster:&amp;#160; Taking the square root of an integer takes between 600 and 700 cycles, whereas the EXEC's routine has a much wider range, taking nearly 10,000 cycles in some cases&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;.&amp;#160; In fact, the worst case performance for a square root is roughly a third faster than the worst case performance of [[fastdivu.asm|FASTDIVU]]&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Where the code below refers to &amp;quot;Qpt&amp;quot; or &amp;quot;Q-point,&amp;quot; this means the same as &amp;quot;fractional point&amp;quot; or &amp;quot;binary point.&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Where the code below refers to &amp;quot;Qpt&amp;quot; or &amp;quot;Q-point,&amp;quot; this means the same as &amp;quot;fractional point&amp;quot; or &amp;quot;binary point.&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mr z</name></author>	</entry>

	<entry>
		<id>http://wiki.intellivision.us/index.php?title=Sqrt.asm&amp;diff=2948&amp;oldid=prev</id>
		<title>Mr z at 20:52, 6 September 2008</title>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Sqrt.asm&amp;diff=2948&amp;oldid=prev"/>
				<updated>2008-09-06T20:52:16Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 20:52, 6 September 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l4&quot; &gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;CENTER&amp;gt;&amp;lt;TABLE BORDER&amp;gt;&amp;lt;TR&amp;gt;&amp;lt;TH&amp;gt;Entry point&amp;lt;/TH&amp;gt;&amp;lt;TH&amp;gt;Function provided&amp;lt;/TH&amp;gt;&amp;lt;TH&amp;gt;Notes&amp;lt;/TH&amp;gt;&amp;lt;/TR&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;CENTER&amp;gt;&amp;lt;TABLE BORDER&amp;gt;&amp;lt;TR&amp;gt;&amp;lt;TH&amp;gt;Entry point&amp;lt;/TH&amp;gt;&amp;lt;TH&amp;gt;Function provided&amp;lt;/TH&amp;gt;&amp;lt;TH&amp;gt;Notes&amp;lt;/TH&amp;gt;&amp;lt;/TR&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;SQRT&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Calculate the square root of a fixed-point number&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Value in register, fractional point (&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Q-point&lt;/del&gt;) in ROM.&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;SQRT&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Calculate the square root of a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[[Fixed Point Arithmetic|&lt;/ins&gt;fixed-point&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]] &lt;/ins&gt;number&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Value in register, fractional point (&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Qpt&lt;/ins&gt;) in ROM.&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;SQRT.1&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Calculate the square root of an integer&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Value in register, fractional point implied to be 0.&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;SQRT.1&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Calculate the square root of an integer&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Value in register, fractional point implied to be 0.&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;SQRT.2&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Calculate the square root of a fixed-point number&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Value and fractional point both in registers&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&amp;lt;/TABLE&amp;gt;&amp;lt;/CENTER&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;SQRT.2&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Calculate the square root of a fixed-point number&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Value and fractional point both in registers&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&amp;lt;/TABLE&amp;gt;&amp;lt;/CENTER&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l17&quot; &gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Unlike the square-root code in the EXEC, this code works over the entire range $0000 to $FFFF.&amp;#160; It is also an order of magnitude faster:&amp;#160; Taking the square root of an integer takes between 600 and 700 cycles, whereas the EXEC's routine has a much wider range, taking nearly 10,000 cycles in some cases.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Unlike the square-root code in the EXEC, this code works over the entire range $0000 to $FFFF.&amp;#160; It is also an order of magnitude faster:&amp;#160; Taking the square root of an integer takes between 600 and 700 cycles, whereas the EXEC's routine has a much wider range, taking nearly 10,000 cycles in some cases.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Where the code below refers to &amp;quot;Qpt&amp;quot; or &amp;quot;Q-point,&amp;quot; this means the same as &amp;quot;fractional point&amp;quot; or &amp;quot;binary point.&amp;quot;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Source Code =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Source Code =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mr z</name></author>	</entry>

	<entry>
		<id>http://wiki.intellivision.us/index.php?title=Sqrt.asm&amp;diff=2944&amp;oldid=prev</id>
		<title>Mr z at 20:47, 6 September 2008</title>
		<link rel="alternate" type="text/html" href="http://wiki.intellivision.us/index.php?title=Sqrt.asm&amp;diff=2944&amp;oldid=prev"/>
				<updated>2008-09-06T20:47:46Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Programming]] [[Category:Library]]&lt;br /&gt;
&lt;br /&gt;
= Functions Provided =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;CENTER&amp;gt;&amp;lt;TABLE BORDER&amp;gt;&amp;lt;TR&amp;gt;&amp;lt;TH&amp;gt;Entry point&amp;lt;/TH&amp;gt;&amp;lt;TH&amp;gt;Function provided&amp;lt;/TH&amp;gt;&amp;lt;TH&amp;gt;Notes&amp;lt;/TH&amp;gt;&amp;lt;/TR&amp;gt;&lt;br /&gt;
&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;SQRT&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Calculate the square root of a fixed-point number&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Value in register, fractional point (Q-point) in ROM.&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;br /&gt;
&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;SQRT.1&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Calculate the square root of an integer&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Value in register, fractional point implied to be 0.&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&lt;br /&gt;
&amp;lt;TR&amp;gt;&amp;lt;TD&amp;gt;SQRT.2&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Calculate the square root of a fixed-point number&amp;lt;/TD&amp;gt;&amp;lt;TD&amp;gt;Value and fractional point both in registers&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;&amp;lt;/TABLE&amp;gt;&amp;lt;/CENTER&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
See source code below for calling convention.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&lt;br /&gt;
(todo... please contribute!)&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
&lt;br /&gt;
Unlike the square-root code in the EXEC, this code works over the entire range $0000 to $FFFF.  It is also an order of magnitude faster:  Taking the square root of an integer takes between 600 and 700 cycles, whereas the EXEC's routine has a much wider range, taking nearly 10,000 cycles in some cases.&lt;br /&gt;
&lt;br /&gt;
= Source Code =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
;* ======================================================================== *;&lt;br /&gt;
;*  These routines are placed into the public domain by their author.  All  *;&lt;br /&gt;
;*  copyright rights are hereby relinquished on the routines and data in    *;&lt;br /&gt;
;*  this file.  -- Joseph Zbiciak, 2008                                     *;&lt;br /&gt;
;* ======================================================================== *;&lt;br /&gt;
&lt;br /&gt;
;; ======================================================================== ;;&lt;br /&gt;
;;  NAME                                                                    ;;&lt;br /&gt;
;;      SQRT        Calculate the square root of a fixed-point number       ;;&lt;br /&gt;
;;      SQRT.1      Calculate the square root of an integer                 ;;&lt;br /&gt;
;;      SQRT.2      Calculate the square root of a fixed-point number       ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  AUTHOR                                                                  ;;&lt;br /&gt;
;;      Joseph Zbiciak &amp;lt;intvnut AT gmail.com&amp;gt;                               ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  REVISION HISTORY                                                        ;;&lt;br /&gt;
;;      12-Sep-2001 Initial revision . . . . . . . . . . .  J. Zbiciak      ;;&lt;br /&gt;
;;      24-Nov-2003 Minor tweaks for speed . . . . . . . .  J. Zbiciak      ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  INPUTS for SQRT                                                         ;;&lt;br /&gt;
;;      R1      Unsigned 16-bit argument to SQRT()                          ;;&lt;br /&gt;
;;      R5      Pointer to DECLE containing Qpt, followed by return addr.   ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  INPUTS for SQRT.1                                                       ;;&lt;br /&gt;
;;      R1      Unsigned 16-bit argument to SQRT()                          ;;&lt;br /&gt;
;;      R5      Return address                                              ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  INPUTS for SQRT.2                                                       ;;&lt;br /&gt;
;;      R0      Qpt for fixed-point value                                   ;;&lt;br /&gt;
;;      R1      Unsigned 16-bit argument to SQRT()                          ;;&lt;br /&gt;
;;      R5      Return address                                              ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  OUTPUTS                                                                 ;;&lt;br /&gt;
;;      R0      Zeroed                                                      ;;&lt;br /&gt;
;;      R1      Unmodified                                                  ;;&lt;br /&gt;
;;      R2      SQRT(R1)                                                    ;;&lt;br /&gt;
;;      R3, R4  Unmodified                                                  ;;&lt;br /&gt;
;;      R5      Trashed                                                     ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  NOTES                                                                   ;;&lt;br /&gt;
;;      The way this code handles odd Q-points on fixed-point numbers is    ;;&lt;br /&gt;
;;      by right-shifting the incoming value 1 bit, thus making the         ;;&lt;br /&gt;
;;      Q-point even.  This has the negative effect of losing precision     ;;&lt;br /&gt;
;;      on odd Q-point numbers.  Rectifying this without losing any         ;;&lt;br /&gt;
;;      performance would require significantly larger codesize.            ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  CODESIZE                                                                ;;&lt;br /&gt;
;;      44 words                                                            ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  CYCLES                                                                  ;;&lt;br /&gt;
;;      cycles = 139 + 71*(8 + Qpt/2) worst case for SQRT                   ;;&lt;br /&gt;
;;      cycles = 121 + 61*(8 + Qpt/2) best case for SQRT                    ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;      Subtract 4 cycles if Qpt is even.                                   ;;&lt;br /&gt;
;;      Subtract 8 cycles if calling SQRT.1.                                ;;&lt;br /&gt;
;;      Subtract 14 cycles if calling SQRT.2.                               ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;  SOURCE                                                                  ;;&lt;br /&gt;
;;      Loosely based on a C code example (mborg_isqrt2) by Paul Hseih and  ;;&lt;br /&gt;
;;      Mark Borgerding, found on the web here:                             ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;          http://www.azillionmonkeys.com/qed/sqroot.html                  ;;&lt;br /&gt;
;;                                                                          ;;&lt;br /&gt;
;;      Includes additional optimizations that eliminate some of the math.  ;;&lt;br /&gt;
;; ======================================================================== ;;&lt;br /&gt;
&lt;br /&gt;
SQRT        PROC&lt;br /&gt;
            MVI@    R5,     R0      ;   8 Get Qpt from after CALL&lt;br /&gt;
            INCR    PC              ;   6 (skip CLRR R0)&lt;br /&gt;
@@1:        CLRR    R0              ;   6 Set Qpt == 0&lt;br /&gt;
@@2:        PSHR    R5              ;   9 Alt entry point w/ all args in regs.&lt;br /&gt;
            PSHR    R1              ;   9 save R1&lt;br /&gt;
            PSHR    R3              ;   9 save R3&lt;br /&gt;
                                    ;----&lt;br /&gt;
                                    ;  41 (worst case: SQRT)&lt;br /&gt;
                                    ;  33 (if SQRT.1)           &lt;br /&gt;
                                    ;  27 (if SQRT.2)          &lt;br /&gt;
                                         &lt;br /&gt;
            CLRR    R2              ;   6 R2 == Result word&lt;br /&gt;
            MVII    #$4000, R3      ;   8 R3 == 1/2 of square of test bit&lt;br /&gt;
            MOVR    R3,     R5      ;   6 R5 == bit * (2*guess + bit)&lt;br /&gt;
                                         &lt;br /&gt;
            INCR    R0              ;   6&lt;br /&gt;
            SARC    R0,     1       ;   6 Check to see if Qpt is odd&lt;br /&gt;
;           BC      @@even_q        ; 7/9&lt;br /&gt;
            ADCR    PC              ;   7&lt;br /&gt;
            SLR     R1,     1       ;   6 Note: We lose LSB if odd Q&lt;br /&gt;
@@even_q:                                &lt;br /&gt;
                                         &lt;br /&gt;
            ADDI    #8,     R0      ;   8&lt;br /&gt;
            B       @@first         ;   9&lt;br /&gt;
                                    ;----&lt;br /&gt;
                                    ;  60 (worst case, q is ODD)&lt;br /&gt;
                                    ;  54 (q is EVEN)            &lt;br /&gt;
                                    ;====&lt;br /&gt;
                                    ;  83 (worst case: SQRT, q is ODD)&lt;br /&gt;
                                         &lt;br /&gt;
@@loop:     SLLC    R1,     1       ;   6 Shift the value left by 1&lt;br /&gt;
            BC      @@b1            ; 7/9 MSB was 1, force guessed bit to 1.&lt;br /&gt;
                                         &lt;br /&gt;
@@first:    CMPR    R5,     R1      ;   6 Is (guess+bit)**2 &amp;lt;= val?&lt;br /&gt;
            BNC     @@b0            ; 7/9 C==0 means the bit should be 0&lt;br /&gt;
                                         &lt;br /&gt;
@@b1:       RLC     R2,     1       ;   6 Yes:  Set bit in result and &lt;br /&gt;
            SUBR    R5,     R1      ;   6       subtract guess from value&lt;br /&gt;
            ADDR    R3,     R5      ;   6 \&lt;br /&gt;
            SLR     R3,     1       ;   6  |-- Calculate next guess value&lt;br /&gt;
            ADDR    R3,     R5      ;   6 /&lt;br /&gt;
            DECR    R0              ;   6&lt;br /&gt;
            BNEQ    @@loop          ; 9/7 Guess next bit&lt;br /&gt;
&lt;br /&gt;
            PULR    R3              ;  11 Restore R3&lt;br /&gt;
            PULR    R1              ;  11 Restore R1&lt;br /&gt;
            PULR    PC              ;  11 Return&lt;br /&gt;
                                    ;----&lt;br /&gt;
                                    ;  71*k + 31 worst case&lt;br /&gt;
                                         &lt;br /&gt;
@@b0:       SLL     R2,     1       ;   6 No:  Clear bit in guessed result&lt;br /&gt;
            SLR     R3,     1       ;   6 \__ Calculate next guess&lt;br /&gt;
            SUBR    R3,     R5      ;   6 /&lt;br /&gt;
            DECR    R0              ;   6&lt;br /&gt;
            BNEQ    @@loop          ; 9/7 Guess next bit&lt;br /&gt;
                                    ;----&lt;br /&gt;
                                    ;  61*k - 2 best case&lt;br /&gt;
&lt;br /&gt;
@@done:     PULR    R3              ;  11 Restore R3&lt;br /&gt;
            PULR    R1              ;  11 Restore R1&lt;br /&gt;
            PULR    PC              ;  11 Return&lt;br /&gt;
            ENDP&lt;br /&gt;
&lt;br /&gt;
;; ======================================================================== ;;&lt;br /&gt;
;;  End of file:  sqrt.asm                                                  ;;&lt;br /&gt;
;; ======================================================================== ;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mr z</name></author>	</entry>

	</feed>