Lingo bytecode
Line 44: | Line 44: | ||
|- | |- | ||
! 04 | ! 04 | ||
− | | <code>a * b</code> | + | | <code>a * b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 50: | Line 50: | ||
|- | |- | ||
! 05 | ! 05 | ||
− | | <code>a + b</code> | + | | <code>a + b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 56: | Line 56: | ||
|- | |- | ||
! 06 | ! 06 | ||
− | | <code>a - b</code> | + | | <code>a - b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 62: | Line 62: | ||
|- | |- | ||
! 07 | ! 07 | ||
− | | <code>a / b</code> | + | | <code>a / b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 76: | Line 76: | ||
|- | |- | ||
! 0A | ! 0A | ||
− | | <code>a & b</code> | + | | <code>a & b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 82: | Line 82: | ||
|- | |- | ||
! 0B | ! 0B | ||
− | | <code>a && b</code> | + | | <code>a && b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 88: | Line 88: | ||
|- | |- | ||
! 0C | ! 0C | ||
− | | <code>a | + | | <code>a < b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 94: | Line 94: | ||
|- | |- | ||
! 0D | ! 0D | ||
− | | <code>a | + | | <code>a <= b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 100: | Line 100: | ||
|- | |- | ||
! 0E | ! 0E | ||
− | | <code>a | + | | <code>a <> b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 106: | Line 106: | ||
|- | |- | ||
! 0F | ! 0F | ||
− | | <code>a = b</code> | + | | <code>a = b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 112: | Line 112: | ||
|- | |- | ||
! 10 | ! 10 | ||
− | | <code>a | + | | <code>a > b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 118: | Line 118: | ||
|- | |- | ||
! 11 | ! 11 | ||
− | | <code>a | + | | <code>a >= b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 124: | Line 124: | ||
|- | |- | ||
! 12 | ! 12 | ||
− | | <code>a and b</code> | + | | <code>a and b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 130: | Line 130: | ||
|- | |- | ||
! 13 | ! 13 | ||
− | | <code>a or b</code> | + | | <code>a or b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 142: | Line 142: | ||
|- | |- | ||
! 15 | ! 15 | ||
− | | <code>a contains b</code> | + | | <code>a contains b</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 150: | Line 150: | ||
|- | |- | ||
! 17 | ! 17 | ||
− | | <code>char a of c</code> | + | | <code>char a of c</code> |
− | <code>char a to b of c</code> | + | <code>char a to b of c</code> |
| -9 | | -9 | ||
| +1 | | +1 | ||
Line 220: | Line 220: | ||
|- | |- | ||
! 42 XX | ! 42 XX | ||
− | | <code>a, b, c</code> | + | | <code>a, b, c</code> |
| -XX | | -XX | ||
| +1 | | +1 | ||
Line 226: | Line 226: | ||
|- | |- | ||
! 43 XX | ! 43 XX | ||
− | | <code>[a, b, c]</code> | + | | <code>[a, b, c]</code> |
| -XX | | -XX | ||
| +1 | | +1 | ||
Line 275: | Line 275: | ||
|- | |- | ||
! 4F XX | ! 4F XX | ||
− | | <code>set someGlobal = 0</code> | + | | <code>set someGlobal = 0</code> |
| -1 | | -1 | ||
| | | | ||
Line 285: | Line 285: | ||
|- | |- | ||
! 52 XX | ! 52 XX | ||
− | | <code>set someLocal = 0</code> | + | | <code>set someLocal = 0</code> |
| -1 | | -1 | ||
| | | | ||
Line 299: | Line 299: | ||
|- | |- | ||
! 57 XX | ! 57 XX | ||
− | | <code>someFunction 1,2,3</code> | + | | <code>someFunction 1,2,3</code> |
<code>someFunction(1,2,3)</code> | <code>someFunction(1,2,3)</code> | ||
Line 309: | Line 309: | ||
|- | |- | ||
! 59 25 | ! 59 25 | ||
− | | <code>put "extra" after textVar</code> | + | | <code>put "extra" after textVar</code> |
| -1 | | -1 | ||
| | | | ||
Line 315: | Line 315: | ||
|- | |- | ||
! 59 35 | ! 59 35 | ||
− | | <code>put "extra" before textVar</code> | + | | <code>put "extra" before textVar</code> |
| -1 | | -1 | ||
| | | | ||
Line 323: | Line 323: | ||
|- | |- | ||
! 5B 05 | ! 5B 05 | ||
− | | <code>delete word 3 of textVar</code> | + | | <code>delete word 3 of textVar</code> |
| -1 | | -1 | ||
| | | | ||
Line 337: | Line 337: | ||
|- | |- | ||
! 09 | ! 09 | ||
− | | <code>the date</code>, <code>the short date</code> | + | | <code>the date</code>, <code>the short date</code> |
|- | |- | ||
! 0A | ! 0A | ||
− | | <code>the abbreviated date</code>, <code>the abbrev date</code>, <code>the abbr date</code> | + | | <code>the abbreviated date</code>, <code>the abbrev date</code>, <code>the abbr date</code> |
|- | |- | ||
! 0B | ! 0B | ||
− | | <code>the long date</code> | + | | <code>the long date</code> |
|} | |} | ||
|- | |- | ||
! 5C 03 | ! 5C 03 | ||
− | | <code>the checkMark of menuItem 1 of menu 1</code> | + | | <code>the checkMark of menuItem 1 of menu 1</code> |
| -3 | | -3 | ||
| +1 | | +1 | ||
Line 359: | Line 359: | ||
|- | |- | ||
! 5C 06 | ! 5C 06 | ||
− | | <code>the cursor of sprite 3</code> | + | | <code>the cursor of sprite 3</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 377: | Line 377: | ||
|- | |- | ||
! 5C 08 | ! 5C 08 | ||
− | | <code>the number of castMembers</code> | + | | <code>the number of castMembers</code> |
| -1 | | -1 | ||
| +1 | | +1 | ||
Line 385: | Line 385: | ||
|- | |- | ||
! 02 | ! 02 | ||
− | | <code>the number of castMembers</code> | + | | <code>the number of castMembers</code> |
|} | |} | ||
|- | |- | ||
! 5C 09 | ! 5C 09 | ||
− | | <code>the number of cast "bob"</code> | + | | <code>the number of cast "bob"</code> |
| -2 | | -2 | ||
| +1 | | +1 | ||
Line 416: | Line 416: | ||
|- | |- | ||
! 5D 06 | ! 5D 06 | ||
− | | set the constraint of sprite 3 = 0 | + | | <code>set the constraint of sprite 3 = 0</code> |
| -3 | | -3 | ||
| | | | ||
Line 422: | Line 422: | ||
|- | |- | ||
! 5D 09 | ! 5D 09 | ||
− | | set the backColor of cast "bob" = 0 | + | | <code>set the backColor of cast "bob" = 0</code> |
| -3 | | -3 | ||
| | | | ||
Line 436: | Line 436: | ||
|- | |- | ||
! 60 XX | ! 60 XX | ||
− | | <code>set the someProperty = 0</code> | + | | <code>set the someProperty = 0</code> |
| -1 | | -1 | ||
| | | | ||
Line 442: | Line 442: | ||
|- | |- | ||
! 61 XX | ! 61 XX | ||
− | | <code>the someProperty of someVariable</code> | + | | <code>the someProperty of someVariable</code> |
| -1 | | -1 | ||
| +1 | | +1 |
Revision as of 16:50, 6 March 2016
This is a partial, work-in-progress examination of the bytecode created when Lingo code is compiled in Macromedia Director 4.0. This is also sometimes known as IML, or Idealized Machine Language. It describes instructions for a stack-based virtual machine.
Each instruction is one, two or three bytes.
- If the first byte is in the range 0x00-0x3F, then the full instruction is one byte.
- If the first byte is in the range 0x40-0x7F, then the full instruction is two bytes.
- If the first byte is in the range 0x80-0xFF, then the full instruction is three bytes.
Constant blobs like string literals are stored after the bytecode, and referred to by records that are six bytes long regardless of the actual length of the data. This means the first constant will be referred to as 0x00, the second constant as 0x06, the third as 0x0C, and so on. Integer literals over 32767 and floating-point number literals are also stored as constants.
There is also a namelist for referring to external identifiers, stored separately from the bytecode. This is a simple array of strings.
03 | +1 |
Push a placeholder value for internal functions with a fixed number of arguments. This is used for example in text operations like | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
04 | a * b
|
-2 | +1 | Pop two values from the stack, multiply them together and push the result. | ||||||||||||||||||
05 | a + b
|
-2 | +1 | Pop two values from the stack, add them together and push the result. | ||||||||||||||||||
06 | a - b
|
-2 | +1 | Pop two values from the stack, subtract the second from the first and push the result. | ||||||||||||||||||
07 | a / b
|
-2 | +1 | Pop two values from the stack, divide the first by the second and push the result. | ||||||||||||||||||
08 | ||||||||||||||||||||||
09 | -a
|
-1 | +1 | Pop one value from the stack, negate it and push the result. | ||||||||||||||||||
0A | a & b
|
-2 | +1 | Pop two values from the stack, concatenate them and push the resulting string. | ||||||||||||||||||
0B | a && b
|
-2 | +1 | Pop two values from the stack, concatenate them with one space character added in between, and push the resulting string. | ||||||||||||||||||
0C | a < b
|
-2 | +1 | Pop two values from the stack, push 1 if the first is less than the second and 0 if not. | ||||||||||||||||||
0D | a <= b
|
-2 | +1 | Pop two values from the stack, push 1 if the first is less than or equal to the second and 0 if not. | ||||||||||||||||||
0E | a <> b
|
-2 | +1 | Pop two values from the stack, push 0 if the two values are the same and 1 if they are not. | ||||||||||||||||||
0F | a = b
|
-2 | +1 | Pop two values from the stack, push 1 if the two values are the same and 0 if they are not. | ||||||||||||||||||
10 | a > b
|
-2 | +1 | Pop two values from the stack, push 1 if the first is greater than the second and 0 if not. | ||||||||||||||||||
11 | a >= b
|
-2 | +1 | Pop two values from the stack, push 1 if the first is greater than or equal to the sceond and 0 if not. | ||||||||||||||||||
12 | a and b
|
-2 | +1 | Pop two values from the stack, push 1 if both are logically true and 0 if not. | ||||||||||||||||||
13 | a or b
|
-2 | +1 | Pop two values from the stack, push 1 if either are logically true and 0 if not. | ||||||||||||||||||
14 | !a
|
-1 | +1 | Pop one value from the stack, push 0 if it is logically true and 1 if not. | ||||||||||||||||||
15 | a contains b
|
-2 | +1 | Pop two values from the stack, push 1 if the first is a string that contains the second and 0 if not. | ||||||||||||||||||
16 | ||||||||||||||||||||||
17 | char a of c
|
-9 | +1 | String slice. The nine arguments it takes from the stack are:
| ||||||||||||||||||
18 | ||||||||||||||||||||||
19 | ||||||||||||||||||||||
1A | ||||||||||||||||||||||
1B | ||||||||||||||||||||||
1C | ||||||||||||||||||||||
1D | ||||||||||||||||||||||
1E | -1 | +1 | Some kind of list transformation or check, seen used just before setting the actorList to []. More research is needed to know exactly what is happening there. | |||||||||||||||||||
1F | -1 | +1 | Transform [#symbol1, val1, #symbol2, val2 ...] to [#symbol1: val1, #symbol2: val2 ...] |
41 XX | 0 .. 127
|
+1 | Push integer of value XX, which must be between 0 and 127, inclusive. | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
42 XX | a, b, c
|
-XX | +1 | Pop the specified number of values off the top of the stack, create an unparenthesized argument list containing them (i.e. for a call statement like myFunction 1, 2, 3 ), and push that to the stack.
| ||||||||||||
43 XX | [a, b, c]
|
-XX | +1 | Pop the specified number of values off the top of the stack, create a list for them (which can also be used for a parenthesized call expression like set result = myFunction(1, 2, 3) ), and push that to the stack.
| ||||||||||||
44 XX |
|
+1 | Push a constant from local constant records onto the stack. These records seem to be six bytes long (regardless of the actual size of the constant value), so pushing the first one is 44 00 , the second is 44 06 , the third is 44 0C , etc.
| |||||||||||||
45 XX | #symbol
|
+1 | Push a symbol with a name from namelist[XX]. Note that the name will be stored as "name", not "#name". | |||||||||||||
46 XX | ||||||||||||||||
47 XX | ||||||||||||||||
48 XX | ||||||||||||||||
49 XX |
(where previously declared: |
+1 | Push the value of a global variable with a name from namelist[XX]. | |||||||||||||
4C XX | someLocal
|
+1 | Push the value of a local variable. The local variable records seem to be 6 bytes long, so the first is pushed with 4C 00 , the second with 4C 06 , etc.
| |||||||||||||
4D XX | ||||||||||||||||
4E XX | ||||||||||||||||
4F XX | set someGlobal = 0
|
-1 | Pop one value and use it to set the global variable with name from namelist[XX]. | |||||||||||||
50 XX | ||||||||||||||||
51 XX | ||||||||||||||||
52 XX | set someLocal = 0
|
-1 | Pop one value and use it to set a local variable. See code 4C 00 for a note about local variable records. | |||||||||||||
53 XX | ||||||||||||||||
54 XX | ||||||||||||||||
55 XX | ||||||||||||||||
56 XX | ||||||||||||||||
57 XX | someFunction 1,2,3
|
-XX | +1 OR +0 | Call the function with name from namelist[XX]. The top value on the stack must be an argument list. If the argument list was created with code 43 XX, one return value will be pushed to the stack. If the argument list was creatd with code 42 XX, no return value will be pushed. | ||||||||||||
58 XX | ||||||||||||||||
59 25 | put "extra" after textVar
|
-1 | (Not sure how the target value is specified, needs more research) | |||||||||||||
59 35 | put "extra" before textVar
|
-1 | (See above) | |||||||||||||
5A XX | ||||||||||||||||
5B 05 | delete word 3 of textVar
|
-1 | (See above) | |||||||||||||
5C 00 | the date
|
-1 | +1 |
Pop a date formatting ID, and push the current date formatting according to it:
| ||||||||||||
5C 03 | the checkMark of menuItem 1 of menu 1
|
-3 | +1 |
Pop [item ID, menu ID, property ID] and push the value of the specified menu item property, using these property IDs:
| ||||||||||||
5C 06 | the cursor of sprite 3
|
-2 | +1 |
Pop [sprite ID, property ID] and push the value of the specified sprite property, using these property IDs:
| ||||||||||||
5C 08 | the number of castMembers
|
-1 | +1 |
Pop a stat ID from the stack and push the value of the stat, using these stat IDs:
| ||||||||||||
5C 09 | the number of cast "bob"
|
-2 | +1 |
Pop [cast ID, property ID] from the stack and push the value of the cast property, using these property IDs:
| ||||||||||||
5D 06 | set the constraint of sprite 3 = 0
|
-3 | Pop [sprite ID, new value, property ID] and set the sprite property. See the table for code 5C 06 for sprite property IDs. | |||||||||||||
5D 09 | set the backColor of cast "bob" = 0
|
-3 | Pop [cast ID, new value, property ID] and set the cast property. See the table for code 5C 09 for cast property IDs. | |||||||||||||
5E XX | ||||||||||||||||
5F XX | the someProperty
|
+1 | Push the value of the contextual property with the name at namelist[XX]. | |||||||||||||
60 XX | set the someProperty = 0
|
-1 | Pop a value and use it to set the contextual property with the name at namelist[XX]. | |||||||||||||
61 XX | the someProperty of someVariable
|
-1 | +1 | Pop a property-owning object from the stack, and push the value of this object's property with the name at namelist[XX]. |
81 XX YY | 128 .. 32767
|
+1 | Push the integer (XX * 0x100 + YY). Larger integers and floats are pushed using constants. |
---|