mirror of
https://github.com/irmen/prog8.git
synced 2024-12-23 09:32:43 +00:00
working on vm
This commit is contained in:
parent
3b6e7eccdd
commit
5494f309c0
@ -6,6 +6,7 @@ import prog8.code.ast.*
|
||||
import prog8.code.core.*
|
||||
import prog8.vm.Instruction
|
||||
import prog8.vm.Opcode
|
||||
import prog8.vm.Syscall
|
||||
import prog8.vm.VmDataType
|
||||
|
||||
|
||||
@ -360,6 +361,17 @@ internal class ExpressionGen(val codeGen: CodeGen) {
|
||||
"lsb" -> {
|
||||
code += translateExpression(call.args.single(), resultRegister, regUsage)
|
||||
}
|
||||
"memory" -> {
|
||||
val name = (call.args[0] as PtString).value
|
||||
val size = (call.args[1] as PtNumber).number.toUInt()
|
||||
val align = (call.args[2] as PtNumber).number.toUInt()
|
||||
TODO("Memory($name, $size, $align)")
|
||||
}
|
||||
"rnd" -> {
|
||||
code += VmCodeInstruction(Instruction(Opcode.SYSCALL, value=Syscall.RND.ordinal))
|
||||
if(resultRegister!=0)
|
||||
code += VmCodeInstruction(Instruction(Opcode.LOADR, VmDataType.BYTE, reg1=resultRegister, reg2=0))
|
||||
}
|
||||
else -> {
|
||||
// TODO builtin functions...
|
||||
TODO("builtinfunc ${call.name}")
|
||||
|
@ -19,6 +19,14 @@ sub spc() {
|
||||
txt.chrout(' ')
|
||||
}
|
||||
|
||||
sub lowercase() {
|
||||
; not supported
|
||||
}
|
||||
|
||||
sub uppercase() {
|
||||
; not supported
|
||||
}
|
||||
|
||||
sub chrout(ubyte char) {
|
||||
syscall1(2, char)
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- adapt to new(?) addresses in cx16 math library https://github.com/commanderx16/x16-docs/blob/master/Commander%20X16%20Programmer's%20Reference%20Guide.md#math-library
|
||||
also fix calls to FPWRT etc as suggested there
|
||||
|
||||
...
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ main {
|
||||
|
||||
repeat 21 {
|
||||
txt.print_uw(fib_next())
|
||||
c64.CHROUT('\n')
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package prog8.vm
|
||||
|
||||
import kotlin.math.min
|
||||
import kotlin.random.Random
|
||||
|
||||
/*
|
||||
SYSCALLS:
|
||||
@ -16,6 +17,7 @@ SYSCALLS:
|
||||
8 = gfx_enable ; enable graphics window r0.b = 0 -> lores 320x240, r0.b = 1 -> hires 640x480
|
||||
9 = gfx_clear ; clear graphics window with shade in r0.b
|
||||
10 = gfx_plot ; plot pixel in graphics window, r0.w/r1.w contain X and Y coordinates, r2.b contains brightness
|
||||
11 = rnd ; random BYTE
|
||||
*/
|
||||
|
||||
enum class Syscall {
|
||||
@ -29,7 +31,8 @@ enum class Syscall {
|
||||
SLEEP,
|
||||
GFX_ENABLE,
|
||||
GFX_CLEAR,
|
||||
GFX_PLOT
|
||||
GFX_PLOT,
|
||||
RND
|
||||
}
|
||||
|
||||
object SysCalls {
|
||||
@ -76,6 +79,9 @@ object SysCalls {
|
||||
Syscall.GFX_ENABLE -> vm.gfx_enable()
|
||||
Syscall.GFX_CLEAR -> vm.gfx_clear()
|
||||
Syscall.GFX_PLOT -> vm.gfx_plot()
|
||||
Syscall.RND -> {
|
||||
vm.registers.setB(0, (Random.nextInt() ushr 3).toUByte())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user