mirror of
https://github.com/irmen/prog8.git
synced 2024-12-03 13:49:23 +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
|
return noModifications
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@ TODO
|
|||||||
For next release
|
For next release
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
- crc ^= mkword(@(data), 0) produces faulty asm, as opposed to crc ^= mkword(variable, 0)
|
- 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 {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
uword ww = $ff34
|
ubyte left = $12
|
||||||
ww = ww ^ ww<<8
|
ubyte right = $34
|
||||||
|
uword ww
|
||||||
|
|
||||||
|
ww = mkword(left, right)
|
||||||
txt.print_uwhex(ww, true)
|
txt.print_uwhex(ww, true)
|
||||||
ww = $ff34
|
ww = mkword(left, 0)
|
||||||
ww = ww ^ mkword(lsb(ww), 0)
|
|
||||||
txt.print_uwhex(ww, true)
|
txt.print_uwhex(ww, true)
|
||||||
ww = $ff34
|
ww = mkword(0, right)
|
||||||
ww = ww ^ ww >> 8
|
|
||||||
txt.print_uwhex(ww, true)
|
txt.print_uwhex(ww, true)
|
||||||
ww = $ff34
|
ww = right as uword
|
||||||
ww = ww ^ msb(ww)
|
|
||||||
txt.print_uwhex(ww, true)
|
txt.print_uwhex(ww, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user