| 1 | package CPU::Emulator::DCPU16::Assembler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | CPU::Emulator::DCPU16::Assembler - assemble DCPU-16 bytecode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Assemble a program | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | my $bytes = CPU::Emulator::DCPU16::Assembler->assemble($asm); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # Then either run it ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | my $cpu = CPU::Emulator::DCPU16->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | $cpu->load($bytes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | $cpu-run; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # ... or disassemble it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | my $asm = CPU::Emulator::DCPU16::Disassembler->dump($bytes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | =head2 assemble <assembler> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | Return bytes representing an assembled program | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 9 | ▶ | sub assemble { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assemble: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 9 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 9 | my $asm = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 9 | my $bytes = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 9 | my %labels = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 9 | my %unres = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 9 | my $idx = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 9 | for my $line (split /\n/, $asm) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 46 | $class->_parse_line($line, $idx++, \$bytes, \%labels, \%unres); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 9 | $class->_resolve_references(\$bytes, \%labels, \%unres); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 9 | return $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | our %_EXTENDED_OPS = (JSR => 0x01); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | our %_OPS = (SET => 0x01, | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ADD => 0x02, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | SUB => 0x03, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | MUL => 0x04, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | DIV => 0x05, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | MOD => 0x06, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | SHL => 0x07, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | SHR => 0x08, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | AND => 0x09, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | BOR => 0x0a, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | XOR => 0x0b, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | IFE => 0x0c, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | IFN => 0x0d, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | IFG => 0x0e, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | IFB => 0x0f); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 46 | ▶ | sub _parse_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_line: called CC=19 SCAR=30.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 46 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 46 | my $line = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 46 | my $idx = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 46 | my $bytes = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 46 | my $labels = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 46 | my $unres = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 46 | my $off = length($$bytes)/2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 46 | my $oc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # trim and clean the line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 46 | $line =~ s!(^\s*|\s*$|;.*$)!!g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 46 | ▶ | return unless length($line); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 38 | my ($label, $op, $a, $b) = $line =~ m! | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | (?::(\w+) \s+)? # optional label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ([A-Za-z]+) \s+ # opcode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ([^,\s]+) (?:, \s+ # operand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ([^,\s]+))? \s* # optional second opcode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | !x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 38 | ▶ | die "Couldn't parse line $idx: $line\n" unless defined $op; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 38 | ▶ | $labels->{$label} = $off if defined $label; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 38 | $op = uc $op; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 38 | ▶ | if ($oc = $_EXTENDED_OPS{$op}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | ▶ | die "$op takes one operand at line $idx: $line\n" unless defined $a && !defined $b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $a and not defined $b
MC/DC0%0/2
defined $a and not defined $b
defined $a
not defined $b
Truth table33%1/3
A and not(B)
A= defined $aB= not defined $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | my ($val, $next_word, $label) = _parse_operand($a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | die "Can't parse operand '$a' at line $idx: $line\n" unless defined $val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | $oc <<= 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | $oc |= $val << 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | $unres->{$off} = [$label] if defined $label; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | $$bytes .= pack("S>", $oc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | ▶ | $$bytes .= pack("S>", $next_word) if defined $next_word; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } elsif ($oc = $_OPS{$op}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 36 | ▶ | die "$op takes two operands at line $idx: $line\n" unless defined $a && defined $b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $a and defined $b
MC/DC0%0/2
defined $a and defined $b
defined $a
defined $b
Truth table33%1/3
A and B
A= defined $aB= defined $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 36 | my ($val_a, $next_word_a, $label_a) = _parse_operand($a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 36 | ▶ | die "Can't parse operand '$a' at line $idx: $line\n" unless defined $val_a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 36 | my ($val_b, $next_word_b, $label_b) = _parse_operand($b); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 36 | ▶ | die "Can't parse operand '$b' at line $idx: $line\n" unless defined $val_b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 36 | $oc |= $val_a << 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 36 | $oc |= $val_b << 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 36 | ▶ | $unres->{$off} = [$label_a, $label_b] if defined $label_a || defined $label_b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $label_a or defined $label_b
MC/DC50%1/2
defined $label_a or defined $label_b
defined $label_a
defined $label_b
Truth table66%2/3
A or B
A= defined $label_aB= defined $label_b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 36 | $$bytes .= pack("S>", $oc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 36 | ▶ | $$bytes .= pack("S>", $next_word_a) if defined $next_word_a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 36 | ▶ | $$bytes .= pack("S>", $next_word_b) if defined $next_word_b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | die "Unknown opcode $op at line $idx: $line\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 25 | ▶ | sub _parse_num { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_num: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 25 | my $num = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 25 | ▶ | $num = oct($num) if $num =~ /^0x/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 25 | $num; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 74 | ▶ | sub _parse_operand { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_operand: called CC=16 SCAR=30.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 74 | my $op = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 74 | my $regs = "ABCXYZIJ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 74 | my $nums = qr/(?:0x[0-9A-F]+|[0-9]+)/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 74 | ▶ | if (0<=index $regs, $op) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 26 | return (index $regs, $op); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } elsif ($op =~ /^\[\s*([$regs])\s*\]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 3 | return (0x08 + index $regs, uc($1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } elsif ($op =~ /^\[\s*($nums)\s*\+\s*([$regs])\s*\]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | return (0x10 + index($regs, uc($2)), _parse_num($1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | ▶ | } elsif ($op eq 'POP' || $op =~ /^\[\s*SP\+\+\s*\]$/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$op eq "POP" or $op =~ /^\[\s*SP\+\+\s*\]$/
MC/DC50%1/2
$op eq "POP" or $op =~ /^\[\s*SP\+\+\s*\]$/
$op eq "POP"
$op =~ /^\[\s*SP\+\+\s*\]$/
Truth table66%2/3
A or B
A= $op eq "POP"B= $op =~ /^\[\s*SP\+\+\s*\]$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | return (0x18); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ▶ | } elsif ($op eq 'PEEK' || $op =~ /^\[\s*\-\-SP\s*\]$/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$op eq "PEEK" or $op =~ /^\[\s*\-\-SP\s*\]$/
MC/DC0%0/2
$op eq "PEEK" or $op =~ /^\[\s*\-\-SP\s*\]$/
$op eq "PEEK"
$op =~ /^\[\s*\-\-SP\s*\]$/
Truth table33%1/3
A or B
A= $op eq "PEEK"B= $op =~ /^\[\s*\-\-SP\s*\]$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return (0x19); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } elsif ($op eq 'PUSH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | return (0x1a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } elsif ($op eq 'SP') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | return (0x1b); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } elsif ($op eq 'PC') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 9 | return (0x1c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } elsif ($op eq 'O') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return (0x1d); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } elsif ($op =~ /^\[\s*($nums)\s*\]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | return (0x1e, _parse_num($1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } elsif ($op =~ /^($nums)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 20 | my $num = _parse_num($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 20 | ▶ | return ($num < 0x20) ? (0x20 + $num) : (0x1f, $num); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } elsif ($op =~ /\w+/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 10 | return (0x1f, 0x00, $op); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 9 | ▶ | sub _resolve_references { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_references: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 9 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 9 | my $bytes = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 9 | my $labels = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 9 | my $unres = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 9 | foreach my $pos (reverse sort { $a <=> $b } keys %$unres) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 10 | my @labels = grep { defined } @{ delete $unres->{$pos} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 10 | ▶ | next unless @labels; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 10 | my $offset = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 10 | for my $label (@labels) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 10 | my $resolved = $labels->{$label}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 10 | ▶ | die "Can't resolve label $label" unless defined $resolved; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 10 | substr($$bytes, $pos * 2 + $offset, 2, pack("S>", $resolved)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 10 | $offset += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||