1#!/usr/bin/perl
2
3# Z88DK Z80 Macro Assembler
4#
5# Copyright (C) Paulo Custodio, 2011-2020
6# License: The Artistic License 2.0, http://www.perlfoundation.org/artistic_license_2_0
7# Repository: https://github.com/z88dk/z88dk/
8#
9# Test additional opcodes from http://www.z80.info/z80oplist.txt
10
11use Modern::Perl;
12use Test::More;
13use Path::Tiny;
14require './t/testlib.pl';
15
16unlink_testfiles();
17test_asm(<<END, "");
18        out (c),f       ; ED 71
19        out (c),0       ; ED 71
20
21        sll b           ; CB 30
22        sll c           ; CB 31
23        sll d           ; CB 32
24        sll e           ; CB 33
25        sll h           ; CB 34
26        sll l           ; CB 35
27        sll (hl)        ; CB 36
28        sll a           ; CB 37
29
30        sls b           ; CB 30
31        sls c           ; CB 31
32        sls d           ; CB 32
33        sls e           ; CB 33
34        sls h           ; CB 34
35        sls l           ; CB 35
36        sls (hl)        ; CB 36
37        sls a           ; CB 37
38
39		res 0,(iy+1),b ; FD CB 01 80
40		res 0,(iy+1),c ; FD CB 01 81
41		res 0,(iy+1),d ; FD CB 01 82
42		res 0,(iy+1),e ; FD CB 01 83
43		res 0,(iy+1),h ; FD CB 01 84
44		res 0,(iy+1),l ; FD CB 01 85
45		res 0,(iy+1)   ; FD CB 01 86
46		res 0,(iy+1),a ; FD CB 01 87
47
48		set 0,(iy+1),b ; FD CB 01 C0
49		set 0,(iy+1),c ; FD CB 01 C1
50		set 0,(iy+1),d ; FD CB 01 C2
51		set 0,(iy+1),e ; FD CB 01 C3
52		set 0,(iy+1),h ; FD CB 01 C4
53		set 0,(iy+1),l ; FD CB 01 C5
54		set 0,(iy+1)   ; FD CB 01 C6
55		set 0,(iy+1),a ; FD CB 01 C7
56
57END
58
59#unlink_testfiles();
60done_testing();
61
62sub test_asm {
63	my($code, $options) = @_;
64	my @asm;
65	my @bin;
66	for (split(/\n/, $code)) {
67		chomp;
68		my($bytes) = /;(.*)/;
69		push @asm, "$_\n";
70		push @bin, map {$_ = hex($_)} split(' ', $bytes) if $bytes;
71	}
72	z80asm(join('', @asm), "$options -b -l", 0, "", "");
73	check_bin_file("test.bin", pack("C*", @bin));
74}
75