JavaScriptによるZ80エミュレーションはフラグを全て実装する必要があるのか

[5月23日の記事](https://qiita.com/KoichiYasuoka/items/a68532e5e2c34f0bd103)でリリースしたJavaScript版『[ΡΟΠΗ](http://kanji.zinbun.kyoto-u.ac.jp/~yasuoka/ropee/ropee.html)』に関して、私(安岡孝一)はこう書いた。

> フラグはZero、Carry、Sign、Parity-Overflowの4つを、何とか実装したつもりだ。

甘かった。40年前の私は、PC-8001向けゲーム『[ΡΟΠΗ](http://kanji.zinbun.kyoto-u.ac.jp/~yasuoka/publications/1986-01ASCII.pdf)』(ASCII, Vol.10, No.1 (1986年1月), pp.274-277,327-329)のBAE0H～BAE9Hに、こんな恐ろしいZ80コードを忍ばせていた。

```
BAE0  F9        LD SP,HL
BAE1  C1       POP BC
BAE2  70        LD (HL),B
BAE3  D1       POP DE
BAE4  E1       POP HL
BAE5  F1       POP AF
BAE6  3B       DEC SP
BAE7  F5      PUSH AF
BAE8  E5      PUSH HL
BAE9  D5      PUSH DE
```

スタックポインタを使って、7バイト分のデータを1バイト手前にずらしている。フラグ(というよりはFレジスタ)の8ビットは、全てちゃんと保持されてないとマズイ。ただ、この手の命令は「POP AF」「PUSH AF」「EX AF,AF'」しか無いので、それだけのためにHalfcarryフラグだのNegationフラグだのサポートするのはシンドイし、ましてや「SCF」や「CCF」で謎の3ビット目と5ビット目がどこから来るかとか、考えたくもない。なので、Zero、Carry、Sign、Parity-Overflow以外の4ビットについては、演算結果には左右されず、値を保持しておくだけにした。

5月25日時点のプログラムリストを、以下に公開しておくことにする。よければ、[昨日の記事](https://qiita.com/KoichiYasuoka/items/eebb63e88a5ddbd523fd)と較べてみてほしい。

```
<!DOCTYPE html><head><meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>&#x03A1;&#x039F;&#x03A0;&#x0397; by Koichi Yasuoka, May 25, 2025</title>
<script>
var pc8001=new Object();
pc8001.memory=new Array(65536);
pc8001.memory.fill(0x76);
["0000 31 FF FF C3 06 A0",
 "0018                         C3 A6 40",
 "093A                               2A 5A EA EB 21 00", // init display 80x25
 "0940 F3 06 50 73 23 10 FC AF 77 23 77 23 36 01 23 72",
 "0950 23 01 50 11 71 23 72 23 10 FA 71 23 77 23 11 00",
 "0960 F3 EB 01 40 0B ED B0 C9",
 "1602       C9",                                        // "date" unsupport
 "40A6                   FE 0C CA 3A 09 76",             // print one-char
 "A000 31 FF FF CD 0F B0 CD 26 A0 CD 62 A8 CD 62 AA CD",
 "A010 F4 AB CD 85 AF CD F0 B0 CD DF B1 CD DE B2 CD FB",
 "A020 BC CD 13 BE 18 E9 DB 01 07 30 FB 21 21 C0 01 00",
 "A030 0E 71 2C 10 FC 2E CB 06 08 71 7D 80 6F 30 FA 21",
 "A040 00 CD 06 04 71 7D 80 6F 20 FA 21 04 CE 06 12 71",
 "A050 7D 80 6F 30 FA CD 02 16 2A 76 EA 22 02 CE 21 00",
 "A060 B8 22 5A EA 26 FF 22 60 EA 3E 05 32 66 EA 01 19",
 "A070 50 C3 3A 09 6B 64 0B 10 11 00 C6 C8 06 21 22 01",
 "A080 8C 80 0C 52 55 02 08 00 08 B5 BA 05 B0 46 B6 00",
 "A090 11 01 60 8C 6C 10 22 12 C0 08 C8 20 55 25 80 00",
 "A0A0 80 50 AB 5B E1 E0 01 01 00 01 C2 C0 02 12 10 02",
 "A0B0 84 80 04 34 30 04 08 00 08 78 70 08 10 0E 1E 10",
 "A0C0 00 10 20 0C 2C 20 01 21 40 08 48 40 03 43 80 00",
 "A0D0 80 80 07 87 48 4F 08 10 10 00 80 8E 00 21 21 01",
 "A0E0 00 0C 00 52 53 02 00 08 00 A4 A7 04 80 F4 84 00",
 "A0F0 01 01 00 E8 08 10 12 12 00 C0 00 20 35 25 00 80",
 "A100 00 40 7A 4A 5A 59 0A 01 00 01 A4 A2 04 03 01 03",
 "A110 48 44 08 16 12 06 80 88 00 2D 24 0D A0 95 A5 10",
 "A120 00 10 40 2A 4A 30 10 30 80 44 84 60 21 61 00 88",
 "A130 08 D0 42 D2 43 4A 03 11 10 01 86 84 06 22 21 02",
 "A140 0C 08 0C 54 52 04 08 00 08 A9 A5 09 30 A4 34 10",
 "A150 01 11 60 48 68 20 12 22 C0 80 C0 40 25 45 80 00",
 "A160 80 90 5A 9A A4 A3 04 10 10 00 48 46 08 30 30 00",
 "A170 80 8C 00 61 60 01 00 08 00 D2 D1 02 40 3A 4A 00",
 "A180 01 01 80 64 84 00 03 03 00 C8 08 10 06 16 00 80",
 "A190 00 20 1D 2D 54 5B 04 10 11 00 A8 A6 08 20 23 00",
 "A1A0 40 4C 00 51 56 01 80 88 00 A2 AD 02 40 B5 45 00",
 "A1B0 11 01 80 6A 8A 00 32 02 00 C4 04 10 65 15 00 88",
 "A1C0 08 20 DA 2A A1 A4 01 01 00 01 42 48 02 12 10 02",
 "A1D0 84 80 04 24 21 04 08 00 08 58 52 08 10 4A 1A 10",
 "A1E0 00 10 20 84 24 20 01 21 40 08 48 40 12 42 80 00",
 "A1F0 80 80 25 85 B3 B6 03 11 10 01 66 6C 06 32 30 02",
 "A200 CC C8 0C 64 61 04 88 80 08 D9 D3 09 30 6B 3B 10",
 "A210 01 11 60 C6 66 20 03 23 C0 8C CC 40 16 46 80 08",
 "A220 88 90 3D 9D 8F 8E 0F 00 01 00 0E 0C 0E 11 13 01",
 "A230 0C 08 0C 23 27 03 08 00 08 47 4F 07 F0 E8 F8 00",
 "A240 10 00 E0 C0 E0 10 31 11 C0 80 C0 30 72 32 80 00",
 "A250 80 70 F4 74 A4 A5 04 01 00 01 48 4A 08 12 10 02",
 "A260 80 84 00 25 21 05 00 08 00 5A 52 0A 40 5A 4A 10",
 "A270 00 10 80 A4 84 20 01 21 00 48 08 50 12 52 00 80",
 "A280 00 A0 25 A5 53 5B 03 10 10 00 A6 A6 06 20 21 00",
 "A290 4C 4C 0C 50 52 00 88 88 08 A1 A5 01 30 B5 35 00",
 "A2A0 01 01 60 6A 6A 00 12 02 C0 C4 C4 00 25 05 80 88",
 "A2B0 88 10 5A 1A 97 91 07 11 10 01 2E 22 0E 32 30 02",
 "A2C0 4C 44 0C 65 60 05 88 88 08 CB C0 0B 70 19 79 10",
 "A2D0 01 11 E0 22 E2 20 03 23 C0 44 C4 50 06 56 80 88",
 "A2E0 88 B0 0C BC A4 A1 04 00 01 00 48 42 08 10 12 00",
 "A2F0 80 84 00 21 24 01 00 08 00 52 58 02 40 1A 4A 00",
 "A300 10 00 80 24 84 00 21 01 00 48 08 10 42 12 00 80",
 "A310 00 20 85 25 BB B0 0B 11 10 01 66 60 06 33 30 03",
 "A320 CC C0 0C 66 60 06 88 80 08 DD D0 0D B0 0B BB 10",
 "A330 01 11 60 06 66 30 03 33 C0 0C CC 60 06 66 80 08",
 "A340 88 D0 0D DD 91 97 01 00 01 00 22 2E 02 10 12 00",
 "A350 44 4C 04 20 25 00 88 88 08 40 4B 00 10 79 19 00",
 "A360 10 00 20 E2 22 00 21 01 40 C4 44 00 52 02 80 88",
 "A370 88 00 B4 04 B9 BC 09 01 00 01 62 68 02 13 11 03",
 "A380 C4 C0 04 26 23 06 88 80 08 5C 56 0C 90 CB 9B 10",
 "A390 00 10 20 86 26 30 11 31 40 0C 4C 60 32 62 80 08",
 "A3A0 88 C0 65 C5 B6 BA 06 00 01 00 6C 64 0C 10 13 00",
 "A3B0 C8 C8 08 21 26 01 80 80 00 53 5D 03 60 AB 6B 00",
 "A3C0 10 00 C0 46 C6 00 31 01 80 8C 8C 10 62 12 00 08",
 "A3D0 08 30 D5 35 0F 0E 0F 10 10 00 0E 0C 0E 21 21 01",
 "A3E0 0C 08 0C 43 43 03 08 00 08 87 87 07 F0 E0 F0 00",
 "A3F0 01 01 E0 C0 E0 10 12 12 C0 80 C0 30 34 34 80 00",
 "A400 80 70 78 78 D1 D7 01 01 00 01 A2 AE 02 12 10 02",
 "A410 44 4C 04 34 31 04 88 88 08 68 63 08 10 7D 1D 10",
 "A420 00 10 20 EA 2A 20 01 21 40 C4 44 40 13 43 80 88",
 "A430 88 80 36 86 1E 15 0E 10 11 00 2C 2A 0E 21 22 01",
 "A440 48 44 08 43 45 03 80 88 00 87 8A 07 E0 51 E1 00",
 "A450 11 01 C0 A2 C2 10 22 12 80 44 84 30 54 34 00 88",
 "A460 08 70 A8 78 F0 F0 00 10 10 00 E0 E0 00 30 30 00",
 "A470 C0 C0 00 70 70 00 80 80 00 F0 F0 00 00 0F 0F 00",
 "A480 01 01 00 0E 0E 00 03 03 00 0C 0C 00 07 07 00 08",
 "A490 08 00 0F 0F 00 00 00 03 04 05 14 05 0A 14 32 04",
 "A4A0 05 06 14 05 06 07 19 0A 0F 14 3C 07 09 0C 1E 08",
 "A4B0 09 0A 19 06 08 0A 1E 0F 14 19 46 09 0C 0F 28 14",
 "A4C0 19 1E 50 0B 0C 0D 2D 03 05 07 1E 07 0A 0F 3C 04",
 "A4D0 07 0A 23 06 07 08 19 0A 0C 0F 28 08 0A 0C 46 06",
 "A4E0 09 0C 50 0C 0F 12 4B 1E 23 28 5A 28 2D 32 64 00",
 "A4F0 00 00 9F 99 0F 1F 31 0F F1 F1 09 8F 88 0F 00 00",
 "A500 00 0C 0C C4 C4 04 4C 0C 00 C0 48 00 C0 C0 80 84",
 "A510 C0 44 C0 C0 C0 C4 C0 48 80 84 77 00 00 47 44 07",
 "A520 70 70 07 77 00 07 00 00 00 70 00 70 70 00 47 07",
 "A530 00 70 61 40 10 16 70 72 50 75 70 74 70 74 70 61",
 "A540 70 72 C0 44 C0 C4 C0 C0 C0 C4 C0 C4 C0 C4 C0 44",
 "A550 70 45 70 11 00 07 70 75 70 11 70 74 60 45 40 44",
 "A560 80 84 C0 C4 C0 C4 C0 C4 C0 44 40 45 70 72 70 70",
 "A570 70 75 70 74 60 45 C0 C0 80 84 C0 44 C4 C0 C4 C0",
 "A580 C4 C0 44 60 61 70 70 50 06 56 70 11 70 74 60 45",
 "A590 88 88 88 08 00 00 00 00 00 00 C0 C4 80 84 C0 C0",
 "A5A0 C0 44 00 C0 44 C0 C4 C0 C4 80 84 C0 C4 C0 44 00",
 "A5B0 10 33 13 00 00 00 00 00 00 00 70 70 70 72 00 07",
 "A5C0 60 45 00 50 75 70 74 70 74 70 70 70 74 70 00 04",
 "A5D0 4C 08 48 08 48 08 48 08 4C 44 0C 08 00 88 88 88",
 "A5E0 88 88 88 88 88 08 00 00 00 4C 0C 48 08 4C 44 0C",
 "A5F0 08 00 2E AA 2E 2E 2E 2E AA AE A2 0E 57 02 27 07",
 "A600 07 07 07 07 65 60 05 02 00 23 22 22 22 22 22 22",
 "A610 22 03 00 00 00 07 07 27 07 65 60 05 02 00 AF 8A",
 "A620 8F 8E 8F 8F FE FF F8 0F 11 11 11 70 52 72 10 11",
 "A630 11 01 00 00 00 00 00 00 00 00 00 00 00 00 11 07",
 "A640 11 11 11 10 1B 10 11 11 01 57 07 00 00 00 00 08",
 "A650 08 0D 04 08 10 0B 06 14 07 13 0D 06 08 0B 12 0E",
 "A660 0E 0A 09 0D 12 88 8C 08 4C 04 4C 4C 0C 23 27 03",
 "A670 57 04 07 07 07 44 0C 0C 0C 8C 04 48 08 56 04 17",
 "A680 07 17 06 07 07 48 08 0C 4C 04 C0 C0 C0 C4 C0 C0",
 "A690 40 4C 47 07 07 07 00 60 61 70 11 70 71 00 07 4C",
 "A6A0 04 0C 0C 07 00 70 00 4C 08 0C 48 08 4C 44 0C 57",
 "A6B0 02 07 47 07 65 60 05 08 0C 08 4C 0C 4C 4C 0C C4",
 "A6C0 C4 04 4C 44 0C 4C 04 23 27 03 47 07 07 07 07 70",
 "A6D0 70 00 65 60 05 57 04 48 08 0C 4C 08 48 08 4C 0C",
 "A6E0 48 08 47 07 07 57 02 27 07 07 07 47 07 C4 04 4C",
 "A6F0 04 0C 0C 70 00 57 04 16 06 4C 0C 4C 0C 0C 4C 04",
 "A700 8C 04 4C 04 C0 C4 C4 C0 C0 40 C4 80 84 57 07 17",
 "A710 01 07 07 00 17 06 57 04 70 70 70 70 71 60 45 70",
 "A720 72 0C 48 08 4C 0C 44 04 07 47 07 47 07 54 04 4C",
 "A730 0C 48 08 C0 C4 C4 C0 44 C0 C4 C0 C4 80 84 C0 C0",
 "A740 40 4C 57 07 27 07 70 70 70 70 45 70 75 70 11 70",
 "A750 72 60 61 00 07 4C 04 48 08 4C 04 4C 0C 0C 0C 4C",
 "A760 4C 0C 07 00 27 07 07 00 47 07 70 00 07 07 07 48",
 "A770 08 4C 04 4C 04 27 07 07 00 07 00 0C 08 0C 08 4C",
 "A780 04 4C 0C 07 23 27 03 57 04 07 07 C4 04 48 08 0C",
 "A790 0C 4C 4C 0C 48 08 70 00 27 07 70 00 07 07 07 27",
 "A7A0 07 C4 C4 04 48 08 4C 0C 0C C0 C4 C4 C0 44 C4 C0",
 "A7B0 C4 C0 C0 70 70 00 27 07 17 01 07 70 70 70 50 06",
 "A7C0 56 70 70 70 71 0C 0C 44 04 48 08 4C 0C 48 08 4C",
 "A7D0 0C 4C 04 70 00 54 04 27 07 07 07 47 07 47 07 56",
 "A7E0 04 4C 04 0C 48 08 40 4C 4C C0 C4 C0 C4 C0 48 56",
 "A7F0 04 07 27 07 00 07 07 70 74 70 11 70 61 88 8C 08",
 "A800 0C 4C 0C 48 08 48 08 23 27 03 07 07 07 47 07 07",
 "A810 07 4C 04 48 08 0C C4 04 0C 0C 57 04 07 07 07 70",
 "A820 00 17 07 4C 04 4C 04 0C 0C 4C 0C 4C 08 C0 C4 C0",
 "A830 56 04 57 04 16 06 47 07 57 02 70 75 70 0C 4C 0C",
 "A840 C0 C0 40 4C 4C C0 C4 00 4C 0C 4C 04 88 8C 08 07",
 "A850 47 07 00 07 00 07 07 70 74 00 57 07 57 04 23 27",
 "A860 03 00 DB 01 07 D0 3E 0C DF 21 98 10 22 53 F3 22",
 "A870 CB F3 3E F8 32 BB F4 32 33 F5 32 F3 F8 32 6B F9",
 "A880 3E 78 32 AB F5 32 23 F6 3E D8 32 9B F6 32 13 F7",
 "A890 7D 32 8B F7 32 03 F8 21 F2 A4 11 03 F3 01 28 00",
 "A8A0 ED B0 1E 7B 0E 28 ED B0 11 70 F5 0E 0E ED B0 1E",
 "A8B0 E8 0E 0E ED B0 11 62 F6 0E 0C ED B0 1E DA 0E 0C",
 "A8C0 ED B0 11 51 F7 0E 0D ED B0 1E C9 0E 0D ED B0 11",
 "A8D0 B4 F8 0E 20 ED B0 11 2C F9 0E 20 ED B0 11 1A FA",
 "A8E0 0E 2C ED B0 1E 92 0E 2C ED B0 11 F0 FC 0E 23 ED",
 "A8F0 B0 3E C0 32 7C FC 21 C0 C4 22 2B FB 21 70 75 22",
 "A900 A3 FB 3E 0F 32 1C FC 32 84 FD 3E 0B 32 94 FC 21",
 "A910 40 C5 22 FB FD 21 70 55 22 73 FE 21 0C 0C 22 8E",
 "A920 FC 21 4C 04 22 99 FC 3A 2D C0 47 04 AF 21 4E A6",
 "A930 86 2C 10 FC 4E 6F 29 11 65 5A 19 79 11 74 F4 ED",
 "A940 B0 1E EC 4F ED B0 3A 2D C0 47 80 80 87 87 6F 61",
 "A950 29 29 11 80 A0 19 F9 D1 C1 E1 78 32 E4 F5 32 D4",
 "A960 F6 32 C4 F7 22 E5 F5 22 D5 F6 22 C5 F7 79 EB 32",
 "A970 6E F5 32 5E F6 32 4E F7 22 6C F5 22 5C F6 22 4C",
 "A980 F7 21 8B F5 3A 2D C0 87 87 C6 97 5F 16 A4 01 04",
 "A990 03 1A F9 D9 21 0A FF 24 95 30 FC 85 87 87 C6 35",
 "A9A0 6F 7C 26 AA 01 C0 44 C5 06 C4 C5 01 80 84 C5 01",
 "A9B0 C0 C4 C5 4E 2C 46 2C 5E 2C 56 C5 87 20 02 3E 14",
 "A9C0 87 C6 35 6F 4E 2C 46 C5 D9 21 84 00 39 71 F9 D9",
 "A9D0 01 70 00 C5 06 74 C5 41 C5 06 74 C5 D5 2C 4E 2C",
 "A9E0 46 C5 D9 21 84 00 39 1C 10 A7 31 FD FF DB 08 E6",
 "A9F0 20 32 00 CE 28 1A 21 C4 00 22 76 FC 21 44 0C 22",
 "AA00 82 FC 21 74 04 22 EE FC 21 55 07 22 FA FC 18 16",
 "AA10 21 44 0C 22 76 FC 6C 22 82 FC 21 56 04 22 EE FC",
 "AA20 21 16 06 22 FA FC 47 DB 08 E6 20 A8 20 BF DB 01",
 "AA30 07 38 F4 C9 00 C0 C4 70 74 40 0C 40 47 40 C4 70",
 "AA40 55 40 C4 50 75 C0 C0 10 71 C0 44 50 75 C0 44 70",
 "AA50 75 40 C4 00 70 C0 C4 70 75 C0 C4 50 75 00 00 00",
 "AA60 00 00 21 2E C0 DB 09 07 30 05 CD E1 BD 18 03 CD",
 "AA70 EF BD 31 62 C0 11 06 06 D5 11 01 01 D5 11 20 20",
 "AA80 D5 11 FF 1A D5 2E C3 71 21 7F C1 11 B8 60 06 13",
 "AA90 73 2D 72 2D 10 FA 73 2D 71 20 FC 11 80 C1 01 80",
 "AAA0 0A ED B0 2E 88 16 F3 0E 78 ED B0 62 01 40 0B ED",
 "AAB0 B0 3E F8 32 51 F3 32 C9 F3 32 91 FE 31 10 F3 21",
 "AAC0 4C 04 E5 55 5C 26 0C E5 E5 D5 5C D5 26 04 E5 63",
 "AAD0 E5 21 48 08 E5 31 88 F3 11 56 04 D5 21 47 07 E5",
 "AAE0 6C E5 6A E5 53 5C D5 50 D5 2E 47 E5 6C E5 31 90",
 "AAF0 FE 21 11 11 06 28 E5 10 FD 21 C0 C4 22 1E F3 21",
 "AB00 70 74 22 96 F3 31 FD FF C9 00 00 00 39 25 2E 3F",
 "AB10 76 22 49 64 53 59 94 71 83 8B 69 2A 9C A6 BC C6",
 "AB20 D0 EA 0A 87 FF 09 87 2E 11 FF 0B 87 FF 00 01 87",
 "AB30 23 24 23 24 23 24 23 24 FF 01 87 FF 23 24 FF 11",
 "AB40 86 89 02 03 41 04 00 00 00 01 86 6A 02 03 24 41",
 "AB50 00 00 00 0A 87 20 8D 0B FF 35 83 26 25 23 4D 10",
 "AB60 01 42 24 FF 01 87 6D 0B FF 09 87 4A 13 10 13 09",
 "AB70 FF 02 87 31 4D FF 01 87 20 21 FF 6C 03 24 4D 6C",
 "AB80 03 24 4D 01 87 33 12 13 11 11 FF 31 83 6D 06 09",
 "AB90 2F 6D 01 FF 09 87 21 90 03 02 05 FF 01 87 67 0C",
 "ABA0 28 87 0B 28 0E 00 0B 87 63 0C 24 0E FF 00 00 00",
 "ABB0 63 0C 20 4D 05 07 10 FF 63 0C 24 FF 11 86 6A 02",
 "ABC0 07 4D 01 08 00 00 09 87 33 03 24 0F 33 03 24 0F",
 "ABD0 0B 87 31 4D 07 32 12 05 FF 00 31 03 4D 07 32 12",
 "ABE0 05 FF 31 0E 4D 07 32 12 05 FF 01 87 31 21 0F FF",
 "ABF0 00 00 00 00 3A 55 C0 B7 C2 66 AC 3A 54 C0 B7 CA",
 "AC00 D7 AC 3A 53 C0 B7 C2 56 AD 3A 52 C0 D6 08 D2 D7",
 "AC10 AD 3A 2C C0 3D F0 32 53 C0 2A 50 C0 7C 85 4F 21",
 "AC20 06 03 22 50 C0 3A 2D C0 C6 3A 6F 26 C0 7E 81 77",
 "AC30 2E 2E 7E 3C FE E1 20 02 3E C3 77 5F 16 BD 2D 1A",
 "AC40 77 C6 3A 6F 3A 52 C0 2F C6 0D 86 77 2E 32 2D 7E",
 "AC50 36 00 3C FE 0A 28 F7 77 2E 52 36 15 11 1F C0 01",
 "AC60 19 00 ED B8 C9 00 CD 59 BE 20 16 F1 3A 32 C0 B7",
 "AC70 CA 09 A0 21 33 C0 11 23 C0 01 07 00 ED B0 C3 09",
 "AC80 A0 31 38 C7 11 80 84 D5 21 84 C0 E5 43 4C C5 D5",
 "AC90 21 4C 4C E5 11 04 40 D5 2E 0C E5 2E 08 E5 16 48",
 "ACA0 D5 6B E5 21 00 C4 E5 31 B8 C7 21 70 72 E5 11 74",
 "ACB0 70 D5 5A D5 E5 21 07 07 E5 3B 11 56 04 D5 01 47",
 "ACC0 07 C5 E5 1C D5 21 70 00 E5 31 FD FF 21 02 37 22",
 "ACD0 00 C7 22 80 C7 C9 00 3A 5A C0 FE 40 C0 3A 2A C0",
 "ACE0 2A 2B C0 B4 B5 2A 58 C0 B4 B5 C0 3A 60 C0 3D 20",
 "ACF0 05 3D 32 55 C0 C9 32 60 C0 3E 54 32 54 C0 ED 5B",
 "AD00 60 C0 0E 2A 21 4F F3 1D 28 20 43 79 D6 03 38 37",
 "AD10 4F 36 00 2D 36 C0 2D 36 00 7D C6 7A 6F 36 72 2D",
 "AD20 36 52 2D 36 70 D6 7B 6F 10 E1 15 28 1A 42 79 D6",
 "AD30 02 38 14 4F 36 08 2D 36 00 7D C6 79 6F 36 13 2D",
 "AD40 36 10 D6 7A 6F 10 E7 0C 41 AF 11 9D F3 77 12 2D",
 "AD50 1C 10 FA C9 00 00 3D 32 53 C0 FE E0 D0 31 2F C7",
 "AD60 21 0C 0C E5 E5 11 48 08 D5 2E 4C E5 7D 32 26 C7",
 "AD70 31 AF C7 11 17 07 D5 01 16 06 C5 1E 27 D5 5A D5",
 "AD80 7A 32 A6 C7 3A 2F C0 87 20 08 3A 30 C0 87 20 15",
 "AD90 18 22 87 C6 35 6F 26 AA F9 E1 22 2F C7 E1 22 AF",
 "ADA0 C7 3A 30 C0 87 87 C6 35 6F 26 AA F9 E1 22 31 C7",
 "ADB0 E1 22 B1 C7 3A 31 C0 87 87 C6 35 6F 26 AA F9 E1",
 "ADC0 22 33 C7 E1 22 B3 C7 31 FD FF 21 02 34 22 00 C7",
 "ADD0 22 80 C7 C9 00 00 00 21 5C C0 35 C0 2C 86 2D 77",
 "ADE0 3A 2C C0 FE 0C D0 47 3A 52 C0 90 47 CD 72 AF 16",
 "ADF0 02 0F 30 02 16 A5 E6 1F B8 D0 D9 21 39 C0 2C 96",
 "AE00 30 FC 7D D6 3A FE 16 38 09 3A 2D C0 28 02 C6 40",
 "AE10 C6 40 D9 47 E6 1F C6 0C 6F 26 AB 6E CB 56 28 15",
 "AE20 3A 54 C0 92 38 02 ED 44 C6 57 30 09 C6 02 5F ED",
 "AE30 53 65 C0 18 0F 4A EB CD 72 AF E6 3F C6 08 6F 61",
 "AE40 22 65 C0 EB 7E 2C 4E 2C EB 21 00 00 CB 6F 28 01",
 "AE50 24 22 69 C0 CB 67 28 05 26 01 08 18 4A CB 5F 20",
 "AE60 0E 08 CD 72 AF 26 00 C6 80 6F 30 3B 24 18 38 08",
 "AE70 3A 65 C0 C6 15 6F 26 AF 6E 3A 66 C0 67 3A 54 C0",
 "AE80 94 30 02 ED 44 26 FF BD 38 05 24 95 BD 30 D3 D5",
 "AE90 54 1E FF 67 AF 24 1C 95 30 FC 25 20 F9 EB D1 24",
 "AEA0 20 05 7D FE 40 38 BB 3A 66 C0 07 30 06 AF 95 6F",
 "AEB0 9F 94 67 22 67 C0 D9 08 E6 03 47 11 65 C0 D9 C5",
 "AEC0 CD D2 AE C1 EB D9 35 C8 1A C6 06 12 10 F0 C9 00",
 "AED0 00 00 21 2C C0 34 21 F2 CE 7D C6 12 6F CB 7E 20",
 "AEE0 F9 71 2C 3A 56 C0 B7 28 0A CB 70 28 06 AF 32 56",
 "AEF0 C0 CB F8 70 2C ED 4B 67 C0 71 2C 36 80 2C 70 2C",
 "AF00 ED 4B 65 C0 70 2C 79 ED 4B 69 C0 71 2C 36 80 2C",
 "AF10 70 2C 77 2C EB 01 08 00 ED B0 C9 00 00 5B 5A 59",
 "AF20 59 58 58 57 57 56 55 55 54 54 53 52 52 51 50 50",
 "AF30 4F 4F 4E 4D 4D 4C 4B 4B 4A 49 48 48 47 46 46 45",
 "AF40 44 43 43 42 41 40 40 3F 3E 3D 3C 3B 3B 3A 39 38",
 "AF50 37 36 35 34 33 32 31 30 2F 2E 2D 2C 2A 29 28 27",
 "AF60 25 24 23 21 20 1E 1C 1A 18 16 14 11 0E 0A 00 00",
 "AF70 00 00 2A 02 CE 7C 07 0F CB 15 1F 8D 3D 67 22 02",
 "AF80 CE C9 00 00 00 3A 54 C0 B7 C8 3A 5A C0 E6 03 20",
 "AF90 18 DB 08 E6 40 CC E4 AF DB 09 E6 40 20 08 3A 01",
 "AFA0 CE B7 C4 1F B0 AF 32 01 CE 3A 57 C0 B7 C0 3A 00",
 "AFB0 CE B7 28 15 DB 00 E6 0A FE 08 28 17 FE 02 C0 21",
 "AFC0 54 C0 7E FE A1 C8 3C 18 12 DB 05 E6 05 FE 04 28",
 "AFD0 EE 3D C0 21 54 C0 7E FE 06 C8 3D 77 2E 58 BE C0",
 "AFE0 2D 36 01 C9 3A C3 C0 B7 C0 3A 61 C0 3D C8 32 61",
 "AFF0 C0 3E 20 D3 40 3A 54 C0 32 C3 C0 21 C5 80 22 C4",
 "B000 C0 21 FE 55 22 C6 C0 3A 5A C0 07 D2 FE AC C9 7C",
 "B010 FE A0 D0 21 69 BE CD ED 52 DB 01 07 38 FB C9 21",
 "B020 2A C0 7E FE 06 D0 34 21 02 CE 34 3E 20 D3 40 2A",
 "B030 53 C0 2E 55 22 65 C0 3A C3 C0 B7 28 06 21 54 C0",
 "B040 96 20 0F 21 00 00 22 67 C0 21 3E FE 22 69 C0 C3",
 "B050 C1 B0 21 00 01 30 04 ED 44 26 FF 22 67 C0 4F 3A",
 "B060 C7 C0 D6 05 47 C6 1E 6F 26 AF 7E B9 20 11 7D 87",
 "B070 C6 02 6F 26 B1 5E 2C 56 ED 53 69 C0 C3 C1 B0 11",
 "B080 6E AF 30 0E 2D 1D 1A 86 B9 30 E3 10 F7 21 2A C0",
 "B090 35 C9 2D 1D 1A 2F 86 B9 38 D4 10 F6 3C 41 4F 21",
 "B0A0 00 00 3E FF 2C 91 30 FC 10 FA 3A 68 C0 3C 20 03",
 "B0B0 95 6F 25 22 67 C0 21 3E FE 22 69 C0 C3 C1 B0 00",
 "B0C0 00 26 C0 3E C3 C6 08 6F 46 04 10 F9 D6 03 6F ED",
 "B0D0 5B 67 C0 73 2C 36 80 2C 72 2C ED 5B 65 C0 72 2C",
 "B0E0 ED 4B 69 C0 71 2C 36 80 2C 70 2C 73 C9 00 00 00",
 "B0F0 AF D3 40 2A C3 C0 B4 C0 B5 C8 DB 00 E6 50 FE 40",
 "B100 20 0B 21 C3 C0 7E FE 06 28 10 35 18 0D FE 10 20",
 "B110 09 21 C3 C0 7E FE A1 28 01 34 DB 01 0F DB 00 1F",
 "B120 E6 82 FE 02 20 09 21 C7 C0 7E FE 06 C8 35 C9 FE",
 "B130 80 C0 21 C7 C0 7E FE 54 C8 34 C9 00 00 00 3E FE",
 "B140 41 FE 44 FE 46 FE 49 FE 4C FE 4F FE 52 FE 55 FE",
 "B150 58 FE 5D FE 5E FE 61 FE 64 FE 67 FE 6A FE 6E FE",
 "B160 71 FE 74 FE 77 FE 7A FE 7E FE 81 FE 84 FE 88 FE",
 "B170 8B FE 8F FE 92 FE 95 FE 99 FE 9D FE A0 FE A4 FE",
 "B180 A7 FE AB FE AF FE B3 FE B7 FE BA FE BE FE C2 FE",
 "B190 C6 FE CA FE CF FE D3 FE D7 FE DB FE E0 FE E4 FE",
 "B1A0 E9 FE ED FE F2 FE F7 FE FC FE 00 FF 05 FF 0B FF",
 "B1B0 10 FF 15 FF 1B FF 20 FF 26 FF 2C FF 32 FF 38 FF",
 "B1C0 3F FF 45 FF 4C FF 53 FF 5B FF 62 FF 6B FF 73 FF",
 "B1D0 7D FF 87 FF 91 FF 9D FF AB FF BB FF D0 FF 00 21",
 "B1E0 5A C0 34 20 31 2C 35 C2 FE AC 36 19 2E 5D 7E FE",
 "B1F0 04 28 01 35 3A 58 C0 B7 20 1C 3A 54 C0 B7 28 16",
 "B200 CD 72 AF 11 01 01 0F 30 03 11 FF A6 21 58 C0 72",
 "B210 2E 64 73 C3 FE AC 7E FE 80 C0 21 02 CE 34 31 40",
 "B220 F3 21 4C 04 E5 55 5C 26 0C E5 E5 D5 5C D5 26 04",
 "B230 E5 63 E5 21 48 08 E5 11 00 00 D5 21 44 C4 E5 21",
 "B240 C4 C0 E5 2E 84 E5 57 D5 31 B8 F3 21 56 04 E5 01",
 "B250 47 07 C5 48 C5 4C C5 65 68 E5 63 E5 0E 47 C5 48",
 "B260 C5 21 10 01 E5 21 06 56 E5 21 70 50 E5 21 72 70",
 "B270 E5 6B E5 31 FD FF 3A 32 C0 B7 28 13 21 10 F3 43",
 "B280 4D 11 40 F3 ED B0 2E 88 1E B8 0E 10 ED B0 C9 21",
 "B290 C0 C4 22 4E F3 21 70 74 22 C6 F3 11 40 F3 01 23",
 "B2A0 C0 0A B7 20 16 12 1C 12 7B C6 77 5F AF 12 1C 12",
 "B2B0 7B D6 77 5F 0C FE 4E 20 E8 C9 0A 87 87 C6 35 6F",
 "B2C0 26 AA ED A0 0C 7E 12 7B C6 77 5F 2C ED A0 0C 7E",
 "B2D0 12 7B D6 77 5F 0C FE 4E 20 E0 C9 00 00 00 CD A8",
 "B2E0 B6 3A 2C C0 B7 28 1A 21 6B C0 74 DD 21 04 CE DD",
 "B2F0 CB 00 7E C4 20 B9 DD 7D C6 12 DD 6F 20 F1 CD 78",
 "B300 BC 2A C3 C0 2C 2D 28 1B DD 21 C0 C0 24 25 28 09",
 "B310 21 C3 C0 5E CD 7F B3 18 0A 3A C7 C0 67 3A C3 C0",
 "B320 CD 9C B3 3A 2A C0 B7 28 13 DD 21 C8 C0 DD 7E 03",
 "B330 B7 C4 64 B3 DD 7D C6 08 DD 6F 20 F1 3A 2B C0 B7",
 "B340 28 19 DD 21 00 CD 3E 20 D3 40 DD 7E 00 B7 C4 AA",
 "B350 B8 DD 7D C6 04 DD 6F 20 F1 D3 40 CD 14 B8 C3 32",
 "B360 B7 00 00 00 DD 7D 6F 26 C0 7E 2C 86 77 2C 7E 2C",
 "B370 8E 77 5F D6 03 FE A2 38 06 36 00 2E 2A 35 C9 2C",
 "B380 7E 4F 2C 86 77 2C 7E 2C 8E FE 5B D2 59 B4 77 57",
 "B390 79 C6 05 DD 77 04 30 02 2D 34 62 7B C6 06 6F 7C",
 "B3A0 CB 3C 37 CB 1C 24 CB 2C CB 1D 38 6C E6 03 20 2B",
 "B3B0 7E 4F F6 13 77 2D CB E6 11 81 FF 19 CB DE 1D 14",
 "B3C0 7D E6 80 45 6F 78 E6 7F 36 02 2C BE 38 01 77 19",
 "B3D0 BE DA 0F B5 77 2D 36 02 C3 0F B5 47 10 1C 7E 4F",
 "B3E0 F6 27 77 2D CB EE 2C 7D E6 80 45 6F 78 E6 7F 36",
 "B3F0 02 2C BE DA 0F B5 77 C3 0F B5 10 0A 7E 4F F6 4E",
 "B400 77 2D CB F6 18 E0 7E 4F F6 8C 77 2D CB FE 11 81",
 "B410 00 19 CB C6 1D 15 18 A8 E6 03 20 12 7E 4F F6 31",
 "B420 77 2C CB C6 11 7F FF 19 CB FE 2C 1C 18 91 47 10",
 "B430 0A 7E 4F F6 72 77 2C CB CE 18 AC 10 0A 7E 4F F6",
 "B440 E4 77 2C CB D6 18 A0 7E 4F F6 C8 77 2C CB DE 11",
 "B450 7F 00 19 CB E6 2C 1C 18 BC 7D D6 07 6F 5E 2C 2C",
 "B460 56 ED 53 67 C0 2C 56 AF 77 1E 5B ED 53 65 C0 2C",
 "B470 96 4F 2C 2C 3E 00 9E 1F CB 19 37 1F CB 19 47 ED",
 "B480 43 69 C0 3A 58 C0 D6 04 38 06 92 FE F9 D4 7F B6",
 "B490 21 2A C0 35 21 2B C0 7E FE 3A D0 C6 07 77 ED 73",
 "B4A0 C1 C0 31 F0 B4 FD 21 FC CD 06 07 FD 7D C6 04 FD",
 "B4B0 6F FD 7E 00 B7 20 F4 2A 67 C0 D1 19 22 67 C0 2A",
 "B4C0 69 C0 D1 19 22 69 C0 16 CC FD 5D EB 73 2C 36 80",
 "B4D0 2C 72 2C ED 5B 65 C0 73 24 7A ED 5B 67 C0 73 2D",
 "B4E0 36 80 2D 72 2D 77 10 C3 ED 7B C1 C0 C9 00 00 00",
 "B4F0 00 00 C0 FF CE FF 18 00 F3 FF 36 00 23 00 2B 00",
 "B500 38 00 00 00 22 00 D5 FF F4 FF CA FF 00 00 00 0C",
 "B510 0D C8 AF 32 C0 C0 DD 56 03 DD 5E 07 DD E5 DD 21",
 "B520 04 CE DD CB 00 7E 28 19 7A DD 96 05 C6 02 FE 05",
 "B530 30 0F 7B DD 96 09 C6 02 FE 05 30 05 D5 CD 87 B5",
 "B540 D1 DD 7D C6 12 DD 6F 20 D9 DD E1 3A C0 C0 B7 C8",
 "B550 DD 7D FE C0 20 0B 21 00 00 22 67 C0 21 C3 C0 18",
 "B560 0E 21 2A C0 35 6F 5E 2C 2C 56 ED 53 67 C0 2C 46",
 "B570 36 00 2C 5E 2C 2C 56 ED 53 69 C0 2C 4E ED 43 65",
 "B580 C0 C3 94 B4 00 00 00 DD 7D 6F 26 CE 32 C0 C0 CB",
 "B590 BE 4E CB 49 20 09 7D C6 05 6F 11 00 00 18 07 2C",
 "B5A0 2C 5E 2C 2C 56 2C ED 53 67 C0 46 CB 41 20 0B DD",
 "B5B0 4E 09 21 00 00 22 69 C0 18 0B 2C 5E 2C 2C 56 2C",
 "B5C0 ED 53 69 C0 4E ED 43 65 C0 21 2C C0 35 2E 52 35",
 "B5D0 DD 7E 01 07 30 18 07 38 06 2E 57 36 00 18 10 57",
 "B5E0 79 FE 05 7A 38 09 ED 43 62 C0 2E 59 35 0F 07 C6",
 "B5F0 97 6F 26 A4 46 CD FB B5 C3 94 B4 21 3A C0 0E 0A",
 "B600 2D 78 86 06 00 04 91 30 FC 81 77 10 F3 7D FE 38",
 "B610 30 10 D9 21 5E C0 35 20 08 2C 34 7E 2D 77 32 56",
 "B620 C0 D9 7D 87 D6 56 5F 16 F3 06 AA 7E 87 87 C6 35",
 "B630 4F 0A 12 0C 1C 0A 12 0C 7B C6 77 5F 0A 12 0C 1C",
 "B640 0A 12 7B D6 77 5F 2C FE 1E 20 E0 2E 32 7E B7 20",
 "B650 12 11 22 C0 06 07 2C 1C 1A BE 38 03 C0 10 F7 2E",
 "B660 32 36 01 3A 5A C0 07 D0 21 10 F3 11 40 F3 01 0E",
 "B670 00 ED B0 2E 88 1E B8 0E 0E ED B0 C9 00 00 00 3A",
 "B680 58 C0 21 40 FE FE 08 38 0A 2E 8D FE A0 30 04 1F",
 "B690 C6 BD 6F 3E 11 77 2C 77 2C 77 21 00 00 22 57 C0",
 "B6A0 06 32 C3 FB B5 00 00 00 2A 57 C0 7C 2D A5 C8 3A",
 "B6B0 5A C0 E6 03 C0 3A 64 C0 84 32 58 C0 21 54 C0 BE",
 "B6C0 20 04 2E 57 36 01 FE 07 30 1A 21 40 FE 3D 28 0E",
 "B6D0 3D 28 26 3D 28 31 3D 28 1D 3D 28 28 18 15 36 11",
 "B6E0 32 58 C0 C9 FE A1 30 25 1F 38 11 C6 BC 6F 26 FE",
 "B6F0 36 11 2C 36 73 2C 36 77 2C 36 13 C9 C6 BD 6F 26",
 "B700 FE 36 31 2C 36 77 2C 36 37 2C 36 11 C9 21 8F FE",
 "B710 D6 A6 28 CA 3C 28 0F 3C 28 12 3C 28 06 3C 28 09",
 "B720 36 37 2D 36 77 2D 36 31 C9 36 77 2D 36 73 2D 36",
 "B730 11 C9 3A 59 C0 B7 C8 3D 32 59 C0 2A 62 C0 3A C3",
 "B740 C0 B7 28 24 94 C6 03 28 12 FE 06 28 0E 30 19 3A",
 "B750 C7 C0 95 C6 03 D6 07 30 0F 18 0A 3A C7 C0 95 C6",
 "B760 02 D6 05 30 03 32 22 C0 7C C6 06 65 6F 7C CB 3C",
 "B770 37 CB 1C 24 CB 2C CB 1D 38 62 E6 03 20 13 7E F6",
 "B780 21 77 2D CB EE 11 80 FF 19 CB FE 2C CB FE 14 18",
 "B790 34 11 52 50 3D 28 06 3D 20 1A 11 A4 A0 2D 7E B2",
 "B7A0 77 2C 7E B3 77 7D E6 80 45 6F 78 E6 7F 36 02 2C",
 "B7B0 BE D8 77 C9 7E F6 48 77 2D CB F6 11 80 00 19 CB",
 "B7C0 E6 2C CB E6 15 7D E6 80 45 6F 78 E6 7F 36 02 2C",
 "B7D0 BE 38 01 77 19 BE D8 77 2D 36 02 C9 E6 03 20 14",
 "B7E0 7E F6 12 77 2C CB CE 11 7F FF 19 CB DE 2C CB DE",
 "B7F0 14 1C 18 D1 11 05 25 3D 28 A4 11 0A 4A 3D 28 9E",
 "B800 7E F6 84 77 2C CB D6 11 7F 00 19 CB C6 2C CB C6",
 "B810 15 1C 18 B1 3A 54 C0 B7 C8 26 CB 1F 38 1A C6 82",
 "B820 6F 7E 57 F6 4E 77 2C 7E 5F F6 4B 77 2C 7E F6 0E",
 "B830 77 2D CB BD CB DE 18 18 C6 82 6F 7E F6 E0 77 2C",
 "B840 7E 57 F6 B4 77 2C 7E 5F F6 E4 77 2D CB BD CB FE",
 "B850 7D 2E 01 BE 38 04 77 2D 36 02 2E 81 3C BE 38 04",
 "B860 77 2D 36 02 7A B3 C8 DD 21 04 CE DD CB 00 7E 28",
 "B870 14 DD 7E 09 FE 56 38 0D 3A 54 C0 DD 96 05 D6 05",
 "B880 FE F7 D4 87 B5 DD 7D C6 12 DD 6F 20 DE 2A 53 C0",
 "B890 2E 5A 22 65 C0 67 6F 22 67 C0 21 40 FF 22 69 C0",
 "B8A0 32 54 C0 32 57 C0 C3 94 B4 00 DD 7D 6F 26 CC 7E",
 "B8B0 2C 86 77 2C 7E 2C 8E 77 C6 40 FE 9C 38 09 DD 36",
 "B8C0 00 00 21 2B C0 35 C9 5F 24 7E 2D 86 77 2D 7E 2D",
 "B8D0 8E 77 D6 04 FE A0 38 07 36 00 21 2B C0 35 C9 C6",
 "B8E0 0A 01 01 01 1F 30 02 0E 10 57 25 7E C6 05 77 30",
 "B8F0 03 2C 2C 34 7B D6 44 F8 1F 30 02 CB 01 0F 30 04",
 "B900 CB 01 CB 01 6A 0F 30 04 CB FD 06 81 F6 C0 3C 67",
 "B910 7E B1 77 AF D3 40 68 7E BA D0 72 2D 36 02 C9 00",
 "B920 DD CB 00 5E 20 4D DD CB 00 4E 28 5A DD 7D C6 02",
 "B930 6F 26 CE 7E 2C 86 77 2C 7E 2C 8E 77 D6 02 FE A4",
 "B940 38 1F DD 7D 6F 36 00 2C 7E FE 40 38 0B E6 C0 E2",
 "B950 54 B9 3E 40 07 07 C6 15 C6 3A 21 2C C0 35 6F 34",
 "B960 C9 C6 02 21 54 C0 BE 20 1D DD 7E 0A E6 E0 EC CB",
 "B970 BA 18 13 3A 5A C0 E6 04 0F 3D DD 86 05 DD 77 05",
 "B980 D6 02 FE A4 30 BC DD CB 00 46 28 30 DD 7D C6 06",
 "B990 6F 26 CE 7E 2C 86 77 2C 7E 2C 8E 77 FE 02 FA 42",
 "B9A0 B9 FE 5A 38 17 36 59 2D 2D 2D AF 96 77 2C 2C 9F",
 "B9B0 96 77 2C 2C 7E E6 E0 FE 20 CC CB BA DD CB 00 56",
 "B9C0 28 19 DD 7E 06 C6 05 DD 77 06 30 0F DD 34 08 20",
 "B9D0 0A DD 7E 0A E6 E0 FE 40 CC CB BA 3A 5A C0 B7 20",
 "B9E0 0A DD 7E 0A E6 E0 FE 80 CC CB BA DD 7E 01 47 80",
 "B9F0 80 87 87 6F 26 00 29 29 3E 78 CB 00 30 02 C6 20",
 "BA00 CB 00 30 02 C6 60 32 67 C0 DD 7E 09 D6 06 30 38",
 "BA10 47 80 80 87 DD 5E 05 CB 3B 30 02 C6 18 C6 8F 4F",
 "BA20 06 A0 09 EB 26 00 22 65 C0 26 C1 2C 2C 1A B6 77",
 "BA30 2C 13 1A B6 77 2C 1C 1A B6 77 7D 2E 01 BE DA 3D",
 "BA40 BC 77 2D 36 02 C3 3D BC 01 74 A0 1F 30 03 0E 7A",
 "BA50 B7 1F 32 66 C0 30 06 57 79 C6 0C 4F 7A 1F 38 0F",
 "BA60 C6 C1 57 DD 7E 05 1F 32 65 C0 5F 38 11 18 13 C6",
 "BA70 C1 57 DD 7E 05 1F 32 65 C0 CB FF 5F 30 04 79 C6",
 "BA80 18 4F 09 F9 1C 1C C1 1A B1 12 1C 1A B0 12 1C C1",
 "BA90 1A B1 12 21 7E 00 19 7E B0 77 2C C1 7E B1 77 2C",
 "BAA0 7E B0 77 31 FB FF 7D E6 80 6F 7B E6 7F 36 02 2C",
 "BAB0 BE 38 01 77 11 80 FF 19 BE 38 04 77 2D 36 02 CD",
 "BAC0 3D BC 21 66 C0 34 C3 3D BC 00 00 DD 7E 0A E6 1F",
 "BAD0 87 C6 12 6F 26 BC F9 C9 00 DD 7D C6 0A 6F 26 CE",
 "BAE0 F9 C1 70 D1 E1 F1 3B F5 E5 D5 DD 71 11 78 E6 E0",
 "BAF0 28 D9 31 F9 FF C9 DD CB 00 86 18 DD DD CB 00 C6",
 "BB00 18 D7 DD CB 00 8E 18 D1 DD CB 00 CE 18 CB DD CB",
 "BB10 00 96 18 C5 DD CB 00 D6 18 BF DD CB 00 DE 18 B9",
 "BB20 DD CB 00 9E 18 B3 DD 36 06 00 DD 36 08 00 18 A9",
 "BB30 DD 36 06 00 DD 36 08 01 18 9F DD CB 08 7E 20 99",
 "BB40 DD 7D C6 06 6F 26 CE AF 96 77 2C 2C 9F 96 77 18",
 "BB50 88 DD CB 08 7E 28 82 18 E7 DD 7E 09 FE 52 D2 D9",
 "BB60 BA C6 04 6F 3A 2A C0 FE 07 CA D9 BA 3C 32 2A C0",
 "BB70 DD 66 05 22 65 C0 21 A0 00 22 69 C0 6C 22 67 C0",
 "BB80 31 F9 FF CD C1 B0 C3 D9 BA 3A 54 C0 DD 96 05 1F",
 "BB90 DD AE 04 F2 D9 BA DD 7D C6 02 18 A8 DD 36 06 00",
 "BBA0 DD 36 08 FF C3 D9 BA DD CB 08 2E DD CB 06 1E C3",
 "BBB0 D9 BA DD CB 06 26 DD CB 08 16 C3 D9 BA 3A 2C C0",
 "BBC0 FE 0E CA D9 BA DD 7D 6F 26 CE 4E 2C 46 78 FE 40",
 "BBD0 38 0E 07 07 E6 03 C6 4F FE 52 20 06 3E 16 CB B8",
 "BBE0 C6 3A 5F 16 C0 1A 3D FA D9 BA 12 2C 5E 2C 2C 56",
 "BBF0 ED 53 67 C0 2C 7E 2C 5E 2C 2C 56 ED 53 69 C0 2C",
 "BC00 6E 67 22 65 C0 11 3B AB 31 F9 FF CD D2 AE C3 D9",
 "BC10 BA 00 D9 BA F6 BA FC BA 02 BB 08 BB 0E BB 14 BB",
 "BC20 1A BB 20 BB 26 BB 30 BB 3A BB 51 BB 59 BB 96 BB",
 "BC30 89 BB 9C BB A7 BB B2 BB BD BB 00 00 00 21 6B C0",
 "BC40 7E BC 20 0D 11 BD C0 73 2E 65 ED A0 ED A0 ED A0",
 "BC50 C9 6F D6 03 32 6B C0 5F 54 2F C6 BE 4F 06 00 3A",
 "BC60 65 C0 BE 38 09 ED A0 ED A0 ED A0 EA 62 BC 2A 66",
 "BC70 C0 EB 77 2C 73 2C 72 C9 21 6B C0 6E 7C 95 C8 47",
 "BC80 F9 E1 4D CB FC 2E AE CB 2C CB 1D 24 36 02 2C 54",
 "BC90 5D 7E B7 28 3E 6F F6 81 FE FB 38 3C 0F 3C 28 2A",
 "BCA0 08 2C 2C 7E 91 28 23 FE 04 38 07 08 3C 28 1B 08",
 "BCB0 2C 2C 79 D6 03 77 7D 12 2C 3B F1 77 08 3C 28 02",
 "BCC0 2C 71 05 05 10 BB 31 FB FF C9 33 05 05 10 B2 31",
 "BCD0 FB FF C9 79 FE 04 38 13 2C 2C 7E 91 28 EC C6 03",
 "BCE0 F2 E5 BC 2C 2C 79 D6 03 77 7D 12 2C 3B F1 77 2C",
 "BCF0 71 05 05 10 8C 31 FB FF C9 00 00 DD 21 01 C1 FD",
 "BD00 21 F0 F3 DD CB FF 3E 28 76 DD F9 C1 78 B9 30 01",
 "BD10 79 41 0E 00 C5 C1 C1 D6 01 1F FE 2A 20 0A 3E 29",
 "BD20 DD 36 54 00 DD 36 55 00 47 4F 05 FD 54 FD 5D EB",
 "BD30 D1 73 2C 72 23 10 F9 11 00 00 41 D5 10 FD 1E 80",
 "BD40 DD 19 1E 78 FD 19 DD CB D6 3E 20 07 30 27 FD F9",
 "BD50 3B 18 1A DD 54 DD 5D 1D 1B 62 6B FD F9 3B 3E 13",
 "BD60 2D 46 2D 4E C5 3D 20 F8 DD 77 D7 EB F9 11 B8 60",
 "BD70 06 13 D5 10 FD DD 7C FE CC 20 88 31 FD FF C9 38",
 "BD80 0F 06 60 10 FE 11 80 00 DD 19 1E 78 FD 19 18 E5",
 "BD90 DD 7E 01 11 00 00 DD 72 01 D6 03 E6 FE FE 52 20",
 "BDA0 02 3E 50 6F 62 FD 44 FD 4D 09 F9 0F 47 D5 10 FD",
 "BDB0 1E 80 DD 19 1E 78 FD 19 DD CB D6 3E 30 B7 FD F9",
 "BDC0 3B 18 AA 00 01 02 02 03 04 05 05 06 07 08 08 09",
 "BDD0 0C 0B 0B 0D 0E 0F 0F 10 11 11 0A 12 12 13 14 14",
 "BDE0 15 AF 32 21 C0 36 C2 01 00 2B 2C 71 10 FC C9 3A",
 "BDF0 21 C0 C6 FD A6 28 EE AF 32 55 C0 2E 53 36 FF 2D",
 "BE00 EB 21 1F C0 01 19 00 ED B8 06 08 12 1D 10 FC 2E",
 "BE10 21 34 C9 3A 22 C0 B7 C8 AF 32 22 C0 32 59 C0 21",
 "BE20 60 C0 34 2C 34 3A 5A C0 07 D4 FE AC 0E 00 3E 20",
 "BE30 D3 40 41 10 FE AF D3 40 41 10 FE 3E 20 D3 40 41",
 "BE40 10 FE AF D3 40 41 10 FE 3E 20 D3 40 41 10 FE AF",
 "BE50 D3 40 41 10 FE 0C 20 D6 C9 DB 01 E6 80 C8 3A 5A",
 "BE60 C0 E6 03 C0 21 55 C0 35 C9 98 9D 20 91 91 0D 0A",
 "BE70 93 9F ED 96 96 93 92 0D 0A 43 6F 70 79 72 69 67",
 "BE80 68 74 20 4D 43 4D 4C 58 58 58 56 20 28 43 29 20",
 "BE90 62 79 20 4B 2E 59 61 73 75 6F 6B 61 0D 0A 0A 20",
 "BEA0 20 53 74 61 72 74 20 41 64 64 72 65 73 73 3A 20",
 "BEB0 41 30 30 30 0D 0A 20 20 41 75 74 6F 73 61 76 65",
 "BEC0 72 20 53 74 61 72 74 20 41 64 64 72 65 73 73 3A",
 "BED0 20 42 46 30 30 0D 0A 0A 20 20 50 72 6F 67 72 61",
 "BEE0 6D 20 41 72 65 61 3A 20 41 30 30 30 2D 42 46 46",
 "BEF0 46 20 28 38 31 39 32 20 62 79 74 65 73 29 0A 00",
 "BF00 31 FF FF 21 A8 BF CD ED 52 DB 01 07 30 FB 21 EC",
 "BF10 BF CD ED 52 DB 01 07 38 FB 21 F9 BF CD ED 52 3A",
 "BF20 66 EA E6 03 F6 08 D3 30 21 7A BF 01 21 04 ED B3",
 "BF30 DB 20 06 06 CD 6F BF 10 FB 06 2A 7E CD 2F 5F 2C",
 "BF40 10 F9 21 00 A0 45 7E CD 2F 5F 80 47 2C 20 F7 ED",
 "BF50 44 CD 2F 5F 24 7C FE C0 20 EB CD 6F BF CD 6F BF",
 "BF60 3A 66 EA E6 F7 F6 04 32 66 EA D3 30 C3 81 00 11",
 "BF70 FF FF 7A B3 1B 20 FB C9 00 00 0E 40 CE 11 3A E8",
 "BF80 AC 6C 3A 21 21 00 A0 45 CD 9E 5F 77 80 47 2C 20",
 "BF90 F7 CD 9E 5F 80 C2 98 5F 24 7C FE C0 20 E9 C3 00",
 "BFA0 A0 00 00 AC E8 2D 3A 00 4D 61 63 68 69 6E 65 20",
 "BFB0 4C 61 6E 67 75 61 67 65 20 41 75 74 6F 73 61 76",
 "BFC0 65 72 0D 0A 43 6F 70 79 72 69 67 68 74 20 4D 43",
 "BFD0 4D 4C 58 58 58 49 56 20 28 43 29 20 62 79 20 4B",
 "BFE0 2E 59 61 73 75 6F 6B 61 0D 0A 0A 00 54 61 70 65",
 "BFF0 20 52 65 61 64 79 3F 0D 00 53 41 56 45 09 09 00"
].forEach(function(v){
  var t=v.split(/ +/);
  var a=parseInt(t[0],16);
  var i;
  for(i=1;i<t.length;i++)
    pc8001.memory[a+i-1]=parseInt(t[i],16);
});
pc8001.initDisplay80x25=function(svg){
  var d=pc8001.display=new Object();
  var t=d.textArray=new Array(80);
  var x,y,e;
  d.svg=svg;
  d.colors=new Array(256);
  d.colors.fill("none");
  for(x=0;x<8;x++){
    d.colors[0x18+x]="#000000";
    d.colors[0x38+x]="#0000ff";
    d.colors[0x58+x]="#ff0000";
    d.colors[0x78+x]="#ff00ff";
    d.colors[0x98+x]="#00ff00";
    d.colors[0xb8+x]="#00ffff";
    d.colors[0xd8+x]="#ffff00";
    d.colors[0xf8+x]="#ffffff";
  }
  d.colors[0x00]="#ffffff";
  for(x=0;x<80;x++)
    t[x]=new Array(25);
  d.start=d.end=0xf300;
  for(y=0;y<25;y++){
    for(x=0;x<80;x++){
      pc8001.memory[d.end]=0;
      d.end++;
      t[x][y]=new Object();
      e=document.createElementNS("http://www.w3.org/2000/svg","text");
      e.setAttribute("y",x*2);
      e.setAttribute("x",y*4);
      e.setAttribute("font-family","monospace");
      e.setAttribute("font-size",2);
      e.setAttribute("transform","matrix(0 1 1 0 1.8 0)");
      e.setAttribute("fill","#ffffff");
      e.setAttribute("stroke","none");
      d.svg.appendChild(e);
      t[x][y].element=e;
      t[x][y].attribute="#ffffff";
    }
    pc8001.memory[d.end]=0;
    d.end++;
    for(x=1;x<39;x++){
      pc8001.memory[d.end]=(x%2==0)?80:0xf8;
      d.end++;
    }
    pc8001.memory[d.end]=0;
    d.end++;
  }
  d.end--;
  e=[[0x3000,0x2598,0x259d,0x2580],
     [0x2596,0x258c,0x259e,0x259b],
     [0x2597,0x259a,0x2590,0x259c],
     [0x2584,0x2599,0x259f,0x2588]];
  d.blocks=new Array(256);
  d.blocks[0]="";
  for(x=1;x<256;x++){
    if((x&0xcc)>0)
      d.blocks[x]=String.fromCodePoint(e[(x>>4)&3][x&3],e[(x>>6)&3][(x>>2)&3]);
    else
      d.blocks[x]=String.fromCodePoint(e[(x>>4)&3][x&3]);
  }
  pc8001.writeMemory(d.start,0xff);
  y=t[0][0].element.getBBox();
  pc8001.writeMemory(d.start,0);
  if(y.width<4){
    e[0][0]=0x2003;
    for(x=1;x<256;x++){
      if((x&0xcc)>0)
        d.blocks[x]=String.fromCodePoint(e[(x>>4)&3][x&3],e[(x>>6)&3][(x>>2)&3]);
      else
        d.blocks[x]=String.fromCodePoint(e[(x>>4)&3][x&3]);
    }
    e=4/y.width;
    for(y=0;y<25;y++){
      for(x=0;x<80;x++){
        t[x][y].element.setAttribute("x",y*4/e);
        t[x][y].element.setAttribute("transform","matrix(0 "+e+" 1 0 1.8 0)");
      }
    }
  }
}
pc8001.writeMemory=function(address,data){
  var t=pc8001.memory[address];
  var d=pc8001.display;
  var x,y,i,j;
  if(data<0||data>0xff){
    console.log("writeMemory",address.toString(16),data);
    Object.keys(pc8001.z80.regs).forEach(function(v){
      console.log(" reg",v,pc8001.z80.regs[v].toString(16).toUpperCase().padStart(v.length*2,"0"));
  });
    console.log(" flags",pc8001.z80.flags);
  }
  pc8001.memory[address]=data;
  if(address<d.start||d.end<address||t==data)
    return;
  x=(address-d.start)%120;
  y=Math.floor((address-d.start)/120);
  if(x<80){
    d.textArray[x][y].element.textContent=d.blocks[data];
    return;
  }
  i=d.start+80+y*120;
  j="#ffffff";
  for(x=0;x<80;x++){
    if(pc8001.memory[i]==x){
      i++;
      j=d.colors[pc8001.memory[i]];
      i++;
    }
    t=d.textArray[x][y];
    if(t.attribute!=j){
      t.element.setAttribute("fill",j);
      t.attribute=j;
    }
  }
}
pc8001.inports=new Array(256);
pc8001.inports.fill(0xff);
pc8001.keymap=new Array(256);
pc8001.keymap.fill([-1,0xff]);
pc8001.keymap[13]=[1,0x7f];                    // enter-key
pc8001.keymap[97]=pc8001.keymap[188]=[0,0xfd]; // ten-key 1 = key <
pc8001.keymap[98]=pc8001.keymap[40]=[0,0xfb];  // ten-key 2 = downarrow
pc8001.keymap[99]=pc8001.keymap[190]=[0,0xf7]; // ten-key 3 = key >
pc8001.keymap[100]=pc8001.keymap[37]=[0,0xef]; // ten-key 4 = leftarrow
pc8001.keymap[102]=pc8001.keymap[39]=[0,0xbf]; // ten-key 6 = rightarrow
pc8001.keymap[104]=pc8001.keymap[38]=[1,0xfe]; // ten-key 8 = uparrow
pc8001.keymap[16]=[8,0xbf];                    // shift-key
pc8001.keymap[32]=[9,0xbf];                    // space-key
pc8001.keydown=function(event){
  var k=pc8001.keymap[event.keyCode]
  if(k[0]<0)
    return;
  pc8001.inports[k[0]]&=k[1];
}
pc8001.keyup=function(event){
  var k=pc8001.keymap[event.keyCode]
  if(k[0]<0)
    return;
  pc8001.inports[k[0]]|=(k[1]^0xff);
  if(pc8001.beep.counter<0){
    pc8001.beep.counter=pc8001.beep.on=0;
    pc8001.beep.start=pc8001.z80.states;
    pc8001.beep.oscillator.start();
  }
}
pc8001.beep=new Object();
pc8001.beep.audio=new(window.AudioContext||window.webkitAudioContext)();
pc8001.beep.buffer=pc8001.beep.audio.createBuffer(1,Math.floor(pc8001.beep.audio.sampleRate/60),pc8001.beep.audio.sampleRate);
pc8001.beep.oscillator=pc8001.beep.audio.createBufferSource();
pc8001.beep.oscillator.buffer=pc8001.beep.buffer;
pc8001.beep.wave=pc8001.beep.buffer.getChannelData(0);
pc8001.beep.wave.fill(0);
pc8001.beep.counter=-1;
pc8001.beep.oscillator.loop=true;
pc8001.beep.oscillator.connect(pc8001.beep.audio.destination);
pc8001.beep.refWave=new Array(pc8001.beep.wave.length);
pc8001.beep.refWave.fill(0);
pc8001.beep.refWave.forEach(function(v,i,a){
  a[i]=Math.sin(i*Math.PI*2/pc8001.beep.audio.sampleRate*2400);
});
pc8001.z80=new Object();
pc8001.z80.frequency=3000000;                  // down to 3MHz
pc8001.z80.millistates=pc8001.z80.frequency/1000;
pc8001.z80.regs={"PC":0,"SP":0,"A":0,"B":0,"C":0,"D":0,"E":0,"H":0,"L":0,"J":0,"X":0,"K":0,"Y":0,"a":0,"b":0,"c":0,"d":0,"e":0,"h":0,"l":0};
pc8001.z80.flags={"Z":0,"C":0,"V":0,"M":0,"DUMMY":0,"z":0,"c":0,"v":0,"m":0,"dummy":0};
pc8001.z80.mnemonics={};
pc8001.z80.halt=pc8001.z80.states=0;
pc8001.z80.ops=new Array(256);
pc8001.z80.ops.fill(["UNDEF","",0]);
pc8001.z80.ops[0xcb]=new Array(257);
pc8001.z80.ops[0xcb].fill(["UNDEF","CB",0]);
pc8001.z80.ops[0xcb][256]=-1;
pc8001.z80.ops[0xdd]=new Array(257);
pc8001.z80.ops[0xdd].fill(["UNDEF","DD",0]);
pc8001.z80.ops[0xdd][256]=-1;
pc8001.z80.ops[0xed]=new Array(257);
pc8001.z80.ops[0xed].fill(["UNDEF","ED",0]);
pc8001.z80.ops[0xed][256]=-1;
pc8001.z80.ops[0xfd]=new Array(257);
pc8001.z80.ops[0xfd].fill(["UNDEF","FD",0]);
pc8001.z80.ops[0xfd][256]=-1;
pc8001.z80.mnemonics["UNDEF"]=function(x,m){
  pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xffff)&0xffff;
  pc8001.z80.halt=1;
  console.log(performance.now()-pc8001.z80.millitimer,"milliseconds");
  console.log(pc8001.z80.states,"states");
  console.log(m[0],m[1],x.toString(16).toUpperCase().padStart(2,"0"));
  Object.keys(pc8001.z80.regs).forEach(function(v){
    console.log(" reg",v,pc8001.z80.regs[v].toString(16).toUpperCase().padStart(v.length*2,"0"));
  });
  console.log(" flags",pc8001.z80.flags);
}
pc8001.z80.ops[0x00]=["NOP",4];
pc8001.z80.mnemonics["NOP"]=function(x,m){
}
pc8001.operators=["ADD","ADC","SUB","SBC","AND","XOR","OR","CP"];
pc8001.params=["B","C","D","E","H","L","(HL)","A"];
pc8001.params.forEach(function(v,i,a){
  var j;
  for(j=0;j<8;j++)
    pc8001.z80.ops[i*8+j+0x40]=["LD",v,a[j],(i==6||j==6)?7:4];
  pc8001.z80.ops[i*8+4]=["INC",v,(i==6)?11:4];
  pc8001.z80.ops[i*8+5]=["DEC",v,(i==6)?11:4];
  pc8001.z80.ops[i*8+6]=["LD",v,"n",(i==6)?10:7];
  pc8001.operators.forEach(function(w,j){
    pc8001.z80.ops[i+j*8+0x80]=[w,"A",v,(i==6)?7:4];
  });
  if(i!=6){
    pc8001.z80.ops[0xdd][i*8+0x46]=["LD",v,"(JX+d)",19];
    pc8001.z80.ops[0xdd][i+0x70]=["LD","(JX+d)",v,19];
    pc8001.z80.ops[0xdd][i*8+0x44]=["LD",v,"J",8];
    pc8001.z80.ops[0xdd][i*8+0x45]=["LD",v,"X",8];
    pc8001.z80.ops[0xdd][i+0x60]=["LD","J",v,8];
    pc8001.z80.ops[0xdd][i+0x68]=["LD","X",v,8];
    pc8001.z80.ops[0xfd][i*8+0x46]=["LD",v,"(KY+d)",19];
    pc8001.z80.ops[0xfd][i+0x70]=["LD","(KY+d)",v,19];
    pc8001.z80.ops[0xfd][i*8+0x44]=["LD",v,"K",8];
    pc8001.z80.ops[0xfd][i*8+0x45]=["LD",v,"Y",8];
    pc8001.z80.ops[0xfd][i+0x60]=["LD","K",v,8];
    pc8001.z80.ops[0xfd][i+0x68]=["LD","Y",v,8];
    pc8001.z80.ops[0xed][i*8+0x40]=["IN",v,"(C)",12];
    pc8001.z80.ops[0xed][i*8+0x41]=["OUT","(C)",v,12];
  }
  pc8001.z80.ops[0xcb][i+0x00]=["RLC",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x08]=["RRC",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x10]=["RL",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x18]=["RR",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x20]=["SLA",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x28]=["SRA",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x30]=["SLL",v,(i==6)?15:8];
  pc8001.z80.ops[0xcb][i+0x38]=["SRL",v,(i==6)?15:8];
  for(j=0;j<8;j++){
    pc8001.z80.ops[0xcb][i+j*8+0x40]=["BIT",j,v,(i==6)?12:8];
    pc8001.z80.ops[0xcb][i+j*8+0x80]=["RES",j,v,(i==6)?15:8];
    pc8001.z80.ops[0xcb][i+j*8+0xc0]=["SET",j,v,(i==6)?15:8];
  }
});
pc8001.operators.forEach(function(v,i){
  pc8001.z80.ops[i*8+0xc6]=[v,"A","n",7];
  pc8001.z80.ops[0xdd][i*8+0x84]=[v,"A","J",8];
  pc8001.z80.ops[0xdd][i*8+0x85]=[v,"A","X",8];
  pc8001.z80.ops[0xdd][i*8+0x86]=[v,"A","(JX+d)",19];
  pc8001.z80.ops[0xfd][i*8+0x84]=[v,"A","K",8];
  pc8001.z80.ops[0xfd][i*8+0x85]=[v,"A","Y",8];
  pc8001.z80.ops[0xfd][i*8+0x86]=[v,"A","(KY+d)",19];
});
pc8001.z80.ops[0x76]=["HALT","",4];
pc8001.z80.mnemonics["HALT"]=pc8001.z80.mnemonics["UNDEF"];
pc8001.z80.ops[0x02]=["LD","(BC)","A",7];
pc8001.z80.ops[0x0a]=["LD","A","(BC)",7];
pc8001.z80.ops[0x12]=["LD","(DE)","A",7];
pc8001.z80.ops[0x1a]=["LD","A","(DE)",7];
pc8001.z80.ops[0x32]=["LD","(nn)","A",13];
pc8001.z80.ops[0x3a]=["LD","A","(nn)",13];
pc8001.z80.ops[0xdd][0x26]=["LD","J","n",11];
pc8001.z80.ops[0xdd][0x2e]=["LD","X","n",11];
pc8001.z80.ops[0xdd][0x36]=["LD","(JX+d)","n",19];
pc8001.z80.ops[0xdd][0x64]=["LD","J","J",8];
pc8001.z80.ops[0xdd][0x65]=["LD","J","X",8];
pc8001.z80.ops[0xdd][0x6c]=["LD","X","J",8];
pc8001.z80.ops[0xdd][0x6d]=["LD","X","X",8];
pc8001.z80.ops[0xfd][0x26]=["LD","K","n",11];
pc8001.z80.ops[0xfd][0x2e]=["LD","Y","n",11];
pc8001.z80.ops[0xfd][0x36]=["LD","(KY+d)","n",19];
pc8001.z80.ops[0xfd][0x64]=["LD","K","K",8];
pc8001.z80.ops[0xfd][0x65]=["LD","K","Y",8];
pc8001.z80.ops[0xfd][0x6c]=["LD","Y","K",8];
pc8001.z80.ops[0xfd][0x6d]=["LD","Y","Y",8];
pc8001.z80.mnemonics["LD"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a=-1;
  var b,c;
  switch(m[1].length){
    case 4:
      if(m[1]=="(nn)"){
        a=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
        pc8001.z80.regs["PC"]=pc=(pc+2)&0xffff;
      }
      else
        a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
  }
  switch(m[2].length){
    case 4:
      if(m[2]=="(nn)"){
        b=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
        pc8001.z80.regs["PC"]=pc=(pc+2)&0xffff;
      }
      else
        b=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      c=pc8001.memory[b];
      break;
    case 6:
      b=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(b>0x7f)
        b+=0xff00;
      b+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      c=pc8001.memory[b&0xffff];
      break;
    default:
      if(m[2]=="n"){
        c=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        c=pc8001.z80.regs[m[2]];
  }
  if(a<0)
    pc8001.z80.regs[m[1]]=c;
  else
    pc8001.writeMemory(a,c);
}
pc8001.z80.ops[0x01]=["LD16","BC","nn",10];
pc8001.z80.ops[0x11]=["LD16","DE","nn",10];
pc8001.z80.ops[0x21]=["LD16","HL","nn",10];
pc8001.z80.ops[0x22]=["LD16","(nn)","HL",16];
pc8001.z80.ops[0x2a]=["LD16","HL","(nn)",16];
pc8001.z80.ops[0x31]=["LD16","SP","nn",10];
pc8001.z80.ops[0xf9]=["LD16","SP","HL",6];
pc8001.z80.ops[0xed][0x43]=["LD16","(nn)","BC",20];
pc8001.z80.ops[0xed][0x4b]=["LD16","BC","(nn)",20];
pc8001.z80.ops[0xed][0x53]=["LD16","(nn)","DE",20];
pc8001.z80.ops[0xed][0x5b]=["LD16","DE","(nn)",20];
pc8001.z80.ops[0xed][0x63]=["LD16","(nn)","HL",20];
pc8001.z80.ops[0xed][0x6b]=["LD16","HL","(nn)",20];
pc8001.z80.ops[0xed][0x73]=["LD16","(nn)","SP",20];
pc8001.z80.ops[0xed][0x7b]=["LD16","SP","(nn)",20];
pc8001.z80.ops[0xdd][0x21]=["LD16","JX","nn",14];
pc8001.z80.ops[0xdd][0x22]=["LD16","(nn)","JX",20];
pc8001.z80.ops[0xdd][0x2a]=["LD16","JX","(nn)",20];
pc8001.z80.ops[0xdd][0xf9]=["LD16","SP","JX",10];
pc8001.z80.ops[0xfd][0x21]=["LD16","KY","nn",14];
pc8001.z80.ops[0xfd][0x22]=["LD16","(nn)","KY",20];
pc8001.z80.ops[0xfd][0x2a]=["LD16","KY","(nn)",20];
pc8001.z80.ops[0xfd][0xf9]=["LD16","SP","KY",10];
pc8001.z80.mnemonics["LD16"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var h,l,a;
  switch(m[2]){
    case "nn":
      l=pc8001.memory[pc];
      h=pc8001.memory[(pc+1)&0xffff];
      pc=pc8001.z80.regs["PC"]=(pc+2)&0xffff;
      break;
    case "(nn)":
      a=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
      pc=pc8001.z80.regs["PC"]=(pc+2)&0xffff;
      l=pc8001.memory[a];
      h=pc8001.memory[(a+1)&0xffff];
      break;
    case "SP":
      a=pc8001.z80.regs["SP"];
      h=a>>8;
      l=a&0xff;
      break;
    default:
      h=pc8001.z80.regs[m[2].substr(0,1)];
      l=pc8001.z80.regs[m[2].substr(1)];
  }
  switch(m[1]){
    case "(nn)":
      a=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
      pc=pc8001.z80.regs["PC"]=(pc+2)&0xffff;
      pc8001.writeMemory(a,l);
      pc8001.writeMemory((a+1)&0xffff,h);
      return;
    case "SP":
      pc8001.z80.regs["SP"]=h*256+l;
      return;
    default:
      pc8001.z80.regs[m[1].substr(0,1)]=h;
      pc8001.z80.regs[m[1].substr(1)]=l;
  }
}
pc8001.z80.ops[0x08]=["EX","AF","af",4];
pc8001.z80.ops[0xe3]=["EX","(SP)","HL",19];
pc8001.z80.ops[0xeb]=["EX","DE","HL",4];
pc8001.z80.mnemonics["EX"]=function(x,m){
  var a,t;
  if(m[1]=="(SP)"){
    a=pc8001.z80.regs["SP"]
    t=pc8001.memory[a];
    pc8001.writeMemory(a,pc8001.z80.regs[m[2].substr(1)]);
    pc8001.z80.regs[m[2].substr(1)]=t;
    a=(a+1)&0xffff;
    t=pc8001.memory[a];
    pc8001.writeMemory(a,pc8001.z80.regs[m[2].substr(0,1)]);
    pc8001.z80.regs[m[2].substr(0,1)]=t;
    return;
  }
  t=pc8001.z80.regs[m[1].substr(0,1)];
  pc8001.z80.regs[m[1].substr(0,1)]=pc8001.z80.regs[m[2].substr(0,1)];
  pc8001.z80.regs[m[2].substr(0,1)]=t;
  if(m[1].substr(1)=="F"){
    a=["Z","C","V","M","DUMMY"];
    a.forEach(function(v){
      var b=pc8001.z80.flags[v];
      pc8001.z80.flags[v]=pc8001.z80.flags[v.toLowerCase()];
      pc8001.z80.flags[v.toLowerCase()]=b;
    });
    return;
  }
  t=pc8001.z80.regs[m[1].substr(1)];
  pc8001.z80.regs[m[1].substr(1)]=pc8001.z80.regs[m[2].substr(1)];
  pc8001.z80.regs[m[2].substr(1)]=t;
}
pc8001.z80.ops[0xd9]=["EXX",4];
pc8001.z80.mnemonics["EXX"]=function(x,m){
  var r=["B","C","D","E","H","L"];
  r.forEach(function(v){
    var t=pc8001.z80.regs[v];
    pc8001.z80.regs[v]=pc8001.z80.regs[v.toLowerCase()];
    pc8001.z80.regs[v.toLowerCase()]=t;
  });
}
pc8001.z80.ops[0xdd][0x34]=["INC","(JX+d)",23];
pc8001.z80.ops[0xfd][0x34]=["INC","(KY+d)",23];
pc8001.z80.mnemonics["INC"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  t=(t+1)&0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["V"]=(t==0x80)?1:0;
}
pc8001.z80.ops[0x03]=["INC16","BC",6];
pc8001.z80.ops[0x13]=["INC16","DE",6];
pc8001.z80.ops[0x23]=["INC16","HL",6];
pc8001.z80.ops[0x33]=["INC16","SP",6];
pc8001.z80.ops[0xdd][0x23]=["INC16","JX",10];
pc8001.z80.ops[0xfd][0x23]=["INC16","KY",10];
pc8001.z80.mnemonics["INC16"]=function(x,m){
  var t;
  if(m[1]=="SP")
    pc8001.z80.regs["SP"]=(pc8001.z80.regs["SP"]+1)&0xffff;
  else{
    pc8001.z80.regs[m[1].substr(1)]=t=(pc8001.z80.regs[m[1].substr(1)]+1)&0xff;
    if(t==0)
      pc8001.z80.regs[m[1].substr(0,1)]=(pc8001.z80.regs[m[1].substr(0,1)]+1)&0xff;
  }
}
pc8001.z80.ops[0xdd][0x35]=["DEC","(JX+d)",23];
pc8001.z80.ops[0xfd][0x35]=["DEC","(KY+d)",23];
pc8001.z80.mnemonics["DEC"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  t=(t+0xff)&0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["V"]=(t==0x7f)?1:0;
}
pc8001.z80.ops[0x0b]=["DEC16","BC",6];
pc8001.z80.ops[0x1b]=["DEC16","DE",6];
pc8001.z80.ops[0x2b]=["DEC16","HL",6];
pc8001.z80.ops[0x3b]=["DEC16","SP",6];
pc8001.z80.ops[0xdd][0x2b]=["DEC16","JX",6];
pc8001.z80.ops[0xfd][0x2b]=["DEC16","KY",6];
pc8001.z80.mnemonics["DEC16"]=function(x,m){
  var t;
  if(m[1]=="SP")
    pc8001.z80.regs["SP"]=(pc8001.z80.regs["SP"]+0xffff)&0xffff;
  else{
    pc8001.z80.regs[m[1].substr(1)]=t=(pc8001.z80.regs[m[1].substr(1)]+0xff)&0xff;
    if(t==0xff)
      pc8001.z80.regs[m[1].substr(0,1)]=(pc8001.z80.regs[m[1].substr(0,1)]+0xff)&0xff;
  }
}
pc8001.z80.ops[0x09]=["ADD16","HL","BC",11];
pc8001.z80.ops[0x19]=["ADD16","HL","DE",11];
pc8001.z80.ops[0x29]=["ADD16","HL","HL",11];
pc8001.z80.ops[0x39]=["ADD16","HL","SP",11];
pc8001.z80.ops[0xdd][0x09]=["ADD16","JX","BC",15];
pc8001.z80.ops[0xdd][0x19]=["ADD16","JX","DE",15];
pc8001.z80.ops[0xdd][0x29]=["ADD16","JX","JX",15];
pc8001.z80.ops[0xdd][0x39]=["ADD16","JX","SP",15];
pc8001.z80.ops[0xfd][0x09]=["ADD16","KY","BC",15];
pc8001.z80.ops[0xfd][0x19]=["ADD16","KY","DE",15];
pc8001.z80.ops[0xfd][0x29]=["ADD16","KY","KY",15];
pc8001.z80.ops[0xfd][0x39]=["ADD16","KY","SP",15];
pc8001.z80.mnemonics["ADD16"]=function(x,m){
  var t;
  t=pc8001.z80.regs[m[1].substr(0,1)]*256+pc8001.z80.regs[m[1].substr(1)];
  if(m[2]=="SP")
    t+=pc8001.z80.regs["SP"];
  else
    t+=pc8001.z80.regs[m[2].substr(0,1)]*256+pc8001.z80.regs[m[2].substr(1)];
  if(t>0xffff){
    pc8001.z80.flags["C"]=1;
    t&=0xffff;
  }
  else
    pc8001.z80.flags["C"]=0;
  pc8001.z80.regs[m[1].substr(0,1)]=t>>8;
  pc8001.z80.regs[m[1].substr(1)]=t&0xff;
}
pc8001.z80.mnemonics["ADD"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t,u,v;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  u=pc8001.z80.regs[m[1]];
  v=t+u;
  pc8001.z80.flags["C"]=(v>0xff)?1:0;
  v&=0xff;
  pc8001.z80.regs[m[1]]=v;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=((t>0x7f&&u>0x7f&&v<0x80)||(t<0x80&&u<0x80&&v>0x7f))?1:0;
}
pc8001.z80.ops[0xed][0x4a]=["ADC16","HL","BC",15]
pc8001.z80.ops[0xed][0x5a]=["ADC16","HL","DE",15]
pc8001.z80.ops[0xed][0x6a]=["ADC16","HL","HL",15]
pc8001.z80.ops[0xed][0x7a]=["ADC16","HL","SP",15]
pc8001.z80.mnemonics["ADC16"]=function(x,m){
  var t,u,v;
  t=pc8001.z80.regs[m[1].substr(0,1)]*256+pc8001.z80.regs[m[1].substr(1)];
  if(m[2]=="SP")
    u=pc8001.z80.regs["SP"];
  else
    u=pc8001.z80.regs[m[2].substr(0,1)]*256+pc8001.z80.regs[m[2].substr(1)];
  v=t+u+pc8001.z80.flags["C"]
  if(v>0xffff){
    pc8001.z80.flags["C"]=1;
    v&=0xffff;
  }
  else
    pc8001.z80.flags["C"]=0;
  pc8001.z80.regs[m[1].substr(0,1)]=v>>8;
  pc8001.z80.regs[m[1].substr(1)]=v&0xff;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7fff)?1:0;
  pc8001.z80.flags["V"]=((u<0x8000&&t<0x8000&&v>0x7fff)||(u>0x7fff&&t>0x7fff&&v<0x8000))?1:0;
}
pc8001.z80.mnemonics["ADC"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t,u,v;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  u=pc8001.z80.regs[m[1]];
  v=t+u+pc8001.z80.flags["C"];
  pc8001.z80.flags["C"]=(v>0xff)?1:0;
  v&=0xff;
  pc8001.z80.regs[m[1]]=v;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=((t>0x7f&&u>0x7f&&v<0x80)||(t<0x80&&u<0x80&&v>0x7f))?1:0;
}
pc8001.z80.ops[0xed][0x44]=["NEG","A",8];
pc8001.z80.mnemonics["NEG"]=function(x,m){
  var t=(256-pc8001.z80.regs[m[1]])&0xff;
  pc8001.z80.regs[m[1]]=t;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["C"]=(t==0)?0:1;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["V"]=(t==0x80)?1:0;
}
pc8001.z80.mnemonics["SUB"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t,u,v;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  u=pc8001.z80.regs[m[1]];
  v=u-t;
  pc8001.z80.flags["C"]=(v<0)?1:0;
  v=(v+256)&0xff;
  pc8001.z80.regs[m[1]]=v;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=((u<0x80&&t>0x7f&&v>0x7f)||(u>0x7f&&t<0x80&&v<0x80))?1:0;
}
pc8001.z80.ops[0xed][0x42]=["SBC16","HL","BC",15]
pc8001.z80.ops[0xed][0x52]=["SBC16","HL","DE",15]
pc8001.z80.ops[0xed][0x62]=["SBC16","HL","HL",15]
pc8001.z80.ops[0xed][0x72]=["SBC16","HL","SP",15]
pc8001.z80.mnemonics["SBC16"]=function(x,m){
  var t,u,v;
  t=pc8001.z80.regs[m[1].substr(0,1)]*256+pc8001.z80.regs[m[1].substr(1)];
  if(m[2]=="SP")
    u=pc8001.z80.regs["SP"];
  else
    u=pc8001.z80.regs[m[2].substr(0,1)]*256+pc8001.z80.regs[m[2].substr(1)];
  v=t-u-pc8001.z80.flags["C"]
  if(v<0){
    pc8001.z80.flags["C"]=1;
    v=(v+65536)&0xffff;
  }
  else
    pc8001.z80.flags["C"]=0;
  pc8001.z80.regs[m[1].substr(0,1)]=v>>8;
  pc8001.z80.regs[m[1].substr(1)]=v&0xff;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7fff)?1:0;
  pc8001.z80.flags["V"]=((u<0x8000&&t>0x7fff&&v>0x7fff)||(u>0x7fff&&t<0x8000&&v<0x8000))?1:0;
}
pc8001.z80.mnemonics["SBC"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t,u,v;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  u=pc8001.z80.regs[m[1]];
  v=u-t-pc8001.z80.flags["C"];
  pc8001.z80.flags["C"]=(v<0)?1:0;
  v=(v+256)&0xff;
  pc8001.z80.regs[m[1]]=v;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=((u<0x80&&t>0x7f&&v>0x7f)||(u>0x7f&&t<0x80&&v<0x80))?1:0;
}
pc8001.z80.mnemonics["AND"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  t&=pc8001.z80.regs[m[1]];
  pc8001.z80.regs[m[1]]=t;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["C"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.ops[0x2f]=["CPL","A",4];
pc8001.z80.mnemonics["CPL"]=function(x,m){
  pc8001.z80.regs[m[1]]^=0xff;
}
pc8001.z80.mnemonics["XOR"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  t^=pc8001.z80.regs[m[1]];
  pc8001.z80.regs[m[1]]=t;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["C"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["OR"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  t|=pc8001.z80.regs[m[1]];
  pc8001.z80.regs[m[1]]=t;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["C"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["CP"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var a,t,u,v;
  switch(m[2].length){
    case 4:
      t=pc8001.memory[pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)]];
      break;
    case 6:
      a=pc8001.memory[pc];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      if(m[2]=="n"){
        t=pc8001.memory[pc];
        pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      }
      else
        t=pc8001.z80.regs[m[2]];
  }
  u=pc8001.z80.regs[m[1]];
  v=u-t;
  pc8001.z80.flags["C"]=(v<0)?1:0;
  v=(v+256)&0xff;
  pc8001.z80.flags["Z"]=(v==0)?1:0;
  pc8001.z80.flags["M"]=(v>0x7f)?1:0;
  pc8001.z80.flags["V"]=((u<0x80&&t>0x7f&&v>0x7f)||(u>0x7f&&t<0x80&&v<0x80))?1:0;
}
pc8001.z80.ops[0x37]=["SCF",4];
pc8001.z80.mnemonics["SCF"]=function(x,m){
  pc8001.z80.flags["C"]=1;
}
pc8001.z80.ops[0x3f]=["CCF",4];
pc8001.z80.mnemonics["CCF"]=function(x,m){
  pc8001.z80.flags["C"]^=1;
}
pc8001.z80.ops[0xc2]=["JP","NZ","nn",10];
pc8001.z80.ops[0xc3]=["JP","","nn",10];
pc8001.z80.ops[0xca]=["JP","Z","nn",10];
pc8001.z80.ops[0xd2]=["JP","NC","nn",10];
pc8001.z80.ops[0xda]=["JP","C","nn",10];
pc8001.z80.ops[0xe2]=["JP","NV","nn",10];
pc8001.z80.ops[0xea]=["JP","V","nn",10];
pc8001.z80.ops[0xf2]=["JP","NM","nn",10];
pc8001.z80.ops[0xfa]=["JP","M","nn",10];
pc8001.z80.ops[0xe9]=["JP","","(HL)",4];
pc8001.z80.ops[0xdd][0xe9]=["JP","","(JX)",8];
pc8001.z80.ops[0xfd][0xe9]=["JP","","(KY)",8];
pc8001.z80.mnemonics["JP"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var c=1;
  switch(m[1].length){
    case 1:
      c=pc8001.z80.flags[m[1]];
      break;
    case 2:
      c=1-pc8001.z80.flags[m[1].substr(1)];
  }
  if(c==0){
    if(m[2]=="nn")
      pc8001.z80.regs["PC"]=(pc+2)&0xffff;
    return;
  }
  switch(m[2].length){
    case 2:
      pc8001.z80.regs["PC"]=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
      return;
    case 4:
      pc8001.z80.regs["PC"]=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      return;
  }
}
pc8001.z80.ops[0x10]=["JR","DJNZ","e",13];
pc8001.z80.ops[0x18]=["JR","","e",12];
pc8001.z80.ops[0x20]=["JR","NZ","e",12];
pc8001.z80.ops[0x28]=["JR","Z","e",12];
pc8001.z80.ops[0x30]=["JR","NC","e",12];
pc8001.z80.ops[0x38]=["JR","C","e",12];
pc8001.z80.mnemonics["JR"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var c=1;
  switch(m[1].length){
    case 1:
      c=pc8001.z80.flags[m[1]];
      break;
    case 2:
      c=1-pc8001.z80.flags[m[1].substr(1)];
      break;
    case 4:
      pc8001.z80.regs["B"]=c=(pc8001.z80.regs["B"]+0xff)&0xff;
  }
  if(c==0){
    if(m[2]=="e")
      pc8001.z80.regs["PC"]=(pc+1)&0xffff;
    return;
  }
  c=pc8001.memory[pc];
  pc8001.z80.regs["PC"]=((c>0x7f)?pc+0xff01+c:pc+1+c)&0xffff;
}
pc8001.z80.ops[0xc4]=["CALL","NZ","nn",17];
pc8001.z80.ops[0xc7]=["CALL","","0000",11];
pc8001.z80.ops[0xcc]=["CALL","Z","nn",17];
pc8001.z80.ops[0xcd]=["CALL","","nn",17];
pc8001.z80.ops[0xcf]=["CALL","","0008",11];
pc8001.z80.ops[0xd4]=["CALL","NC","nn",17];
pc8001.z80.ops[0xd7]=["CALL","","0010",11];
pc8001.z80.ops[0xdc]=["CALL","C","nn",17];
pc8001.z80.ops[0xdf]=["CALL","","0018",11];
pc8001.z80.ops[0xe4]=["CALL","NV","nn",17];
pc8001.z80.ops[0xe7]=["CALL","","0020",11];
pc8001.z80.ops[0xec]=["CALL","V","nn",17];
pc8001.z80.ops[0xef]=["CALL","","0028",11];
pc8001.z80.ops[0xf4]=["CALL","NM","nn",17];
pc8001.z80.ops[0xf7]=["CALL","","0030",11];
pc8001.z80.ops[0xfc]=["CALL","M","nn",17];
pc8001.z80.ops[0xff]=["CALL","","0038",11];
pc8001.z80.mnemonics["CALL"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var sp=pc8001.z80.regs["SP"];
  var c=1;
  switch(m[1].length){
    case 1:
      c=pc8001.z80.flags[m[1]];
      break;
    case 2:
      c=1-pc8001.z80.flags[m[1].substr(1)];
  }
  if(c==0){
    if(m[2]=="nn")
      pc8001.z80.regs["PC"]=(pc+2)&0xffff;
    return;
  }
  if(m[2]=="nn"){
    a=pc8001.memory[pc]+pc8001.memory[(pc+1)&0xffff]*256;
    pc=(pc+2)&0xffff;
  }
  else
    a=parseInt(m[2],16);
  pc8001.writeMemory((sp+0xffff)&0xffff,pc>>8);
  pc8001.z80.regs["SP"]=sp=(sp+0xfffe)&0xffff;
  pc8001.writeMemory(sp,pc&0xff);
  pc8001.z80.regs["PC"]=a;
}
pc8001.z80.ops[0xc0]=["RET","NZ",11];
pc8001.z80.ops[0xc8]=["RET","Z",11];
pc8001.z80.ops[0xc9]=["RET","",10];
pc8001.z80.ops[0xd0]=["RET","NC",11];
pc8001.z80.ops[0xd8]=["RET","C",11];
pc8001.z80.ops[0xe0]=["RET","NV",11];
pc8001.z80.ops[0xe8]=["RET","V",11];
pc8001.z80.ops[0xf0]=["RET","NM",11];
pc8001.z80.ops[0xf8]=["RET","M",11];
pc8001.z80.mnemonics["RET"]=function(x,m){
  var sp=pc8001.z80.regs["SP"];
  var c=1;
  switch(m[1].length){
    case 1:
      c=pc8001.z80.flags[m[1]];
      break;
    case 2:
      c=1-pc8001.z80.flags[m[1].substr(1)];
  }
  if(c==0)
    return;
  pc8001.z80.regs["PC"]=pc8001.memory[sp]+pc8001.memory[(sp+1)&0xffff]*256;
  pc8001.z80.regs["SP"]=(sp+2)&0xffff;
}
pc8001.z80.ops[0xc5]=["PUSH","BC",11];
pc8001.z80.ops[0xd5]=["PUSH","DE",11];
pc8001.z80.ops[0xe5]=["PUSH","HL",11];
pc8001.z80.ops[0xf5]=["PUSH","AF",11];
pc8001.z80.ops[0xdd][0xe5]=["PUSH","JX",15];
pc8001.z80.ops[0xfd][0xe5]=["PUSH","KY",15];
pc8001.z80.mnemonics["PUSH"]=function(x,m){
  var sp=pc8001.z80.regs["SP"];
  pc8001.writeMemory((sp+0xffff)&0xffff,pc8001.z80.regs[m[1].substr(0,1)]);
  pc8001.z80.regs["SP"]=sp=(sp+0xfffe)&0xffff;
  if(m[1]=="AF")
    pc8001.writeMemory(sp,(pc8001.z80.flags["DUMMY"]&0x3a)|pc8001.z80.flags["C"]|(pc8001.z80.flags["V"]<<2)|(pc8001.z80.flags["Z"]<<6)|(pc8001.z80.flags["M"]<<7));
  else
    pc8001.writeMemory(sp,pc8001.z80.regs[m[1].substr(1)]);
}
pc8001.z80.ops[0xc1]=["POP","BC",10];
pc8001.z80.ops[0xd1]=["POP","DE",10];
pc8001.z80.ops[0xe1]=["POP","HL",10];
pc8001.z80.ops[0xf1]=["POP","AF",10];
pc8001.z80.ops[0xdd][0xe1]=["POP","JX",14];
pc8001.z80.ops[0xfd][0xe1]=["POP","KY",14];
pc8001.z80.mnemonics["POP"]=function(x,m){
  var sp=pc8001.z80.regs["SP"];
  var t=pc8001.memory[sp];
  if(m[1]=="AF"){
    pc8001.z80.flags["C"]=((t&1)==0)?0:1;
    pc8001.z80.flags["V"]=((t&4)==0)?0:1;
    pc8001.z80.flags["Z"]=((t&0x40)==0)?0:1;
    pc8001.z80.flags["M"]=((t&0x80)==0)?0:1;
    pc8001.z80.flags["DUMMY"]=t;
  }
  else
    pc8001.z80.regs[m[1].substr(1)]=t;
  pc8001.z80.regs[m[1].substr(0,1)]=pc8001.memory[(sp+1)&0xffff];
  pc8001.z80.regs["SP"]=(sp+2)&0xffff;
}
pc8001.z80.ops[0x07]=["RLCA",4];
pc8001.z80.mnemonics["RLCA"]=function(x,m){
  var t=pc8001.z80.regs["A"];
  var c=(t>0x7f)?1:0;
  pc8001.z80.regs["A"]=((t<<1)+c)&0xff;
  pc8001.z80.flags["C"]=c;
}
pc8001.z80.mnemonics["RLC"]=function(x,m){
  var a,t,c;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  c=(t>0x7f)?1:0;
  t=((t<<1)+c)&0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["C"]=c;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.ops[0x0f]=["RRCA",4];
pc8001.z80.mnemonics["RRCA"]=function(x,m){
  var t=pc8001.z80.regs["A"];
  var c=t&1;
  pc8001.z80.regs["A"]=(t>>1)+c*0x80;
  pc8001.z80.flags["C"]=c;
}
pc8001.z80.mnemonics["RRC"]=function(x,m){
  var a,t,c;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  c=t&1;
  t=(t>>1)+c*0x80;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["C"]=c;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.ops[0x17]=["RLA",4];
pc8001.z80.mnemonics["RLA"]=function(x,m){
  var t=pc8001.z80.regs["A"];
  var c=(t>0x7f)?1:0;
  pc8001.z80.regs["A"]=((t<<1)+pc8001.z80.flags["C"])&0xff;
  pc8001.z80.flags["C"]=c;
}
pc8001.z80.mnemonics["RL"]=function(x,m){
  var a,t,c;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  c=(t>0x7f)?1:0;
  t=((t<<1)+pc8001.z80.flags["C"])&0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["C"]=c;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.ops[0x1f]=["RRA",4];
pc8001.z80.mnemonics["RRA"]=function(x,m){
  var t=pc8001.z80.regs["A"];
  pc8001.z80.regs["A"]=(t>>1)+pc8001.z80.flags["C"]*0x80;
  pc8001.z80.flags["C"]=t&1;
}
pc8001.z80.mnemonics["RR"]=function(x,m){
  var a,t,c;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  c=t&1;
  t=(t>>1)+pc8001.z80.flags["C"]*0x80;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["C"]=c;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["SLA"]=function(x,m){
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  t=t<<1;
  pc8001.z80.flags["C"]=(t>0xff)?1:0;
  t&=0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["SRA"]=function(x,m){
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  pc8001.z80.flags["C"]=t&1;
  t=((t>>1)|(t&0x80));
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["SLL"]=function(x,m){
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  t=(t<<1)|1;
  pc8001.z80.flags["C"]=(t>0xff)?1:0;
  t&=0xff;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["SRL"]=function(x,m){
  var a,t;
  switch(m[1].length){
    case 4:
      a=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[1].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[1].substr(1,1)]*256+pc8001.z80.regs[m[1].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[1]];
  }
  pc8001.z80.flags["C"]=t&1;
  t=t>>1;
  if(a<0)
    pc8001.z80.regs[m[1]]=t;
  else
    pc8001.writeMemory(a,t);
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=0;
  t=(((t>>6)|4)^(t>>3)^t)&3;
  pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
}
pc8001.z80.mnemonics["BIT"]=function(x,m){
  var a,t;
  switch(m[2].length){
    case 4:
      a=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[2].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[2]];
  }
  pc8001.z80.flags["Z"]=((t&(1<<m[1]))==0)?1:0;
}
pc8001.z80.mnemonics["RES"]=function(x,m){
  var a,t
  switch(m[2].length){
    case 4:
      a=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[2].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[2]]
  }
  t&=(1<<m[1])^0xff;
  if(a<0)
    pc8001.z80.regs[m[2]]=t;
  else
    pc8001.writeMemory(a,t);
}
pc8001.z80.mnemonics["SET"]=function(x,m){
  var a,t;
  switch(m[2].length){
    case 4:
      a=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      t=pc8001.memory[a];
      break;
    case 7:
      a=parseInt(m[2].substr(4,2),16);
      if(a>0x7f)
        a+=0xff00;
      a+=pc8001.z80.regs[m[2].substr(1,1)]*256+pc8001.z80.regs[m[2].substr(2,1)];
      a&=0xffff;
      t=pc8001.memory[a];
      break;
    default:
      a=-1;
      t=pc8001.z80.regs[m[2]]
  }
  t|=1<<m[1];
  if(a<0)
    pc8001.z80.regs[m[2]]=t;
  else
    pc8001.writeMemory(a,t);
}
pc8001.z80.ops[0xed][0xa0]=["LDI",16];
pc8001.z80.mnemonics["LDI"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var de=pc8001.z80.regs["D"]*256+pc8001.z80.regs["E"];
  var bc=pc8001.z80.regs["B"]*256+pc8001.z80.regs["C"];
  pc8001.writeMemory(de,pc8001.memory[hl]);
  hl=(hl+1)&0xffff;
  de=(de+1)&0xffff;
  bc=(bc+0xffff)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["D"]=de>>8;
  pc8001.z80.regs["E"]=de&0xff;
  pc8001.z80.regs["B"]=bc>>8;
  pc8001.z80.regs["C"]=bc&0xff;
  pc8001.z80.flags["V"]=(bc==0)?0:1;
}
pc8001.z80.ops[0xed][0xb0]=["LDIR",21];
pc8001.z80.mnemonics["LDIR"]=function(x,m){
  pc8001.z80.mnemonics["LDI"](x,m);
  if(pc8001.z80.flags["V"]==1)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xed][0xa8]=["LDD",16];
pc8001.z80.mnemonics["LDD"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var de=pc8001.z80.regs["D"]*256+pc8001.z80.regs["E"];
  var bc=pc8001.z80.regs["B"]*256+pc8001.z80.regs["C"];
  pc8001.writeMemory(de,pc8001.memory[hl]);
  hl=(hl+0xffff)&0xffff;
  de=(de+0xffff)&0xffff;
  bc=(bc+0xffff)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["D"]=de>>8;
  pc8001.z80.regs["E"]=de&0xff;
  pc8001.z80.regs["B"]=bc>>8;
  pc8001.z80.regs["C"]=bc&0xff;
  pc8001.z80.flags["V"]=(bc==0)?0:1;
}
pc8001.z80.ops[0xed][0xb8]=["LDDR",21];
pc8001.z80.mnemonics["LDDR"]=function(x,m){
  pc8001.z80.mnemonics["LDD"](x,m);
  if(pc8001.z80.flags["V"]==1)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xed][0xa1]=["CPI",16];
pc8001.z80.mnemonics["CPI"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var bc=pc8001.z80.regs["B"]*256+pc8001.z80.regs["C"];
  var t=(pc8001.z80.regs["A"]-pc8001.memory[hl]+256)&0xff;
  hl=(hl+1)&0xffff;
  bc=(bc+0xffff)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=bc>>8;
  pc8001.z80.regs["C"]=bc&0xff;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["V"]=(bc==0)?0:1;
}
pc8001.z80.ops[0xed][0xb1]=["CPIR",21];
pc8001.z80.mnemonics["CPIR"]=function(x,m){
  pc8001.z80.mnemonics["CPI"](x,m);
  if(pc8001.z80.flags["V"]==1&&pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xed][0xa9]=["CPD",16];
pc8001.z80.mnemonics["CPD"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var bc=pc8001.z80.regs["B"]*256+pc8001.z80.regs["C"];
  var t=(pc8001.z80.regs["A"]-pc8001.memory[hl]+256)&0xff;
  hl=(hl+0xffff)&0xffff;
  bc=(bc+0xffff)&0xffff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=bc>>8;
  pc8001.z80.regs["C"]=bc&0xff;
  pc8001.z80.flags["Z"]=(t==0)?1:0;
  pc8001.z80.flags["M"]=(t>0x7f)?1:0;
  pc8001.z80.flags["V"]=(bc==0)?0:1;
}
pc8001.z80.ops[0xed][0xb9]=["CPDR",21];
pc8001.z80.mnemonics["CPDR"]=function(x,m){
  pc8001.z80.mnemonics["CPD"](x,m);
  if(pc8001.z80.flags["V"]==1&&pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xdb]=["IN","A","(n)",11];
pc8001.z80.mnemonics["IN"]=function(x,m){
  var c,t,pc;
  if(m[2]=="(n)"){
    pc=pc8001.z80.regs["PC"];
    c=pc8001.memory[pc];
    pc8001.z80.regs["PC"]=(pc+1)&0xffff;
  }
  else
    c=pc8001.z80.regs[m[2].substr(1,1)];
  pc8001.z80.regs[m[1]]=t=pc8001.inports[c];
  if(m[2]!="(n)"){
    pc8001.z80.flags["Z"]=(t==0)?1:0;
    pc8001.z80.flags["M"]=(t>0x7f)?1:0;
    t=(((t>>6)|4)^(t>>3)^t)&3;
    pc8001.z80.flags["V"]=((t>>2)^(t>>1)^t)&1;
  }
}
pc8001.z80.ops[0xed][0xa2]=["INI",16];
pc8001.z80.mnemonics["INI"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var b=pc8001.z80.regs["B"];
  pc8001.writeMemory(hl,pc8001.inports(pc8001.z80.regs["C"]));
  hl=(hl+1)&0xffff;
  b=(b+0xff)&0xff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=b;
  pc8001.z80.flags["Z"]=(b==0)?1:0;
}
pc8001.z80.ops[0xed][0xb2]=["INIR",21];
pc8001.z80.mnemonics["INIR"]=function(x,m){
  pc8001.z80.mnemonics["INI"](x,m);
  if(pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xed][0xaa]=["IND",16];
pc8001.z80.mnemonics["IND"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var b=pc8001.z80.regs["B"];
  pc8001.writeMemory(hl,pc8001.inports(pc8001.z80.regs["C"]));
  hl=(hl+0xffff)&0xffff;
  b=(b+0xff)&0xff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=b;
  pc8001.z80.flags["Z"]=(b==0)?1:0;
}
pc8001.z80.ops[0xed][0xb2]=["INDR",21];
pc8001.z80.mnemonics["INDR"]=function(x,m){
  pc8001.z80.mnemonics["IND"](x,m);
  if(pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xd3]=["OUT","(n)","A",11];
pc8001.z80.mnemonics["OUT"]=function(x,m){
  var c,pc;
  if(m[1]=="(n)"){
    pc=pc8001.z80.regs["PC"];
    c=pc8001.memory[pc];
    pc8001.z80.regs["PC"]=(pc+1)&0xffff;
  }
  else
    c=pc8001.z80.regs[m[1].substr(1,1)];
  pc8001.outports(c,pc8001.z80.regs[m[2]]);
}
pc8001.z80.ops[0xed][0xa3]=["OUTI",16];
pc8001.z80.mnemonics["OUTI"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var b=pc8001.z80.regs["B"];
  pc8001.outports(pc8001.z80.regs["C"],pc8001.memory[hl]);
  hl=(hl+1)&0xffff;
  b=(b+0xff)&0xff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=b;
  pc8001.z80.flags["Z"]=(b==0)?1:0;
}
pc8001.z80.ops[0xed][0xb3]=["OTIR",21];
pc8001.z80.mnemonics["OTIR"]=function(x,m){
  pc8001.z80.mnemonics["OUTI"](x,m);
  if(pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.z80.ops[0xed][0xab]=["OUTD",16];
pc8001.z80.mnemonics["OUTD"]=function(x,m){
  var hl=pc8001.z80.regs["H"]*256+pc8001.z80.regs["L"];
  var b=pc8001.z80.regs["B"];
  pc8001.outports(pc8001.z80.regs["C"],pc8001.memory[hl]);
  hl=(hl+0xffff)&0xffff;
  b=(b+0xff)&0xff;
  pc8001.z80.regs["H"]=hl>>8;
  pc8001.z80.regs["L"]=hl&0xff;
  pc8001.z80.regs["B"]=b;
  pc8001.z80.flags["Z"]=(b==0)?1:0;
}
pc8001.z80.ops[0xed][0xbb]=["OTDR",21];
pc8001.z80.mnemonics["OTDR"]=function(x,m){
  pc8001.z80.mnemonics["OUTD"](x,m);
  if(pc8001.z80.flags["Z"]==0)
    pc8001.z80.regs["PC"]=(pc8001.z80.regs["PC"]+0xfffe)&0xffff;
}
pc8001.outports=function(p,d){
  if(p!=0x40){
    pc8001.z80.mnemonics["UNDEF"](p,["UNDEF","OUT",0]);
    return;
  }
  pc8001.beep.on=((d&0x20)==0)?0:1;
}
pc8001.z80.ops[0xdd][0xcb]=["EXTCB","DD CB dd","JX",20];
pc8001.z80.ops[0xfd][0xcb]=["EXTCB","FD CB dd","KY",20];
pc8001.z80.mnemonics["EXTCB"]=function(x,m){
  var pc=pc8001.z80.regs["PC"];
  var d=pc8001.memory[pc];
  var e=pc8001.memory[(pc+1)&0xffff];
  var f=pc8001.z80.ops[0xcb][e].slice();
  pc8001.z80.regs["PC"]=(pc+2)&0xffff;
  if(f[f.length-2]=="(HL)"){
    f[f.length-2]="("+m[2]+"+"+d.toString(16).padStart(2,"0")+")";
    pc8001.z80.mnemonics[f[0]](e,f);
    return;
  }
  pc8001.z80.mnemonics["UNDEF"](e,["UNDEF",m[1],0]);
}
pc8001.z80.run=function(){
  var i,pc,v,m,s;
  for(i=0;i<4000;i++){
    pc=pc8001.z80.regs["PC"];
    v=pc8001.memory[pc];
    m=pc8001.z80.ops[v];
    pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
    s=m[m.length-1];
    if(s<0){
      v=pc8001.memory[pc];
      m=m[v];
      pc8001.z80.regs["PC"]=pc=(pc+1)&0xffff;
      s=m[m.length-1];
    }
    pc8001.z80.states+=s;
    pc8001.z80.mnemonics[m[0]](v,m);
    if(pc8001.z80.halt==1)
      return;
    if(pc8001.beep.counter!=-1){
      v=Math.floor(pc8001.z80.states*pc8001.beep.audio.sampleRate/pc8001.z80.frequency)%pc8001.beep.refWave.length;
      if(v==pc8001.beep.counter){
        pc8001.beep.wave[v]=pc8001.beep.on*pc8001.beep.refWave[v];
        pc8001.beep.counter=(pc8001.beep.counter+1)%pc8001.beep.refWave.length;
      }
    }
    s=pc8001.z80.states-(performance.now()-pc8001.z80.millitimer)*pc8001.z80.millistates;
    if(s>1000)
      break;
  }
  if(s<0){
    pc8001.z80.states%=pc8001.z80.frequency;
    pc8001.z80.millitimer=performance.now()-pc8001.z80.states/pc8001.z80.millistates;
  }
  pc8001.z80.timer=setTimeout("clearTimeout(pc8001.z80.timer);pc8001.z80.run()",(s>1000)?s/pc8001.z80.millistates:0);
}
pc8001.run=function(){
  document.addEventListener("keydown",pc8001.keydown);
  document.addEventListener("keyup",pc8001.keyup);
  pc8001.z80.millitimer=performance.now();
  pc8001.z80.run();
}
</script>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg"
 xmlns:xlink="http://www.w3.org/1999/xlink"
 width=984 height=624 viewBox="-2 -2 164 104"
 style="background-color:black"
 onload="pc8001.initDisplay80x25(this);pc8001.run()">
</svg>
</body>
</html>
```