-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
2,334 additions
and
2,516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"flag" | ||
"io" | ||
"log" | ||
"os" | ||
|
||
"github.com/koron-go/z80" | ||
"github.com/koron-go/z80/internal/opcode" | ||
"golang.org/x/tools/imports" | ||
) | ||
|
||
var name string | ||
var nofmt bool | ||
|
||
func main() { | ||
err := z80.GenerateSwitchDecoder(os.Stdout) | ||
flag.StringVar(&name, "name", "", "filename to output") | ||
flag.BoolVar(&nofmt, "nofmt", false, "suppress to format") | ||
flag.Parse() | ||
|
||
bb := &bytes.Buffer{} | ||
err := opcode.WriteSwitchDecoder(bb) | ||
if err != nil { | ||
log.Fatalf("failed to generate: %s", err) | ||
} | ||
b := bb.Bytes() | ||
|
||
if !nofmt { | ||
b, err = imports.Process(name, b, nil) | ||
if err != nil { | ||
log.Fatalf("failed to formatting: %s", err) | ||
} | ||
} | ||
|
||
var w io.Writer = os.Stdout | ||
if name != "" { | ||
f, err := os.Create(name) | ||
if err != nil { | ||
log.Fatalf("failed to create a file: %s", err) | ||
} | ||
defer f.Close() | ||
w = f | ||
} | ||
_, err = w.Write(b) | ||
if err != nil { | ||
log.Fatal(err) | ||
log.Fatalf("failed to write: %s", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,24 @@ | ||
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= | ||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= | ||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | ||
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= | ||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | ||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= | ||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||
golang.org/x/tools v0.0.0-20200823205832-c024452afbcd h1:KNSumuk5eGuQV7zbOrDDZ3MIkwsQr0n5oKiH4oE0/hU= | ||
golang.org/x/tools v0.0.0-20200823205832-c024452afbcd/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= | ||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package opcode | ||
|
||
var arith16 = []*OPCode{ | ||
|
||
{ | ||
N: "ADD HL, ss", | ||
C: []Code{ | ||
{0x09, 0x30, vReg16_4}, | ||
}, | ||
T: []int{4, 4, 3}, | ||
}, | ||
|
||
{ | ||
N: "ADC HL, ss", | ||
C: []Code{ | ||
{0xed, 0x00, nil}, | ||
{0x4a, 0x30, vReg16_4}, | ||
}, | ||
T: []int{4, 4, 4, 3}, | ||
}, | ||
|
||
{ | ||
N: "SBC HL, ss", | ||
C: []Code{ | ||
{0xed, 0x00, nil}, | ||
{0x42, 0x30, vReg16_4}, | ||
}, | ||
T: []int{4, 4, 4, 3}, | ||
}, | ||
|
||
{ | ||
N: "ADD IX, pp", | ||
C: []Code{ | ||
{0xdd, 0x00, nil}, | ||
{0x09, 0x30, vReg16_4}, | ||
}, | ||
T: []int{4, 4, 4, 3}, | ||
}, | ||
|
||
{ | ||
N: "ADD IY, rr", | ||
C: []Code{ | ||
{0xfd, 0x00, nil}, | ||
{0x09, 0x30, vReg16_4}, | ||
}, | ||
T: []int{4, 4, 4, 3}, | ||
}, | ||
|
||
{ | ||
N: "INC ss", | ||
C: []Code{ | ||
{0x03, 0x30, vReg16_4}, | ||
}, | ||
T: []int{6}, | ||
}, | ||
|
||
{ | ||
N: "INC IX", | ||
C: []Code{ | ||
{0xdd, 0x00, nil}, | ||
{0x23, 0x00, nil}, | ||
}, | ||
T: []int{4, 6}, | ||
}, | ||
|
||
{ | ||
N: "INC IY", | ||
C: []Code{ | ||
{0xfd, 0x00, nil}, | ||
{0x23, 0x00, nil}, | ||
}, | ||
T: []int{4, 6}, | ||
}, | ||
|
||
{ | ||
N: "DEC ss", | ||
C: []Code{ | ||
{0x0b, 0x30, vReg16_4}, | ||
}, | ||
T: []int{6}, | ||
}, | ||
|
||
{ | ||
N: "DEC IX", | ||
C: []Code{ | ||
{0xdd, 0x00, nil}, | ||
{0x2b, 0x00, nil}, | ||
}, | ||
T: []int{4, 6}, | ||
}, | ||
|
||
{ | ||
N: "DEC IY", | ||
C: []Code{ | ||
{0xfd, 0x00, nil}, | ||
{0x2b, 0x00, nil}, | ||
}, | ||
T: []int{4, 6}, | ||
}, | ||
} |
Oops, something went wrong.