1#!/usr/bin/perl
2
3#------------------------------------------------------------------------------
4# z80asm tests
5# Copyright (C) Paulo Custodio, 2020
6# License: http://www.perlfoundation.org/artistic_license_2_0
7#------------------------------------------------------------------------------
8use strict;
9use warnings;
10use testlib;
11
12note "Test issue #1221";
13my $test = test_name();
14
15path("$test.asm")->spew(<<END);
16	byte 	1
17	db 		2
18	defb 	3
19	defb	c1, c2
20
21	defm	"hello"
22	dm		"world"
23
24	defw	0x1234
25	word	0x1234
26	dw		0x1234
27
28	defdb	0x5678
29	ddb		0x5678
30
31	defp	0x123456
32	ptr		0x123456
33	dp		0x123456
34
35	defq	0x12345678
36	dword	0x12345678
37	dq		0x12345678
38
39	defs	2, 0x55
40	ds		2, 0xaa
41
42	defc	c1 = 4
43	dc		c2 = 5
44END
45
46run_ok("z88dk-z80asm -b $test.asm", '', '');
47my $bin = path("$test.bin")->slurp_raw();
48ok $bin eq  "\x01\x02\x03\x04\x05".
49			"helloworld".
50			"\x34\x12\x34\x12\x34\x12".
51			"\x56\x78\x56\x78".
52			"\x56\x34\x12\x56\x34\x12\x56\x34\x12".
53			"\x78\x56\x34\x12\x78\x56\x34\x12\x78\x56\x34\x12".
54			"\x55\x55\xaa\xaa", "bin ok";
55
56run_ok("z88dk-z80nm -a $test.o", <<'END', '');
57Object  file test1.o at $0000: Z80RMF14
58  Name: test1
59  Section "": 50 bytes
60    C $0000: 01 02 03 04 05 68 65 6C 6C 6F 77 6F 72 6C 64 34
61    C $0010: 12 34 12 34 12 56 78 56 78 56 34 12 56 34 12 56
62    C $0020: 34 12 78 56 34 12 78 56 34 12 78 56 34 12 55 55
63    C $0030: AA AA
64  Symbols:
65    L C $0004 c1 (section "") (file test1.asm:27)
66    L C $0005 c2 (section "") (file test1.asm:28)
67END
68end_test();
69