1
0
mirror of https://github.com/zellyn/go6502.git synced 2024-06-15 18:29:47 +00:00

split redbook into a and b

This commit is contained in:
Zellyn Hunter 2014-06-04 08:35:31 -07:00
parent 255fa86640
commit 48b5b11754
7 changed files with 156 additions and 129 deletions

View File

@ -19,8 +19,9 @@ var flavor string
func init() { func init() {
flavorsByName = map[string]flavors.F{ flavorsByName = map[string]flavors.F{
"scma": scma.New(), "scma": scma.New(),
"redbook": redbook.New(), "redbooka": redbook.NewRedbookA(),
"redbookb": redbook.NewRedbookB(),
} }
var names []string var names []string
for name := range flavorsByName { for name := range flavorsByName {

View File

@ -45,13 +45,14 @@ type Base struct {
Operators map[string]expr.Operator Operators map[string]expr.Operator
context.SimpleContext context.SimpleContext
context.LabelerBase context.LabelerBase
LabelChars string LabelChars string
LabelColons Requiredness LabelColons Requiredness
ExplicitARegister Requiredness ExplicitARegister Requiredness
ExtraCommenty func(string) bool ExtraCommenty func(string) bool
TwoSpacesIsComment bool // two spaces after command means comment field? SpacesForComment int // this many spaces after command means it's the comment field
StringEndOptional bool // can omit closing delimeter from string args? StringEndOptional bool // can omit closing delimeter from string args?
SetAsciiVariation func(*inst.I, *lines.Parse) SetAsciiVariation func(*inst.I, *lines.Parse)
CommentChar rune
} }
// Parse an entire instruction, or return an appropriate error. // Parse an entire instruction, or return an appropriate error.
@ -83,7 +84,7 @@ func (a *Base) ParseInstr(line lines.Line) (inst.I, error) {
// Empty line or comment // Empty line or comment
trimmed := strings.TrimSpace(lp.Rest()) trimmed := strings.TrimSpace(lp.Rest())
if trimmed == "" || trimmed[0] == '*' || trimmed[0] == ';' { if trimmed == "" || trimmed[0] == '*' || rune(trimmed[0]) == a.CommentChar {
in.Type = inst.TypeNone in.Type = inst.TypeNone
return in, nil return in, nil
} }
@ -253,11 +254,17 @@ func (a *Base) ParseOpArgs(in inst.I, lp *lines.Parse, summary opcodes.OpSummary
} }
// Nothing else on the line? Must be MODE_A // Nothing else on the line? Must be MODE_A
lp.Consume(whitespace) lp.AcceptRun(whitespace)
if !a.TwoSpacesIsComment { ws := lp.Emit()
lp.IgnoreRun(whitespace) atEnd := false
if a.SpacesForComment != 0 && len(ws) >= a.SpacesForComment {
atEnd = true
} }
if (a.TwoSpacesIsComment && lp.Consume(whitespace)) || lp.Peek() == lines.Eol || lp.Peek() == ';' { if lp.Peek() == lines.Eol || lp.Peek() == a.CommentChar {
atEnd = true
}
if atEnd {
// Nothing left on line except comments. // Nothing left on line except comments.
if !summary.AnyModes(opcodes.MODE_A) { if !summary.AnyModes(opcodes.MODE_A) {
return i, in.Errorf("%s with no arguments", in.Command) return i, in.Errorf("%s with no arguments", in.Command)

View File

@ -14,42 +14,52 @@ type RedBook struct {
oldschool.Base oldschool.Base
} }
func New() *RedBook { func NewRedbookA() *RedBook {
a := &RedBook{} r := newRedbook()
return r
}
a.LabelChars = oldschool.Letters + oldschool.Digits + "." func NewRedbookB() *RedBook {
a.LabelColons = oldschool.ReqOptional r := newRedbook()
a.ExplicitARegister = oldschool.ReqRequired r.ExplicitARegister = oldschool.ReqRequired
a.StringEndOptional = true r.SpacesForComment = 3
return r
}
a.Directives = map[string]oldschool.DirectiveInfo{ func newRedbook() *RedBook {
".IN": {inst.TypeInclude, a.ParseInclude, 0}, r := &RedBook{}
"ORG": {inst.TypeOrg, a.ParseAddress, 0},
"OBJ": {inst.TypeNone, nil, 0}, r.LabelChars = oldschool.Letters + oldschool.Digits + "."
".TF": {inst.TypeNone, nil, 0}, r.LabelColons = oldschool.ReqOptional
".EN": {inst.TypeEnd, a.ParseNoArgDir, 0}, r.ExplicitARegister = oldschool.ReqRequired
"EQU": {inst.TypeEqu, a.ParseEquate, 0}, r.StringEndOptional = true
"DFB": {inst.TypeData, a.ParseData, inst.DataBytes}, r.CommentChar = ';'
"DW": {inst.TypeData, a.ParseData, inst.DataWordsLe},
"DDB": {inst.TypeData, a.ParseData, inst.DataWordsBe}, r.Directives = map[string]oldschool.DirectiveInfo{
"ASC": {inst.TypeData, a.ParseAscii, inst.DataAscii}, "ORG": {inst.TypeOrg, r.ParseAddress, 0},
"DCI": {inst.TypeData, a.ParseAscii, inst.DataAsciiFlip}, "OBJ": {inst.TypeNone, nil, 0},
".BS": {inst.TypeBlock, a.ParseBlockStorage, 0}, "ENDASM": {inst.TypeEnd, r.ParseNoArgDir, 0},
".LIST": {inst.TypeNone, nil, 0}, "EQU": {inst.TypeEqu, r.ParseEquate, inst.EquNormal},
".PG": {inst.TypeNone, nil, 0}, "EPZ": {inst.TypeEqu, r.ParseEquate, inst.EquPageZero},
".DO": {inst.TypeIfdef, a.ParseDo, 0}, "DFB": {inst.TypeData, r.ParseData, inst.DataBytes},
".ELSE": {inst.TypeIfdefElse, a.ParseNoArgDir, 0}, "DW": {inst.TypeData, r.ParseData, inst.DataWordsLe},
".FIN": {inst.TypeIfdefEnd, a.ParseNoArgDir, 0}, "DDB": {inst.TypeData, r.ParseData, inst.DataWordsBe},
".MA": {inst.TypeMacroStart, a.ParseMacroStart, 0}, "ASC": {inst.TypeData, r.ParseAscii, inst.DataAscii},
".EM": {inst.TypeMacroEnd, a.ParseNoArgDir, 0}, "DCI": {inst.TypeData, r.ParseAscii, inst.DataAsciiFlip},
".US": {inst.TypeNone, a.ParseNotImplemented, 0}, ".DO": {inst.TypeIfdef, r.ParseDo, 0},
"PAGE": {inst.TypeNone, nil, 0}, // New page ".ELSE": {inst.TypeIfdefElse, r.ParseNoArgDir, 0},
"SBTL": {inst.TypeNone, nil, 0}, // Subtitle ".FIN": {inst.TypeIfdefEnd, r.ParseNoArgDir, 0},
"SKP": {inst.TypeNone, nil, 0}, // Skip lines ".MA": {inst.TypeMacroStart, r.ParseMacroStart, 0},
"REP": {inst.TypeNone, nil, 0}, // Repeat character ".EM": {inst.TypeMacroEnd, r.ParseNoArgDir, 0},
"CHR": {inst.TypeNone, nil, 0}, // Set repeated character ".US": {inst.TypeNone, r.ParseNotImplemented, 0},
"PAGE": {inst.TypeNone, nil, 0}, // New page
"TITLE": {inst.TypeNone, nil, 0}, // Title
"SBTL": {inst.TypeNone, nil, 0}, // Subtitle
"SKP": {inst.TypeNone, nil, 0}, // Skip lines
"REP": {inst.TypeNone, nil, 0}, // Repeat character
"CHR": {inst.TypeNone, nil, 0}, // Set repeated character
} }
a.Operators = map[string]expr.Operator{ r.Operators = map[string]expr.Operator{
"*": expr.OpMul, "*": expr.OpMul,
"/": expr.OpDiv, "/": expr.OpDiv,
"+": expr.OpPlus, "+": expr.OpPlus,
@ -59,14 +69,14 @@ func New() *RedBook {
"=": expr.OpEq, "=": expr.OpEq,
} }
a.OnOff = map[string]bool{ r.OnOff = map[string]bool{
"MSB": true, // MSB defaults to true, as per manual "MSB": true, // MSB defaults to true, as per manual
"LST": true, // Display listing: not used "LST": true, // Display listing: not used
} }
a.SetAsciiVariation = func(in *inst.I, lp *lines.Parse) { r.SetAsciiVariation = func(in *inst.I, lp *lines.Parse) {
if in.Command == "ASC" { if in.Command == "ASC" {
if a.Setting("MSB") { if r.Setting("MSB") {
in.Var = inst.DataAsciiHi in.Var = inst.DataAsciiHi
} else { } else {
in.Var = inst.DataAscii in.Var = inst.DataAscii
@ -80,5 +90,5 @@ func New() *RedBook {
} }
} }
return a return r
} }

View File

@ -23,7 +23,7 @@ func New() *SCMA {
a.LabelChars = oldschool.Letters + oldschool.Digits + ".:" a.LabelChars = oldschool.Letters + oldschool.Digits + ".:"
a.LabelColons = oldschool.ReqDisallowed a.LabelColons = oldschool.ReqDisallowed
a.ExplicitARegister = oldschool.ReqDisallowed a.ExplicitARegister = oldschool.ReqDisallowed
a.TwoSpacesIsComment = true a.SpacesForComment = 2
a.Directives = map[string]oldschool.DirectiveInfo{ a.Directives = map[string]oldschool.DirectiveInfo{
".IN": {inst.TypeInclude, a.ParseInclude, 0}, ".IN": {inst.TypeInclude, a.ParseInclude, 0},

View File

@ -26,7 +26,8 @@ func TestMultiline(t *testing.T) {
o := lines.NewTestOpener() o := lines.NewTestOpener()
ss := asm.NewAssembler(scma.New(), o) ss := asm.NewAssembler(scma.New(), o)
rb := asm.NewAssembler(redbook.New(), o) ra := asm.NewAssembler(redbook.NewRedbookA(), o)
// rb := asm.NewAssembler(redbook.NewRedbookB(), o)
// aa := asm.NewAssembler(as65.New(), o) // aa := asm.NewAssembler(as65.New(), o)
// mm := asm.NewAssembler(merlin.New(), o) // mm := asm.NewAssembler(merlin.New(), o)
@ -220,7 +221,7 @@ func TestMultiline(t *testing.T) {
}, true}, }, true},
// Check turning MSB on and off // Check turning MSB on and off
{rb, "MSB toggle", []string{ {ra, "MSB toggle", []string{
" ASC 'AB'", " ASC 'AB'",
" MSB OFF", " MSB OFF",
" ASC 'AB'", " ASC 'AB'",

View File

@ -14,9 +14,10 @@ import (
func TestSimpleCommonFunctions(t *testing.T) { func TestSimpleCommonFunctions(t *testing.T) {
ss := scma.New() ss := scma.New()
rb := redbook.New() ra := redbook.NewRedbookA()
aa := as65.New() rb := redbook.NewRedbookB()
mm := merlin.New() // aa := as65.New()
// mm := merlin.New()
tests := []struct { tests := []struct {
a flavors.F // assembler flavor a flavors.F // assembler flavor
@ -25,95 +26,99 @@ func TestSimpleCommonFunctions(t *testing.T) {
b string // bytes, expected b string // bytes, expected
}{ }{
{ss, "* Comment", "{-}", ""}, {ss, "* Comment", "{-}", ""},
{rb, "* Comment", "{-}", ""}, {ra, "* Comment", "{-}", ""},
{rb, " ; Comment", "{-}", ""}, {ra, " ; Comment", "{-}", ""},
{aa, "; Comment", "{-}", ""}, // {aa, "; Comment", "{-}", ""},
{mm, "* Comment", "{-}", ""}, // {mm, "* Comment", "{-}", ""},
{ss, " far-out-comment", "{-}", ""}, {ss, " far-out-comment", "{-}", ""},
{ss, "Label", "{- 'Label'}", ""}, {ss, "Label", "{- 'Label'}", ""},
{rb, "Label", "{- 'Label'}", ""}, {ra, "Label", "{- 'Label'}", ""},
{rb, "Label:", "{- 'Label'}", ""}, {ra, "Label:", "{- 'Label'}", ""},
{aa, "Label", "{- 'Label'}", ""}, // {aa, "Label", "{- 'Label'}", ""},
{mm, "Label", "{- 'Label'}", ""}, // {mm, "Label", "{- 'Label'}", ""},
{ss, " .IN FILE.NAME", "{inc 'FILE.NAME'}", ""}, {ss, " .IN FILE.NAME", "{inc 'FILE.NAME'}", ""},
{ss, " .IN S.DEFS", "{inc 'S.DEFS'}", ""}, {ss, " .IN S.DEFS", "{inc 'S.DEFS'}", ""},
{aa, ` include "FILE.NAME"`, "{inc 'FILE.NAME'}", ""}, // {aa, ` include "FILE.NAME"`, "{inc 'FILE.NAME'}", ""},
{mm, " PUT !FILE.NAME", "{inc 'FILE.NAME'}", ""}, // {mm, " PUT !FILE.NAME", "{inc 'FILE.NAME'}", ""},
{ss, " .TI 76,Title here", "{-}", ""}, {ss, " .TI 76,Title here", "{-}", ""},
{rb, ` SBTL Title here`, "{-}", ""}, {ra, ` SBTL Title here`, "{-}", ""},
{aa, ` title "Title here"`, "{-}", ""}, {ra, ` TITLE Title here`, "{-}", ""},
{mm, ` TTL "Title here"`, "{-}", ""}, // {aa, ` title "Title here"`, "{-}", ""},
// {mm, ` TTL "Title here"`, "{-}", ""},
{ss, " .TF OUT.BIN", "{-}", ""}, {ss, " .TF OUT.BIN", "{-}", ""},
{mm, " DSK OUTFILE", "{-}", ""}, // {mm, " DSK OUTFILE", "{-}", ""},
{mm, " SAV OUTFILE", "{-}", ""}, // {mm, " SAV OUTFILE", "{-}", ""},
{ss, " .OR $D000", "{org $d000}", ""}, {ss, " .OR $D000", "{org $d000}", ""},
{rb, " ORG $D000", "{org $d000}", ""}, {ra, " ORG $D000", "{org $d000}", ""},
{aa, " org $D000", "{org $d000}", ""}, // {aa, " org $D000", "{org $d000}", ""},
{mm, " ORG $D000", "{org $d000}", ""}, // {mm, " ORG $D000", "{org $d000}", ""},
// {ss, " .TA *-1234", "{target (- * $04d2)}", ""}, // {ss, " .TA *-1234", "{target (- * $04d2)}", ""},
{ss, " .DA $1234", "{data $1234}", "3412"}, {ss, " .DA $1234", "{data $1234}", "3412"},
{aa, " dw $1234", "{data/wle $1234}", "3412"}, // {aa, " dw $1234", "{data/wle $1234}", "3412"},
{mm, " DW $1234", "{data/wle $1234}", "3412"}, // {mm, " DW $1234", "{data/wle $1234}", "3412"},
{ss, " .DA/$1234,#$1234,$1234", "{data (msb $1234),(lsb $1234),$1234}", "12343412"}, {ss, " .DA/$1234,#$1234,$1234", "{data (msb $1234),(lsb $1234),$1234}", "12343412"},
{rb, " DFB $12", "{data/b $0012}", "12"}, {ra, " DFB $12", "{data/b $0012}", "12"},
{rb, " DFB $12,$34,$1234", "{data/b $0012,$0034,$1234}", "123434"}, {ra, " DFB $12,$34,$1234", "{data/b $0012,$0034,$1234}", "123434"},
{rb, " DW $12,$34,$1234", "{data/wle $0012,$0034,$1234}", "120034003412"}, {ra, " DW $12,$34,$1234", "{data/wle $0012,$0034,$1234}", "120034003412"},
{rb, " DDB $12,$34,$1234", "{data/wbe $0012,$0034,$1234}", "001200341234"}, {ra, " DDB $12,$34,$1234", "{data/wbe $0012,$0034,$1234}", "001200341234"},
{ss, " ROL", "{ROL/a}", "2a"}, {ss, " ROL", "{ROL/a}", "2a"},
{aa, " rol a", "{ROL/a}", "2a"}, // {aa, " rol a", "{ROL/a}", "2a"},
{rb, " ROL A", "{ROL/a}", "2a"}, {ra, " ROL A", "{ROL/a}", "2a"},
{rb, " ROL A", "{ROL/a}", "2a"}, // two spaces is no big deal {ra, " ROL A", "{ROL/a}", "2a"}, // two spaces is no big deal
{mm, " ROL", "{ROL/a}", "2a"}, // {mm, " ROL", "{ROL/a}", "2a"},
{ss, " ROL Comment after two spaces", "{ROL/a}", "2a"}, {ss, " ROL Comment after two spaces", "{ROL/a}", "2a"},
{ss, " ROL X", "{ROL/a}", "2a"}, // two spaces = comment {ss, " ROL X", "{ROL/a}", "2a"}, // two spaces = comment
{rb, " ROL", "{ROL/a}", "2a"},
{rb, " ROL Comment after three spaces", "{ROL/a}", "2a"},
{rb, " ROL X", "{ROL/a}", "2a"}, // two spaces = comment
{ss, " ROL $1234", "{ROL/abs $1234}", "2e3412"}, {ss, " ROL $1234", "{ROL/abs $1234}", "2e3412"},
{aa, " rol $1234", "{ROL/abs $1234}", "2e3412"}, // {aa, " rol $1234", "{ROL/abs $1234}", "2e3412"},
{mm, " ROL $1234", "{ROL/abs $1234}", "2e3412"}, // {mm, " ROL $1234", "{ROL/abs $1234}", "2e3412"},
{ss, " ROL $12", "{ROL/zp $0012}", "2612"}, {ss, " ROL $12", "{ROL/zp $0012}", "2612"},
{aa, " rol $12", "{ROL/zp $0012}", "2612"}, // {aa, " rol $12", "{ROL/zp $0012}", "2612"},
{mm, " ROL $12", "{ROL/zp $0012}", "2612"}, // {mm, " ROL $12", "{ROL/zp $0012}", "2612"},
{ss, " LDA #$12", "{LDA/imm (lsb $0012)}", "a912"}, {ss, " LDA #$12", "{LDA/imm (lsb $0012)}", "a912"},
{aa, " lda #$12", "{LDA/imm (lsb $0012)}", "a912"}, // {aa, " lda #$12", "{LDA/imm (lsb $0012)}", "a912"},
{mm, " LDA #$12", "{LDA/imm (lsb $0012)}", "a912"}, // {mm, " LDA #$12", "{LDA/imm (lsb $0012)}", "a912"},
{ss, " JMP $1234", "{JMP/abs $1234}", "4c3412"}, {ss, " JMP $1234", "{JMP/abs $1234}", "4c3412"},
{aa, " jmp $1234", "{JMP/abs $1234}", "4c3412"}, // {aa, " jmp $1234", "{JMP/abs $1234}", "4c3412"},
{mm, " JMP $1234", "{JMP/abs $1234}", "4c3412"}, // {mm, " JMP $1234", "{JMP/abs $1234}", "4c3412"},
{ss, " JMP ($1234)", "{JMP/ind $1234}", "6c3412"}, {ss, " JMP ($1234)", "{JMP/ind $1234}", "6c3412"},
{aa, " jmp ($1234)", "{JMP/ind $1234}", "6c3412"}, // {aa, " jmp ($1234)", "{JMP/ind $1234}", "6c3412"},
{mm, " JMP ($1234)", "{JMP/ind $1234}", "6c3412"}, // {mm, " JMP ($1234)", "{JMP/ind $1234}", "6c3412"},
{ss, " BEQ $2345", "{BEQ/rel $2345}", "f0fe"}, {ss, " BEQ $2345", "{BEQ/rel $2345}", "f0fe"},
{aa, " beq $2345", "{BEQ/rel $2345}", "f0fe"}, // {aa, " beq $2345", "{BEQ/rel $2345}", "f0fe"},
{mm, " BEQ $2345", "{BEQ/rel $2345}", "f0fe"}, // {mm, " BEQ $2345", "{BEQ/rel $2345}", "f0fe"},
{ss, " BEQ $2347", "{BEQ/rel $2347}", "f000"}, {ss, " BEQ $2347", "{BEQ/rel $2347}", "f000"},
{aa, " beq $2347", "{BEQ/rel $2347}", "f000"}, // {aa, " beq $2347", "{BEQ/rel $2347}", "f000"},
{mm, " BEQ $2347", "{BEQ/rel $2347}", "f000"}, // {mm, " BEQ $2347", "{BEQ/rel $2347}", "f000"},
{ss, " BEQ $2343", "{BEQ/rel $2343}", "f0fc"}, {ss, " BEQ $2343", "{BEQ/rel $2343}", "f0fc"},
{aa, " beq $2343", "{BEQ/rel $2343}", "f0fc"}, // {aa, " beq $2343", "{BEQ/rel $2343}", "f0fc"},
{mm, " BEQ $2343", "{BEQ/rel $2343}", "f0fc"}, // {mm, " BEQ $2343", "{BEQ/rel $2343}", "f0fc"},
{ss, " LDA $1234", "{LDA/abs $1234}", "ad3412"}, {ss, " LDA $1234", "{LDA/abs $1234}", "ad3412"},
{aa, " lda $1234", "{LDA/abs $1234}", "ad3412"}, // {aa, " lda $1234", "{LDA/abs $1234}", "ad3412"},
{mm, " LDA $1234", "{LDA/abs $1234}", "ad3412"}, // {mm, " LDA $1234", "{LDA/abs $1234}", "ad3412"},
{ss, " LDA $1234,X", "{LDA/absX $1234}", "bd3412"}, {ss, " LDA $1234,X", "{LDA/absX $1234}", "bd3412"},
{aa, " lda $1234,x", "{LDA/absX $1234}", "bd3412"}, // {aa, " lda $1234,x", "{LDA/absX $1234}", "bd3412"},
{mm, " LDA $1234,X", "{LDA/absX $1234}", "bd3412"}, // {mm, " LDA $1234,X", "{LDA/absX $1234}", "bd3412"},
{ss, " STA $1234,Y", "{STA/absY $1234}", "993412"}, {ss, " STA $1234,Y", "{STA/absY $1234}", "993412"},
{aa, " sta $1234,y", "{STA/absY $1234}", "993412"}, // {aa, " sta $1234,y", "{STA/absY $1234}", "993412"},
{mm, " STA $1234,Y", "{STA/absY $1234}", "993412"}, // {mm, " STA $1234,Y", "{STA/absY $1234}", "993412"},
{ss, " LDA $12", "{LDA/zp $0012}", "a512"}, {ss, " LDA $12", "{LDA/zp $0012}", "a512"},
{aa, " lda $12", "{LDA/zp $0012}", "a512"}, // {aa, " lda $12", "{LDA/zp $0012}", "a512"},
{mm, " LDA $12", "{LDA/zp $0012}", "a512"}, // {mm, " LDA $12", "{LDA/zp $0012}", "a512"},
{ss, " LDA $12,X", "{LDA/zpX $0012}", "b512"}, {ss, " LDA $12,X", "{LDA/zpX $0012}", "b512"},
{aa, " lda $12,x", "{LDA/zpX $0012}", "b512"}, // {aa, " lda $12,x", "{LDA/zpX $0012}", "b512"},
{mm, " LDA $12,X", "{LDA/zpX $0012}", "b512"}, // {mm, " LDA $12,X", "{LDA/zpX $0012}", "b512"},
{ss, " LDX $12,Y", "{LDX/zpY $0012}", "b612"}, {ss, " LDX $12,Y", "{LDX/zpY $0012}", "b612"},
{aa, " ldx $12,y", "{LDX/zpY $0012}", "b612"}, // {aa, " ldx $12,y", "{LDX/zpY $0012}", "b612"},
{mm, " LDX $12,Y", "{LDX/zpY $0012}", "b612"}, // {mm, " LDX $12,Y", "{LDX/zpY $0012}", "b612"},
{ss, " LDA ($12),Y", "{LDA/indY $0012}", "b112"}, {ss, " LDA ($12),Y", "{LDA/indY $0012}", "b112"},
{aa, " lda ($12),y", "{LDA/indY $0012}", "b112"}, // {aa, " lda ($12),y", "{LDA/indY $0012}", "b112"},
{mm, " LDA ($12),Y", "{LDA/indY $0012}", "b112"}, // {mm, " LDA ($12),Y", "{LDA/indY $0012}", "b112"},
{ss, " LDA ($12,X)", "{LDA/indX $0012}", "a112"}, {ss, " LDA ($12,X)", "{LDA/indX $0012}", "a112"},
{aa, " lda ($12,x)", "{LDA/indX $0012}", "a112"}, // {aa, " lda ($12,x)", "{LDA/indX $0012}", "a112"},
{mm, " LDA ($12,X)", "{LDA/indX $0012}", "a112"}, // {mm, " LDA ($12,X)", "{LDA/indX $0012}", "a112"},
{ss, ` .AS "ABC"`, "{data/b}", "414243"}, {ss, ` .AS "ABC"`, "{data/b}", "414243"},
{ss, ` .AT "ABC"`, "{data/b}", "4142c3"}, {ss, ` .AT "ABC"`, "{data/b}", "4142c3"},
{ss, ` .AS /ABC/`, "{data/b}", "414243"}, {ss, ` .AS /ABC/`, "{data/b}", "414243"},
@ -122,11 +127,11 @@ func TestSimpleCommonFunctions(t *testing.T) {
{ss, ` .AT -"ABC"`, "{data/b}", "c1c243"}, {ss, ` .AT -"ABC"`, "{data/b}", "c1c243"},
{ss, ` .AS -dABCd`, "{data/b}", "c1c2c3"}, {ss, ` .AS -dABCd`, "{data/b}", "c1c2c3"},
{ss, ` .AT -dABCd`, "{data/b}", "c1c243"}, {ss, ` .AT -dABCd`, "{data/b}", "c1c243"},
{rb, ` ASC "ABC"`, "{data/b}", "c1c2c3"}, {ra, ` ASC "ABC"`, "{data/b}", "c1c2c3"},
{rb, ` ASC $ABC$ ;comment`, "{data/b}", "c1c2c3"}, {ra, ` ASC $ABC$ ;comment`, "{data/b}", "c1c2c3"},
{rb, ` ASC $ABC`, "{data/b}", "c1c2c3"}, {ra, ` ASC $ABC`, "{data/b}", "c1c2c3"},
{rb, ` DCI "ABC"`, "{data/b}", "4142c3"}, {ra, ` DCI "ABC"`, "{data/b}", "4142c3"},
{rb, ` ASC -ABC-`, "{data/b}", "c1c2c3"}, {ra, ` ASC -ABC-`, "{data/b}", "c1c2c3"},
{ss, " .HS 0001ffAb", "{data/b}", "0001ffab"}, {ss, " .HS 0001ffAb", "{data/b}", "0001ffab"},
{ss, "A.B .EQ *-C.D", "{= 'A.B' (- * C.D)}", ""}, {ss, "A.B .EQ *-C.D", "{= 'A.B' (- * C.D)}", ""},
{ss, " .BS $8", "{block $0008}", "xxxxxxxxxxxxxxxx"}, {ss, " .BS $8", "{block $0008}", "xxxxxxxxxxxxxxxx"},
@ -141,10 +146,10 @@ func TestSimpleCommonFunctions(t *testing.T) {
{ss, " LDX #']+$80", "{LDX/imm (lsb (+ $005d $0080))}", "a2dd"}, {ss, " LDX #']+$80", "{LDX/imm (lsb (+ $005d $0080))}", "a2dd"},
{ss, " CMP #';'+1", "{CMP/imm (lsb (+ $003b $0001))}", "c93c"}, {ss, " CMP #';'+1", "{CMP/imm (lsb (+ $003b $0001))}", "c93c"},
{rb, " LST ON", "{set LST ON}", ""}, {ra, " LST ON", "{set LST ON}", ""},
{rb, " LST OFF", "{set LST OFF}", ""}, {ra, " LST OFF", "{set LST OFF}", ""},
{rb, " MSB ON", "{set MSB ON}", ""}, {ra, " MSB ON", "{set MSB ON}", ""},
{rb, " MSB OFF", "{set MSB OFF}", ""}, {ra, " MSB OFF", "{set MSB OFF}", ""},
} }
// TODO(zellyn): Add tests for finalization of four SCMA directives: // TODO(zellyn): Add tests for finalization of four SCMA directives:
@ -154,9 +159,6 @@ func TestSimpleCommonFunctions(t *testing.T) {
for i, tt := range tests { for i, tt := range tests {
// TODO(zellyn): Test AS65 and Merlin too. // TODO(zellyn): Test AS65 and Merlin too.
if tt.a != ss && tt.a != rb {
continue
}
// Initialize to a known state for testing. // Initialize to a known state for testing.
tt.a.Clear() tt.a.Clear()

View File

@ -48,6 +48,12 @@ const (
DataAsciiHiFlip // Data: from ASCII strings, high bit set, except last char DataAsciiHiFlip // Data: from ASCII strings, high bit set, except last char
) )
// Variants for "TypeEqu" instructions.
const (
EquNormal = iota
EquPageZero
)
type I struct { type I struct {
Type Type // Type of instruction Type Type // Type of instruction
Label string // Text of label part Label string // Text of label part