Documentation ¶
Index ¶
- type Address
- type Assembler
- func (a *Assembler) AddData(data []byte) Address
- func (a *Assembler) AddLabel(name string)
- func (a *Assembler) AddLabelAt(name string, address uint32)
- func (a *Assembler) AddRegisterNumber(registerNameTo string, number uint64)
- func (a *Assembler) AddRegisterRegister(registerNameTo string, registerNameFrom string)
- func (a *Assembler) CPUID()
- func (a *Assembler) Call(label string)
- func (a *Assembler) Code() []byte
- func (a *Assembler) CompareRegisterNumber(registerName string, number uint64)
- func (a *Assembler) CompareRegisterRegister(registerNameA string, registerNameB string)
- func (a *Assembler) Compile() error
- func (a *Assembler) Data() []byte
- func (a *Assembler) DecreaseRegister(registerName string)
- func (a *Assembler) DivRegister(registerName string)
- func (a *Assembler) EndBr64()
- func (a *Assembler) Exit(code int32)
- func (a *Assembler) IncreaseRegister(registerName string)
- func (a *Assembler) Jump(label string)
- func (a *Assembler) JumpIfEqual(label string)
- func (a *Assembler) JumpIfGreater(label string)
- func (a *Assembler) JumpIfGreaterOrEqual(label string)
- func (a *Assembler) JumpIfLess(label string)
- func (a *Assembler) JumpIfLessOrEqual(label string)
- func (a *Assembler) JumpIfNotEqual(label string)
- func (a *Assembler) LoadRegister(registerNameTo string, registerNameFrom string, offset byte, byteCount byte)
- func (a *Assembler) Merge(b *Assembler)
- func (a *Assembler) MoveRegisterAddress(registerNameTo string, address uint32)
- func (a *Assembler) MoveRegisterNumber(registerNameTo string, number uint64) uint32
- func (a *Assembler) MoveRegisterRegister(registerNameTo string, registerNameFrom string)
- func (a *Assembler) MulRegisterNumber(registerNameTo string, number uint64)
- func (a *Assembler) MulRegisterRegister(registerNameTo string, registerNameFrom string)
- func (a *Assembler) Open(fileName string)
- func (a *Assembler) Pointers() []Pointer
- func (a *Assembler) PopRegister(registerName string)
- func (a *Assembler) Position() Address
- func (a *Assembler) Print(msg string)
- func (a *Assembler) Println(msg string)
- func (a *Assembler) PushRegister(registerName string)
- func (a *Assembler) ReadTimeStampCounterAndProcessorID()
- func (a *Assembler) Reset()
- func (a *Assembler) Return()
- func (a *Assembler) SignExtendToDX(registerName string)
- func (a *Assembler) StoreNumber(registerNameTo string, offset byte, byteCount byte, number uint64)
- func (a *Assembler) StoreRegister(registerNameTo string, offset byte, byteCount byte, registerNameFrom string)
- func (a *Assembler) SubRegisterNumber(registerNameTo string, number uint64)
- func (a *Assembler) SubRegisterRegister(registerNameTo string, registerNameFrom string)
- func (a *Assembler) Syscall()
- func (a *Assembler) Write(code []byte) (int, error)
- func (a *Assembler) WriteBytes(someBytes ...byte)
- func (a *Assembler) WriteUint16(number uint16)
- func (a *Assembler) WriteUint32(number uint32)
- func (a *Assembler) WriteUint64(number uint64)
- type Pointer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address = uint32
Address represents a memory address, usually the jump address of a label.
type Assembler ¶
type Assembler struct { EnableOptimizer bool // contains filtered or unexported fields }
Assembler implements machine-code encoding.
func (*Assembler) AddData ¶
AddData writes the given byte slice to the data segment and returns the address.
func (*Assembler) AddLabelAt ¶
AddLabelAt adds a label for the given address.
func (*Assembler) AddRegisterNumber ¶
AddRegisterNumber adds a number to the given register.
func (*Assembler) AddRegisterRegister ¶
AddRegisterRegister adds a register value into another register.
func (*Assembler) CPUID ¶
func (a *Assembler) CPUID()
CPUID is used to query CPU relevant data based on the contents of EAX.
func (*Assembler) Call ¶
Call places the return address on the top of the stack and continues program flow at the new address. The address is relative to the next instruction.
func (*Assembler) CompareRegisterNumber ¶
CompareRegisterNumber compares a register with a number.
func (*Assembler) CompareRegisterRegister ¶
CompareRegisterRegister compares a register with a register.
func (*Assembler) DecreaseRegister ¶
DecreaseRegister decreases the register value by 1.
func (*Assembler) DivRegister ¶
DivRegister divides the value in rax (usually) by the value in the specified register. This is a signed division. Quotient: AL AX EAX RAX Remainder: AH DX EDX RDX
func (*Assembler) EndBr64 ¶
func (a *Assembler) EndBr64()
EndBr64 is a security related instruction enabling CET (Control-flow Enforcement Technology). It ensures that indirect branches go to a valid location.
func (*Assembler) IncreaseRegister ¶
IncreaseRegister increases the register value by 1.
func (*Assembler) Jump ¶
Jump continues program flow at the new address. The address is relative to the next instruction.
func (*Assembler) JumpIfEqual ¶
JumpIfEqual jumps if the result was equal.
func (*Assembler) JumpIfGreater ¶
JumpIfGreater jumps if the result was greater.
func (*Assembler) JumpIfGreaterOrEqual ¶
JumpIfGreaterOrEqual jumps if the result was greater or equal.
func (*Assembler) JumpIfLess ¶
JumpIfLess jumps if the result was less.
func (*Assembler) JumpIfLessOrEqual ¶
JumpIfLessOrEqual jumps if the result was less or equal.
func (*Assembler) JumpIfNotEqual ¶
JumpIfNotEqual jumps if the result was not equal.
func (*Assembler) LoadRegister ¶
func (a *Assembler) LoadRegister(registerNameTo string, registerNameFrom string, offset byte, byteCount byte)
LoadRegister loads from memory into a register.
func (*Assembler) MoveRegisterAddress ¶
MoveRegisterAddress moves an address into the given register.
func (*Assembler) MoveRegisterNumber ¶
MoveRegisterNumber moves a number into the given register.
func (*Assembler) MoveRegisterRegister ¶
MoveRegisterRegister moves a register value into another register.
func (*Assembler) MulRegisterNumber ¶
MulRegisterNumber multiplies a register with a number.
func (*Assembler) MulRegisterRegister ¶
MulRegisterRegister multiplies a register with another register.
func (*Assembler) PopRegister ¶
PopRegister pops a value from the stack and saves it into the register.
func (*Assembler) PushRegister ¶
PushRegister pushes the value inside the register onto the stack.
func (*Assembler) ReadTimeStampCounterAndProcessorID ¶
func (a *Assembler) ReadTimeStampCounterAndProcessorID()
ReadTimeStampCounterAndProcessorID is used for performance benchmarks.
func (*Assembler) Reset ¶
func (a *Assembler) Reset()
Reset deletes the entire contents of the assembler.
func (*Assembler) Return ¶
func (a *Assembler) Return()
Return transfers program control to a return address located on the top of the stack. The address is usually placed on the stack by a Call instruction.
func (*Assembler) SignExtendToDX ¶
SignExtendToDX doubles the size of the register by sign-extending to DX/EDX/RDX.
func (*Assembler) StoreNumber ¶
StoreNumber stores a number into the memory address included in the given register.
func (*Assembler) StoreRegister ¶
func (a *Assembler) StoreRegister(registerNameTo string, offset byte, byteCount byte, registerNameFrom string)
StoreRegister stores the contents of a register into the memory address included in the given register.
func (*Assembler) SubRegisterNumber ¶
SubRegisterNumber subtracts a number from a register.
func (*Assembler) SubRegisterRegister ¶
SubRegisterRegister subtracts a register value from another register.
func (*Assembler) WriteBytes ¶
WriteBytes writes the given bytes to the machine code.
func (*Assembler) WriteUint16 ¶
WriteUint16 writes an unsigned 16-bit integer in little endian format to the machine code.
func (*Assembler) WriteUint32 ¶
WriteUint32 writes an unsigned 32-bit integer in little endian format to the machine code.
func (*Assembler) WriteUint64 ¶
WriteUint64 writes an unsigned 64-bit integer in little endian format to the machine code.