Added label type
This commit is contained in:
@ -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")
|
||||
|
Reference in New Issue
Block a user