User Tools

Site Tools


ocmbytecode

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
ocmbytecode [2023/04/14 08:42] – [Opcodes 50..5F] nopsledocmbytecode [2023/04/23 14:55] – [Opcodes 40..4F] nopsled
Line 236: Line 236:
 ===== Opcodes 20..2F ===== ===== Opcodes 20..2F =====
  
-=== Opcode 0x20 (32): Compare Small Ints for equal ===+=== Opcode 0x20 (32): Compare Small Ints for equal (cmp) ===
 stack input: smallint a (next to top); smallint b (top of stack) stack input: smallint a (next to top); smallint b (top of stack)
  
 stack output: smallint containing 1 if a == b, 0 otherwise stack output: smallint containing 1 if a == b, 0 otherwise
  
-=== Opcode 0x21 (33): Test for Small Int Zero ===+=== Opcode 0x21 (33): Test for Small Int Zero (iszerow) ===
 stack input: object of any type (maybe only smallint intended) stack input: object of any type (maybe only smallint intended)
  
 stack output: 1 if object has type smallint and is zero stack output: 1 if object has type smallint and is zero
  
-=== Opcode 0x22 (34): Add DWORDs ===+=== Opcode 0x22 (34): Add DWORDs (add) ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 253: Line 253:
 note: DWORD instructions only use the 32 least significant bits in bigint input operands, and samllint operands are treated as unsigned for unknown reasons. All arithmetic is unsigned. As bigints are in sign/magnitude representation, the input sign is ignored for bigints, but not for small ints that are two's complement. But do not use the function with negative inputs unless you wrote the OCM bytecode interpreter, because the sign of the output is undefined in that case (unless you know the internals of the interpreter, that is) note: DWORD instructions only use the 32 least significant bits in bigint input operands, and samllint operands are treated as unsigned for unknown reasons. All arithmetic is unsigned. As bigints are in sign/magnitude representation, the input sign is ignored for bigints, but not for small ints that are two's complement. But do not use the function with negative inputs unless you wrote the OCM bytecode interpreter, because the sign of the output is undefined in that case (unless you know the internals of the interpreter, that is)
  
-=== Opcode 0x23 (35): Subtract DWORDs ===+=== Opcode 0x23 (35): Subtract DWORDs (sub)  ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 260: Line 260:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x24 (36): Multiply DWORDs ===+=== Opcode 0x24 (36): Multiply DWORDs (mul) ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 267: Line 267:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x25 (37): Divide DWORDs ===+=== Opcode 0x25 (37): Divide DWORDs (div) ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 274: Line 274:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x26 (38): Division and Modulus of DWORDs ===+=== Opcode 0x26 (38): Division and Modulus of DWORDs (divmod) ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 281: Line 281:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x27 (39): Modulus of DWORDs ===+=== Opcode 0x27 (39): Modulus of DWORDs (moddiv) ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 288: Line 288:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x28 (40): Xor DWORDs ===+=== Opcode 0x28 (40): Xor DWORDs (xor) ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 295: Line 295:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x29 (41): And DWORDs ===+=== Opcode 0x29 (41): And DWORDs (and) ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 302: Line 302:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x2A (42): Or DWORDs ===+=== Opcode 0x2A (42): Or DWORDs (or) ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 309: Line 309:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x2B (43): Bitwise Not DWORD ===+=== Opcode 0x2B (43): Bitwise Not DWORD (not) ===
 stack input: small/big int a (top of stack) stack input: small/big int a (top of stack)
  
Line 316: Line 316:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x2C (44): Shift Left DWORD ===+=== Opcode 0x2C (44): Shift Left DWORD (shl) ===
 stack input: small/big int a (next to top); small/big int count (top of stack) stack input: small/big int a (next to top); small/big int count (top of stack)
  
Line 323: Line 323:
 note: See Opcode 0x22 for important notes on DWORD instructions. note: See Opcode 0x22 for important notes on DWORD instructions.
  
-=== Opcode 0x2D (45): Shift Right DWORD ===+=== Opcode 0x2D (45): Shift Right DWORD (shr) ===
 stack input: small/big int a (next to top); small/big int count (top of stack) stack input: small/big int a (next to top); small/big int count (top of stack)
  
Line 330: Line 330:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x2E (46): Compare DWORDs for Less ===+=== Opcode 0x2E (46): Compare DWORDs for Less (cmp) ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 337: Line 337:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x2F (47): Compare DWORDs for Greater ===+=== Opcode 0x2F (47): Compare DWORDs for Greater (cmp.gt) ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 346: Line 346:
  
 ===== Opcodes 30..3F ===== ===== Opcodes 30..3F =====
-=== Opcode 0x30 (48): Compare DWORDs for Equality ===+=== Opcode 0x30 (48): Compare DWORDs for Equality (cmp.eq) ===
 stack input: small/big int a (next to top); small/big int b (top of stack) stack input: small/big int a (next to top); small/big int b (top of stack)
  
Line 353: Line 353:
 note: See Opcode 22 for important notes on DWORD instructions. note: See Opcode 22 for important notes on DWORD instructions.
  
-=== Opcode 0x31 (49): Execute ===+=== Opcode 0x31 (49): Execute (exec) ===
 stack input: binary blob containing bytecode stack input: binary blob containing bytecode
  
Line 362: Line 362:
 PostScript equivalent: "exec" PostScript equivalent: "exec"
  
-=== Opcode 0x32 (50): If/Else ===+=== Opcode 0x32 (50): If/Else (ifelse) ===
 stack input: selector (smallint at second to top of stack), blob for the true case (next to top), blob for the false case (top of stack) stack input: selector (smallint at second to top of stack), blob for the true case (next to top), blob for the false case (top of stack)
  
Line 455: Line 455:
 note: in contrast to Opcode 21 "Test for Small Int Zero", this opcode has undefined behaviour of the operand is not a small integer. note: in contrast to Opcode 21 "Test for Small Int Zero", this opcode has undefined behaviour of the operand is not a small integer.
  
-=== Opcode 0x47 (71): Duplicate second-to-top ===+=== Opcode 0x47 (71): Duplicate second-to-top (index.1) ===
 effect: pushes a copy of the second-to-top (the third value if you call top-of-stack the first one) to the standard stack. effect: pushes a copy of the second-to-top (the third value if you call top-of-stack the first one) to the standard stack.
  
 PostScript equivalent: "2 index" PostScript equivalent: "2 index"
  
-=== Opcode 0x48 (72): Duplicate third-to-top ===+=== Opcode 0x48 (72): Duplicate third-to-top (index.2) ===
 effect: pushes a copy of the third-to-top (the fourth value if you call top-of-stack the first one) to the standard stack. effect: pushes a copy of the third-to-top (the fourth value if you call top-of-stack the first one) to the standard stack.
  
 PostScript equivalent: "3 index" PostScript equivalent: "3 index"
  
-=== Opcode 0x49 (73): Duplicate fourth-to-top ===+=== Opcode 0x49 (73): Duplicate fourth-to-top (index.3) ===
 effect: pushes a copy of the fourth-to-top (the 5th value if you call top-of-stack the first one) to the standard stack. effect: pushes a copy of the fourth-to-top (the 5th value if you call top-of-stack the first one) to the standard stack.
  
 PostScript equivalent: "4 index" PostScript equivalent: "4 index"
  
-=== Opcode 0x4A (74): Duplicate 5th-to-top ===+=== Opcode 0x4A (74): Duplicate 5th-to-top (index.4) ===
 effect: pushes a copy of the 5th-to-top (the 6th value if you call top-of-stack the first one) to the standard stack. effect: pushes a copy of the 5th-to-top (the 6th value if you call top-of-stack the first one) to the standard stack.
  
 PostScript equivalent: "5 index" PostScript equivalent: "5 index"
  
-=== Opcode 0x4B (75): Move Top-3 to top ===+=== Opcode 0x4B (75): Move Top-3 to top (rollin.5) ===
 effect: The value at Top-3 gets moved to top of stack, top of stack becomes top-1 and so on. effect: The value at Top-3 gets moved to top of stack, top of stack becomes top-1 and so on.
  
 PostScript equivalent: "4 -1 roll" PostScript equivalent: "4 -1 roll"
  
-=== Opcode 0x4C (76): Move Top-4 to top ===+=== Opcode 0x4C (76): Move Top-4 to top (rollin.4) ===
 effect: The value at Top-4 gets moved to top of stack, top of stack becomes top-1 and so on. effect: The value at Top-4 gets moved to top of stack, top of stack becomes top-1 and so on.
  
 PostScript equivalent: "5 -1 roll" PostScript equivalent: "5 -1 roll"
  
-=== Opcode 0x4D (77): Move Top-5 to top ===+=== Opcode 0x4D (77): Move Top-5 to top (rollin.3) ===
 effect: The value at Top-5 gets moved to top of stack, top of stack becomes top-1 and so on. effect: The value at Top-5 gets moved to top of stack, top of stack becomes top-1 and so on.
  
 PostScript equivalent: "6 -1 roll" PostScript equivalent: "6 -1 roll"
  
-=== Opcode 0x4E (78): Increment Small Int ===+=== Opcode 0x4E (78): Increment Small Int (inc.w) ===
 stack input: smallint a stack input: smallint a
  
 stack ouput: smallint (a+1) stack ouput: smallint (a+1)
  
-=== Opcode 0x4F (79): Decrement Small Int ===+=== Opcode 0x4F (79): Decrement Small Int (dec.w) ===
 stack input: smallint a stack input: smallint a
  
ocmbytecode.txt · Last modified: 2023/04/23 15:05 by nopsled

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki