<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 2010-2023 j8takagi -->
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>End value (YACASL2 - CASL II 処理システム)</title>
<meta name="description" content="End value (YACASL2 - CASL II 処理システム)">
<meta name="keywords" content="End value (YACASL2 - CASL II 処理システム)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Register-and-memory.html" rel="up" title="Register and memory">
<link href="Step-count.html" rel="next" title="Step count">
<link href="Register-specify.html" rel="prev" title="Register specify">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body lang="ja_JP">
<span id="End-value"></span><div class="header">
<p>
Next: <a href="Step-count.html" accesskey="n" rel="next">Step count</a>, Previous: <a href="Register-specify.html" accesskey="p" rel="prev">Register specify</a>, Up: <a href="Register-and-memory.html" accesskey="u" rel="up">Register and memory</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<hr>
<span id="puroguramuZhong-Liao-Shi-noZhi-woBiao-Shi"></span><h4 class="subsection">2.3.2 プログラム終了時の値を表示</h4>
<p><code>grep</code>と<code>tail</code>を組み合わせれば、プログラム終了時の値を表示できます。
</p>
<p><samp>addl.casl</samp>でプログラム終了時のGR1の値を確認するには、次のようにします。
</p>
<div class="example">
<pre class="example">$ <kbd>casl2 -t addl.casl | grep 'GR1:' | tail -1</kbd>
#0006: GR1: 5 = #0005 = 0000000000000101
</pre></div>
<p><samp>sum_10.casl</samp>は、1から10までの整数の和を求め、GR2に格納してからメモリにストア(書き込み)します。
</p>
<div class="example">
<pre class="example">$ <kbd>cat sum_10.casl</kbd>
;;; sum_10.casl
;;; 1から10までの整数をすべて加算した値をメモリーに格納する
MAIN START
XOR GR2,GR2 ; GR2を初期化
LD GR1,FST ; GR1に初項をメモリーから転送
LOOP ADDL GR2,GR1 ; ループ先頭。GR2 <- GR2 + GR1
ADDL GR1,STEP ; GR1 <- GR1 + 公差
CPL GR1,LST ; GR1が末項より大きい場合は終了
JPL FIN ; ↓
JUMP LOOP ; ループ終端
FIN ST GR2,RST ; GR2の結果をメモリーに転送
RET
FST DC 1 ; 初項
LST DC 10 ; 末項
STEP DC 1 ; 公差
RST DS 1 ; 結果
END
</pre></div>
<p><samp>sum_10.casl</samp>でプログラム終了時のGR2の値を確認するには、次のようにします。
</p>
<div class="example">
<pre class="example">$ <kbd>casl2 -t sum_10.casl | grep 'GR2:' | tail -1</kbd>
#000E: GR2: 55 = #0037 = 0000000000110111 = '7'
</pre></div>
</body>
</html>