util

package
v0.0.0-...-7a30345 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddrArg

func AddrArg(defAdr, maxAdr uint, args []string) (uint, error)

AddrArg converts an address argument to an address value.

func BitMask

func BitMask(msb, lsb uint) uint

BitMask returns a bit mask from the msb to lsb bits.

func BoolToInt

func BoolToInt(x bool) int

BoolToInt converts a boolean to an int (1 or 0).

func DisplayEnum

func DisplayEnum(x uint, m map[uint]string, unknown string) string

DisplayEnum returns the display string for an enumeration.

func FileExists

func FileExists(name string) bool

FileExists returns true if the file exists.

func FmtDec

func FmtDec(x uint) string

FmtDec formats a uint as a decimal string.

func FmtHex

func FmtHex(x uint) string

FmtHex formats a uint as a hexadecimal string.

func FmtHex16

func FmtHex16(x uint) string

FmtHex16 formats a uint as a 4-nybble hexadecimal string.

func FmtHex8

func FmtHex8(x uint) string

FmtHex8 formats a uint as a 2-nybble hexadecimal string.

func GetBits

func GetBits(x, msb, lsb uint) uint

GetBits reads a bit field from a value.

func GetELFClass

func GetELFClass(filename string) (elf.Class, error)

GetELFClass return the elf file class (32 or 64 bit)

func GreenString

func GreenString(s string) string

GreenString returns a green string.

func MaskBits

func MaskBits(x, msb, lsb uint) uint

MaskBits masks a bit field within a value.

func MemArg

func MemArg(defAdr, maxAdr uint, args []string) (uint, uint, error)

MemArg converts memory arguments to an (address, size) tuple.

func RedString

func RedString(s string) string

RedString returns a red string.

func SetBits

func SetBits(x, val, msb, lsb uint) uint

SetBits writes a bit field within a value.

Types

type Field

type Field struct {
	Name     string
	Msb, Lsb uint
	Fmt      fmtFunc
}

Field is a bit field within a uint value.

func (*Field) Display

func (f *Field) Display(x uint) string

Display returns a display string for a bit field.

type FieldSet

type FieldSet []Field

FieldSet is a set of field definitions.

func (FieldSet) Display

func (fs FieldSet) Display(x uint) string

Display returns a display string for the bit fields of a uint value.

Jump to

Keyboard shortcuts

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