asm

package
v0.0.0-...-85084b6 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageError   = iota
	MessageWarning = iota
	MessageInfo    = iota
)
View Source
const (
	OpColumn      = 16
	CommentColumn = 32
)

Variables

This section is empty.

Functions

func WriteListing

func WriteListing(inputs []string, linker *Linker) error

WriteListing prints the generated bytes next to the original source, ie an assembly listing.

Types

type BytesLiteral

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

type CharLiteral

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

type DefineByteStatement

type DefineByteStatement struct {
	Node
	// contains filtered or unexported fields
}

type DefineSpaceStatement

type DefineSpaceStatement struct {
	Node
	// contains filtered or unexported fields
}

type DefineWordStatement

type DefineWordStatement struct {
	Node
	// contains filtered or unexported fields
}

type EquateStatement

type EquateStatement struct {
	Node
	// contains filtered or unexported fields
}

type Expr

type Expr interface {
	// contains filtered or unexported methods
}

type ExprBinary

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

type ExprIdent

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

type ExprUnary

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

ExprUnary is a unary operation (+, -) on an expression.

type FpParam

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

type FunctionStatement

type FunctionStatement struct {
	Node
	// contains filtered or unexported fields
}

type ImportStatement

type ImportStatement struct {
	Node
	// contains filtered or unexported fields
}

type Input

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

Input implements TokenReader but delegates to a list of underlying TokenReaders, reading each in order until EOF and then moving to the next. Copied from Go's asm/lexer/stack except this one is in order rather than stack based. Need it in order because the first source file will establish the org, all others must be libraries with relocatable code.

func NewInput

func NewInput(readers []TokenReader) *Input

func (*Input) Append

func (i *Input) Append(r TokenReader)

func (*Input) Column

func (i *Input) Column() int

func (*Input) FileName

func (i *Input) FileName() string

func (*Input) Files

func (i *Input) Files() []string

func (*Input) Line

func (i *Input) Line() int

func (*Input) Next

func (i *Input) Next() TokenType

func (*Input) Token

func (i *Input) Token() TokenType

func (*Input) TokenText

func (i *Input) TokenText() string

type InstructionStatement

type InstructionStatement struct {
	Node
	// contains filtered or unexported fields
}

type IntLiteral

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

type LabelStatement

type LabelStatement struct {
	Node
	// contains filtered or unexported fields
}

type Lexer

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

func NewLexer

func NewLexer(name string, r io.Reader) *Lexer

func (*Lexer) Column

func (l *Lexer) Column() int

func (*Lexer) FileName

func (l *Lexer) FileName() string

func (*Lexer) Line

func (l *Lexer) Line() int

func (*Lexer) Next

func (l *Lexer) Next() TokenType

func (*Lexer) Token

func (l *Lexer) Token() TokenType

func (*Lexer) TokenText

func (l *Lexer) TokenText() string

type Linker

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

func NewLinker

func NewLinker(stmt Statement) *Linker

func (*Linker) BytesFor

func (l *Linker) BytesFor(stmt Statement) []byte

func (*Linker) Code

func (l *Linker) Code() []byte

func (*Linker) HasErrors

func (l *Linker) HasErrors() bool
func (l *Linker) Link()

Link uses two passes to try to resolve all references and generate code into l.code.

func (*Linker) PrintMessages

func (l *Linker) PrintMessages()

type Message

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

Message describes a compiler error, warning, or informational message.

func (Message) String

func (m Message) String() string

type Messages

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

Messages is a collection of compiler messages.

func (*Messages) AddMessage

func (m *Messages) AddMessage(messageType int, file string, line, column int, message string)

func (*Messages) Error

func (m *Messages) Error(file string, line int, column int, message string)

func (*Messages) Info

func (m *Messages) Info(file string, line int, column int, message string)

func (*Messages) Print

func (m *Messages) Print()

func (*Messages) Warn

func (m *Messages) Warn(file string, line int, column int, message string)

type Node

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

Node defines the common fields that all statements share.

func (*Node) BlockComment

func (n *Node) BlockComment() []string

func (*Node) EolComment

func (n *Node) EolComment() string

func (*Node) File

func (n *Node) File() string

func (*Node) Line

func (n *Node) Line() int

func (*Node) NewlineBefore

func (n *Node) NewlineBefore() bool

func (*Node) Next

func (n *Node) Next() Statement

func (*Node) PcEnd

func (n *Node) PcEnd() int

func (*Node) PcStart

func (n *Node) PcStart() int

func (*Node) SetBlockComment

func (n *Node) SetBlockComment(blockComment []string)

func (*Node) SetEolComment

func (n *Node) SetEolComment(eolComment string)

func (*Node) SetFile

func (n *Node) SetFile(file string)

func (*Node) SetLine

func (n *Node) SetLine(line int)

func (*Node) SetNewlineBefore

func (n *Node) SetNewlineBefore(newlineBefore bool)

func (*Node) SetNext

func (n *Node) SetNext(next Statement)

func (*Node) SetPcEnd

func (n *Node) SetPcEnd(pcEnd int)

func (*Node) SetPcStart

func (n *Node) SetPcStart(pcStart int)

func (*Node) String

func (n *Node) String() string

type Operand

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

type OrgStatement

type OrgStatement struct {
	Node
	// contains filtered or unexported fields
}

type Parser

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

func NewParser

func NewParser(lex *Input) *Parser

func NewParserFromReader

func NewParserFromReader(name string, r io.Reader) *Parser

func (*Parser) Files

func (p *Parser) Files() []string

Files returns the list of all files processed.

func (*Parser) HasErrors

func (p *Parser) HasErrors() bool

func (*Parser) Parse

func (p *Parser) Parse()

Parse the input.

func (*Parser) PrintErrors

func (p *Parser) PrintErrors()

func (*Parser) SetProcessImport

func (p *Parser) SetProcessImport(process bool)

func (*Parser) Statements

func (p *Parser) Statements() Statement

type Printer

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

Printer pretty-prints statements to a writer.

func NewPrinter

func NewPrinter(w io.Writer) *Printer

func (*Printer) Print

func (p *Printer) Print(stmt Statement)

type Source

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

Source represents a source file and the current state of lexing it.

func NewSource

func NewSource(filename string, reader io.Reader) *Source

func (*Source) Backup

func (s *Source) Backup()

Backup one character.

func (*Source) GetTokenImage

func (s *Source) GetTokenImage() string

GetTokenImage gets the marked token as a string.

func (*Source) MarkEnd

func (s *Source) MarkEnd()

MarkEnd sets the last read character as the end of the current token.

func (*Source) MarkStart

func (s *Source) MarkStart()

MarkStart sets the last read character as the start of a token.

func (*Source) NextCh

func (s *Source) NextCh() int

func (*Source) SkipToEOL

func (s *Source) SkipToEOL()

SkipToEOL advances to the EOL marker (either CR or CRLF), such that the next call will return the character following the EOL.

type Statement

type Statement interface {
	Next() Statement
	SetNext(next Statement)
	File() string
	SetFile(file string)
	Line() int
	SetLine(line int)
	NewlineBefore() bool
	SetNewlineBefore(newlineBefore bool)
	BlockComment() []string
	SetBlockComment(blockComment []string)
	EolComment() string
	SetEolComment(eolComment string)
	PcStart() int
	SetPcStart(pcStart int)
	PcEnd() int
	SetPcEnd(pcEnd int)
}

Statement is an interface of Node just so all my types can implement the same interface?

type Symbol

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

type SymbolTable

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

func NewSymbolTable

func NewSymbolTable() *SymbolTable

func (*SymbolTable) AddFpSymbol

func (s *SymbolTable) AddFpSymbol(file string, line int, text string, offset int)

func (*SymbolTable) AddSymbol

func (s *SymbolTable) AddSymbol(file string, line int, text string)

func (*SymbolTable) Define

func (s *SymbolTable) Define(text string, value int)

func (*SymbolTable) GetSymbol

func (s *SymbolTable) GetSymbol(text string) *Symbol

type TokenReader

type TokenReader interface {
	FileName() string
	Line() int
	Column() int
	Next() TokenType
	Token() TokenType
	TokenText() string
}

type TokenType

type TokenType int
const (
	TokNone TokenType = iota
	TokEOF
	TokIdent
	TokInt
	TokChar
	TokString
	TokDot
	TokColon
	TokHash
	TokStar
	TokComma
	TokPlus
	TokMinus
	TokPipe
	TokCaret
	TokSlash
	TokPercent
	TokLeftShift
	TokRightShift
	TokLeftParen
	TokRightParen
	TokLeftBracket
	TokRightBracket
	TokEquals
	TokOrg
	TokDw
	TokDb
	TokDs
	TokLocal
	TokAdd
	TokSub
	TokMul
	TokDiv
	TokCmp
	TokAnd
	TokOr
	TokXor
	TokCpy
	TokPsh
	TokPop
	TokJmp
	TokJeq
	TokJne
	TokJge
	TokJlt
	TokInc
	TokDec
	TokJsr
	TokRet
	TokClc
	TokSec
	TokClb
	TokSeb
	TokJcc
	TokJcs
	TokSav
	TokRst
	TokHlt
	TokFunction
	TokImport
	TokVar
	TokComment
	TokEOL
)

func (TokenType) String

func (t TokenType) String() string

type VarStatement

type VarStatement struct {
	Node
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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