blob: 4612dd7b2e723f1dfb08ff45e16501936ada2bf3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
package me.any
import AccessSerializer
import AddresationSerializer
import InstructionSerializer
import kotlinx.serialization.Serializable
@Serializable(with = AccessSerializer::class)
interface Access
@Serializable
data class SAccess(val sAddress: Access) : Access
@Serializable
data class Address(val address: Int) : Access
enum class Operation {
ADD, SUB, MUL, DIV, AND, OR, XOR
}
@Serializable(with = AddresationSerializer::class)
interface Addresation
data class AddressAddresation(val address: Access) : Addresation
data class BinaryOperation(
val op: Operation,
val left: Access,
val right: Access
) : Addresation
interface SysCall
class WriteSysCall : SysCall
class ReadSysCall : SysCall
enum class BranchPolarity {
IFTRUE, IFFALSE
}
@Serializable(with = InstructionSerializer::class)
interface Instruction
@Serializable
data class Comment(val comment: String = "") : Instruction
@Serializable
data class Write(val target: Int, val source: Addresation) : Instruction
@Serializable
data class LarsCode(val call: SysCall) : Instruction
@Serializable
data class Label(val label: String) : Instruction
@Serializable
data class GoTo(val label: String) : Instruction
@Serializable
data class Branch(val polarity: BranchPolarity, val address: Address, val label: String) : Instruction
@Serializable
data class Program(val instructions: List<Instruction>)
|