<!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/accept.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/accept.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>
; ( addr n1 -- n2 ) System
; R( -- )
; reads a line with with KEY into addr until n2 characters are reveived or cr/lf detected.
VE_ACCEPT:
    .db $06, &quot;accept&quot;,0
    .dw VE_HEAD
    .set VE_HEAD = VE_ACCEPT
XT_ACCEPT:
    .dw DO_COLON
PFA_ACCEPT:
    .dw XT_DUP        ; ( -- addr n1 n1)
    .dw XT_TO_R
    .dw XT_TO_R
PFA_ACCEPT1:          ; ( -- addr )
    .dw XT_KEY        ; ( -- addr k )
    .dw XT_DUP        ; ( -- addr k k )
    .dw XT_DOLITERAL
    .dw 10
    .dw XT_NOTEQUAL
    .dw XT_DOCONDBRANCH
    .dw PFA_ACCEPT2
    .dw XT_DUP
    .dw XT_DOLITERAL
    .dw 13
    .dw XT_NOTEQUAL
    .dw XT_DOCONDBRANCH
    .dw PFA_ACCEPT2
    ; check backspace
    .dw XT_DUP
    .dw XT_DOLITERAL
    .dw 8
    .dw XT_EQUAL
    .dw XT_DOCONDBRANCH
    .dw PFA_ACCEPT3
    ; delete previous character
    ; check beginning of line
    .dw XT_R_FROM             ; ( -- addr k n1 )
    .dw XT_R_FETCH            ; ( -- addr k n1 n2)
    .dw XT_OVER               ; ( -- addr k n1 n2 n1)
    .dw XT_TO_R
    .dw XT_EQUAL              ; ( -- addr k f )
    .dw XT_DOCONDBRANCH
    .dw PFA_ACCEPT5
    ; we are at the beginning of the line, ignore this character
    .dw XT_DROP               ; ( -- addr )
    .dw XT_DOBRANCH
    .dw PFA_ACCEPT1
PFA_ACCEPT5:
    .dw XT_DUP                ; ( -- addr k k )
    .dw XT_EMIT               ; ( -- addr k )
    .dw XT_SPACE              ; ( -- addr k )
    .dw XT_EMIT               ; ( -- addr )
    .dw XT_1MINUS             ; ( -- addr--)
    .dw XT_R_FROM
    .dw XT_1PLUS
    .dw XT_DOBRANCH
    .dw PFA_ACCEPT4
PFA_ACCEPT3:
    ; check for remaining control characters, replace them with blank
    .dw XT_DUP            ; ( -- addr k k )
    .dw XT_BL
    .dw XT_LESS
    .dw XT_DOCONDBRANCH
    .dw PFA_ACCEPT6
    .dw XT_DROP
    .dw XT_BL
PFA_ACCEPT6:
    ; emit the key
    .dw XT_DUP            ; ( -- addr k k)
    .dw XT_EMIT           ; ( -- addr k)
    ; now store the key
    .dw XT_OVER           ; ( -- addr k addr
    .dw XT_CSTORE         ; ( -- addr)
    .dw XT_1PLUS          ; ( -- addr++)
    .dw XT_R_FROM         ; ( -- addr n1)
    .dw XT_1MINUS         ; ( -- addr n1--)
PFA_ACCEPT4:
    .dw XT_DUP
    .dw XT_TO_R
    .dw XT_EQUALZERO
    .dw XT_DOCONDBRANCH
    .dw PFA_ACCEPT1
    .dw XT_DUP
PFA_ACCEPT2:
    .dw XT_SLASHKEY
    .dw XT_DROP
    .dw XT_DROP
    .dw XT_R_FROM
    .dw XT_R_FROM
    .dw XT_SWAP
    .dw XT_MINUS
    .dw XT_CR
    .dw XT_EXIT
</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>