1#!/usr/bin/perl 2 3# Z88DK Z80 Module 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 DEFB, DEFM - more complete tests in build_opcodes.asm 10 11use Modern::Perl; 12use Test::More; 13require './t/testlib.pl'; 14 15for my $DEFB (qw(DEFB DEFM)) { 16 ok 1, "Test with $DEFB"; 17 18 z80asm("xx: $DEFB", "", 1, "", <<END); 19Error at file 'test.asm' line 1: syntax error 20END 21 22 unlink_testfiles(); 23 z80asm("xx: $DEFB xx"); 24 check_bin_file("test.bin", pack("C*", 0)); 25 26 z80asm("xx: $DEFB xx,", "", 1, "", <<END); 27Error at file 'test.asm' line 1: syntax error 28END 29 30 unlink_testfiles(); 31 z80asm("xx: $DEFB xx,xx+1"); 32 check_bin_file("test.bin", pack("C*", 0, 1)); 33 34 z80asm("xx: $DEFB \"", "", 1, "", <<END); 35Error at file 'test.asm' line 1: unclosed quoted string 36END 37 38 z80asm("xx: $DEFB \"hello", "", 1, "", <<END); 39Error at file 'test.asm' line 1: unclosed quoted string 40END 41 42 # escape chars 43 unlink_testfiles(); 44 z80asm('xx: '.$DEFB.' xx, "\0\1\2", 3, '. 45 '"\a\b\e\f\n\r\t\v", '. 46 '"\0\1\2\3\4\5\6\7\10\11\12\376\377", '. 47 '"\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xB\xc\xD\xe\xF\x10\xfe\xFF" '); 48 check_bin_file("test.bin", 49 pack("C*", 0, 0, 1, 2, 3). 50 "\a\b\e\f\n\r\t\x0B". 51 pack("C*", 0..10, 254, 255). 52 pack("C*", 0..16, 254, 255)); 53} 54 55unlink_testfiles(); 56done_testing(); 57