~ok2/retro-language/arduino

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
chain: variations'
{{
  : ignore  ( - )   repeat getToken "}" compare if; again ;
---reveal---
  : size    ( -n )  -13 5 out wait 5 in dup 0 = [ drop 32 ] ifTrue ;
  : endian  ( -n )  -14 5 out wait 5 in ;
  : bits{  ( n"- )  size <> &ignore ifTrue ;
  : bigEndian{    ( n"- )  endian 1 = &ignore ifTrue ;
  : littleEndian  ( n"- )  endian 0 = &ignore ifTrue ;
  : }  ( - )  ; immediate
}}
;chain


doc{
===========
variations'
===========

--------
Overview
--------
This library provides some functions for determining the differences between
VM implementations and conditionally evaluating code blocks based on these
differences.

Specifically, it provides functions for determining the number of bits per
cell and the endian nature of an implementation.


---------
Functions
---------

+--------------+-------+------------------------------------------------+
| Function     | Stack | Usage                                          |
+==============+=======+================================================+
| size         | -n    | Return the number of bits per cell             |
+--------------+-------+------------------------------------------------+
| endian       | -n    | Return 0 for little endian or 1 for big endian |
+--------------+-------+------------------------------------------------+
| bits{        | n"-   | Execute code up to **}** if the bits per cell  |
|              |       | matches *n*                                    |
+--------------+-------+------------------------------------------------+
| bigEndian    | "-    | Execute code up to **}** if endian is big      |
+--------------+-------+------------------------------------------------+
| littleEndian | "-    | Execute code up to **}** if endian is little   |
+--------------+-------+------------------------------------------------+
| }            | ``-`` | Does nothing                                   |
+--------------+-------+------------------------------------------------+
}doc