Implemented code pointers on arm64

This commit is contained in:
2025-04-29 18:12:51 +02:00
parent aae3a552bb
commit 9d6356e8a9

View File

@ -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,