assembler

package
v0.0.0-...-d185933 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressMode

type AddressMode int

AddressMode represents different 6502 addressing modes

const (
	Implicit AddressMode = iota
	Accumulator
	Immediate
	ZeroPage
	ZeroPageX
	ZeroPageY
	Absolute
	AbsoluteX
	AbsoluteY
	Indirect
	IndirectX
	IndirectY
	Relative
)

type Assembler

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

Assembler holds the state of our assembler

func NewAssembler

func NewAssembler() *Assembler

NewAssembler creates a new instance of our assembler

func (*Assembler) Assemble

func (a *Assembler) Assemble(source string) error

Helper functions for assembler

func (*Assembler) GetOutput

func (a *Assembler) GetOutput() []byte

type DirectiveHandler

type DirectiveHandler func(a *Assembler, operand string) error

DirectiveHandler defines a function type for directive processing

type Instruction

type Instruction struct {
	Opcode      byte
	Size        int
	Cycles      int
	AddressMode AddressMode
}

Instruction represents a 6502 assembly instruction

type InstructionEntry

type InstructionEntry struct {
	BaseOpcode byte
	Modes      map[AddressMode]Instruction
}

InstructionEntry represents an entry in our instruction lookup table

type Lexer

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

Lexer breaks source code into tokens

func NewLexer

func NewLexer(input string) *Lexer

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

NextToken returns the next token from the input

type Line

type Line struct {
	Label       string
	Instruction string
	Directive   string
	Operand     string
	AddressMode AddressMode
	Value       uint16
	IsRelative  bool
	SymbolName  string
}

Line represents a parsed assembly line

type Parser

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

Parser represents the assembly parser

func NewParser

func NewParser(lexer *Lexer, assembler *Assembler) *Parser

func (*Parser) ParseLine

func (p *Parser) ParseLine() (*Line, error)

type Symbol

type Symbol struct {
	Name      string
	Value     uint16
	IsDefined bool
}

Symbol represents a label or variable in the assembly

type Token

type Token struct {
	Type    TokenType
	Value   string
	LineNum int
}

Token represents the smallest unit of code in our assembly

type TokenType

type TokenType int

TokenType identifies different types of tokens

const (
	LABEL TokenType = iota
	INSTRUCTION
	DIRECTIVE
	OPERAND
	COMMENT
	EOL
	EOF = 6
)

Jump to

Keyboard shortcuts

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