retro-nga

Check-in [9ec683cd98]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fix some references to the old end instruction (now called halt)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9ec683cd989ae9f7186047422149200d256146cb68bf0f273e702054fcfae3c0
User & Date: crc 2020-02-20 20:28:48
Context
2020-02-20
20:48
examples: rename a word to make an example a little clearer check-in: 4b087b4d34 user: crc tags: trunk
20:28
fix some references to the old end instruction (now called halt) check-in: 9ec683cd98 user: crc tags: trunk
2020-02-18
14:44
example: local variables check-in: 6e0142ac02 user: crc tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to doc/Muri.md.

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'no'.

    0  nop      7  jump      14  gt        21  and     28  iquery
    1  lit <v>  8  call      15  fetch     22  or      29  iinteract
    2  dup      9  ccall     16  store     23  xor
    3  drop    10  return    17  add       24  shift
    4  swap    11  eq        18  sub       25  zret
    5  push    12  neq       19  mul       26  end
    6  pop     13  lt        20  divmod    27  ienum

E.g., for a sequence of dup, multiply, no-op, drop:

    i dupmu..dr

An example of a small program:







|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'no'.

    0  nop      7  jump      14  gt        21  and     28  iquery
    1  lit <v>  8  call      15  fetch     22  or      29  iinteract
    2  dup      9  ccall     16  store     23  xor
    3  drop    10  return    17  add       24  shift
    4  swap    11  eq        18  sub       25  zret
    5  push    12  neq       19  mul       26  halt
    6  pop     13  lt        20  divmod    27  ienum

E.g., for a sequence of dup, multiply, no-op, drop:

    i dupmu..dr

An example of a small program:
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  if (strcmp(s, "ne") == 0) return 12; if (strcmp(s, "lt") == 0) return 13;
  if (strcmp(s, "gt") == 0) return 14; if (strcmp(s, "fe") == 0) return 15;
  if (strcmp(s, "st") == 0) return 16; if (strcmp(s, "ad") == 0) return 17;
  if (strcmp(s, "su") == 0) return 18; if (strcmp(s, "mu") == 0) return 19;
  if (strcmp(s, "di") == 0) return 20; if (strcmp(s, "an") == 0) return 21;
  if (strcmp(s, "or") == 0) return 22; if (strcmp(s, "xo") == 0) return 23;
  if (strcmp(s, "sh") == 0) return 24; if (strcmp(s, "zr") == 0) return 25;
  if (strcmp(s, "en") == 0) return 26; if (strcmp(s, "ie") == 0) return 27;
  if (strcmp(s, "iq") == 0) return 28; if (strcmp(s, "ii") == 0) return 29;
  return 0;
}
~~~

Now for the first pass. This lays down code, with dummy values
for the references. They will be resolved in `pass2()`.







|







174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  if (strcmp(s, "ne") == 0) return 12; if (strcmp(s, "lt") == 0) return 13;
  if (strcmp(s, "gt") == 0) return 14; if (strcmp(s, "fe") == 0) return 15;
  if (strcmp(s, "st") == 0) return 16; if (strcmp(s, "ad") == 0) return 17;
  if (strcmp(s, "su") == 0) return 18; if (strcmp(s, "mu") == 0) return 19;
  if (strcmp(s, "di") == 0) return 20; if (strcmp(s, "an") == 0) return 21;
  if (strcmp(s, "or") == 0) return 22; if (strcmp(s, "xo") == 0) return 23;
  if (strcmp(s, "sh") == 0) return 24; if (strcmp(s, "zr") == 0) return 25;
  if (strcmp(s, "ha") == 0) return 26; if (strcmp(s, "ie") == 0) return 27;
  if (strcmp(s, "iq") == 0) return 28; if (strcmp(s, "ii") == 0) return 29;
  return 0;
}
~~~

Now for the first pass. This lays down code, with dummy values
for the references. They will be resolved in `pass2()`.

Changes to doc/RETRO-Book.md.

3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
| 19     | mu   | multiplication     | xy-n       |   -           |
| 20     | di   | divide & remainder | xy-rq      |   -           |
| 21     | an   | bitwise and        | xy-n       |   -           |
| 22     | or   | bitwise or         | xy-n       |   -           |
| 23     | xo   | bitwise xor        | xy-n       |   -           |
| 24     | sh   | shift              | xy-n       |   -           |
| 25     | zr   | zero return        |  n-?       |   -           |
| 26     | en   | end                |   -        |   -           |
| 27     | ie   | i/o enumerate      |   -n       |   -           |
| 28     | iq   | i/o query          |  n-xy      |   -           |
| 29     | ii   | i/o invoke         | ...n-      |   -           |

## Encoding

Up to four instructions can be packed into each memory cell.







|







3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
| 19     | mu   | multiplication     | xy-n       |   -           |
| 20     | di   | divide & remainder | xy-rq      |   -           |
| 21     | an   | bitwise and        | xy-n       |   -           |
| 22     | or   | bitwise or         | xy-n       |   -           |
| 23     | xo   | bitwise xor        | xy-n       |   -           |
| 24     | sh   | shift              | xy-n       |   -           |
| 25     | zr   | zero return        |  n-?       |   -           |
| 26     | ha   | halt               |   -        |   -           |
| 27     | ie   | i/o enumerate      |   -n       |   -           |
| 28     | iq   | i/o query          |  n-xy      |   -           |
| 29     | ii   | i/o invoke         | ...n-      |   -           |

## Encoding

Up to four instructions can be packed into each memory cell.
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
| 0008 | Syscalls: Unix   |                            |
| 0009 | Scripting Hooks  |                            |
| 0010 | Random Number    |                            |

This list may be revised in the future. The only guaranteed
stable indentifier is 0000 for generic output.

## Trivia

There are 810,000 possible combinations of instructions. Only
73 are used in the implementation of RETRO.

# Internals: Interface Layers

Nga provides a virtual processor and an extensible way of adding
I/O devices, but does not provide any I/O itself. Adding I/O is
the responsability of the *interface layer*.

An interface layer will wrap Nga, providing at least one I/O







<
<
<
<
<







3583
3584
3585
3586
3587
3588
3589





3590
3591
3592
3593
3594
3595
3596
| 0008 | Syscalls: Unix   |                            |
| 0009 | Scripting Hooks  |                            |
| 0010 | Random Number    |                            |

This list may be revised in the future. The only guaranteed
stable indentifier is 0000 for generic output.






# Internals: Interface Layers

Nga provides a virtual processor and an extensible way of adding
I/O devices, but does not provide any I/O itself. Adding I/O is
the responsability of the *interface layer*.

An interface layer will wrap Nga, providing at least one I/O

Changes to doc/book/internals/nga.

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
| 19     | mu   | multiplication     | xy-n       |   -           |
| 20     | di   | divide & remainder | xy-rq      |   -           |
| 21     | an   | bitwise and        | xy-n       |   -           |
| 22     | or   | bitwise or         | xy-n       |   -           |
| 23     | xo   | bitwise xor        | xy-n       |   -           |
| 24     | sh   | shift              | xy-n       |   -           |
| 25     | zr   | zero return        |  n-?       |   -           |
| 26     | en   | end                |   -        |   -           |
| 27     | ie   | i/o enumerate      |   -n       |   -           |
| 28     | iq   | i/o query          |  n-xy      |   -           |
| 29     | ii   | i/o invoke         | ...n-      |   -           |

## Encoding

Up to four instructions can be packed into each memory cell.







|







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
| 19     | mu   | multiplication     | xy-n       |   -           |
| 20     | di   | divide & remainder | xy-rq      |   -           |
| 21     | an   | bitwise and        | xy-n       |   -           |
| 22     | or   | bitwise or         | xy-n       |   -           |
| 23     | xo   | bitwise xor        | xy-n       |   -           |
| 24     | sh   | shift              | xy-n       |   -           |
| 25     | zr   | zero return        |  n-?       |   -           |
| 26     | ha   | halt               |   -        |   -           |
| 27     | ie   | i/o enumerate      |   -n       |   -           |
| 28     | iq   | i/o query          |  n-xy      |   -           |
| 29     | ii   | i/o invoke         | ...n-      |   -           |

## Encoding

Up to four instructions can be packed into each memory cell.
149
150
151
152
153
154
155
156
157
158
159
160
| 0007 | Network: Sockets |                            |
| 0008 | Syscalls: Unix   |                            |
| 0009 | Scripting Hooks  |                            |
| 0010 | Random Number    |                            |

This list may be revised in the future. The only guaranteed
stable indentifier is 0000 for generic output.

## Trivia

There are 810,000 possible combinations of instructions. Only
73 are used in the implementation of RETRO.







<
<
<
<
<
149
150
151
152
153
154
155





| 0007 | Network: Sockets |                            |
| 0008 | Syscalls: Unix   |                            |
| 0009 | Scripting Hooks  |                            |
| 0010 | Random Number    |                            |

This list may be revised in the future. The only guaranteed
stable indentifier is 0000 for generic output.





Changes to example/export-as-html.retro.

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
:format (s-)
  (ignore_empty_tokens)
  dup s:length n:zero? [ '&nbsp; s:put drop ] if;

  (tokens_with_prefixes)
  dup fetch
  $: [ 'colon     span ] case
  $( [ 'comment   span ] case
  $' [ 'str       span ] case
  $# [ 'num       span ] case
  $. [ 'fnum      span ] case
  $& [ 'ptr       span ] case
  $$ [ 'char      span ] case
  $` [ 'inst      span ] case
  $\ [ 'inst      span ] case







|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
:format (s-)
  (ignore_empty_tokens)
  dup s:length n:zero? [ '&nbsp; s:put drop ] if;

  (tokens_with_prefixes)
  dup fetch
  $: [ 'colon     span ] case
  $( [ 'note      span ] case
  $' [ 'str       span ] case
  $# [ 'num       span ] case
  $. [ 'fnum      span ] case
  $& [ 'ptr       span ] case
  $$ [ 'char      span ] case
  $` [ 'inst      span ] case
  $\ [ 'inst      span ] case
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

/* CSS Begins */

* { background: #1d1f21; color: #b5bd68; font-family: monospace; }
span { white-space: pre }
.text { color: #c5c8c6; white-space: pre }
.colon {  color:  #cc6666; }
.comment {  color: #969896; }
.str {  color: #f0c674; }
.num { color: #8abeb7; }
.fnum { color: #8abeb7; font-weight: bold; }
.ptr { color: #b294bb; font-weight: bold; }
.fetch { color: #b294bb; }
.store { color: #b294bb; }
.char { color:  #81a2be; }
.inst { color: #de935f; }
.defer { color: #888; }
.imm { color: #de935f; }
.prim { color: #b5bd68; font-weight: bold; }







|











121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

/* CSS Begins */

* { background: #1d1f21; color: #b5bd68; font-family: monospace; }
span { white-space: pre }
.text { color: #c5c8c6; white-space: pre }
.colon {  color:  #cc6666; }
.note {  color: #969896; }
.str {  color: #f0c674; }
.num { color: #8abeb7; }
.fnum { color: #8abeb7; font-weight: bold; }
.ptr { color: #b294bb; font-weight: bold; }
.fetch { color: #b294bb; }
.store { color: #b294bb; }
.char { color:  #81a2be; }
.inst { color: #de935f; }
.defer { color: #888; }
.imm { color: #de935f; }
.prim { color: #b5bd68; font-weight: bold; }