<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wikiti.brandonw.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wikiti.brandonw.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Quigibo</id>
		<title>WikiTI - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wikiti.brandonw.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Quigibo"/>
		<link rel="alternate" type="text/html" href="https://wikiti.brandonw.net/index.php?title=Special:Contributions/Quigibo"/>
		<updated>2026-04-05T17:49:13Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>https://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:4012</id>
		<title>83Plus:BCALLs:4012</title>
		<link rel="alternate" type="text/html" href="https://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:4012"/>
				<updated>2010-07-30T06:14:16Z</updated>
		
		<summary type="html">&lt;p&gt;Quigibo: /* Comments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:83Plus:BCALLs:By Name:Math|DivHLByA]] [[Category:83Plus:BCALLs:By Name|DivHLByA]] [[Category:83Plus:BCALLs:By Address|4012 - DivHLByA]]&lt;br /&gt;
== Synopsis ==&lt;br /&gt;
'''Official Name:''' DivHLByA&lt;br /&gt;
&lt;br /&gt;
'''BCALL Address:''' 4012&lt;br /&gt;
&lt;br /&gt;
Divides the value in HL by the value in A.&lt;br /&gt;
&lt;br /&gt;
=== Inputs ===&lt;br /&gt;
* HL: integer&lt;br /&gt;
* A: integer&lt;br /&gt;
&lt;br /&gt;
=== Outputs ===&lt;br /&gt;
* HL = HL / A&lt;br /&gt;
* A = HL mod A&lt;br /&gt;
&lt;br /&gt;
=== Registers Destroyed ===&lt;br /&gt;
* none&lt;br /&gt;
&lt;br /&gt;
== Comments ==&lt;br /&gt;
Simple enough to implement if speed is important.  However, it may return invalid results if A is larger than 127 since the routine does not correctly handle overflows.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
 ld hl,13&lt;br /&gt;
 ld a,5&lt;br /&gt;
 B_CALL DivHLByA  ;should return HL=2, A=3&lt;/div&gt;</summary>
		<author><name>Quigibo</name></author>	</entry>

	<entry>
		<id>https://wikiti.brandonw.net/index.php?title=Category:83Plus:Quirks</id>
		<title>Category:83Plus:Quirks</title>
		<link rel="alternate" type="text/html" href="https://wikiti.brandonw.net/index.php?title=Category:83Plus:Quirks"/>
				<updated>2010-07-21T21:45:01Z</updated>
		
		<summary type="html">&lt;p&gt;Quigibo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
The TI-83+ family of calculators has some interesting quirks in the hardware.&lt;br /&gt;
&lt;br /&gt;
*The calculator will crash if PC is greater than or equal to C000, provided an even-numbered RAM page is swapped in the upper bank. This is the default (page 80h).  This is where the 8kb limit comes from&lt;br /&gt;
*Later models of calculators are missing RAM pages&lt;br /&gt;
*Later models of calculators have a longer LCD delay&lt;br /&gt;
*If a LD A,I or LD A,R instruction is interrupted, then the P/V flag is reset, even if interrupts were enabled beforehand.&lt;/div&gt;</summary>
		<author><name>Quigibo</name></author>	</entry>

	<entry>
		<id>https://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Multiplication</id>
		<title>Z80 Routines:Math:Multiplication</title>
		<link rel="alternate" type="text/html" href="https://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Multiplication"/>
				<updated>2010-07-03T19:33:21Z</updated>
		
		<summary type="html">&lt;p&gt;Quigibo: /* 16*16 multiplication */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Z80 Routines:Math|Multiplication]]&lt;br /&gt;
[[Category:Z80 Routines|Multiplication]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
All these routines use the restoring multiplication algorithm, adapted to the z80 architecture to maximize speed.&lt;br /&gt;
They can easily be unrolled to gain some speed.&lt;br /&gt;
&lt;br /&gt;
== Unsigned versions ==&lt;br /&gt;
&lt;br /&gt;
=== 8*8 multiplication ===&lt;br /&gt;
&lt;br /&gt;
The following routine multiplies h by e and places the result in hl&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
mult_h_e&lt;br /&gt;
   ld	l, 0&lt;br /&gt;
   ld	d, l&lt;br /&gt;
&lt;br /&gt;
   sla	h		; optimised 1st iteration&lt;br /&gt;
   jr	nc, $+3&lt;br /&gt;
   ld	l, e&lt;br /&gt;
   &lt;br /&gt;
   ld b, 7&lt;br /&gt;
_loop:&lt;br /&gt;
   add	hl, hl          &lt;br /&gt;
   jr	nc, $+3&lt;br /&gt;
   add	hl, de&lt;br /&gt;
   &lt;br /&gt;
   djnz	_loop&lt;br /&gt;
   &lt;br /&gt;
   ret&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 16*8 multiplication ===&lt;br /&gt;
&lt;br /&gt;
The following routine multiplies de by a and places the result in ahl (which means a is the most significant byte of the product, l the least significant and h the intermediate one...)&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
mult_a_de&lt;br /&gt;
   ld	c, 0&lt;br /&gt;
   ld	h, c&lt;br /&gt;
   ld	l, h&lt;br /&gt;
&lt;br /&gt;
   add	a, a		; optimised 1st iteration&lt;br /&gt;
   jr	nc, $+4&lt;br /&gt;
   ld	h,d&lt;br /&gt;
   ld	l,e&lt;br /&gt;
&lt;br /&gt;
   ld b, 7&lt;br /&gt;
_loop:&lt;br /&gt;
   add	hl, hl&lt;br /&gt;
   rla&lt;br /&gt;
   jr	nc, $+4&lt;br /&gt;
   add	hl, de&lt;br /&gt;
   adc	a, c            ; yes this is actually adc a, 0 but since c is free we set it to zero and so we can save 1 byte and up to 3 T-states per iteration&lt;br /&gt;
   &lt;br /&gt;
   djnz	_loop&lt;br /&gt;
   &lt;br /&gt;
   ret&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 16*16 multiplication ===&lt;br /&gt;
&lt;br /&gt;
The following routine multiplies bc by de and places the result in dehl.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
mult_de_bc&lt;br /&gt;
   ld	hl, 0&lt;br /&gt;
&lt;br /&gt;
   sla	e		; optimised 1st iteration&lt;br /&gt;
   rl	d&lt;br /&gt;
   jr	nc, $+4&lt;br /&gt;
   ld	h, b&lt;br /&gt;
   ld	l, c&lt;br /&gt;
&lt;br /&gt;
   ld	a, 15&lt;br /&gt;
_loop:&lt;br /&gt;
   add	hl, hl&lt;br /&gt;
   rl	e&lt;br /&gt;
   rl	d&lt;br /&gt;
   jr	nc, $+6&lt;br /&gt;
   add	hl, bc&lt;br /&gt;
   jr	nc, $+3&lt;br /&gt;
   inc	de&lt;br /&gt;
   &lt;br /&gt;
   dec	a&lt;br /&gt;
   jr	nz, _loop&lt;br /&gt;
   &lt;br /&gt;
   ret&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Signed versions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- do the routines later, basically try to use cpu instruction that preserve bit 7 (sign) or if this is not possible, just take the sign out, do the multiplication and give the sign afterwards and accordingly. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 8*8 multiplication ===&lt;br /&gt;
&lt;br /&gt;
=== 16*8 multiplication ===&lt;/div&gt;</summary>
		<author><name>Quigibo</name></author>	</entry>

	<entry>
		<id>https://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Multiplication</id>
		<title>Z80 Routines:Math:Multiplication</title>
		<link rel="alternate" type="text/html" href="https://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Multiplication"/>
				<updated>2010-07-03T19:33:05Z</updated>
		
		<summary type="html">&lt;p&gt;Quigibo: /* 16*16 multiplication */ It is actually less T states and the same size to do ld hl,0 than ld h,0 / ld l,h&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Z80 Routines:Math|Multiplication]]&lt;br /&gt;
[[Category:Z80 Routines|Multiplication]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
All these routines use the restoring multiplication algorithm, adapted to the z80 architecture to maximize speed.&lt;br /&gt;
They can easily be unrolled to gain some speed.&lt;br /&gt;
&lt;br /&gt;
== Unsigned versions ==&lt;br /&gt;
&lt;br /&gt;
=== 8*8 multiplication ===&lt;br /&gt;
&lt;br /&gt;
The following routine multiplies h by e and places the result in hl&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
mult_h_e&lt;br /&gt;
   ld	l, 0&lt;br /&gt;
   ld	d, l&lt;br /&gt;
&lt;br /&gt;
   sla	h		; optimised 1st iteration&lt;br /&gt;
   jr	nc, $+3&lt;br /&gt;
   ld	l, e&lt;br /&gt;
   &lt;br /&gt;
   ld b, 7&lt;br /&gt;
_loop:&lt;br /&gt;
   add	hl, hl          &lt;br /&gt;
   jr	nc, $+3&lt;br /&gt;
   add	hl, de&lt;br /&gt;
   &lt;br /&gt;
   djnz	_loop&lt;br /&gt;
   &lt;br /&gt;
   ret&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 16*8 multiplication ===&lt;br /&gt;
&lt;br /&gt;
The following routine multiplies de by a and places the result in ahl (which means a is the most significant byte of the product, l the least significant and h the intermediate one...)&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
mult_a_de&lt;br /&gt;
   ld	c, 0&lt;br /&gt;
   ld	h, c&lt;br /&gt;
   ld	l, h&lt;br /&gt;
&lt;br /&gt;
   add	a, a		; optimised 1st iteration&lt;br /&gt;
   jr	nc, $+4&lt;br /&gt;
   ld	h,d&lt;br /&gt;
   ld	l,e&lt;br /&gt;
&lt;br /&gt;
   ld b, 7&lt;br /&gt;
_loop:&lt;br /&gt;
   add	hl, hl&lt;br /&gt;
   rla&lt;br /&gt;
   jr	nc, $+4&lt;br /&gt;
   add	hl, de&lt;br /&gt;
   adc	a, c            ; yes this is actually adc a, 0 but since c is free we set it to zero and so we can save 1 byte and up to 3 T-states per iteration&lt;br /&gt;
   &lt;br /&gt;
   djnz	_loop&lt;br /&gt;
   &lt;br /&gt;
   ret&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 16*16 multiplication ===&lt;br /&gt;
&lt;br /&gt;
The following routine multiplies bc by de and places the result in dehl.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
mult_de_bc&lt;br /&gt;
   ld	hl,0&lt;br /&gt;
&lt;br /&gt;
   sla	e		; optimised 1st iteration&lt;br /&gt;
   rl	d&lt;br /&gt;
   jr	nc, $+4&lt;br /&gt;
   ld	h, b&lt;br /&gt;
   ld	l, c&lt;br /&gt;
&lt;br /&gt;
   ld	a, 15&lt;br /&gt;
_loop:&lt;br /&gt;
   add	hl, hl&lt;br /&gt;
   rl	e&lt;br /&gt;
   rl	d&lt;br /&gt;
   jr	nc, $+6&lt;br /&gt;
   add	hl, bc&lt;br /&gt;
   jr	nc, $+3&lt;br /&gt;
   inc	de&lt;br /&gt;
   &lt;br /&gt;
   dec	a&lt;br /&gt;
   jr	nz, _loop&lt;br /&gt;
   &lt;br /&gt;
   ret&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Signed versions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- do the routines later, basically try to use cpu instruction that preserve bit 7 (sign) or if this is not possible, just take the sign out, do the multiplication and give the sign afterwards and accordingly. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 8*8 multiplication ===&lt;br /&gt;
&lt;br /&gt;
=== 16*8 multiplication ===&lt;/div&gt;</summary>
		<author><name>Quigibo</name></author>	</entry>

	<entry>
		<id>https://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Logarithm</id>
		<title>Z80 Routines:Math:Logarithm</title>
		<link rel="alternate" type="text/html" href="https://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Logarithm"/>
				<updated>2010-06-17T20:32:42Z</updated>
		
		<summary type="html">&lt;p&gt;Quigibo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Z80 Routines:Math|Logarithm]]&lt;br /&gt;
[[Category:Z80 Routines|Logarithm]]&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
== Integer Log of base 2 ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
; input: hl (16-bit integer unsigned)&lt;br /&gt;
; output: a = log2(hl) (rounded down and from -1 to 15) (8-bit integer signed)&lt;br /&gt;
log2:&lt;br /&gt;
	ld	a,16&lt;br /&gt;
	scf&lt;br /&gt;
log2loop:&lt;br /&gt;
	adc	hl,hl&lt;br /&gt;
	dec	a&lt;br /&gt;
	jr	nc,log2loop&lt;br /&gt;
	ret&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Integer Log of base 10 ==&lt;br /&gt;
&lt;br /&gt;
Since log10=log2(hl)/log2(10).&lt;br /&gt;
We can multiply by 1/log2(10).&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Integer Log of base B ==&lt;br /&gt;
&lt;br /&gt;
The same trick as above.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
;unfinished&lt;br /&gt;
logB:&lt;br /&gt;
; input: hl = number&lt;br /&gt;
;	 b = base&lt;br /&gt;
; output: a = log hl base b&lt;br /&gt;
	&lt;br /&gt;
	ret&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Quigibo</name></author>	</entry>

	</feed>