z80:Directives:CLEARPAGE

From Learn @ Cemetech
Revision as of 17:11, 5 February 2016 by Maintenance script (talk | contribs) (Initial automated import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Clears the data output on a particular page.

Syntax

   .clearpage page

Uses

This directive can be useful to switch to a temporary page, do some assembling, then remove the output data so it doesn't appear in the output file.

Use the smallest of two source snippets:

   /* Returns the output size (in bytes) of compiled source */
   .function size_of_source(src)
   
       /* Preserve $ and @ */
       old_$_p = :$ \ old_$_v = $:
       old_@_p = :@ \ old_@_v = @:
       
       /* Move to a temporary page (-1) */
       :$ = -1
       
       /* Evaluate the source */
       eval(src)
       
       size_of_source = @ - old_@_v
       
       /* Clear all output data from temporary page */
       .clearpage -1
       
       /* Restore $ and @ */
       :$ = old_$_p \ $: = old_$_v
       :@ = old_@_p \ @: = old_@_v
   
   .endfunction
   
   /* Uses the smallest of two pieces of source code */
   .function use_smallest(src_a, src_b)
       
       /* Get the size of both snippets */
       size_of_src_a = size_of_source(src_a)
       size_of_src_b = size_of_source(src_b)
       
       .if size_of_src_a <= size_of_src_b
           use_smallest = size_of_src_a
           eval(src_a)
       .else
           use_smallest = size_of_src_b
           eval(src_b)
       .endif
   
   .endfunction
   
   /* Uses "xor a" and displays 1: */
   .echoln use_smallest("ld a,0", "xor a")


See Also