Added label type

This commit is contained in:
2025-03-13 16:57:13 +01:00
parent d96c351b4b
commit c1913d99d0
32 changed files with 102 additions and 63 deletions

View File

@ -3,7 +3,6 @@ package asmc
import (
"encoding/binary"
"fmt"
"strings"
"git.urbach.dev/cli/q/src/arm"
"git.urbach.dev/cli/q/src/asm"
@ -44,8 +43,11 @@ func (c *compiler) compileARM(x asm.Instruction) {
case asm.LABEL:
label := c.assembler.Param.Label[x.Index]
c.codeLabels[label.Name] = Address(len(c.code))
c.append(arm.StorePair(arm.FP, arm.LR, arm.SP, -16))
c.append(arm.MoveRegisterRegister(arm.FP, arm.SP))
if label.Type == asm.FunctionLabel {
c.append(arm.StorePair(arm.FP, arm.LR, arm.SP, -16))
c.append(arm.MoveRegisterRegister(arm.FP, arm.SP))
}
case asm.LOAD:
switch x.Type {
@ -140,13 +142,13 @@ func (c *compiler) compileARM(x asm.Instruction) {
position := Address(len(c.code))
c.append(arm.LoadAddress(operands.Register, 0))
if strings.HasPrefix(operands.Label, "data ") {
if operands.Label.Type == asm.DataLabel {
c.dataPointers = append(c.dataPointers, &pointer{
Position: position,
OpSize: 0,
Size: 4,
Resolve: func() Address {
destination, exists := c.dataLabels[operands.Label]
destination, exists := c.dataLabels[operands.Label.Name]
if !exists {
panic("unknown label")