Added x86 package
All checks were successful
/ test (push) Successful in 14s

This commit is contained in:
Eduard Urbach 2025-06-23 11:45:57 +02:00
parent 31c5ed614c
commit bac5986425
Signed by: akyoto
GPG key ID: 49226B848C78F6C8
61 changed files with 2745 additions and 0 deletions

27
src/x86/StoreDynamic.go Normal file
View file

@ -0,0 +1,27 @@
package x86
import (
"encoding/binary"
"git.urbach.dev/cli/q/src/cpu"
)
// StoreDynamicNumber writes a number to a memory address with a register offset.
func StoreDynamicNumber(code []byte, base cpu.Register, offset cpu.Register, length byte, number int) []byte {
code = memAccessDynamic(code, 0xC6, 0xC7, 0b000, base, offset, length)
switch length {
case 8, 4:
return binary.LittleEndian.AppendUint32(code, uint32(number))
case 2:
return binary.LittleEndian.AppendUint16(code, uint16(number))
}
return append(code, byte(number))
}
// StoreDynamicRegister writes the contents of a register to a memory address with a register offset.
func StoreDynamicRegister(code []byte, base cpu.Register, offset cpu.Register, length byte, source cpu.Register) []byte {
return memAccessDynamic(code, 0x88, 0x89, source, base, offset, length)
}