Skip to content

Commit 48c45de

Browse files
committed
something
1 parent c59909e commit 48c45de

File tree

8 files changed

+17
-66
lines changed

8 files changed

+17
-66
lines changed

archive.zip

144 KB
Binary file not shown.

main.kar

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
help printr
2+
str f1 "Hello, World!"
3+
call println
4+
xlit x1 0.2
5+
xlit x2 3.14
6+
xadd x1 x2
7+
cpy r5 f1
8+
call strings.cheekyfloat

src/main/kotlin/data/registers/IntelNames.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class IntelNames {
5454
IntelRegisters.SF -> RegisterType.I2
5555
IntelRegisters.GF -> RegisterType.I3
5656
IntelRegisters.EF -> RegisterType.I4
57-
IntelRegisters.SCSF -> RegisterType.I5 // todo, actually implement
57+
IntelRegisters.SCSF -> RegisterType.I5
5858
IntelRegisters.ENSF -> RegisterType.I6
5959
IntelRegisters.ESF -> RegisterType.I7
6060

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package data.registers
22

33
import data.registers.RegisterDataType.*
4-
import errors
5-
import kotlin.system.exitProcess
64

75
/**
86
* Represents a supertype encompassing all register types in the virtual machine.
@@ -60,56 +58,8 @@ data class RegisterData(val name: RegisterType, var data: Long?, var dataType: R
6058
}
6159

6260

63-
fun readDouble(): Double {
64-
return try {
65-
Double.fromBits(data!!)
66-
} catch (_: NullPointerException) {
67-
errors.NullRegisterException(name)
68-
exitProcess(1)
69-
}
70-
}
71-
72-
fun readFloat(): Float {
73-
return try {
74-
Float.fromBits(data!!.toInt())
75-
} catch (_: NullPointerException) {
76-
errors.NullRegisterException(name)
77-
exitProcess(1)
78-
}
79-
}
80-
81-
fun writeDouble(value: Double?) {
82-
if (value == null) {
83-
data = null
84-
return
85-
}
86-
data = when (dataType) {
87-
RByte -> value.toInt().toByte()
88-
RShort -> value.toInt().toShort()
89-
RInt -> value.toInt()
90-
RLong -> value.toLong()
91-
RFloat -> value.toFloat()
92-
RDouble -> value.toDouble()
93-
94-
}.toDouble().toBits()
95-
}
96-
9761

98-
fun writeFloat(value: Float?) {
99-
if (value == null) {
100-
data = null
101-
return
102-
}
103-
data = when (dataType) {
104-
RByte -> value.toInt().toByte()
105-
RShort -> value.toInt().toShort()
106-
RInt -> value.toInt()
107-
RLong -> value.toLong()
108-
RFloat -> value.toFloat()
109-
RDouble -> value.toDouble()
11062

111-
}.toFloat().toBits().toLong()
112-
}
11363

11464
fun settype(newType: RegisterDataType) {
11565
dataType = when (newType) {
@@ -121,14 +71,6 @@ data class RegisterData(val name: RegisterType, var data: Long?, var dataType: R
12171
RDouble -> RDouble
12272
}
12373

124-
// data = when(newType) {
125-
// RByte -> data?.toByte()
126-
// RShort -> data?.toShort()
127-
// RInt -> data?.toInt()
128-
// RLong -> data?.toLong()
129-
// RFloat -> data?.toFloat()?.toBits()
130-
// RDouble -> data?.toDouble()?.toBits()
131-
// }?.toLong()
13274
}
13375

13476
}

src/main/kotlin/engine/Parser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fun parser(file: List<String>): List<InstructData> {
9393
"syscall" -> {
9494
InstructData(
9595
name = "syscall", arrayOf(
96-
RegisterType.S0, RegisterType.S1, RegisterType.S2, RegisterType.S3
96+
RegisterType.S1, RegisterType.S2, RegisterType.S3, RegisterType.S4
9797
)
9898

9999
)

src/main/kotlin/engine/v2/TransMapIDs.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class TransMapIDs {
1919
G2 to '@',
2020
G3 to '#',
2121
G4 to '$',
22-
S0 to '%',
23-
S1 to '^',
24-
S2 to '&',
25-
S3 to '*',
22+
S1 to '%',
23+
S2 to '^',
24+
S3 to '&',
25+
S4 to '*',
2626
R1 to '(',
2727
R2 to ')',
2828
R3 to '-',

src/main/kotlin/helpers/ConfigStructure.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package helpers
22

3+
34
import kotlinx.serialization.Serializable
45

56
@Serializable

src/main/resources/lib/println.lib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// needs arg F1, which is the string address
22
LIT S1 24
3-
MOV F1 S1
4-
STRLEN S1
3+
MOV F1 S2
4+
STRLEN S2
55
ADD R4 F1
66
LIT G1 10
77
LIT G2 0

0 commit comments

Comments
 (0)