| 1 | <?php |
| 2 | namespace Std\Lib\Syntax; |
| 3 | |
| 4 | /** |
| 5 | * Z80・GBZ80・eZ80 |
| 6 | */ |
| 7 | class AsmZ80 extends Assembly { |
| 8 | // 「af'」の様な裏レジスターも1つの単語にする(「%」は2進数なので接頭辞にしない) |
| 9 | protected string $identifier = '[.A-Za-z_][\w.$]*\'?'; |
| 10 | |
| 11 | protected array $tokens = [ |
| 12 | 'register' => [ |
| 13 | // 16ビット |
| 14 | "af'", "bc'", "de'", "hl'", 'af', 'bc', 'de', 'hl', 'ix', 'iy', 'ixh', 'ixl', 'iyh', 'iyl', 'sp', 'pc', |
| 15 | // 8ビット |
| 16 | 'a', 'b', 'c', 'd', 'e', 'f', 'h', 'l', 'i', 'r', |
| 17 | "a'", "b'", "c'", "d'", "e'", "f'", "h'", "l'", |
| 18 | // eZ80 |
| 19 | 'mb', |
| 20 | ], |
| 21 | 'instruction' => [ |
| 22 | // Z80 + GBZ80 + eZ80 |
| 23 | 'adc', 'add', 'and', 'bit', 'call', 'ccf', 'cp', 'cpl', 'daa', 'dec', 'di', 'djnz', 'ei', |
| 24 | 'halt', 'im', 'inc', 'in', 'jp', 'jr', 'ld', 'ldd', 'ldh', 'ldi', |
| 25 | 'nop', 'otir', 'otdr', 'or', 'pop', 'push', 'retn', 'reti', 'ret', 'res', |
| 26 | 'rst', 'rrc', 'rrca', 'rr', 'rra', 'rlc', 'rlca', 'rl', 'rla', 'sub', 'srl', 'sra', 'sla', 'set', 'scf', 'sbc', 'xor', |
| 27 | // Z80 + GBZ80のみ |
| 28 | 'sll', 'sl1', |
| 29 | // eZ80のみ |
| 30 | 'ind2', 'ind2r', 'indm', 'indmr', 'indr2', 'indrx', 'ini2', 'ini2r', 'inim', 'inimr', 'inirx', 'lea', 'mlt', |
| 31 | 'otd2r', 'otdm', 'otdmr', 'otdrx', 'oti2r', 'otim', 'otimr', 'otirx', 'out0', 'in0', 'outd2', 'outi2', |
| 32 | 'pea', 'rsmix', 'slp', 'stmix', 'tst', 'tstio', |
| 33 | // Z80のみ |
| 34 | 'cpdr', 'cpir', 'cpd', 'cpi', 'exx', 'ex', 'outd', 'inir', 'ini', 'indr', 'ind', 'lddr', 'ldir', |
| 35 | 'neg', 'outi', 'out', 'rld', 'rrd', |
| 36 | // GBZ80のみ |
| 37 | 'stop', 'swap', |
| 38 | ], |
| 39 | 'keyword' => [ |
| 40 | // 条件 |
| 41 | 'nz', 'z', 'nc', 'po', 'pe', 'p', 'm', |
| 42 | ], |
| 43 | 'directive' => [ |
| 44 | 'org', 'equ', 'db', 'dw', 'ds', 'defb', 'defw', 'defs', 'defm', 'dm', 'include', 'incbin', 'end', 'macro', 'endm', |
| 45 | 'section', 'rb', 'rw', 'if', 'else', 'endc', 'endif', 'rept', 'endr', 'export', 'assert', 'align', 'charmap', |
| 46 | ], |
| 47 | ]; |
| 48 | } |