mirror of
https://github.com/irmen/prog8.git
synced 2024-11-22 15:33:02 +00:00
optimized mkword(0, X)
This commit is contained in:
parent
4d2b21816d
commit
4d840c7db8
@ -331,6 +331,14 @@ class ExpressionSimplifier(private val program: Program) : AstWalker() {
|
||||
}
|
||||
}
|
||||
|
||||
if(functionCallExpr.target.nameInSource == listOf("mkword")) {
|
||||
if(functionCallExpr.args[0].constValue(program)?.number==0.0) {
|
||||
// just cast the lsb to uword
|
||||
val cast = TypecastExpression(functionCallExpr.args[1], DataType.UWORD, true, functionCallExpr.position)
|
||||
return listOf(IAstModification.ReplaceNode(functionCallExpr, cast, parent))
|
||||
}
|
||||
}
|
||||
|
||||
return noModifications
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,6 @@ TODO
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- crc ^= mkword(@(data), 0) produces faulty asm, as opposed to crc ^= mkword(variable, 0)
|
||||
- optimize asm generated for mkword(0, X) and mkword(X, 0)
|
||||
- check signed value >> and << .... do we calculate the right thing?
|
||||
|
||||
...
|
||||
|
||||
|
@ -3,17 +3,17 @@
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
uword ww = $ff34
|
||||
ww = ww ^ ww<<8
|
||||
ubyte left = $12
|
||||
ubyte right = $34
|
||||
uword ww
|
||||
|
||||
ww = mkword(left, right)
|
||||
txt.print_uwhex(ww, true)
|
||||
ww = $ff34
|
||||
ww = ww ^ mkword(lsb(ww), 0)
|
||||
ww = mkword(left, 0)
|
||||
txt.print_uwhex(ww, true)
|
||||
ww = $ff34
|
||||
ww = ww ^ ww >> 8
|
||||
ww = mkword(0, right)
|
||||
txt.print_uwhex(ww, true)
|
||||
ww = $ff34
|
||||
ww = ww ^ msb(ww)
|
||||
ww = right as uword
|
||||
txt.print_uwhex(ww, true)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user