mirror of
https://github.com/irmen/prog8.git
synced 2025-08-15 14:27:37 +00:00
fix push() of signed values
This commit is contained in:
@@ -174,11 +174,12 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun funcPush(fcall: IFunctionCall, func: FSignature) {
|
private fun funcPush(fcall: IFunctionCall, func: FSignature) {
|
||||||
|
val signed = fcall.args[0].inferType(program).oneOf(DataType.BYTE, DataType.WORD)
|
||||||
if(func.name=="push") {
|
if(func.name=="push") {
|
||||||
asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.A)
|
asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.A, signed)
|
||||||
asmgen.out(" pha")
|
asmgen.out(" pha")
|
||||||
} else {
|
} else {
|
||||||
asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.AY, signed)
|
||||||
if (asmgen.isTargetCpu(CpuType.CPU65c02))
|
if (asmgen.isTargetCpu(CpuType.CPU65c02))
|
||||||
asmgen.out(" pha | phy")
|
asmgen.out(" pha | phy")
|
||||||
else
|
else
|
||||||
|
@@ -2083,7 +2083,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
else -> throw AssemblyError("weird target kind for inplace negate float ${target.kind}")
|
else -> throw AssemblyError("weird target kind for inplace negate float ${target.kind}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> throw AssemblyError("negate of invalid type")
|
else -> throw AssemblyError("negate of invalid type $dt")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,8 +14,9 @@ main {
|
|||||||
uword @shared uw
|
uword @shared uw
|
||||||
ubyte @shared ub
|
ubyte @shared ub
|
||||||
word @shared ww
|
word @shared ww
|
||||||
|
byte @shared bb
|
||||||
|
|
||||||
push(127)
|
push(-bb)
|
||||||
pop(ub)
|
pop(ub)
|
||||||
txt.print_ub(ub)
|
txt.print_ub(ub)
|
||||||
txt.nl()
|
txt.nl()
|
||||||
|
Reference in New Issue
Block a user