m64

package
v0.0.0-...-3948e75 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package m64 provides a 64-bit arithmetic evaluator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Evaluator

type Evaluator struct {
	// contains filtered or unexported fields
}

Evaluator for arithmetic programs with 64-bit limbs.

func NewEvaluator

func NewEvaluator() *Evaluator

func (*Evaluator) Execute

func (e *Evaluator) Execute(p *ir.Program) error

Execute the program p.

func (*Evaluator) Int

func (e *Evaluator) Int(z ir.Registers) (*big.Int, error)

Int returns the integer represented by the 64-bit limbs in the given registers.

func (*Evaluator) Register

func (e *Evaluator) Register(r ir.Register) (uint64, error)

Register returns the value in the given register.

func (*Evaluator) SetInt

func (e *Evaluator) SetInt(z ir.Registers, x *big.Int)

SetInt sets registers to the 64-bit limbs of x.

func (*Evaluator) SetRegister

func (e *Evaluator) SetRegister(r ir.Register, x uint64)

SetRegister sets register r to value x.

type Processor

type Processor struct {
	// contains filtered or unexported fields
}

Processor is a 64-bit arithmetic evaluator.

func New

func New() *Processor

New builds a new 64-bit arithmetic processor.

func (*Processor) ADD

func (p *Processor) ADD(x, y, cin eval.Value) (sum, cout eval.Value)

ADD executes an add with carry instruction.

func (Processor) Bits

func (Processor) Bits() uint

Bits returns the word size.

func (Processor) Const

func (Processor) Const(x uint64, n uint) eval.Value

Const builds an n-bit constant.

func (*Processor) Errors

func (p *Processor) Errors() []error

Errors returns any errors encountered during execution.

func (*Processor) ITE

func (p *Processor) ITE(l, r, x, y eval.Value) eval.Value

ITE returns x if l≡r else y.

func (*Processor) MUL

func (p *Processor) MUL(x, y eval.Value) (hi, lo eval.Value)

MUL executes a multiply instruction.

func (*Processor) SHL

func (p *Processor) SHL(x eval.Value, s uint) eval.Value

SHL executes a shift left instruction.

func (*Processor) SHR

func (p *Processor) SHR(x eval.Value, s uint) eval.Value

SHR executes a shift right instruction.

func (*Processor) SUB

func (p *Processor) SUB(x, y, bin eval.Value) (diff, bout eval.Value)

SUB executes a subtract with borrow instruction.

type Word

type Word uint64

Word is a 64-bit machine word.

func (Word) Bits

func (x Word) Bits() uint

Bits returns the number of bits required to represent x.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL