mirror of
				https://github.com/irmen/prog8.git
				synced 2025-11-04 10:16:13 +00:00 
			
		
		
		
	fix long bitwise expressions temp register usage
This commit is contained in:
		@@ -2034,25 +2034,24 @@ internal class AssignmentAsmGen(
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // TODO use R14:R15 instead
 | 
					 | 
				
			||||||
            val targetreg = target.register
 | 
					            val targetreg = target.register
 | 
				
			||||||
            if(targetreg!=RegisterOrPair.R12R13_32) {
 | 
					            if(targetreg!=RegisterOrPair.R14R15_32) {
 | 
				
			||||||
                asmgen.pushLongRegisters(RegisterOrPair.R12R13_32, 1)
 | 
					                asmgen.pushLongRegisters(RegisterOrPair.R14R15_32, 1)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            asmgen.assignExpressionToRegister(expr.left, RegisterOrPair.R12R13_32, expr.left.type.isSigned)
 | 
					            asmgen.assignExpressionToRegister(expr.left, RegisterOrPair.R14R15_32, expr.left.type.isSigned)
 | 
				
			||||||
            val constval = expr.right.asConstInteger()
 | 
					            val constval = expr.right.asConstInteger()
 | 
				
			||||||
            val varname = (expr.right as? PtIdentifier)?.name
 | 
					            val varname = (expr.right as? PtIdentifier)?.name
 | 
				
			||||||
            if(constval!=null)
 | 
					            if(constval!=null)
 | 
				
			||||||
                augmentableAsmGen.inplacemodificationLongWithLiteralval("cx16.r12", expr.operator, constval)
 | 
					                augmentableAsmGen.inplacemodificationLongWithLiteralval("cx16.r14", expr.operator, constval)
 | 
				
			||||||
            else if(varname!=null)
 | 
					            else if(varname!=null)
 | 
				
			||||||
                augmentableAsmGen.inplacemodificationLongWithVariable("cx16.r12", expr.operator, varname)
 | 
					                augmentableAsmGen.inplacemodificationLongWithVariable("cx16.r14", expr.operator, varname)
 | 
				
			||||||
            else {
 | 
					            else {
 | 
				
			||||||
                // TODO: preserve R14:R15 on stack here?  (the function does't do it for us)
 | 
					                // TODO: preserve R14:R15 on stack here?  (the function does't do it for us)
 | 
				
			||||||
                augmentableAsmGen.inplacemodificationLongWithExpression("cx16.r12", expr.operator, expr.right)
 | 
					                augmentableAsmGen.inplacemodificationLongWithExpression("cx16.r14", expr.operator, expr.right)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            assignRegisterLong(target, RegisterOrPair.R12R13_32)
 | 
					            assignRegisterLong(target, RegisterOrPair.R14R15_32)
 | 
				
			||||||
            if(targetreg!=RegisterOrPair.R12R13_32) {
 | 
					            if(targetreg!=RegisterOrPair.R14R15_32) {
 | 
				
			||||||
                asmgen.popLongRegisters(RegisterOrPair.R12R13_32, 1)
 | 
					                asmgen.popLongRegisters(RegisterOrPair.R14R15_32, 1)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return true
 | 
					            return true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,6 @@
 | 
				
			|||||||
TODO
 | 
					TODO
 | 
				
			||||||
====
 | 
					====
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- optimizedBitwiseExpr(): use R14:R15 instead to save copying/stack manipulation?
 | 
					 | 
				
			||||||
- implement inplaceLongAdd/Sub in PointerAssignmentGen
 | 
					- implement inplaceLongAdd/Sub in PointerAssignmentGen
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,17 +7,12 @@ main {
 | 
				
			|||||||
    sub start() {
 | 
					    sub start() {
 | 
				
			||||||
        long @shared lv, lv2
 | 
					        long @shared lv, lv2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cx16.r0L = if lv==9999  then 99 else 42
 | 
					        lv = $11111111
 | 
				
			||||||
        txt.print_ub(cx16.r0L)
 | 
					        lv2 = $55555555
 | 
				
			||||||
        txt.nl()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        lv2 = if lv==9999  then 999999 else 424242
 | 
					        lv = lv | lv2 ^ 999999
 | 
				
			||||||
        txt.print_l(lv2)
 | 
					
 | 
				
			||||||
        txt.nl()
 | 
					        txt.print_ulhex(lv, true)           ; $555b177b
 | 
				
			||||||
        lv=9999
 | 
					 | 
				
			||||||
        lv2 = if lv==9999  then 999999 else 424242
 | 
					 | 
				
			||||||
        txt.print_l(lv2)
 | 
					 | 
				
			||||||
        txt.nl()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
;        long @shared lv1 = $12345678
 | 
					;        long @shared lv1 = $12345678
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user