<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=Z80%3ADirectives%3ACLEARPAGE</id>
	<title>Z80:Directives:CLEARPAGE - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=Z80%3ADirectives%3ACLEARPAGE"/>
	<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=Z80:Directives:CLEARPAGE&amp;action=history"/>
	<updated>2026-04-28T18:49:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>http://learn.cemetech.net/index.php?title=Z80:Directives:CLEARPAGE&amp;diff=197&amp;oldid=prev</id>
		<title>Maintenance script: Initial automated import</title>
		<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=Z80:Directives:CLEARPAGE&amp;diff=197&amp;oldid=prev"/>
		<updated>2016-02-05T17:11:53Z</updated>

		<summary type="html">&lt;p&gt;Initial automated import&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Clears the data output on a particular page.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&lt;br /&gt;
    .clearpage page&lt;br /&gt;
&lt;br /&gt;
== Uses ==&lt;br /&gt;
&lt;br /&gt;
This directive can be useful to switch to a temporary page, do some assembling, then remove the output data so it doesn&amp;#039;t appear in the output file.&lt;br /&gt;
&lt;br /&gt;
Use the smallest of two source snippets:&lt;br /&gt;
&lt;br /&gt;
    /* Returns the output size (in bytes) of compiled source */&lt;br /&gt;
    .function size_of_source(src)&lt;br /&gt;
    &lt;br /&gt;
        /* Preserve $ and @ */&lt;br /&gt;
        old_$_p = :$ \ old_$_v = $:&lt;br /&gt;
        old_@_p = :@ \ old_@_v = @:&lt;br /&gt;
        &lt;br /&gt;
        /* Move to a temporary page (-1) */&lt;br /&gt;
        :$ = -1&lt;br /&gt;
        &lt;br /&gt;
        /* Evaluate the source */&lt;br /&gt;
        eval(src)&lt;br /&gt;
        &lt;br /&gt;
        size_of_source = @ - old_@_v&lt;br /&gt;
        &lt;br /&gt;
        /* Clear all output data from temporary page */&lt;br /&gt;
        .clearpage -1&lt;br /&gt;
        &lt;br /&gt;
        /* Restore $ and @ */&lt;br /&gt;
        :$ = old_$_p \ $: = old_$_v&lt;br /&gt;
        :@ = old_@_p \ @: = old_@_v&lt;br /&gt;
    &lt;br /&gt;
    .endfunction&lt;br /&gt;
    &lt;br /&gt;
    /* Uses the smallest of two pieces of source code */&lt;br /&gt;
    .function use_smallest(src_a, src_b)&lt;br /&gt;
        &lt;br /&gt;
        /* Get the size of both snippets */&lt;br /&gt;
        size_of_src_a = size_of_source(src_a)&lt;br /&gt;
        size_of_src_b = size_of_source(src_b)&lt;br /&gt;
        &lt;br /&gt;
        .if size_of_src_a &amp;lt;= size_of_src_b&lt;br /&gt;
            use_smallest = size_of_src_a&lt;br /&gt;
            eval(src_a)&lt;br /&gt;
        .else&lt;br /&gt;
            use_smallest = size_of_src_b&lt;br /&gt;
            eval(src_b)&lt;br /&gt;
        .endif&lt;br /&gt;
    &lt;br /&gt;
    .endfunction&lt;br /&gt;
    &lt;br /&gt;
    /* Uses &amp;quot;xor a&amp;quot; and displays 1: */&lt;br /&gt;
    .echoln use_smallest(&amp;quot;ld a,0&amp;quot;, &amp;quot;xor a&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
{{lowercase}}&lt;br /&gt;
[[Category:Z80 Assembly]]&lt;br /&gt;
[[Category:Z80 Heaven]]&lt;br /&gt;
[[Category:Z80 Directives]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>