Up: (dir)
A general format of instruction is:
<command code byte> <parameter bytes>
• Structures: | Common elements of different commands. | |
• Commands: | Command codes. | |
• Codelist: | A list of command codes. |
• cnt: | The cnt format | |
• selector: | Selector coding | |
• order: | Order coding | |
• cell: | Cell reference coding | |
• descriptor: | Descriptor coding | |
• strings: | Arbitrary strings ("Quirks is VM") coding |
Next: selector, Up: Structures
Natural numbers of any size are represented by cnt
format.
Only coding of numbers < 0x8000
is implemented now.
If cnt
< 0x80U
then it is coded as a one byte (this number
themself), but if it is not equal to 0x7f
. If this number is
0
then it is coded as 7f
.
The coding of 0x7f
is not implemented now!
If 0x80
<= cnt
< 0x8000
then it is coded as two
bytes, the first - (the high byte of this number | 0x80), the second -
(the low byte of this number).
Coding of numbers >= 0x8000
is not implemented by this coding
mechanism.
Next: order, Previous: cnt, Up: Structures
If the selector is AU selector and its number is less than 8 and module number is less then 16 then it is coded as follows:
[1|n|n|n|m|m|m|m]
where nnn
is a selector number (1..7), mmmm
- the module
(1..15).
If nnn
= 0 then the selector number follows in cnt
format. If mmmm
= 0 then the module code follows in cnt
format. If both are 0 then the cnt
for a module preceades the
cnt
for a number.
For selectors other than AU the format is:
[0|t|t|t|n|n|n|n]
where ttt
is a selector type code (0..7) and nnnn
is a
selector number (1..15). If nnnn
= 0 then a selector number
follows in cnt
format.
Selector types coding:
Next: cell, Previous: selector, Up: Structures
An order is represented as a sequence of fixed size words. This sequence is preceded by a size prefix:
[w|w|w|w|n|n|n|n]
where wwww
- word size in bytes for one order element (1..15, 0
is reserverd for large words), mmmm
- order depth (1..15, 0 is
reserved for deeper orders).
All words are big-endian.
Example:
[0|0|1|0|0|0|1|1] [[0 || 0]] [[0 || 1]] [[255 || 255]]
represents the order [0:1:65535]
.
Next: descriptor, Previous: order, Up: Structures
Each cell is represented as selector code and order (see above).
cell_ref ::= selector order
Next: strings, Previous: cell, Up: Structures
NB: Any descriptor code always starts with a zero bit (7 bit in the any first byte of descriptor declaration).
descriptor ::= prim_type | structure | union | array | discriminated
prim_type is coded as follows:
[0|0|0|m|m|c|c|c]
where cccc
codes a type:
and mm
is an access mode
structure ::= STU_prefix {descriptor}(1,k)
STU_prefix:
[0|0|1|k|k|k|k|k]
kkkkk
- is a number of elements, if = 0 then this number follows
in cnt
format.
union ::= UNI_prefix {descriptor}(1,k)
[0|1|0|k|k|k|k|k]
kkkkk
- is a number of elements, if = 0 then this number follows
in cnt
format.
array ::= ARR_prefix descriptor ARR_prefix ::= array_control_word cnt1 cnt2
array_control_word is coded as follows:
[0|1|1|x1|x2|y1|y2|0]
x1
= 1 - bottom index is got from a discriminant;
x2
= 1 - top index is got from a discriminant;
y1
= 1 - bottom index is negative;
y2
= 1 - top index is negative.
cnt1
is bottom index in the cnt format or number of
discriminant if x1
= 1;
cnt2
is top index in the cnt format or number of
discriminant if x2
= 1.
Previous: descriptor, Up: Structures
Now strings are used as parts of debug commands. ASCII string don’t contain zeros, so its coding is trivial:
string ::= cnt { string_character }
cnt is a length of string in cnt format (== 0 for an empty string). string_character is any non-zero byte.
Next: Codelist, Previous: Structures, Up: Top
• nop: | ||
• enter_block: | ||
• mov: | ||
• act: | ||
• if_block: | ||
• loop_block: | ||
• exit: | ||
• call: | ||
• print: |
Next: enter_block, Up: Commands
[0|0|0|1|0|0|0|0]
The block instruction consists of a number of selector groups. Each selector group is a set of selector declarations with optionally following map.
enter_block ::= {selector_group} selector_group ::= sel_group_prefix sel_decl { sel_decl } sel_group_postfix [map_decl] sel_decl ::= descriptor selector map_decl ::= cnt { cell_ref cell_ref }
sel_group_prefix is coded as follows:
[1|1|1|0|1|0|0|t]
where t
= 1 then a map declaration follows these selectors.
sel_group_postfix is coded as follows:
[1|1|1|0|0|0|0|0]
NB: sel_decl always starts with a zero bit (7 bit in the any first byte of descriptor declaration).
map_decl consists of cnt prefix which is the number of cell pairs.
map_decl ::= cnt { cell_ref cell_ref }
Next: act, Previous: enter_block, Up: Commands
[0|0|1|1|0|0|0|0] <cell_ref> <cell_ref>
[0|1|0|0|0|0|0|0] <selector>
Next: loop_block, Previous: act, Up: Commands
If block is coded as one or two parts. The second part is else part and is optional part.
If part:
[1|0|0|1|1|0|0|i] cell_ref
if i = 1 then it is inverse if (if not) condition.
Else part (optional):
[1|0|0|1|0|1|0|0]
End part (always):
[1|0|0|1|0|0|0|0]
Each loop starts and ends with a special code.
The leading sequence:
[1|0|1|0|1|x|c|t] [cell_ref] [label_id]
if x = 1 then the loop is labeled and label_id is present (in the cnt format);
if c = 1 then there is a check of condition at the start (and cell_ref element is present);
if t = 1 then loop exits when the condition != 0.
The ending sequence:
[1|0|1|0|0|0|c|t] [cell_ref]
if c = 1 then there is a check of condition at the end (and cell_ref element is present);
if t = 1 then loop exits when the condition != 0.
Next: call, Previous: loop_block, Up: Commands
[1|0|1|1|t|n|n|n] [label_id] cell_ref
where t
= 1 - exit when the cell contains zero, otherwize when
non zero; nnn
- the label of the loop (when = 0 follows in the cnt format).
[0|1|1|0|x|p|p|p] [<proc_id>] [<selector>]
x
= 1 - selector follows,
ppp
- proc_id
, = 0 - follows in cnt
format.
[1|1|0|0|0|0|s|ln] ( <string> | <cell_ref> )
where
ln == 0 - doesn’t feed line after printing; s == 1 - print a string (otherwise print a cell).
This is a list of command codes (high 4 bits in the command byte).
0000 - reserver 0001 - nop 0010 - end of block 0011 - mov 0100 - act 0101 - not used 0110 - call 0111 - not used 1000 - not used 1001 - if block 1010 - loop block 1011 - exit 1100 - debugging instructions 1110 - the selector group