diff --git a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt index 07312c5bd..8a7263ff0 100644 --- a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt +++ b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt @@ -985,9 +985,21 @@ class FunctionCallExpression(override var target: IdentifierReference, return InferredTypes.knownFor(stmt.returntypes[0]) // multiple return values. Can occur for asmsub routines. If there is exactly one register return value, take that. - val numRegisterReturns = stmt.asmReturnvaluesRegisters.count { it.registerOrPair!=null } - if(numRegisterReturns==1) - return InferredTypes.InferredType.known(DataType.UBYTE) + val registerReturns = stmt.asmReturnvaluesRegisters.filter {it.registerOrPair != null } + if(registerReturns.size==1) { + val reg = registerReturns.single().registerOrPair!! + return when(reg) { + RegisterOrPair.A, + RegisterOrPair.X, + RegisterOrPair.Y -> InferredTypes.InferredType.known(DataType.UBYTE) + RegisterOrPair.AX, + RegisterOrPair.AY, + RegisterOrPair.XY, in Cx16VirtualRegisters -> InferredTypes.InferredType.known(DataType.UWORD) + RegisterOrPair.FAC1, + RegisterOrPair.FAC2 -> InferredTypes.InferredType.known(DataType.FLOAT) + else -> throw FatalAstException("weird reg") + } + } return InferredTypes.unknown() // has multiple return types... so not a single resulting datatype possible } diff --git a/examples/test.p8 b/examples/test.p8 index cba0c4597..6ce9e7c67 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -7,27 +7,35 @@ main { sub start() { + txt.print("keyboard api test\n") + + cx16.kbdbuf_put('l') + cx16.kbdbuf_put('o') + cx16.kbdbuf_put('a') + cx16.kbdbuf_put('d') + cx16.kbdbuf_put(13) + ; the "pixelshader": - syscall1(8, 0) ; enable lo res creen - ubyte shifter - - shifter >>= 1 - - repeat { - uword xx - uword yy = 0 - repeat 240 { - xx = 0 - repeat 320 { - syscall3(10, xx, yy, xx*yy + shifter) ; plot pixel - xx++ - } - yy++ - } - shifter+=4 - - txt.print_ub(shifter) - txt.nl() - } +; syscall1(8, 0) ; enable lo res creen +; ubyte shifter +; +; shifter >>= 1 +; +; repeat { +; uword xx +; uword yy = 0 +; repeat 240 { +; xx = 0 +; repeat 320 { +; syscall3(10, xx, yy, xx*yy + shifter) ; plot pixel +; xx++ +; } +; yy++ +; } +; shifter+=4 +; +; txt.print_ub(shifter) +; txt.nl() +; } } }