From 72272ed9af7a018650a13984966a519f29da48ea Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 14 Mar 2025 12:08:14 +0100 Subject: [PATCH] Implemented multiplication with a number on arm64 --- src/asmc/compileARM.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/asmc/compileARM.go b/src/asmc/compileARM.go index fbf01b5..5658a91 100644 --- a/src/asmc/compileARM.go +++ b/src/asmc/compileARM.go @@ -144,16 +144,19 @@ func (c *compiler) compileARM(x asm.Instruction) { operand := c.assembler.Param.RegisterRegister[x.Index] c.append(arm.MulRegisterRegister(operand.Destination, operand.Destination, operand.Source)) case asm.TypeRegisterNumber: - panic("not implemented") + operand := c.assembler.Param.RegisterNumber[x.Index] + tmp := arm.X28 + c.append(arm.MoveRegisterNumber(tmp, operand.Number)) + c.append(arm.MulRegisterRegister(operand.Register, operand.Register, tmp)) } case asm.MODULO: switch x.Type { case asm.TypeRegisterRegister: operand := c.assembler.Param.RegisterRegister[x.Index] - quotient := arm.X28 - c.append(arm.DivSigned(quotient, operand.Destination, operand.Source)) - c.append(arm.MultiplySubtract(operand.Destination, quotient, operand.Source, operand.Destination)) + tmp := arm.X28 + c.append(arm.DivSigned(tmp, operand.Destination, operand.Source)) + c.append(arm.MultiplySubtract(operand.Destination, tmp, operand.Source, operand.Destination)) case asm.TypeRegisterNumber: panic("not implemented") }