diff --git a/src/asmc/armCompiler.go b/src/asmc/armCompiler.go index 0ce0434..e8529a0 100644 --- a/src/asmc/armCompiler.go +++ b/src/asmc/armCompiler.go @@ -80,7 +80,7 @@ func (c *armCompiler) handleMoveInstruction(instruction asm.Instruction) { if operands.Label.Type == asm.DataLabel { c.dataPointers = append(c.dataPointers, c.createDataPointer(operands, position)) } else { - panic("not implemented") + c.codePointers = append(c.codePointers, c.createCodePointer(operands, position)) } } } @@ -398,6 +398,24 @@ func (c *armCompiler) handleNegateInstruction(instruction asm.Instruction) { } } +func (c *armCompiler) createCodePointer(operands asm.RegisterLabel, position Address) *pointer { + return &pointer{ + Position: position, + OpSize: 0, + Size: 4, + Resolve: func() Address { + destination, exists := c.codeLabels[operands.Label.Name] + + if !exists { + panic("unknown label") + } + + distance := destination - position + 8 + return arm.LoadAddress(operands.Register, int(distance)) + }, + } +} + func (c *armCompiler) createDataPointer(operands asm.RegisterLabel, position Address) *pointer { return &pointer{ Position: position,