Implemented dynamic array indices

This commit is contained in:
2025-01-24 22:47:28 +01:00
parent c0b30e9c22
commit 6dad6fb6a6
10 changed files with 393 additions and 21 deletions

View File

@ -3,6 +3,7 @@ package asm
import (
"encoding/binary"
"fmt"
"math"
"slices"
"strings"
@ -287,9 +288,17 @@ func (a Assembler) Finalize(dlls dll.List) ([]byte, []byte) {
case STORE:
switch operands := x.Data.(type) {
case *MemoryNumber:
code = x64.StoreNumber(code, operands.Address.Base, operands.Address.Offset, operands.Address.Length, operands.Number)
if operands.Address.OffsetRegister == math.MaxUint8 {
code = x64.StoreNumber(code, operands.Address.Base, operands.Address.Offset, operands.Address.Length, operands.Number)
} else {
code = x64.StoreDynamicOffsetNumber(code, operands.Address.Base, operands.Address.OffsetRegister, operands.Address.Length, operands.Number)
}
case *MemoryRegister:
code = x64.StoreRegister(code, operands.Address.Base, operands.Address.Offset, operands.Address.Length, operands.Register)
if operands.Address.OffsetRegister == math.MaxUint8 {
code = x64.StoreRegister(code, operands.Address.Base, operands.Address.Offset, operands.Address.Length, operands.Register)
} else {
code = x64.StoreDynamicOffsetRegister(code, operands.Address.Base, operands.Address.OffsetRegister, operands.Address.Length, operands.Register)
}
}
case SYSCALL: