Toi (programming language): Difference between revisions

Content deleted Content added
m example,the->example, the - Fix a typo in one click
Tags: Mobile edit Mobile web edit Advanced mobile edit
Opcode: split subsections
Line 162:
----
Hex | Memnonic | arguments - description
'''1 -==== Stack manipulation''' ====
----
'''1 - Stack manipulation'''
 
These subroutines operate on the current-working stack(1).
Line 171 ⟶ 170:
12 DUP - duplicates the top of the stack
13 ROT_THREE - rotates top three elements of stack
'''2 -==== Variable management''' ====
----
'''2 - Variable management'''
----
20 DEC S<nowiki><scope></nowiki> S<nowiki><type></nowiki> N - declare variable of type
21 LOV S<nowiki><scope></nowiki> N - loads reference variable on to stack
Line 179 ⟶ 176:
23 CTV S<nowiki><scope></nowiki> N D<nowiki><data></nowiki> - loads constant into variable
24 CTS D<nowiki><data></nowiki> - loads constant into stack
'''3 -==== Type management''' ====
----
'''3 - Type management'''
 
Types are in the air at this moment. I'll detail what types there are when
the time comes
----
30 [[typeof|TYPEOF]] - pushes type of TOS on to the stack TBI
31 CAST S<nowiki><type></nowiki> - Tries to cast TOS to <nowiki><type></nowiki> TBI
'''4 -==== Binary Ops''' ====
----
'''4 - Binary Ops'''
 
OPS take the two top elements of the stack, perform an operation and push
Line 209 ⟶ 204:
4E XOR - xor's TBI
4F NAND - and's TBI
'''5 -==== [[Conditional (computer programming)|Conditional Expressions]]''' ====
----
'''5 - [[Conditional (computer programming)|Conditional Expressions]]'''
 
Things for comparison, < > = ! and so on and so forth.
Line 225 ⟶ 219:
57 OR - Boolean OR
58 AND - Boolean AND
==== Loops ====
----
'''6 - Loops'''
----
60 STARTL - Start of loop
61 CLOOP - Conditional loop. If TOS is true, continue looping, else break
6E BREAK - Breaks out of loop
6F ENDL - End of loop
'''7 -==== Code flow''' ====
----
'''7 - Code flow'''
 
These instructions dictate code flow.
----
70 [[GOTO]] A<nowiki><addr></nowiki> - Goes to address
71 JUMPF A<nowiki><n></nowiki> - Goes forward <n> lines
72 IFDO - If TOS is TRUE, do until done, if not, jump to done
Line 247 ⟶ 238:
7E DONE - End of block
7F CALL N - Calls function, pushes return value on to STACK.
'''8 -==== Generic object interface. Expects object on TOS''' ====
----
'''8 - Generic object interface. Expects object on TOS'''
----
80 GETN N<nowiki><name></nowiki> - Returns variable associated with name in object
81 SETN N<nowiki><name></nowiki> - Sets the variable associated with name in object
Line 256 ⟶ 245:
83 INDEXO - Index an object, uses argument stack
84 MODO S<nowiki><OP></nowiki> - Modify an object based on op. [+, -, *, /, %, ^ .. etc.]
 
----
'''==== F - Functions/classes''' ====
 
----
FF DEFUN NS<nowiki><type></nowiki> D<nowiki><args></nowiki> - Un-funs everything. no, no- it defines a
function. D is its name, S<nowiki><type></nowiki> is
Line 268 ⟶ 257:
F1 NEW S<scope> N - Instantiates class
F0 RETURN - Returns from function
'''0 -==== Special Bytes''' ====
----
00 [[NULL]] - No-op
'''0 - Special Bytes'''
----
00 NULL - No-op
01 LC N<nowiki><name></nowiki> - Calls OS function library, i.e. I/O, opening files, etc. TBI
02 PRINT - Prints whatever is on the TOS.