<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> words/doplusloop.asm </title>
<meta name="keywords" content="amforth programming language Forth ATmega ATMEL">
<meta name="description" content="amforth - laguage Forth for ATMEL ATmega">
<!-- AUTOINCLUDE START "Page/Head.en.ihtml" DO NOT REMOVE -->
<link rel="StyleSheet" href="../../../../Web/CSS/MLAB.css" type="text/css" title="MLAB Basic Style">
<link rel="StyleSheet" href="../../../../Web/CSS/MLAB_Print.css" type="text/css" media="print">
<link rel="shortcut icon" type="image/x-icon" href="../../../../Web/PIC/MLAB.ico">
<script type="text/javascript" src="../../../../Web/JS/MLAB_Menu.js"></script>
<!-- AUTOINCLUDE END -->
</head>
<body lang="en">
<!-- AUTOINCLUDE START "Page/Header.en.ihtml" DO NOT REMOVE -->
<!-- ============== HEADER ============== -->
<div class="Header">
<script type="text/javascript">
<!--
SetRelativePath("../../../../");
DrawHeader();
// -->
</script>
<noscript>
<p><b> JavaScript is required for including of the header </b></p>
</noscript>
</div>
<!-- AUTOINCLUDE END -->
<!-- AUTOINCLUDE START "Page/Menu.en.ihtml" DO NOT REMOVE -->
<!-- ============== MENU ============== -->
<div class="Menu">
<script type="text/javascript">
<!--
SetRelativePath("../../../../");
DrawMenu();
// -->
</script>
<noscript>
<p><b> JavaScript is required for including of the menu </b><p>
</noscript>
</div>
<!-- AUTOINCLUDE END -->
<!-- ============== TEXT ============== -->
<div class="Text">
<h1> words/doplusloop.asm </h1>
<p>
<input type=button onClick="history.back()" value="Back">
<input type=button onClick="history.forward()" value="Forward">
<a href="../WordList.en.html">Jump to Vocabulary</a>
</p>
<pre>
; ( n1 -- )
; R(llimit counter -- limit counter+n1|)
; runtime of +loop
;VE_DOPLUSLOOP:
; .db 7, "(+loop)"
; .dw VE_HEAD
; .set VE_HEAD = VE_DOPLUSLOOP
XT_DOPLUSLOOP:
.dw PFA_DOPLUSLOOP
PFA_DOPLUSLOOP:
pop zl
pop zh
add zl, tosl
adc zh, tosh
loadtos
PFA_DOPLUSLOOP4: ; entry point for (loop)
pop temp2
pop temp3
cp zl, temp2
cpc zh, temp3
sbrs tosh, 7 ; if msb is set, increment is negative. in that case skip the next instruction
rjmp PFA_DOPLUSLOOP2 ; jump to test for positive overflow
brlt PFA_DOPLUSLOOP1 ; exit if underflow
rjmp PFA_DOPLUSLOOP3
PFA_DOPLUSLOOP2:
brge PFA_DOPLUSLOOP1 ; exit if overflow
PFA_DOPLUSLOOP3:
; next iteration
push temp3
push temp2
push zh
push zl
rjmp PFA_DOBRANCH ; read next cell from dictionary and jump to its destination
PFA_DOPLUSLOOP1:
pop temp0
pop temp1 ; remove leave destination
adiw xl, 1 ; skip branch-back address
rjmp DO_NEXT
</pre>
<p>
<input type=button onClick="history.back()" value="Back">
<input type=button onClick="history.forward()" value="Forward">
<a href="../WordList.en.html">Jump to Vocabulary</a>
</p>
</div>
<!-- AUTOINCLUDE START "Page/Footer.en.ihtml" DO NOT REMOVE -->
<!-- ============== FOOTER ============== -->
<div class="Footer">
<script type="text/javascript">
<!--
SetRelativePath("../../../../");
DrawFooter();
// -->
</script>
<noscript>
<p><b> JavaScript is required for including of the footer </b></p>
</noscript>
</div>
<!-- AUTOINCLUDE END -->
</body>
</html>