| 1 | #!/usr/bin/perl -Ilib | ||||||||||||||||||||||||||||||||||||||||||
| 2 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Assemble and execute the Zero programming language. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Philip R Brenan at appaapps dot com, Appa Apps Ltd Inc., 2023 | ||||||||||||||||||||||||||||||||||||||||||
| 5 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # Pointless adds and subtracts by 0. Perhaps we should flag adds and subtracts by 1 as well so we can have an instruction optimized for these variants. | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # Assign needs to know from whence we got the value so we can write a better error message when it is no good | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # Count number of ways an if statement actually goes. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use v5.30; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | package Zero::Emulator; | ||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our $VERSION = 20230511; # Version | |||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use warnings FATAL=> qw(all); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Carp qw(cluck confess); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Data::Dump qw(dump); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Data::Table::Text qw(:all); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | eval "use Test::More tests=>75" unless caller; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | makeDieConfess; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | my sub maximumInstructionsToExecute {1e6} # Maximum number of subroutines to execute | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
maximumInstructionsToExecute: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | sub execute(%) # Execute a block of code.. | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | {my (%options) = @_; # Execution options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | my $exec= genHash("Zero::Emulator::Execution", # Execution results | ||||||||||||||||||||||||||||||||||||||||||
| 27 | calls=> [], # Call stack | ||||||||||||||||||||||||||||||||||||||||||
| 28 | block=> $options{code}, # Block of code to be executed | ||||||||||||||||||||||||||||||||||||||||||
| 29 | count=> 0, # Executed instructions count | ||||||||||||||||||||||||||||||||||||||||||
| 30 | counts=> {}, # Executed instructions by name counts | ||||||||||||||||||||||||||||||||||||||||||
| 31 | tally=> 0, # Tally executed instructions in a bin of this name | ||||||||||||||||||||||||||||||||||||||||||
| 32 | tallyCount=> 0, # Executed instructions tally count | ||||||||||||||||||||||||||||||||||||||||||
| 33 | tallyCounts=> {}, # Executed instructions by name tally counts | ||||||||||||||||||||||||||||||||||||||||||
| 34 | instructionPointer=> 0, # Current instruction | ||||||||||||||||||||||||||||||||||||||||||
| 35 | memory=> {}, # Memory contents at the end of execution | ||||||||||||||||||||||||||||||||||||||||||
| 36 | memoryType=> {}, # Memory contents at the end of execution | ||||||||||||||||||||||||||||||||||||||||||
| 37 | rw=> {}, # Read / write access to memory | ||||||||||||||||||||||||||||||||||||||||||
| 38 | read=> {}, # Records whether a memory address was ever read allowing us to find all the unused locations | ||||||||||||||||||||||||||||||||||||||||||
| 39 | notReadAddresses=> {}, # Memory addresses never read | ||||||||||||||||||||||||||||||||||||||||||
| 40 | out=> [], # The out channel | ||||||||||||||||||||||||||||||||||||||||||
| 41 | doubleWrite=> {}, # Source of double writes {instruction number} to count - an existing value was overwritten before it was used | ||||||||||||||||||||||||||||||||||||||||||
| 42 | pointlessAssign=> {}, # Location already has the specified value | ||||||||||||||||||||||||||||||||||||||||||
| 43 | suppressOutput=> $options{suppressOutput}, # If true the Out instruction will only write to the execution out array but not to stdout as well. | ||||||||||||||||||||||||||||||||||||||||||
| 44 | stopOnError=> $options{stopOnError}, # Stop on non fatal errors if true | ||||||||||||||||||||||||||||||||||||||||||
| 45 | trace=> $options{trace}, # Trace all statements | ||||||||||||||||||||||||||||||||||||||||||
| 46 | tracePoints=> undef, # Trace changes in execution flow | ||||||||||||||||||||||||||||||||||||||||||
| 47 | printNotRead=> $options{NotRead}, # Memory locations never read | ||||||||||||||||||||||||||||||||||||||||||
| 48 | printDoubleWrite=> $options{doubleWrite}, # Double writes: earlier instruction number to later instruction number | ||||||||||||||||||||||||||||||||||||||||||
| 49 | printPointlessAssign=> $options{pointlessAssign}, # Pointless assigns {instruction number} to count - address already has the specified value | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | watch=> {}, # Addresses to watch for changes | |||||||||||||||||||||||||||||||||||||||||
| 51 | instructionCounts=> {}, # The number of times each actual instruction is executed | ||||||||||||||||||||||||||||||||||||||||||
| 52 | lastAssignArea=> undef, # Last assignment performed - area | ||||||||||||||||||||||||||||||||||||||||||
| 53 | lastAssignAddress=> undef, # Last assignment performed - address | ||||||||||||||||||||||||||||||||||||||||||
| 54 | lastAssignValue=> undef, # Last assignment performed - value | ||||||||||||||||||||||||||||||||||||||||||
| 55 | lastAssignBefore=> undef, # Prior value of memory area before assignment | ||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | my sub Code(%) # A block of code | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | {my (%options) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Code: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | genHash("Zero::Emulator::Code", # Description of a call stack entry | |||||||||||||||||||||||||||||||||||||||||
| 63 | assembled=> undef, # Needs to be assembled unless this field is true | ||||||||||||||||||||||||||||||||||||||||||
| 64 | code=> [], # An array of instructions | ||||||||||||||||||||||||||||||||||||||||||
| 65 | variables=> AreaStructure("Variables"), # Variables in this block of code | ||||||||||||||||||||||||||||||||||||||||||
| 66 | labels=> {}, # Label name to instruction | ||||||||||||||||||||||||||||||||||||||||||
| 67 | labelCounter=> 0, # Label counter used to generate unique labels | ||||||||||||||||||||||||||||||||||||||||||
| 68 | files=> [], # File number to file name | ||||||||||||||||||||||||||||||||||||||||||
| 69 | procedures=> {}, # Procedures defined in this block of code | ||||||||||||||||||||||||||||||||||||||||||
| 70 | %options, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | my sub stackFrame(%) # Describe an entry on the call stack: the return address, the parameter list length, the parameter list address, the line of code from which the call was made, the file number of the file from which the call was made | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | {my (%options) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stackFrame: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | genHash("Zero::Emulator::StackFrame", # Description of a stack frame. A stack frame provides the context in which a method runs. | ||||||||||||||||||||||||||||||||||||||||||
| 78 | target=> $options{target}, # The address of the subroutine being called | ||||||||||||||||||||||||||||||||||||||||||
| 79 | instruction=> $options{call}, # The address of the instruction making the call | ||||||||||||||||||||||||||||||||||||||||||
| 80 | stackArea=> $options{stackArea}, # Memory area containing data for this method | ||||||||||||||||||||||||||||||||||||||||||
| 81 | params=> $options{params}, # Memory area containing parameter list | ||||||||||||||||||||||||||||||||||||||||||
| 82 | return=> $options{return}, # Memory area containing returned result | ||||||||||||||||||||||||||||||||||||||||||
| 83 | line=> $options{line}, # The line number from which the call was made | ||||||||||||||||||||||||||||||||||||||||||
| 84 | file=> $options{file}, # The file number from which the call was made - this could be folded into the line number but for reasons best known to themselves people who cannot program very well often scatter projects across several files a practice that is completely pointless in this day of git and so can only lead to chaos and confusion | ||||||||||||||||||||||||||||||||||||||||||
| 85 | variables=> $options{variables}, # Variables local to this stack frame | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | sub Zero::Emulator::Code::instruction($%) #P Create a new instruction.. | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | {my ($block, %options) = @_; # Block of code descriptor, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instruction: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | my ($package, $fileName, $line) = caller($options{level} // 1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options{"level"} // 1
MC/DC0%0/1
$options{"level"} // 1
$options{"level"}
Truth table0%0/2
A
A= $options{"level"}
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | my sub stackTrace() # File numbers and line numbers of callers | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | {my @s; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stackTrace: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | for my $c(1..99) | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | {my @c = caller($c); | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | last unless @c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | push @s, [$c[1], $c[2]]; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | \@s | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ($options{action} !~ m(\Avariable\Z)i) # Non variable | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | {push $block->code->@*, my $i = genHash("Zero::Emulator::Code::Instruction", # Instruction details | ||||||||||||||||||||||||||||||||||||||||||
| 106 | action=> $options{action }, # Instruction name | ||||||||||||||||||||||||||||||||||||||||||
| 107 | number=> $options{number }, # Instruction sequence number | ||||||||||||||||||||||||||||||||||||||||||
| 108 | source=> $options{source }, # Source memory address | ||||||||||||||||||||||||||||||||||||||||||
| 109 | source2=> $options{source2 }, # Secondary source memory address | ||||||||||||||||||||||||||||||||||||||||||
| 110 | target=> $options{target }, # Target memory address | ||||||||||||||||||||||||||||||||||||||||||
| 111 | target2=> $options{target2 }, # Secondary target memory address | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | line=> $line, # Line in source file at which this instruction was encoded | |||||||||||||||||||||||||||||||||||||||||
| 113 | file=> fne $fileName, # Source file in which instruction was encoded | ||||||||||||||||||||||||||||||||||||||||||
| 114 | context=> stackTrace(), # The call context in which this instruction was created | ||||||||||||||||||||||||||||||||||||||||||
| 115 | executed=> 0, # The number of times this instruction was executed | ||||||||||||||||||||||||||||||||||||||||||
| 116 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | return $i; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | sub Zero::Emulator::Code::Instruction::contextString($$$) #P Stack trace back for this instruction.. | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | {my ($i, $exec, $title) = @_; # Instruction, execution environment, title | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contextString: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my @s; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | push @s, $title; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if (!defined($exec->suppressOutput)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | {for my $c($i->context->@*) | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | {push @s, sprintf " at %s line %d", $$c[0], $$c[1]; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | @s | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | sub AreaStructure($@) # Describe a data structure mapping a memory area.. | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | ▶ | {my ($structureName, @names) = @_; # Structure name, fields names | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AreaStructure: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | my $d = genHash("Zero::Emulator::AreaStructure", # Description of a data structure mapping a memory area | |||||||||||||||||||||||||||||||||||||||||
| 138 | structureName=> $structureName, # Name of the structure | ||||||||||||||||||||||||||||||||||||||||||
| 139 | fieldOrder=> [], # Order of the elements in the structure, in effect, giving the offset of each element in the data structure | ||||||||||||||||||||||||||||||||||||||||||
| 140 | fieldNames=> {}, # Maps the names of the fields to their offsets in the structure | ||||||||||||||||||||||||||||||||||||||||||
| 141 | instructions3=> [], # The variable instruction associated with this variable | ||||||||||||||||||||||||||||||||||||||||||
| 142 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | $d->field($_) for @names; # Add the field descriptions | |||||||||||||||||||||||||||||||||||||||||
| 144 | 3 | $d | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | my sub isScalar($) # Check whether an element is a scalar or an array | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | {my ($value) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isScalar: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ! ref $value; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | sub Zero::Emulator::AreaStructure::count($) #P Add a field to a data structure.. | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | {my ($d) = @_; # Area structure | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | scalar $d->fieldOrder->@* | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | sub Zero::Emulator::AreaStructure::name($$) #P Add a field to a data structure.. | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 15 | ▶ | {my ($d, $name) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=3 SCAR=11.6
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 15 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 15 | ▶ | if (!defined $d->fieldNames->{$name}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 15 | {$d->fieldNames->{$name} = $d->fieldOrder->@*; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 15 | push $d->fieldOrder->@*, $name; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | else | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | {confess "Duplicate name: $name in structure: ".$d->name; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 15 | \($d->fieldNames->{$name}) | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | my sub procedure($%) # Describe a procedure | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | {my ($label, %options) = @_; # Start label of procedure, options describing procedure | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
procedure: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | genHash("Zero::Emulator::Procedure", # Description of a procedure | |||||||||||||||||||||||||||||||||||||||||
| 174 | target=> $label, # Label to call to call this procedure | ||||||||||||||||||||||||||||||||||||||||||
| 175 | variables=> AreaStructure("Procedure"), # Registers local to this procedure | ||||||||||||||||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | sub Zero::Emulator::AreaStructure::registers($) #P Create one or more temporary variables. Need to reuse registers no longer in use.. | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | {my ($d, $count) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
registers: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if (!defined($count)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | {my $o = $d->fieldOrder->@*; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | push $d->fieldOrder->@*, undef; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | return \$o; # One temporary | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | map {__SUB__->($d)} 1..$count; # Array of temporaries | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | sub Zero::Emulator::AreaStructure::offset($$) #P Offset of a field in a data structure.. | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | {my ($d, $name) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if (defined(my $n = $d->fieldNames->{$name})){return $n} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | confess "No such name: '$name' in structure: ".$d->structureName; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | sub Zero::Emulator::AreaStructure::address($$) #P Address of a field in a data structure.. | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | {my ($d, $name) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
address: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if (defined(my $n = $d->fieldNames->{$name})){return \$n} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | confess "No such name: '$name' in structure: ".$d->structureName; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | sub Zero::Emulator::Procedure::registers($) #P Allocate a register within a procedure.. | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | {my ($procedure) = @_; # Procedure description | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
registers: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $procedure->variables->registers(); | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | my sub RefRight($) # Record a reference to a right address | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | {my ($r) = @_; # Reference | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
RefRight: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | @_ == 1 or confess "One parameter required formatted as either a address or an [area, address, name]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | ref($r) and ref($r) !~ m(\A(array|scalar|ref)\Z)i and confess "Scalar or reference required, not: ".dump($r); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $r and not ref($r) =~ /\A(array|scalar|ref)\Z/iu
MC/DC0%0/2
ref $r and not ref($r) =~ /\A(array|scalar|ref)\Z/iu
ref $r
not ref($r) =~ /\A(array|scalar|ref)\Z/iu
Truth table0%0/3
A and not(B)
A= ref $rB= not ref($r) =~ /\A(array|scalar|ref)\Z/iu
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if (ref($r) =~ m(array)i) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | {my ($area, $address, $name) = @$r; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | defined($area) and !defined($name) and confess "Name required for address specification: in [Area, address, name]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $area and not defined $name
MC/DC0%0/2
defined $area and not defined $name
defined $area
not defined $name
Truth table0%0/3
A and not(B)
A= defined $areaB= not defined $name
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | !defined($area) and defined($name) and confess "Area required for address specification: in [Area, address, name]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $area and defined $name
MC/DC0%0/2
not defined $area and defined $name
not defined $area
defined $name
Truth table0%0/3
not(A) and B
A= not defined $areaB= defined $name
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | isScalar($address) and defined($area) || defined($name) and confess "Constants cannot have an associated area"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
isScalar $address and defined $area || defined $name
defined $area or defined $name
MC/DC0%0/3
isScalar $address and defined $area || defined $name
isScalar $address
defined $area
defined $name
Truth table0%0/4
A and B or C
A= isScalar $addressB= defined $areaC= defined $name
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return genHash("Zero::Emulator::RefRight", | |||||||||||||||||||||||||||||||||||||||||
| 222 | area=> $area, | ||||||||||||||||||||||||||||||||||||||||||
| 223 | address=> $address, | ||||||||||||||||||||||||||||||||||||||||||
| 224 | name=> $name, | ||||||||||||||||||||||||||||||||||||||||||
| 225 | variable=> 1, | ||||||||||||||||||||||||||||||||||||||||||
| 226 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | else | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | {return genHash("Zero::Emulator::RefRight", | |||||||||||||||||||||||||||||||||||||||||
| 230 | area=> undef, | ||||||||||||||||||||||||||||||||||||||||||
| 231 | address=> $r, | ||||||||||||||||||||||||||||||||||||||||||
| 232 | name=> 'stackArea', | ||||||||||||||||||||||||||||||||||||||||||
| 233 | variable=> 0, | ||||||||||||||||||||||||||||||||||||||||||
| 234 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | my sub RefLeft($) # Record a reference to a left address | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | {my ($r) = @_; # Reference | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
RefLeft: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | @_ == 1 or confess "One parameter required formatted as either a address or an [area, address, name]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | ref($r) and ref($r) !~ m(\A(array|scalar|ref)\Z)i and confess "Scalar or reference required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $r and not ref($r) =~ /\A(array|scalar|ref)\Z/iu
MC/DC0%0/2
ref $r and not ref($r) =~ /\A(array|scalar|ref)\Z/iu
ref $r
not ref($r) =~ /\A(array|scalar|ref)\Z/iu
Truth table0%0/3
A and not(B)
A= ref $rB= not ref($r) =~ /\A(array|scalar|ref)\Z/iu
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | if (ref($r) =~ m(array)i) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | {my ($area, $address, $name) = @$r; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | defined($area) and !defined($name) and confess "Name required for area: in {area, address, name]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $area and not defined $name
MC/DC0%0/2
defined $area and not defined $name
defined $area
not defined $name
Truth table0%0/3
A and not(B)
A= defined $areaB= not defined $name
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | !defined($area) and defined($name) and confess "Area required for name: in {area, address, name]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $area and defined $name
MC/DC0%0/2
not defined $area and defined $name
not defined $area
defined $name
Truth table0%0/3
not(A) and B
A= not defined $areaB= defined $name
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | return genHash("Zero::Emulator::RefLeft", | |||||||||||||||||||||||||||||||||||||||||
| 250 | area=> $area, | ||||||||||||||||||||||||||||||||||||||||||
| 251 | address=> $address, | ||||||||||||||||||||||||||||||||||||||||||
| 252 | name=> $name, | ||||||||||||||||||||||||||||||||||||||||||
| 253 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | else | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | {return genHash("Zero::Emulator::RefLeft", | |||||||||||||||||||||||||||||||||||||||||
| 257 | area=> undef, | ||||||||||||||||||||||||||||||||||||||||||
| 258 | address=> $r, | ||||||||||||||||||||||||||||||||||||||||||
| 259 | name=> 'stackArea', | ||||||||||||||||||||||||||||||||||||||||||
| 260 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | sub Zero::Emulator::Reference::print($) #P Print the value of an address.. | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | {my ($ref) = @_; # Reference specification | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $a = dump($ref->area); | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $l = dump($ref->address); | |||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $s = "Reference area: $a, address: $l"; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | say STDERR $s; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | sub Zero::Emulator::Address::print($$) #P Print the value of an address in the current execution.. | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | {my ($address, $exec) = @_; # Address specification | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $e = $exec; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my $m = $e->memory; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $t = $e->memoryType; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $a = $address->area; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my $l = $address->address; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $s = "Address area: $a"; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | $s .= "(".($$t{$a} // "unknown")."), "; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$t->{$a} // "unknown"
MC/DC0%0/1
$t->{$a} // "unknown"
$t->{$a}
Truth table0%0/2
A
A= $t->{$a}
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $s .= "address: $l"; | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | sub Zero::Emulator::Address::get($$) #P Get the value of the specified address in memory in the specified execution environment.. | ||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | {my ($address, $exec) = @_; # Address specification | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my $e = $exec; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $m = $e->memory; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $a = $address->area; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $l = $address->address; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $$m{$a}[$l]; | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | sub Zero::Emulator::Address::at($$) #P Reference to the specified address in memory of current execution environment.. | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | {my ($address, $exec) = @_; # Address specification | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
at: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $e = $exec; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $m = $e->memory; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my $a = $address->area; | |||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my $l = $address->address; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | \$$m{$a}[$l] | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | sub Zero::Emulator::Procedure::call($) #P Call a procedure. Arguments are supplied by the L<ParamsPut> and L<ParamsGet> commands, return values are supplied by the L<ReturnPut> and L<ReturnGet> commands.. | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | {my ($procedure) = @_; # Procedure description | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | Zero::Emulator::Call($procedure->target); | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | sub Zero::Emulator::Code::registers($) #P Allocate registers. | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | {my ($code, $number) = @_; # Code block, number of registers required | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
registers: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $code->variables->registers | |||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | sub Zero::Emulator::Code::assemble($%) #P Assemble a block of code to prepare it for execution. | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | {my ($Block, %options) = @_; # Code block, assembly options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assemble: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | return $Block if $Block->assembled; # Already assembled | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $code = $Block->code; # The code to be assembled | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my $vars = $Block->variables; # The variables referenced by the code | |||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my %labels; # Load labels | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $stackFrame = AreaStructure("Stack"); # The current stack frame we are creating variables in | |||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | for my $c(keys @$code) # Labels | |||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | {my $i = $$code[$c]; | |||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $i->number = $c; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | next unless $i->action eq "label"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $labels{$i->source->address} = $i; # Point label to instruction | |||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | for my $c(keys @$code) # Target jump and call instructions | |||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | {my $i = $$code[$c]; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | next unless $i->action =~ m(\A(j|call))i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if (my $l = $i->target->address) # Label | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | {if (my $t = $labels{$l}) # Found label | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | {$i->target = RefRight($t->number - $c); # Relative jump | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | else | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | {my $a = $i->action; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | confess "No target for $a to label: $l"; | |||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $Block->labels = {%labels}; # Labels created during assembly | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $Block->assembled = time; # Time of assembly | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $Block | |||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | #D1 Execution | ||||||||||||||||||||||||||||||||||||||||||
| 354 | #D2 Analysis | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | sub Zero::Emulator::Execution::areaContent($$) #P Content of an area containing a address in memory in the specified execution. | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | {my ($exec, $address) = @_; # Execution environment, address specification | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
areaContent: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $e = $exec; | |||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my $m = $e->memory; | |||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | my $a = isScalar($address) ? $address : $$m{$exec->stackArea}[$$address]; # Dereference area | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $A = $$m{$a}; | |||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | $exec->stackTraceAndExit("Invalid area: ".dump($a)."\n".dump($e->memory)) unless defined $A; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | @$A | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | sub Zero::Emulator::Execution::dumpMemory($) #P Dump memory. | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dumpMemory: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $memory = $exec->memory; | |||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my @m; | |||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | for my $area(sort {$a <=> $b} keys %$memory) | |||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | {next if $area =~ m(\Astack\Z)i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $l = dump($$memory{$area}); | |||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | $l = substr($l, 0, 100) if length($l) > 100; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | push @m, "$area=$l"; | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | @m | ||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | sub Zero::Emulator::Execution::analyzeExecutionResultsLeast($%) #P Analyze execution results for least used code. | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | {my ($exec, %options) = @_; # Execution results, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyzeExecutionResultsLeast: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my @c = $exec->block->code->@*; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my %l; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | for my $i(@c) # Count executions of each instruction | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | {$l{$i->file}{$i->line} += $i->executed unless $i->action =~ m(\Aassert)i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my @L; | |||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | for my $f(keys %l) | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | {for my $l(keys $l{$f}->%*) | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | {push @L, [$l{$f}{$l}, $f, $l]; | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my @l = sort {$$a[0] <=> $$b[0]} # By frequency | |||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | sort {$$a[2] <=> $$b[2]} @L; # By line number | |||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | my $N = $options{least}//1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options{"least"} // 1
MC/DC0%0/1
$options{"least"} // 1
$options{"least"}
Truth table0%0/2
A
A= $options{"least"}
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | $#l = $N if @l > $N; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | map {sprintf "%4d at %s line %4d", $$_[0], $$_[1], $$_[2]} @l; | |||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | sub Zero::Emulator::Execution::analyzeExecutionResultsMost($%) #P Analyze execution results for most used code. | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | {my ($exec, %options) = @_; # Execution results, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyzeExecutionResultsMost: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my @c = $exec->block->code->@*; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my %m; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | for my $i(@c) # Count executions of each instruction | |||||||||||||||||||||||||||||||||||||||||
| 411 | {my $t = # Traceback | ||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | join "\n", map {sprintf " at %s line %4d", $$_[0], $$_[1]} $i->context->@*; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $m{$t} += $i->executed; | |||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my @m = reverse sort {$$a[1] <=> $$b[1]} map {[$_, $m{$_}]} keys %m; # Sort a hash into value order | |||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | my $N = $options{most}//1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options{"most"} // 1
MC/DC0%0/1
$options{"most"} // 1
$options{"most"}
Truth table0%0/2
A
A= $options{"most"}
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | $#m = $N if @m > $N; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | map{sprintf "%4d\n%s", $m[$_][1], $m[$_][0]} keys @m; | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | sub Zero::Emulator::Execution::analyzeExecutionNotRead($%) #P Analyze execution results for variables never read. | ||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | {my ($exec, %options) = @_; # Execution results, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyzeExecutionNotRead: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my @t; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $n = $exec->notRead; | |||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | for my $areaK(sort keys %$n) | |||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | {my $area = $$n{$areaK}; | |||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | for my $addressK(sort keys %$area) | |||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | {my $address = $$area{$addressK}; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | push @t, $exec->block->code->[$addressK]->contextString | |||||||||||||||||||||||||||||||||||||||||
| 431 | ($exec, "Not read from area: $areaK, address: $addressK in context:"); | ||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | @t; | |||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | sub Zero::Emulator::Execution::analyzeExecutionResultsDoubleWrite($%) #P Analyze execution results - double writes. | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | {my ($exec, %options) = @_; # Execution results, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyzeExecutionResultsDoubleWrite: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my @r; | |||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $W = $exec->doubleWrite; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | if (keys %$W) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | {for my $p(sort keys %$W) | |||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | {for my $q(keys $$W{$p}->%*) | |||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | {push @r, sprintf "Double write occured %d times. ", $$W{$p}{$q}; | |||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | if ($p eq $q) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | {push @r, "First and second write\n$p\n"; | |||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | else | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | {push @r, "First write:\n$p\n"; | |||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | push @r, "Second write:\n$q\n"; | |||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||
| 457 | @r | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | sub Zero::Emulator::Execution::analyzeExecutionResults($%) #P Analyze execution results. | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | {my ($exec, %options) = @_; # Execution results, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyzeExecutionResults: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my @r; | |||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | if (1) | |||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | {my @l = $exec->analyzeExecutionResultsLeast(%options); # Least/most executed | |||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my @m = $exec->analyzeExecutionResultsMost (%options); | |||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if (@l and $options{leastExecuted}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@l and $options{"leastExecuted"}
MC/DC0%0/2
@l and $options{"leastExecuted"}
@l
$options{"leastExecuted"}
Truth table0%0/3
A and B
A= @lB= $options{"leastExecuted"}
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | {push @r, "Least executed:"; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | push @r, @l; | |||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | if (@m and $options{mostExecuted}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@m and $options{"mostExecuted"}
MC/DC0%0/2
@m and $options{"mostExecuted"}
@m
$options{"mostExecuted"}
Truth table0%0/3
A and B
A= @mB= $options{"mostExecuted"}
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | {push @r, "Most executed:"; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | push @r, @m; | |||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | if (my @n = $exec->analyzeExecutionNotRead(%options)) # Variables not read | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | {my $n = @n; | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | @n = () unless $options{notRead}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | push @r, @n; | |||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | push @r, sprintf "# %8d variables not read", $n; | |||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if (my @d = $exec->analyzeExecutionResultsDoubleWrite(%options)) # Analyze execution results - double writes | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | {my $d = @d; | |||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | @d = () unless $options{doubleWrite}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | push @r, @d; | |||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | push @r, sprintf "# %8d double writes", $d/2; | |||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | push @r, sprintf "# %8d instructions executed", $exec->count; | |||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | join "\n", @r; | |||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | #D2 Memory # Access memory | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | sub Zero::Emulator::Execution::check($$$) #P Check that a user area access is valid. | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | {my ($exec, $area, $name) = @_; # Execution environment, area, expected area name | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | if ($area and $area =~ m(\A\d+\Z)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$area and $area =~ /\A\d+\Z/u
MC/DC0%0/2
$area and $area =~ /\A\d+\Z/u
$area
$area =~ /\A\d+\Z/u
Truth table0%0/3
A and B
A= $areaB= $area =~ /\A\d+\Z/u
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | {my $Name = $exec->memoryType->{$area}; | |||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | if ($name ne $Name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | {$exec->stackTraceAndExit("Attempting to access area: $Name using: $name"); | |||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | sub Zero::Emulator::Execution::getMemory($$$;$%) #P Get from memory. | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | {my ($exec, $area, $address, $name, %options) = @_; # Execution environment, area, address, expected name of area, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMemory: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | @_ < 3 and confess "At least three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $exec->check($area, $name); | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $g = $exec->get($area, $address); | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | my $n = $name // 'unknown'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$name // "unknown"
MC/DC0%0/1
$name // "unknown"
$name
Truth table0%0/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | if (!defined($g) and !defined($options{undefinedOk})) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $g or defined $options{"undefinedOk"}
MC/DC0%0/2
defined $g or defined $options{"undefinedOk"}
defined $g
defined $options{"undefinedOk"}
Truth table0%0/3
A or B
A= defined $gB= defined $options{"undefinedOk"}
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | {$exec->stackTraceAndExit("Undefined memory accessed at area: $area ($n), address: $address\n"); | |||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||
| 518 | $g | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | sub Zero::Emulator::Execution::get($$$) #P Get from memory. | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | {my ($exec, $area, $address) = @_; # Execution environment, area, address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $exec->memory->{$area}[$address]; | |||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | sub Zero::Emulator::Execution::set($$$) #P Set the value of an address at the specified address in memory in the current execution environment. | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | {my ($exec, $address, $value) = @_; # Execution environment, address specification, value | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my $e = $exec; | |||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my $m = $e->memory; | |||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | my $a = $address->area; | |||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | my $l = $address->address; | |||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | $exec->lastAssignArea = $a; | |||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | $exec->lastAssignAddress = $l; | |||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $exec->lastAssignValue = $value; | |||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $exec->lastAssignBefore = $$m{$a}[$l]; | |||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | $$m{$a}[$l] = $value; | |||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | #D2 Execution # Execute assembly code in the emulator | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | sub Zero::Emulator::Execution::stackArea($) #P Current stack frame. | ||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stackArea: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | $exec->calls->[-1]->stackArea; # Stack area | |||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | sub Zero::Emulator::Execution::address($$$$) #P Record a reference to memory. | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | {my ($exec, $area, $address, $name) = @_; # Execution environment, area, address in area, memory | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
address: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | @_ == 4 or confess "Four parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | genHash("Zero::Emulator::Address", # Address memory | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$name // "stackArea"
MC/DC0%0/1
$name // "stackArea"
$name
Truth table0%0/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | area=> $area, # Area in memory | ||||||||||||||||||||||||||||||||||||||||||
| 555 | address=> $address, # Address within area | ||||||||||||||||||||||||||||||||||||||||||
| 556 | name=> $name // 'stackArea', # Name of area | ||||||||||||||||||||||||||||||||||||||||||
| 557 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | sub Zero::Emulator::Execution::stackTrace($;$) #P Create a stack trace. | ||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | {my ($exec, $title) = @_; # Execution environment, title | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stackTrace: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my $i = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $s = $exec->suppressOutput; # Suppress file and line numbers in dump to facilitate automated testing | |||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my @t; | |||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | push @t, $i->contextString($exec, $title//"Stack trace"); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$title // "Stack trace"
MC/DC0%0/1
$title // "Stack trace"
$title
Truth table0%0/2
A
A= $title
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | for my $j(reverse keys $exec->calls->@*) | |||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | {my $c = $exec->calls->[$j]; | |||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my $i = $c->instruction; | |||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | push @t, sprintf "%5d %4d %s", $j+1, $i->number+1, $i->action if $s; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | push @t, sprintf "%5d %4d %-16s at %s line %d", | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | $j+1, $i->number+1, $i->action, $i->file, $i->line unless $s; | ||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | @t | ||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | sub Zero::Emulator::Execution::stackTraceAndExit($$%) #P Create a stack trace and exit from the emulated program. | ||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | {my ($exec, $title, %options) = @_; # Execution environment, title, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stackTraceAndExit: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | @_ >= 2 or confess "At least two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | my @t = $exec->stackTrace($title); | |||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | push $exec->out->@*, @t; | |||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | my $t = join "\n", @t; | |||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | if (!defined $exec->suppressOutput) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | {confess $t if $options{confess}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | say STDERR $t; | |||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $exec->instructionPointer = undef; # Execution terminates as soon as undefined instruction is encountered | |||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $t | |||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | 1 | my $allocs = 0; my $allocsStacked = 0; # Normal arrays allocated by the user, stacked allocations are made to support subroutine calling, parameter passing, result returning. | |||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | sub Zero::Emulator::Execution::allocMemory($$;$) #P Create the name of a new memory area. | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | {my ($exec, $name, $stacked) = @_; # Execution environment, name of allocation, stacked if true | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allocMemory: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if ($stacked) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | {my $a = $allocsStacked--; | |||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | $exec->memory->{$a} = bless [], $name; | |||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $exec->memoryType->{$a} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | return $a | |||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my $a = ++$allocs; | |||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $exec->memory ->{$a} = bless [], $name; | |||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $exec->memoryType->{$a} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | $a | |||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||
| 611 | sub Zero::Emulator::Execution::setMemoryType($$$) #P Set the type of a memory area - a name that can be used to confirm the validity of reads and writes to that array represented by that area. | ||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | {my ($exec, $area, $name) = @_; # Execution environment, area name, name of allocation | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setMemoryType: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | $exec->memoryType->{$area} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | $exec | |||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | sub Zero::Emulator::Execution::notRead() #P Record the unused memory locations in the current stack frame. | ||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | {my ($exec) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notRead: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my $area = $exec->stackArea; | |||||||||||||||||||||||||||||||||||||||||
| 621 | # my @area = $memory{$area}->@*; # Memory in area | ||||||||||||||||||||||||||||||||||||||||||
| 622 | # my %r; # Location in stack frame=> instruction defining vasriable | ||||||||||||||||||||||||||||||||||||||||||
| 623 | # for my $a(keys @area) | ||||||||||||||||||||||||||||||||||||||||||
| 624 | # {if (my $I = $calls[-1]->variables->instructions->[$a]) | ||||||||||||||||||||||||||||||||||||||||||
| 625 | # {$r{$a} = $I; # Number of instruction creating variable | ||||||||||||||||||||||||||||||||||||||||||
| 626 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 627 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | # | ||||||||||||||||||||||||||||||||||||||||||
| 629 | # if (my $r = $read{$area}) # Locations in this area that have ben read | ||||||||||||||||||||||||||||||||||||||||||
| 630 | # {delete $r{$_} for keys %$r; # Delete locations that have been read from | ||||||||||||||||||||||||||||||||||||||||||
| 631 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 632 | # | ||||||||||||||||||||||||||||||||||||||||||
| 633 | # $notRead{$area} = {%r} if keys %r; # Record not read | ||||||||||||||||||||||||||||||||||||||||||
| 634 | {} | ||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | sub Zero::Emulator::Execution::rwWrite($$$) #P Observe write to memory. | ||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | {my ($exec, $area, $address) = @_; # Area in memory, address within area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rwWrite: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | my $P = $exec->rw->{$area}{$address}; | |||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | if (defined($P)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | {my $M = $exec->memory->{$area}[$address]; # If the memory address is zero we will assume that it has been cleared rather than set. | |||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | if ($M) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | {my $Q = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | my $p = $P->contextString($exec, "Previous write"); | |||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my $q = $Q->contextString($exec, "Current write"); | |||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | $exec->doubleWrite->{$p}{$q}++; | |||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | $exec->rw->{$area}{$address} = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | sub Zero::Emulator::Execution::markAsRead($$$) #P Mark a memory address as having been read from. | ||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | {my ($exec, $area, $address) = @_; # Area in memory, address within area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
markAsRead: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | delete $exec->rw->{$area}{$address}; # Clear last write operation | |||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||
| 658 | sub Zero::Emulator::Execution::rwRead($$$) #P Observe read from memory. | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | {my ($exec, $area, $address) = @_; # Area in memory, address within area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rwRead: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | if (defined(my $a = $exec->rw->{$area}{$address})) # Can only read from locations that actually have something in them | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | {$exec->markAsRead($area, $address); # Clear last write operation | |||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | $exec->read->{$area}{$address}++; # Track reads | |||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | sub Zero::Emulator::Execution::left($$;$) #P Address a memory address. | ||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | {my ($exec, $ref, $extra) = @_; # Reference, an optional extra offset to add or subtract to the final memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
left: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | @_ == 2 or @_ == 3 or confess "Two or three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 2 or @_ == 3
MC/DC0%0/2
@_ == 2 or @_ == 3
@_ == 2
@_ == 3
Truth table0%0/3
A or B
A= @_ == 2B= @_ == 3
| |||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | ref($ref) =~ m((RefLeft|RefRight)\Z) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 671 | or confess "RefLeft or RefRight required, not: ".dump($ref); | ||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | my $r = $ref->address; | |||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my $a = $r; | |||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | $a = \$r if isScalar $a; # Interpret constants as direct memory locations | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | my $area = $ref->area; | |||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | my $x = $extra // 0; # Default is to use the address as supplied without locating a nearby address | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$extra // 0
MC/DC0%0/1
$extra // 0
$extra
Truth table0%0/2
A
A= $extra
| |||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my $S = $exec->stackArea; # Current stack frame | |||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | my sub invalid() | ||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | ▶ | {my ($p) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invalid: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | my $i = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my $l = $i->line; | |||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $f = $i->file; | |||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | $exec->stackTraceAndExit( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 685 | "Invalid left area: ".dump($area) | ||||||||||||||||||||||||||||||||||||||||||
| 686 | ." address: ".dump($a) | ||||||||||||||||||||||||||||||||||||||||||
| 687 | .(defined($extra) ? " + extra: ".dump($extra) : '')) | ||||||||||||||||||||||||||||||||||||||||||
| 688 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | my $M; # Memory address | |||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | ▶ | if (isScalar $$a) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | {$M = $$a+$x | |||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 694 | elsif (isScalar $$$a) | ||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | {$exec->rwRead($S, $$$a); | |||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | $M = $exec->getMemory($S, $$$a, $ref->name)+$x | |||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||
| 698 | else | ||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | {invalid | |||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | if ($M < 0) # Disallow negative addresses because they mean something special to Perl | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | {$exec->stackTraceAndExit("Negative address for area: " | |||||||||||||||||||||||||||||||||||||||||
| 704 | .dump($area) | ||||||||||||||||||||||||||||||||||||||||||
| 705 | .", address: ".dump($a) | ||||||||||||||||||||||||||||||||||||||||||
| 706 | ." extra:".dump($x)); | ||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 708 | elsif (!defined($area)) # Current stack frame | ||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | {$exec->rwWrite( $S, $M); | |||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | return $exec->address($S, $M, $ref->name); # Stack frame | |||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 712 | elsif (isScalar($area)) | ||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | {$exec->rwWrite( $area, $M); | |||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | return $exec->address($area, $M, $ref->name) # Specified constant area | |||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||
| 716 | elsif (isScalar($$area)) | ||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | {$exec->rwRead ( $S, $$area); | |||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | my $A = $exec->getMemory($S, $$area, $ref->name); | |||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | $exec->rwWrite( $A, $M); | |||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | return $exec->address($A, $M, $ref->name) # Indirect area | |||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | invalid; | |||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||
| 725 | sub Zero::Emulator::Execution::leftSuppress($$) #P Indicate that a memory address has been read. | ||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | {my ($exec, $ref) = @_; # Execution environment, Reference | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
leftSuppress: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | ▶ | ref($ref) =~ m((RefLeft|RefRight)\Z) or confess "RefLeft or RefRight required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | my $A = $ref->address; | |||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | my $area = $ref->area; | |||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | my $a = $A; | |||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | $a = \$A if isScalar $a; # Interpret constants as direct memory locations | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | my $m; | |||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | my $memory = $exec->memory; | |||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | my $stackArea = $exec->stackArea; | |||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | if (isScalar $$a) # Direct | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | {$m = $$a; | |||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||
| 741 | elsif (isScalar $$$a) # Indirect | ||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | {$exec->rwRead ($stackArea, $$$a); | |||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | $m = $exec->get($stackArea, $$$a, $ref->name); | |||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | if (defined($m)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | {if (!defined($area)) # Current stack frame | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | {$exec->rwRead($stackArea, $m); | |||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||
| 750 | elsif (isScalar($area)) # Direct area | ||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | {$exec->rwRead($area, $m); | |||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||
| 753 | elsif (isScalar($$area)) # Indirect area | ||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | {$exec->rwRead( $stackArea, $area); | |||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | $exec->rwRead($exec->get($stackArea, $$area), $m); | |||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | sub Zero::Emulator::Execution::right($$) #P Get a constant or a memory address. | ||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | {my ($exec, $ref) = @_; # Location, optional area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
right: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | ref($ref) =~ m((RefLeft|RefRight)\Z) or confess "RefLeft or RefRight required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | my $a = $ref->address; | |||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | my $area = $ref->area; | |||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | my $stackArea = $exec->stackArea; | |||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | my $r; my $e = 0; my $tAddress; my $tArea; | |||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | my sub invalid() | ||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invalid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | my $l = $i->line; | |||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | my $f = $i->file; | |||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | $exec->stackTraceAndExit( | |||||||||||||||||||||||||||||||||||||||||
| 774 | "Invalid right area: ".dump($area) | ||||||||||||||||||||||||||||||||||||||||||
| 775 | ." address: " .dump($a) | ||||||||||||||||||||||||||||||||||||||||||
| 776 | ." stack: " .$exec->stackArea | ||||||||||||||||||||||||||||||||||||||||||
| 777 | ." error: " .dump($e) | ||||||||||||||||||||||||||||||||||||||||||
| 778 | ." target Area: ".dump($tArea) | ||||||||||||||||||||||||||||||||||||||||||
| 779 | ." address: " .dump($tAddress)); | ||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | if (isScalar($a)) # Constant | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 783 | {#rwRead($area//&stackArea, $a) if $a =~ m(\A\-?\d+\Z); | ||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | ▶ | return $a if defined $a; # Attempting to read a address that has never been set is an error | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | $exec->stackTraceAndExit("Undefined right address: ".dump($a)); | |||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | my $m; | |||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | my $memory = $exec->memory; | |||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | if (isScalar($$a)) # Direct | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | {$m = $$a; | |||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||
| 794 | elsif (isScalar($$$a)) # Indirect | ||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | {$exec->rwRead($stackArea, $$$a); | |||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | $m = $exec->getMemory($stackArea, $$$a); | |||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||
| 798 | else | ||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | {$exec->stackTraceAndExit("Invalid right address: ".dump($a)); | |||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | ▶ | if (!defined($m)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | {invalid; | |||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | if (!defined($area)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | {$exec->rwRead($stackArea, $m); | |||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | $r = $exec->getMemory($stackArea, $m); # Indirect from stack area | |||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | $e = 1; $tAddress = $m; $tArea = $exec->stackArea; | |||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||
| 810 | elsif (isScalar($area)) | ||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | {$exec->rwRead( $area, $m); | |||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | $r = $exec->getMemory($area, $m, $ref->name); # Indirect from stack area | |||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | $e = 2; $tAddress = $m; $tArea = $area; | |||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||
| 815 | elsif (isScalar($$area)) | ||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | {$exec->rwRead($exec->stackArea, $$area); # Mark the address holding the area as having been read | |||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | ▶ | if (defined(my $j = $$memory{$exec->stackArea}[$$area])) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | {$exec->rwRead($j, $m); | |||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | $r = $$memory{$j}[$m]; # Indirect from indirect area | |||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | $r = $exec->getMemory($j, $m, $ref->name); # Indirect from stack area | |||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | $e = 9; $tAddress = $m; $tArea = $j; | |||||||||||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||||||||||||
| 823 | } | ||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | invalid if !defined $r; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | $r | |||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||
| 828 | sub Zero::Emulator::Execution::jumpOp($$$) #P Jump to the target address if the tested memory area if the condition is matched. | ||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | ▶ | {my ($exec, $i, $check) = @_; # Execution environment, Instruction, check | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jumpOp: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | ▶ | $exec->instructionPointer = $i->number + $exec->right($i->target) if &$check; # Check if condition is met | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||
| 834 | sub Zero::Emulator::Execution::assert($$$) #P Assert generically. | ||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | ▶ | {my ($exec, $test, $sub) = @_; # Execution environment, Text of test, subroutine of test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | my $i = $exec->currentInstruction; | |||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | my ($a, $b) = ($exec->right($i->source), $exec->right($i->source2)); | |||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | ▶ | unless($sub->($a, $b)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | {$exec->stackTraceAndExit("Assert $a $test $b failed"); | |||||||||||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||
| 844 | sub Zero::Emulator::Execution::assign($$$) #P Assign - check for pointless assignments. | ||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | ▶ | {my ($exec, $target, $value) = @_; # Execution environment, Target of assign, value to assign | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | @_ == 3 or confess "Three parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | ▶ | ref($target) =~ m(Address)i or confess "Not an address: ".dump($target); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | my $a = $target->area; | |||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my $l = $target->address; | |||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | my $n = $target->name//'unknown'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$target->name // "unknown"
MC/DC0%0/1
$target->name // "unknown"
$target->name
Truth table0%0/2
A
A= $target->name
| |||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | my $N = $exec->memoryType->{$a}; | |||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | ▶ | if (!defined $N) # Check that the area has a name | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | {$exec->stackTraceAndExit("No name for area $a\n".dump($exec->memory)." address:".dump($target), confess=>1); | |||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | if ($n ne $N) # Check that the area name matches the one supplied in the address | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | {$exec->stackTraceAndExit | |||||||||||||||||||||||||||||||||||||||||
| 860 | ("Area name provided: '$n' does not match actual area name '$N' for area: $a"); | ||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | ▶ | if (!defined($value)) # Check that the assign is not pointless | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | {$exec->stackTraceAndExit | |||||||||||||||||||||||||||||||||||||||||
| 865 | ("Cannot assign an undefined value to area: $a ($n), address: $l"); | ||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||
| 867 | else | ||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | {my $currently = $target->get($exec); | |||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | if (defined($currently) and $currently == $value) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $currently and $currently == $value
MC/DC0%0/2
defined $currently and $currently == $value
defined $currently
$currently == $value
Truth table0%0/3
A and B
A= defined $currentlyB= $currently == $value
| |||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | {$exec->pointlessAssign->{$exec->currentInstruction->number}++; | |||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | ▶ | if ($exec->stopOnError) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | {$exec->stackTraceAndExit("Pointless assign of: $currently to area: $a, at: $l"); | |||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | ▶ | if (defined $exec->watch->{$a}{$l}) # Watch for specified changes | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | {my @s = $exec->stackTrace("Change at watched area: $a ($n), address: $l\n"); | |||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | push @s, join ' ', "Current value:", $exec->memory->{$a}[$l]; | |||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | push @s, join ' ', "New value:", $value; | |||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | push @s, $exec->dumpMemory; | |||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | ▶ | say STDERR join "\n", @s unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | push $exec->out->@*, @s; | |||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | $exec->set($target, $value); # Actually do the assign | |||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||
| 889 | sub Zero::Emulator::Execution::allocateSystemAreas($) #P Allocate system areas for a new stack frame. | ||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allocateSystemAreas: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | (stackArea=> $exec->allocMemory("stackArea", 1), | |||||||||||||||||||||||||||||||||||||||||
| 893 | params=> $exec->allocMemory("params", 1), | ||||||||||||||||||||||||||||||||||||||||||
| 894 | return=> $exec->allocMemory("return", 1)); | ||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||
| 897 | sub Zero::Emulator::Execution::freeSystemAreas($$) #P Free system areas for the specified stack frame. | ||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | {my ($exec, $c) = @_; # Execution environment, stack frame | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
freeSystemAreas: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | ▶ | @_ == 2 or confess "Two parameters"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | $exec->notRead; # Record unread memory locations in the current stack frame | |||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | delete $exec->memory->{$_} for $c->stackArea, $c->params, $c->return; | |||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | $allocsStacked -= 3; | |||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | sub Zero::Emulator::Execution::currentInstruction($) #P Locate current instruction. | ||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
currentInstruction: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | $exec->calls->[-1]->instruction; | |||||||||||||||||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||
| 911 | sub Zero::Emulator::Execution::createInitialStackEntry($) #P Create the initial stack frame. | ||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | ▶ | {my ($exec) = @_; # Execution environment | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
createInitialStackEntry: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | ▶ | push $exec->calls->@*, # Variables in initial stack frame | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 915 | stackFrame( | ||||||||||||||||||||||||||||||||||||||||||
| 916 | $exec->block ? (variables=> $exec->block->variables) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 917 | $exec->allocateSystemAreas); | ||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | $exec | |||||||||||||||||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | sub Zero::Emulator::Code::execute($%) #P Execute a block of code. | ||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | {my ($block, %options) = @_; # Block of code, execution options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | $block->assemble; # Assemble if necessary | |||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | my $exec = execute(code=>$block, %options); # Execution environment | |||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||
| 928 | my %instructions = # Instruction definitions | ||||||||||||||||||||||||||||||||||||||||||
| 929 | (add=> sub # Add the two source operands and store the result in the target | ||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | my $a = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | my $b = $exec->right($i->source2); | |||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | $exec->assign($t, $a + $b); | |||||||||||||||||||||||||||||||||||||||||
| 935 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||
| 937 | subtract=> sub # Subtract the second source operand from the first and store the result in the target | ||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | my $a = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | my $b = $exec->right($i->source2); | |||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | $exec->assign($t, $a - $b); | |||||||||||||||||||||||||||||||||||||||||
| 943 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | assert=> sub # Assert | ||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | $exec->stackTraceAndExit("Assert failed"); | |||||||||||||||||||||||||||||||||||||||||
| 948 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | assertEq=> sub # Assert equals | ||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | {$exec->assert("==", sub {my ($a, $b) = @_; $a == $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | ▶ | }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||
| 954 | assertNe=> sub # Assert not equals | ||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | ▶ | {$exec->assert("!=", sub {my ($a, $b) = @_; $a != $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||
| 958 | assertLt=> sub # Assert less than | ||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | ▶ | {$exec->assert("< ", sub {my ($a, $b) = @_; $a < $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||
| 962 | assertLe=> sub # Assert less than or equal | ||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | ▶ | {$exec->assert("<=", sub {my ($a, $b) = @_; $a <= $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | ▶ | }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||
| 966 | assertGt=> sub # Assert greater than | ||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | {$exec->assert("> ", sub {my ($a, $b) = @_; $a > $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | ▶ | }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||
| 970 | assertGe=> sub # Assert greater | ||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | ▶ | {$exec->assert(">=", sub {my ($a, $b) = @_; $a >= $b}) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | ▶ | }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||
| 974 | array=> sub # Create a new memory area and write its number into the address named by the target operand | ||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | my $a = $exec->allocMemory($i->source); # The reason for this allocation | |||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | my $A = $exec->memory->{$a} = []; | |||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | bless $A, $i->source; # Useful because dump then prints the type of each area for us | |||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | $exec->assign($t, $a); | |||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | $a | |||||||||||||||||||||||||||||||||||||||||
| 983 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||
| 985 | free=> sub # Free the memory area named by the source operand | ||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | my $area = $exec->right($i->target); # Area | |||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | my $name = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | ▶ | if (!defined($name)) # A name is required | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | {$exec->stackTraceAndExit("Area name required to free an area: $area"); | |||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | ▶ | if ($area !~ m(\A\d+\Z)) # User free-able area | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | {$exec->stackTraceAndExit("Attempting to allocate non user area: $area"); | |||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | my $Name = $exec->memoryType->{$area}; # Area has a name | |||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | ▶ | if (!defined($Name)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | {$exec->stackTraceAndExit("No name associated with area: $area"); | |||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | ▶ | if ($name ne $Name) # Name matches supplied name | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | {$exec->stackTraceAndExit("Wrong name: $name for area with name: $Name"); | |||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1009 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | delete $exec->memory->{$area} # Free validly identified area | |||||||||||||||||||||||||||||||||||||||||
| 1012 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||
| 1014 | areaSize=> sub # Get the size of the specified area | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | my $size = $exec->left ($i->target); # Location to store size in | |||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | my $area = $exec->right($i->source); # Location of area | |||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | my $name = $i->source2; # Name of area | |||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | ▶ | if (!defined($name)) # A name is required | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | {$exec->stackTraceAndExit("Area name required to size an area: ".dump($area)); | |||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | my $Name = $exec->memoryType->{$area}; # Area has a name | |||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | ▶ | if (!defined($Name)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | {$exec->stackTraceAndExit("No name associated with area: $area"); | |||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | if ($name ne $Name) # Name matches supplied name | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | {$exec->stackTraceAndExit("Wrong name: $name for area with name: $Name"); | |||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1034 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | $exec->assign($size, scalar $exec->memory->{$area}->@*) # Size of area | |||||||||||||||||||||||||||||||||||||||||
| 1037 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||
| 1039 | resize=> sub # Resize an area | ||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | my $size = $exec->right($i->source); # Size to reduce area to | |||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | my $area = $exec->right($i->target); # Area to reduce to | |||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | ▶ | $exec->stackTraceAndExit("Attempting to resize non user area: $area") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1044 | unless $area =~ m(\A\d+\Z); | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | $#{$exec->memory->{$area}} = $size-1; | |||||||||||||||||||||||||||||||||||||||||
| 1046 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||
| 1048 | call=> sub # Call a subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | my $t = $i->target->address; # Subroutine to call | |||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | ▶ | if (isScalar($t)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | {$exec->instructionPointer = $i->number + $t; # Relative call if we know where the subroutine is relative to the call instruction | |||||||||||||||||||||||||||||||||||||||||
| 1054 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | {$exec->instructionPointer = $t; # Absolute call | |||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | push $exec->calls->@*, | |||||||||||||||||||||||||||||||||||||||||
| 1059 | stackFrame(target=>$block->code->[$exec->instructionPointer], # Create a new call stack entry | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | instruction=>$i, variables=>$i->source->variables, | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | $exec->allocateSystemAreas()); | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||||||||||||||||
| 1064 | return=> sub # Return from a subroutine call via the call stack | ||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | ▶ | $exec->calls or $exec->stackTraceAndExit("The call stack is empty so I do not know where to return to"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | $exec->freeSystemAreas(pop $exec->calls->@*); | |||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | ▶ | if ($exec->calls) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | {my $c = $exec->calls->[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | $exec->instructionPointer = $c->instruction->number+1; | |||||||||||||||||||||||||||||||||||||||||
| 1071 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | {$exec->instructionPointer = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||
| 1077 | confess=> sub # Print the current call stack and stop | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | 0 | ▶ | {$exec->stackTraceAndExit("Confess at:", confess=>1); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1079 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||
| 1081 | trace=> sub # Start/stop/change tracing status from a program. A trace writes out which instructions have been executed and how they affected memory | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | ▶ | my $s = $exec->right($i->source) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | $exec->trace = $s; | |||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | my $m = join ' ', "Trace: $s"; | |||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | ▶ | say STDERR $m unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | push $exec->out->@*, $m; | |||||||||||||||||||||||||||||||||||||||||
| 1088 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||
| 1090 | tracePoints=> sub # Start trace points | ||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | ▶ | my $s = $exec->right($i->source) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | $exec->tracePoints = $s; | |||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | my $m = "TracePoints: $s"; | |||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | ▶ | say STDERR $m unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | push $exec->out->@*, $m; | |||||||||||||||||||||||||||||||||||||||||
| 1097 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||
| 1099 | tracePoint=> sub # Trace point | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | ▶ | {return unless $exec->tracePoints; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | my @s = $exec->stackTrace("Trace"); | |||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | ▶ | say STDERR join "\n", @s unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | push $exec->out->@*, @s; | |||||||||||||||||||||||||||||||||||||||||
| 1104 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||
| 1106 | dump=> sub # Dump memory | ||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | my @m; | |||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | ▶ | if (ref($i->source) =~ m(Code)i) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | {$i->source->($exec); | |||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | ▶ | push @m, $i->source // "Memory dump"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$i->source // "Memory dump"
MC/DC0%0/1
$i->source // "Memory dump"
$i->source
Truth table0%0/2
A
A= $i->source
| |||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | push @m, $exec->dumpMemory; | |||||||||||||||||||||||||||||||||||||||||
| 1116 | 0 | push @m, $exec->stackTrace; | |||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||
| 1118 | 0 | ▶ | say STDERR join "\n", @m unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | push $exec->out->@*, @m; | |||||||||||||||||||||||||||||||||||||||||
| 1120 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||
| 1122 | dumpArray=> sub # Dump array in memory | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1124 | 0 | my @m; | |||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | ▶ | push @m, $i->source // "Array dump"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$i->source // "Array dump"
MC/DC0%0/1
$i->source // "Array dump"
$i->source
Truth table0%0/2
A
A= $i->source
| |||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | my $a = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | push @m, dump($exec->memory->{$a}); | |||||||||||||||||||||||||||||||||||||||||
| 1128 | 0 | push @m, $exec->stackTrace; | |||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | ▶ | say STDERR join "\n", @m unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | push $exec->out->@*, @m; | |||||||||||||||||||||||||||||||||||||||||
| 1132 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||
| 1134 | dec=> sub # Decrement locations in memory. The first address is incremented by 1, the next by two, etc. | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | my $T = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1138 | 0 | ▶ | $exec->set($t, defined($t) ? $T-1 : -1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1139 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||
| 1141 | inc=> sub # Increment locations in memory. The first address is incremented by 1, the next by two, etc. | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | my $T = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | ▶ | $exec->set($t, defined($t) ? $T+1 : 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1146 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||
| 1148 | jmp=> sub # Jump to the target address | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | my $n = $i->number; | |||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | my $r = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | $exec->instructionPointer = $n + $r; | |||||||||||||||||||||||||||||||||||||||||
| 1153 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | # Conditional jumps | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | ▶ | jEq=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) == $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | ▶ | jNe=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) != $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | ▶ | jLe=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) <= $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | ▶ | jLt=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) < $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | ▶ | jGe=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) >= $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | ▶ | jGt=> sub {my $i = $exec->currentInstruction; $exec->jumpOp($i, sub{$exec->right($i->source) > $exec->right($i->source2)})}, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||
| 1162 | label=> sub # Label - no operation | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | ▶ | {my ($i) = @_; # Instruction | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1164 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||
| 1166 | clear=> sub # Clear the first bytes of an area as specified by the target operand | ||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | my $n = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1169 | 0 | for my $a(0..$n->address-1) | |||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | {my $A = $exec->left(RefLeft([$i->target->area, $a, q(aaa)])); | |||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | $exec->set($A, 0); | |||||||||||||||||||||||||||||||||||||||||
| 1172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1173 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||
| 1175 | leAddress=> sub # Load the address component of a reference | ||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | my $s = $exec->left($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1178 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | $exec->assign($t, $s->address); | |||||||||||||||||||||||||||||||||||||||||
| 1180 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||
| 1182 | leArea=> sub # Load the area component of an address | ||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | my $s = $exec->left($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | $exec->assign($t, $s->area); | |||||||||||||||||||||||||||||||||||||||||
| 1187 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||
| 1189 | mov=> sub # Move data moves data from one part of memory to another - "set", by contrast, sets variables from constant values | ||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1191 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | $exec->assign($t, $s); | |||||||||||||||||||||||||||||||||||||||||
| 1194 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||
| 1196 | not=> sub # Not in place | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1199 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | $exec->assign($t, !$s); | |||||||||||||||||||||||||||||||||||||||||
| 1201 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||
| 1203 | paramsGet=> sub # Get a parameter from the previous parameter block - this means that we must always have two entries on the call stack - one representing the caller of the program, the second representing the current context of the program | ||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | my $p = RefLeft([$exec->calls->[-2]->params, $i->source->address, | |||||||||||||||||||||||||||||||||||||||||
| 1206 | 'params']); | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | 0 | my $t = $exec->left ($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | $exec->leftSuppress ($p); # The source will be read from | |||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | my $s = $exec->left ($p); # The source has to be a left hand side because we want to address a memory area not get a constant | |||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | $exec->assign($t, $s->get($exec)); | |||||||||||||||||||||||||||||||||||||||||
| 1211 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||||||||
| 1213 | paramsPut=> sub # Place a parameter in the current parameter block | ||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | ▶ | my $p = $i->target->area // $exec->calls->[-1]->params; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$i->target->area // $exec->calls->[-1]->params
MC/DC0%0/2
$i->target->area // $exec->calls->[-1]->params
$i->target->area
$exec->calls->[-1]->params
Truth table0%0/3
A // B
A= $i->target->areaB= $exec->calls->[-1]->params
| |||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | my $r = RefLeft [$p, $i->target->address, 'params']; | |||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | $exec->leftSuppress ($r); | |||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | my $t = $exec->left ($r); | |||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1220 | 0 | $exec->assign($t, $s); | |||||||||||||||||||||||||||||||||||||||||
| 1221 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||
| 1223 | returnGet=> sub # Get a word from the return area | ||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1225 | 0 | my $p = $exec->calls->[-1]->return; # Memory area | |||||||||||||||||||||||||||||||||||||||||
| 1226 | 0 | my $t = $exec->left ($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | my $r = RefLeft([$p, \$i->source->address, 'return']); # The source will be read from | |||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | $exec->leftSuppress($r); # The source will be read from | |||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | my $s = $exec->left($r); # The source has to be a left hand side because we want to address a memory area not get a constant | |||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | $exec->assign($t, $s->get($exec)); | |||||||||||||||||||||||||||||||||||||||||
| 1231 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||
| 1233 | returnPut=> sub # Put a word into the return area | ||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | my $p = $exec->calls->[-2]->return; | |||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | my $t = $exec->left (RefLeft([$p, $i->target->address, q(return)])); | |||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1238 | 0 | $exec->assign($t, $s); | |||||||||||||||||||||||||||||||||||||||||
| 1239 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||
| 1241 | nop=> sub # No operation | ||||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | ▶ | {my ($i) = @_; # Instruction | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1243 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||
| 1245 | out=> sub # Write source as output to an array of words | ||||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | my $t = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | ▶ | lll $t unless $exec->suppressOutput; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | push $exec->out->@*, $t; | |||||||||||||||||||||||||||||||||||||||||
| 1250 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||
| 1252 | pop=> sub # Pop a value from the specified memory area if possible else confess | ||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | my $s = $i->source; | |||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | ▶ | my $area = $i->source ? $exec->right($i->source) : &stackArea; # Memory area to pop | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | ▶ | if (!defined($exec->memory->{$area}) or !$exec->memory->{$area}->@*) # Stack not pop-able | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $exec->memory->{$area} and @{$exec->memory->{$area}}
MC/DC0%0/2
defined $exec->memory->{$area} and @{$exec->memory->{$area}}
defined $exec->memory->{$area}
@{$exec->memory->{$area}}
Truth table0%0/3
A and B
A= defined $exec->memory->{$area}B= @{$exec->memory->{$area}}
| |||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | {$exec->stackTraceAndExit("Cannot pop area $area"); | |||||||||||||||||||||||||||||||||||||||||
| 1258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | my $p = pop $exec->memory->{$area}->@*; | |||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | $exec->assign($t, $p); # Pop from memory area into indicated memory address | |||||||||||||||||||||||||||||||||||||||||
| 1262 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||
| 1264 | push=> sub # Push a value onto the specified memory area | ||||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | ▶ | if ($i->target) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | {my $t = $exec->right($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | push $exec->memory->{$t}->@*, $s; | |||||||||||||||||||||||||||||||||||||||||
| 1270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | {push $exec->memory->{&stackArea}->@*, right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1274 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||||||||||||||||
| 1276 | shiftLeft=> sub # Shift left within an element | ||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | $exec->leftSuppress ($i->target); # Make sure there something to shift | |||||||||||||||||||||||||||||||||||||||||
| 1279 | 0 | my $t = $exec->left ($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | $exec->assign($t, $t->get($exec) << $s); | |||||||||||||||||||||||||||||||||||||||||
| 1282 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||||||||||||
| 1284 | shiftRight=> sub # Shift right within an element | ||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | $exec->leftSuppress ($i->target); # Make sure there something to shift | |||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | my $t = $exec->left ($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1289 | 0 | $exec->assign($t, $t->get($exec) >> $s); | |||||||||||||||||||||||||||||||||||||||||
| 1290 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||
| 1292 | shiftUp=> sub # Shift an element up in a memory area | ||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | my $s = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1295 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1296 | 0 | my $L = $exec->areaContent($t->area); # Length of area | |||||||||||||||||||||||||||||||||||||||||
| 1297 | 0 | my $l = $t->address; | |||||||||||||||||||||||||||||||||||||||||
| 1298 | 0 | for my $j(reverse 1..$L-$l) | |||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | {my $s = $exec->left($i->target, $j-1); | |||||||||||||||||||||||||||||||||||||||||
| 1300 | 0 | my $t = $exec->left($i->target, $j); | |||||||||||||||||||||||||||||||||||||||||
| 1301 | 0 | $exec->assign($t, $s->get($exec)); | |||||||||||||||||||||||||||||||||||||||||
| 1302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1303 | 0 | $exec->assign($t, $s); | |||||||||||||||||||||||||||||||||||||||||
| 1304 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||||||||||||||||
| 1306 | shiftDown=> sub # Shift an element down in a memory area | ||||||||||||||||||||||||||||||||||||||||||
| 1307 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1308 | 0 | my $s = $exec->left($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1309 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1310 | 0 | my $L = $exec->areaContent($s->area); # Length of area | |||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | my $l = $s->address; | |||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | my $v = $s->get($exec); | |||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | for my $j($l..$L-2) # Each element in specified range | |||||||||||||||||||||||||||||||||||||||||
| 1314 | 0 | {my $S = $exec->left(RefLeft([$s->area, $j+1, $s->name])); | |||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | my $T = $exec->left(RefLeft([$s->area, $j, $s->name])); | |||||||||||||||||||||||||||||||||||||||||
| 1316 | 0 | $exec->assign($T, $S->get($exec)); | |||||||||||||||||||||||||||||||||||||||||
| 1317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1318 | 0 | pop $exec->memory->{$s->area}->@*; | |||||||||||||||||||||||||||||||||||||||||
| 1319 | 0 | my $T = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1320 | 0 | $exec->assign($T, $v); | |||||||||||||||||||||||||||||||||||||||||
| 1321 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||
| 1323 | tally=> sub # Tally instruction usage | ||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1325 | 0 | my $t = $exec->right($i->source); | |||||||||||||||||||||||||||||||||||||||||
| 1326 | 0 | $exec->tally = $t; | |||||||||||||||||||||||||||||||||||||||||
| 1327 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||
| 1329 | watch=> sub # Watch a memory location for changes | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | ▶ | {my $i = $exec->currentInstruction; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | my $t = $exec->left($i->target); | |||||||||||||||||||||||||||||||||||||||||
| 1332 | 0 | $exec->watch->{$t->area}{$t->address}++; | |||||||||||||||||||||||||||||||||||||||||
| 1333 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1334 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | $exec->createInitialStackEntry; # Variables in initial stack frame | |||||||||||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||||||||||||
| 1338 | my $mi = $options{maximumInstructionsToExecute} // # Prevent run away executions | ||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | ▶ | maximumInstructionsToExecute; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$options{"maximumInstructionsToExecute"} // maximumInstructionsToExecute()
MC/DC0%0/2
$options{"maximumInstructionsToExecute"} // maximumInstructionsToExecute()
$options{"maximumInstructionsToExecute"}
maximumInstructionsToExecute()
Truth table0%0/3
A // B
A= $options{"maximumInstructionsToExecute"}B= maximumInstructionsToExecute()
| |||||||||||||||||||||||||||||||||||||||||||
| 1340 | 0 | for my $j(1..$mi) # Each instruction in the code until we hit an undefined instruction | |||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | ▶ | {last unless defined($exec->instructionPointer); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | my $i = $exec->block->code->[$exec->instructionPointer++]; # Current instruction | |||||||||||||||||||||||||||||||||||||||||
| 1343 | 0 | $exec->calls->[-1]->instruction = $i; | |||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | ▶ | last unless $i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | ▶ | if (my $a = $i->action) # Action | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1346 | 0 | {$exec->counts->{$a}++; $exec->count++; # Execution instruction counts | |||||||||||||||||||||||||||||||||||||||||
| 1347 | $exec->stackTraceAndExit(qq(Invalid instruction: "$a"\n)) | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | ▶ | unless my $c = $instructions{$a}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||
| 1350 | 0 | ▶ | if (my $t = $exec->tally) # Tally instruction counts | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1351 | 0 | ▶ | {if ($a !~ m(\A(label|tally)\Z)) # Omit instructions that are not tally-able | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | {$exec->tallyCount++; | |||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | $exec->tallyCounts->{$t}{$a}++; | |||||||||||||||||||||||||||||||||||||||||
| 1354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||
| 1357 | 0 | $exec->lastAssignArea = $exec->lastAssignAddress = $exec->lastAssignValue = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | $c->($i); # Execute instruction | |||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||
| 1360 | 0 | $exec->instructionCounts->{$i->number}++; # Execution count by actual instruction | |||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||
| 1362 | 0 | ++$i->executed; | |||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | ▶ | if ($exec->trace) # Trace changes to memory | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | {my $e = $exec->instructionCounts->{$i->number}; # Execution count for this instruction | |||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | my $f = $exec->formatTrace; | |||||||||||||||||||||||||||||||||||||||||
| 1367 | 0 | my $s = $exec->suppressOutput; | |||||||||||||||||||||||||||||||||||||||||
| 1368 | 0 | my $a = $i->action; | |||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | my $n = $i->number; | |||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | my $m = sprintf "%4d %4d %4d %12s %20s", $j, $n, $e, $a, $f; | |||||||||||||||||||||||||||||||||||||||||
| 1371 | 0 | ▶ | $m .= sprintf " at %s line %d", $i->file, $i->line unless $s; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1372 | 0 | $m .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | ▶ | say STDERR $m unless $s; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1374 | 0 | push $exec->out->@*, $m; | |||||||||||||||||||||||||||||||||||||||||
| 1375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||
| 1377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | ▶ | confess "Out of instructions after $j"if $j >= maximumInstructionsToExecute; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | $exec->freeSystemAreas($exec->calls->[0]); # Free first stack frame | |||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||
| 1383 | 0 | $exec | |||||||||||||||||||||||||||||||||||||||||
| 1384 | } # Execution results | ||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||
| 1386 | sub Zero::Emulator::Execution::formatTrace($) #P Describe last memory assignment. | ||||||||||||||||||||||||||||||||||||||||||
| 1387 | 0 | ▶ | {my ($exec) = @_; # Execution | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
formatTrace: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | ▶ | return "" unless defined(my $area = $exec->lastAssignArea); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | ▶ | return "" unless defined(my $addr = $exec->lastAssignAddress); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | ▶ | return "" unless defined(my $type = $exec->memoryType->{$area}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | ▶ | return "" unless defined(my $value = $exec->lastAssignValue); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | my $B = $exec->lastAssignBefore; | |||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | ▶ | my $b = $B ? " was $B" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | sprintf "[%d, %d, %s] = %d$b", $area, $addr, $type, $value; | |||||||||||||||||||||||||||||||||||||||||
| 1395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||||||||||||||||
| 1397 | 1 | my $assembly; # The current assembly | |||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||
| 1399 | my sub label() # Next unique label | ||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | ▶ | {++$assembly->labelCounter; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||
| 1403 | my sub setLabel(;$) # Set and return a label | ||||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | ▶ | {my ($l) = @_; # Optional preset label | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setLabel: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | ▶ | $l //= label; # Create label if none supplied | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$l //= label
MC/DC0%0/2
$l //= label
$l
label
Truth table0%0/3
A //= B
A= $lB= label
| |||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | Label($l); # Set label | |||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | $l # Return (new) label | |||||||||||||||||||||||||||||||||||||||||
| 1408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||
| 1410 | my sub xSource($) # Record a source argument | ||||||||||||||||||||||||||||||||||||||||||
| 1411 | 0 | ▶ | {my ($s) = @_; # Source expression | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xSource: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | (q(source), RefRight $s) | |||||||||||||||||||||||||||||||||||||||||
| 1413 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1414 | |||||||||||||||||||||||||||||||||||||||||||
| 1415 | my sub xSource2($) # Record a source argument | ||||||||||||||||||||||||||||||||||||||||||
| 1416 | 0 | ▶ | {my ($s) = @_; # Source expression | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xSource2: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1417 | 0 | (q(source2), RefRight $s) | |||||||||||||||||||||||||||||||||||||||||
| 1418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||
| 1420 | my sub xTarget($) # Record a target argument | ||||||||||||||||||||||||||||||||||||||||||
| 1421 | 0 | ▶ | {my ($t) = @_; # Target expression | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xTarget: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1422 | 0 | (q(target), RefLeft $t) | |||||||||||||||||||||||||||||||||||||||||
| 1423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1424 | |||||||||||||||||||||||||||||||||||||||||||
| 1425 | sub Start($) # Start the current assembly using the specified version of the Zero language. At the moment only version 1 works.. | ||||||||||||||||||||||||||||||||||||||||||
| 1426 | 0 | ▶ | {my ($version) = @_; # Version desired - at the moment only 1 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Start: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1427 | 0 | ▶ | $version == 1 or confess "Version 1 is currently the only version available\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1428 | 0 | $allocs = $allocsStacked = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1429 | 0 | $assembly = Code; # The current assembly | |||||||||||||||||||||||||||||||||||||||||
| 1430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||
| 1432 | sub Add($$;$) # Add the source locations together and store in the result in the target area. | ||||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | ▶ | {my ($target, $s1, $s2) = @_ == 2 ? (&Var(), @_) : @_; # Target address, source one, source two | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Add: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | $assembly->instruction(action=>"add", xTarget($target), | |||||||||||||||||||||||||||||||||||||||||
| 1435 | xSource($s1), xSource2($s2)); | ||||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | $target | |||||||||||||||||||||||||||||||||||||||||
| 1437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||||||||||||
| 1439 | sub Subtract($$;$) # Subtract the second source address from the first and store in the result in the target area. | ||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | ▶ | {my ($target, $s1, $s2) = @_ == 2 ? (&Var(), @_) : @_; # Target address, source one, source two | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Subtract: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | $assembly->instruction(action=>"subtract", xTarget($target), | |||||||||||||||||||||||||||||||||||||||||
| 1442 | xSource($s1), xSource2($s2)); | ||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | $target | |||||||||||||||||||||||||||||||||||||||||
| 1444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||
| 1446 | sub Array($) # Create a new memory area and write its number into the address named by the target operand. | ||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | ▶ | {my ($name) = @_; # Name of allocation | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Array: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | $assembly->instruction(action=>"array", target=>RefLeft($t), source=>$name); | |||||||||||||||||||||||||||||||||||||||||
| 1450 | 0 | $t; | |||||||||||||||||||||||||||||||||||||||||
| 1451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1452 | |||||||||||||||||||||||||||||||||||||||||||
| 1453 | sub Free($$) # Free the memory area named by the target operand after confirming that it has the name specified on the source operand. | ||||||||||||||||||||||||||||||||||||||||||
| 1454 | 0 | ▶ | {my ($target, $source) = @_; # Target area yielding the id of the area to be freed, source area yielding the name of the area to be freed | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Free: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | $assembly->instruction(action=>"free", xTarget($target), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1456 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||
| 1458 | sub AreaSize($$) # The current size of an area. | ||||||||||||||||||||||||||||||||||||||||||
| 1459 | 0 | ▶ | {my ($area, $name) = @_; # Location of area, name of area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AreaSize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1460 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1461 | 0 | $assembly->instruction(action=>"areaSize", # Target - location to place the size in, source - address of the area, source2 - the name of the area which cannot be taken from the area of the first source operand because that area name is the name of the area that contains the location of the area we wish to work on. | |||||||||||||||||||||||||||||||||||||||||
| 1462 | target=>RefLeft($t), xSource($area), source2=>$name); | ||||||||||||||||||||||||||||||||||||||||||
| 1463 | 0 | $t | |||||||||||||||||||||||||||||||||||||||||
| 1464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||
| 1466 | sub Call($) # Call the subroutine at the target address. | ||||||||||||||||||||||||||||||||||||||||||
| 1467 | 0 | ▶ | {my ($p) = @_; # Procedure description | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Call: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1468 | 0 | $assembly->instruction(action=>"call", | |||||||||||||||||||||||||||||||||||||||||
| 1469 | target=>RefLeft($p->target), source=>$p); | ||||||||||||||||||||||||||||||||||||||||||
| 1470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||||||||||||
| 1472 | sub Confess() # Confess. | ||||||||||||||||||||||||||||||||||||||||||
| 1473 | 0 | ▶ | {$assembly->instruction(action=>"confess"); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Confess: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||
| 1476 | sub Dump(;$) # Dump memory. | ||||||||||||||||||||||||||||||||||||||||||
| 1477 | 0 | ▶ | {my ($title) = @_; # Title | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Dump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1478 | 0 | $assembly->instruction(action=>"dump", source=>$title); | |||||||||||||||||||||||||||||||||||||||||
| 1479 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||
| 1481 | sub DumpArray($;$) # Dump an array. | ||||||||||||||||||||||||||||||||||||||||||
| 1482 | 0 | ▶ | {my ($target, $title) = @_; # Array to dump, title of dump | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DumpArray: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1483 | 0 | $assembly->instruction(action=>"dumpArray", target=>RefRight($target), source=>$title); | |||||||||||||||||||||||||||||||||||||||||
| 1484 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||
| 1486 | sub Trace($) # Trace. | ||||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | ▶ | {my ($source) = @_; # Trace setting | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Trace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1488 | 0 | $assembly->instruction(action=>"trace", xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1490 | |||||||||||||||||||||||||||||||||||||||||||
| 1491 | sub TracePoints($) # Enable trace points. | ||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | ▶ | {my ($source) = @_; # Trace points if true | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TracePoints: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1493 | 0 | $assembly->instruction(action=>"tracePoints", xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||
| 1496 | sub TracePoint(%) #P Trace point - a point in the code where the flow of execution might change. | ||||||||||||||||||||||||||||||||||||||||||
| 1497 | 0 | ▶ | {my (%options) = @_; # Parameters | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TracePoint: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | $assembly->instruction(action=>"tracePoint", %options); | |||||||||||||||||||||||||||||||||||||||||
| 1499 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||||||||||||||||
| 1501 | sub Dec($) # Decrement the target. | ||||||||||||||||||||||||||||||||||||||||||
| 1502 | 0 | ▶ | {my ($target) = @_; # Target address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Dec: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1503 | 0 | $assembly->instruction(action=>"dec", xTarget($target)) | |||||||||||||||||||||||||||||||||||||||||
| 1504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||
| 1506 | sub Inc($) # Increment the target. | ||||||||||||||||||||||||||||||||||||||||||
| 1507 | 0 | ▶ | {my ($target) = @_; # Target address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Inc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1508 | 0 | $assembly->instruction(action=>"inc", xTarget($target)) | |||||||||||||||||||||||||||||||||||||||||
| 1509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||||||||||
| 1511 | sub Jmp($) # Jump to a label. | ||||||||||||||||||||||||||||||||||||||||||
| 1512 | 0 | ▶ | {my ($target) = @_; # Target address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jmp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1513 | 0 | $assembly->instruction(action=>"jmp", xTarget($target)); | |||||||||||||||||||||||||||||||||||||||||
| 1514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1515 | |||||||||||||||||||||||||||||||||||||||||||
| 1516 | sub Jle($$$) # Jump to a target label if the first source field is less than or equal to the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jle: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1518 | 0 | $assembly->instruction(action=>"jLe", | |||||||||||||||||||||||||||||||||||||||||
| 1519 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 1520 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||||||||||||||||
| 1522 | sub Jlt($$$) # Jump to a target label if the first source field is less than the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 1523 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jlt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1524 | 0 | $assembly->instruction(action=>"jLt", | |||||||||||||||||||||||||||||||||||||||||
| 1525 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 1526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1527 | |||||||||||||||||||||||||||||||||||||||||||
| 1528 | sub Jge($$$) # Jump to a target label if the first source field is greater than or equal to the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 1529 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jge: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1530 | 0 | $assembly->instruction(action=>"jGe", | |||||||||||||||||||||||||||||||||||||||||
| 1531 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 1532 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||
| 1534 | sub Jgt($$$) # Jump to a target label if the first source field is greater than the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 1535 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jgt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1536 | 0 | $assembly->instruction(action=>"jGt", | |||||||||||||||||||||||||||||||||||||||||
| 1537 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 1538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||||||||||||||||
| 1540 | sub Jeq($$$) # Jump to a target label if the first source field is equal to the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 1541 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jeq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1542 | 0 | $assembly->instruction(action=>"jEq", | |||||||||||||||||||||||||||||||||||||||||
| 1543 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 1544 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||
| 1546 | sub Jne($$$) # Jump to a target label if the first source field is not equal to the second source field. | ||||||||||||||||||||||||||||||||||||||||||
| 1547 | 0 | ▶ | {my ($target, $source, $source2) = @_; # Target label, source to test | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Jne: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1548 | 0 | $assembly->instruction(action=>"jNe", | |||||||||||||||||||||||||||||||||||||||||
| 1549 | xTarget($target), xSource($source), xSource2($source2)); | ||||||||||||||||||||||||||||||||||||||||||
| 1550 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1551 | |||||||||||||||||||||||||||||||||||||||||||
| 1552 | sub Label($) # Create a label.. | ||||||||||||||||||||||||||||||||||||||||||
| 1553 | 0 | ▶ | {my ($source) = @_; # Name of label | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Label: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | $assembly->instruction(action=>"label", xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||
| 1557 | sub Clear($) # Clear the first bytes of an area. The area is specified by the first element of the address, the number of locations to clear is specified by the second element of the target address.. | ||||||||||||||||||||||||||||||||||||||||||
| 1558 | 0 | ▶ | {my ($target) = @_; # Target address, source address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Clear: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1559 | 0 | $assembly->instruction(action=>"clear", xTarget($target)); | |||||||||||||||||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||
| 1562 | sub LeAddress($;$) { # Load the address component. | ||||||||||||||||||||||||||||||||||||||||||
| 1563 | 0 | ▶ | if (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
LeAddress: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1564 | 0 | {my ($source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 1565 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1566 | 0 | $assembly->instruction(action=>"leAddress", | |||||||||||||||||||||||||||||||||||||||||
| 1567 | target=>RefLeft($t), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1568 | 0 | return $t; | |||||||||||||||||||||||||||||||||||||||||
| 1569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1570 | elsif (@ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 1571 | 0 | {my ($target, $source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 1572 | 0 | $assembly->instruction(action=>"leAddress", | |||||||||||||||||||||||||||||||||||||||||
| 1573 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1575 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1576 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 1577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1579 | |||||||||||||||||||||||||||||||||||||||||||
| 1580 | sub LeArea($;$) { # Load the address component. | ||||||||||||||||||||||||||||||||||||||||||
| 1581 | 0 | ▶ | if (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
LeArea: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1582 | 0 | {my ($source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 1583 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1584 | 0 | $assembly->instruction(action=>"leArea", | |||||||||||||||||||||||||||||||||||||||||
| 1585 | target=>RefLeft($t), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1586 | 0 | return $t; | |||||||||||||||||||||||||||||||||||||||||
| 1587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1588 | elsif (@ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 1589 | 0 | {my ($target, $source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 1590 | 0 | $assembly->instruction(action=>"leArea", | |||||||||||||||||||||||||||||||||||||||||
| 1591 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1593 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1594 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 1595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||||||||||||||||
| 1598 | sub Mov($;$) { # Copy a constant or memory address to the target address. | ||||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | ▶ | if (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Mov: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1600 | 0 | {my ($source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 1601 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1602 | 0 | $assembly->instruction(action=>"mov", target=>RefLeft($t),xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1603 | 0 | return $t; | |||||||||||||||||||||||||||||||||||||||||
| 1604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1605 | elsif (@ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 1606 | 0 | {my ($target, $source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 1607 | 0 | $assembly->instruction(action=>"mov", xTarget($target), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1608 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1609 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1610 | 0 | {confess "One or two parameters required for mov"; | |||||||||||||||||||||||||||||||||||||||||
| 1611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1612 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1613 | |||||||||||||||||||||||||||||||||||||||||||
| 1614 | sub Not($) { # Move and not. | ||||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | ▶ | if (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Not: not called CC=3 SCAR=24.8
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1616 | 0 | {my ($source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 1617 | 0 | my $t = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1618 | 0 | $assembly->instruction(action=>"not", target=>RefLeft($t),xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | return $t; | |||||||||||||||||||||||||||||||||||||||||
| 1620 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1621 | elsif (@ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 1622 | 0 | {my ($target, $source) = @_; # Target address, source address | |||||||||||||||||||||||||||||||||||||||||
| 1623 | 0 | $assembly->instruction(action=>"not", xTarget($target), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1624 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1625 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1626 | 0 | {confess "One or two parameters required for not"; | |||||||||||||||||||||||||||||||||||||||||
| 1627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1628 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||||||||||||
| 1630 | sub Nop() # Do nothing (but do it well!). | ||||||||||||||||||||||||||||||||||||||||||
| 1631 | 0 | ▶ | {$assembly->instruction(action=>"nop"); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Nop: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1632 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||||||||||||||||
| 1634 | sub Out($) # Write memory contents to out. | ||||||||||||||||||||||||||||||||||||||||||
| 1635 | 0 | ▶ | {my ($source) = @_; # Either a scalar constant or memory address to output | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Out: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1636 | 0 | $assembly->instruction(action=>"out", xSource($source)) | |||||||||||||||||||||||||||||||||||||||||
| 1637 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1638 | |||||||||||||||||||||||||||||||||||||||||||
| 1639 | sub Procedure($$) # Define a procedure. | ||||||||||||||||||||||||||||||||||||||||||
| 1640 | 0 | ▶ | {my ($name, $source) = @_; # Name of procedure, source code as a subroutine# $assembly->instruction(action=>"procedure", target=>$target, source=>$source); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Procedure: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1641 | 0 | ▶ | if ($name and my $n = $assembly->procedures->{$name}) # Reuse existing named procedure | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name and my $n = $assembly->procedures->{$name}
MC/DC0%0/2
$name and my $n = $assembly->procedures->{$name}
$name
my $n = $assembly->procedures->{$name}
Truth table0%0/3
A and B
A= $nameB= my $n = $assembly->procedures->{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 1642 | 0 | {return $n; | |||||||||||||||||||||||||||||||||||||||||
| 1643 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||
| 1645 | 0 | Jmp(my $end = label); # Jump over the code of the procedure body | |||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | my $start = setLabel; | |||||||||||||||||||||||||||||||||||||||||
| 1647 | 0 | my $p = procedure($start); # Procedure description | |||||||||||||||||||||||||||||||||||||||||
| 1648 | 0 | my $save_registers = $assembly->variables; | |||||||||||||||||||||||||||||||||||||||||
| 1649 | 0 | $assembly->variables = $p->variables; | |||||||||||||||||||||||||||||||||||||||||
| 1650 | 0 | &$source($p); # Code of procedure called with start label as a parameter | |||||||||||||||||||||||||||||||||||||||||
| 1651 | 0 | &Return; | |||||||||||||||||||||||||||||||||||||||||
| 1652 | 0 | $assembly->variables = $save_registers; | |||||||||||||||||||||||||||||||||||||||||
| 1653 | |||||||||||||||||||||||||||||||||||||||||||
| 1654 | 0 | setLabel $end; | |||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | $assembly->procedures->{$name} = $p; # Return the start of the procedure | |||||||||||||||||||||||||||||||||||||||||
| 1656 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1657 | |||||||||||||||||||||||||||||||||||||||||||
| 1658 | sub ParamsGet($;$) { # Get a word from the parameters in the previous frame and store it in the current frame. | ||||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | ▶ | if (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ParamsGet: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | {my ($source) = @_; # Memory address to place parameter in, parameter number | |||||||||||||||||||||||||||||||||||||||||
| 1661 | 0 | my $p = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1662 | 0 | $assembly->instruction(action=>"paramsGet", | |||||||||||||||||||||||||||||||||||||||||
| 1663 | target=>RefLeft($p), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1664 | 0 | return $p; | |||||||||||||||||||||||||||||||||||||||||
| 1665 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1666 | elsif (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 1667 | 0 | {my ($target, $source) = @_; # Memory address to place parameter in, parameter number | |||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | $assembly->instruction(action=>"paramsGet", | |||||||||||||||||||||||||||||||||||||||||
| 1669 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1670 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1671 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1672 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 1673 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1674 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||||||||||||||||
| 1676 | sub ParamsPut($$) # Put a word into the parameters list to make it visible in a called procedure. | ||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | ▶ | {my ($target, $source) = @_; # Parameter number, address to fetch parameter from | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ParamsPut: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1678 | 0 | $assembly->instruction(action=>"paramsPut", | |||||||||||||||||||||||||||||||||||||||||
| 1679 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1681 | |||||||||||||||||||||||||||||||||||||||||||
| 1682 | sub Return() # Return from a procedure via the call stack. | ||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | ▶ | {$assembly->instruction(action=>"return"); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Return: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1684 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1685 | |||||||||||||||||||||||||||||||||||||||||||
| 1686 | sub ReturnGet($;$) { # Get a word from the return area and save it. | ||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | ▶ | if (@_ == 1) # Create a variable | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ReturnGet: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1688 | 0 | {my ($source) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 1689 | 0 | my $p = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1690 | 0 | $assembly->instruction(action=>"returnGet", | |||||||||||||||||||||||||||||||||||||||||
| 1691 | target=>RefLeft($p), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1692 | 0 | return $p; | |||||||||||||||||||||||||||||||||||||||||
| 1693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1694 | elsif (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 1695 | 0 | {my ($target, $source) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 1696 | 0 | $assembly->instruction(action=>"returnGet", | |||||||||||||||||||||||||||||||||||||||||
| 1697 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1698 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1699 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1700 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 1701 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1702 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1703 | |||||||||||||||||||||||||||||||||||||||||||
| 1704 | sub ReturnPut($$) # Put a word into the return area. | ||||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | ▶ | {my ($target, $source) = @_; # Offset in return area to write to, memory address whose contents are to be placed in the return area | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ReturnPut: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1706 | 0 | $assembly->instruction(action=>"returnPut", | |||||||||||||||||||||||||||||||||||||||||
| 1707 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1708 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1709 | |||||||||||||||||||||||||||||||||||||||||||
| 1710 | sub Resize($$) # Resize the target area to the source size. | ||||||||||||||||||||||||||||||||||||||||||
| 1711 | 0 | ▶ | {my ($target, $source) = @_; # Target address, source address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Resize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1712 | 0 | $assembly->instruction(action=>"resize", xTarget($target), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1713 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1714 | |||||||||||||||||||||||||||||||||||||||||||
| 1715 | sub Pop(;$$) { # Pop the memory area specified by the source operand into the memory address specified by the target operand. | ||||||||||||||||||||||||||||||||||||||||||
| 1716 | 0 | ▶ | if (@_ == 0) # Pop current stack frame into a local variable | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Pop: not called CC=4 SCAR=30.0
Pod
undocumented
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1717 | 0 | {my $p = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1718 | 0 | my $i = $assembly->instruction(action=>"pop", target=>RefLeft($p)); | |||||||||||||||||||||||||||||||||||||||||
| 1719 | 0 | $i->source = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1720 | 0 | return $p; | |||||||||||||||||||||||||||||||||||||||||
| 1721 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1722 | elsif (@_ == 1) # Pop indicated area into a local variable | ||||||||||||||||||||||||||||||||||||||||||
| 1723 | 0 | {my ($source) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 1724 | 0 | my $p = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1725 | 0 | $assembly->instruction(action=>"pop", target=>RefLeft($p),xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1726 | 0 | return $p; | |||||||||||||||||||||||||||||||||||||||||
| 1727 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1728 | elsif (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 1729 | 0 | {my ($target, $source) = @_; # Pop indicated area into target address | |||||||||||||||||||||||||||||||||||||||||
| 1730 | 0 | $assembly->instruction(action=>"pop", xTarget($target), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1731 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1732 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1733 | 0 | {confess "Zero, One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 1734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1735 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1736 | |||||||||||||||||||||||||||||||||||||||||||
| 1737 | sub Push($;$) { # Push the value in the current stack frame specified by the source operand onto the memory area identified by the target operand.. | ||||||||||||||||||||||||||||||||||||||||||
| 1738 | 0 | ▶ | if (@_ == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Push: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1739 | 0 | {my ($source) = @_; # Push a value onto the current stack frame | |||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | $assembly->instruction(action=>"push", xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1741 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1742 | elsif (@_ == 2) # Push a value onto the specified memory area | ||||||||||||||||||||||||||||||||||||||||||
| 1743 | 0 | {my ($target, $source) = @_; # Memory area to push to, memory containing value to push | |||||||||||||||||||||||||||||||||||||||||
| 1744 | 0 | $assembly->instruction(action=>"push", xTarget($target), xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1745 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1746 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1747 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 1748 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1749 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1750 | |||||||||||||||||||||||||||||||||||||||||||
| 1751 | sub ShiftLeft($;$) { # Shift left within an element. | ||||||||||||||||||||||||||||||||||||||||||
| 1752 | 0 | ▶ | my ($target, $source) = @_; # Target to shift, amount to shift | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ShiftLeft: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1753 | 0 | $assembly->instruction(action=>"shiftLeft", | |||||||||||||||||||||||||||||||||||||||||
| 1754 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1755 | 0 | $target | |||||||||||||||||||||||||||||||||||||||||
| 1756 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1757 | |||||||||||||||||||||||||||||||||||||||||||
| 1758 | sub ShiftRight($;$) { # Shift right with an element. | ||||||||||||||||||||||||||||||||||||||||||
| 1759 | 0 | ▶ | my ($target, $source) = @_; # Target to shift, amount to shift | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ShiftRight: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1760 | 0 | $assembly->instruction(action=>"shiftRight", | |||||||||||||||||||||||||||||||||||||||||
| 1761 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1762 | 0 | $target | |||||||||||||||||||||||||||||||||||||||||
| 1763 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1764 | |||||||||||||||||||||||||||||||||||||||||||
| 1765 | sub ShiftUp($;$) # Shift an element up one in an area. | ||||||||||||||||||||||||||||||||||||||||||
| 1766 | 0 | ▶ | {my ($target, $source) = @_; # Target to shift, amount to shift | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ShiftUp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1767 | 0 | $assembly->instruction(action=>"shiftUp", | |||||||||||||||||||||||||||||||||||||||||
| 1768 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1769 | 0 | $target | |||||||||||||||||||||||||||||||||||||||||
| 1770 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||||||||||||||||
| 1772 | sub ShiftDown($;$) { # Shift an element down one in an area. | ||||||||||||||||||||||||||||||||||||||||||
| 1773 | 0 | ▶ | if (@_ == 1) # Create a variable | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ShiftDown: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1774 | 0 | {my ($source) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 1775 | 0 | my $p = &Var(); | |||||||||||||||||||||||||||||||||||||||||
| 1776 | 0 | $assembly->instruction(action=>"shiftDown", | |||||||||||||||||||||||||||||||||||||||||
| 1777 | target=>RefLeft($p), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1778 | 0 | return $p; | |||||||||||||||||||||||||||||||||||||||||
| 1779 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1780 | elsif (@_ == 2) | ||||||||||||||||||||||||||||||||||||||||||
| 1781 | 0 | {my ($target, $source) = @_; # Memory address to place return value in, return value to get | |||||||||||||||||||||||||||||||||||||||||
| 1782 | 0 | $assembly->instruction(action=>"shiftDown", | |||||||||||||||||||||||||||||||||||||||||
| 1783 | xTarget($target), xSource($source)); | ||||||||||||||||||||||||||||||||||||||||||
| 1784 | 0 | confess "Needs work"; | |||||||||||||||||||||||||||||||||||||||||
| 1785 | 0 | return $target; | |||||||||||||||||||||||||||||||||||||||||
| 1786 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1787 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1788 | 0 | {confess "One or two parameters required"; | |||||||||||||||||||||||||||||||||||||||||
| 1789 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1790 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1791 | |||||||||||||||||||||||||||||||||||||||||||
| 1792 | sub Watch($) # Shift an element down one in an area. | ||||||||||||||||||||||||||||||||||||||||||
| 1793 | 0 | ▶ | {my ($target) = @_; # Memory address to watch | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Watch: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1794 | 0 | $assembly->instruction(action=>"watch", xTarget($target)); | |||||||||||||||||||||||||||||||||||||||||
| 1795 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||||||||||||||||
| 1797 | sub Tally($) # Counts instructions when enabled. | ||||||||||||||||||||||||||||||||||||||||||
| 1798 | 0 | ▶ | {my ($source) = @_; # Tally instructions when true | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Tally: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1799 | 0 | $assembly->instruction(action=>"tally", xSource($source)); | |||||||||||||||||||||||||||||||||||||||||
| 1800 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1801 | |||||||||||||||||||||||||||||||||||||||||||
| 1802 | sub Then(&) # Then block. | ||||||||||||||||||||||||||||||||||||||||||
| 1803 | 0 | ▶ | {my ($t) = @_; # Then block subroutine | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Then: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1805 | 0 | (then=> $t) | |||||||||||||||||||||||||||||||||||||||||
| 1806 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1807 | |||||||||||||||||||||||||||||||||||||||||||
| 1808 | sub Else(&) # Else block. | ||||||||||||||||||||||||||||||||||||||||||
| 1809 | 0 | ▶ | {my ($e) = @_; # Else block subroutine | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Else: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1810 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1811 | 0 | (else=> $e) | |||||||||||||||||||||||||||||||||||||||||
| 1812 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||||||||||||||||
| 1814 | sub Ifx($$$%) #P Execute then or else clause depending on whether two memory locations are equal.. | ||||||||||||||||||||||||||||||||||||||||||
| 1815 | 0 | ▶ | {my ($cmp, $a, $b, %options) = @_; # Comparison, first memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Ifx: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1816 | 0 | ▶ | confess "Then required" unless $options{then}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1817 | 0 | ▶ | if ($options{else}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1818 | 0 | {my $else = label; | |||||||||||||||||||||||||||||||||||||||||
| 1819 | 0 | my $end = label; | |||||||||||||||||||||||||||||||||||||||||
| 1820 | 0 | &$cmp($else, $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 1821 | 0 | TracePoint level=>2; | |||||||||||||||||||||||||||||||||||||||||
| 1822 | 0 | &{$options{then}}; | |||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | Jmp $end; | |||||||||||||||||||||||||||||||||||||||||
| 1824 | 0 | setLabel($else); | |||||||||||||||||||||||||||||||||||||||||
| 1825 | 0 | TracePoint level=>2; | |||||||||||||||||||||||||||||||||||||||||
| 1826 | 0 | &{$options{else}}; | |||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | setLabel($end); | |||||||||||||||||||||||||||||||||||||||||
| 1828 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1829 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1830 | 0 | {my $end = label; | |||||||||||||||||||||||||||||||||||||||||
| 1831 | 0 | &$cmp($end, $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 1832 | 0 | &{$options{then}}; | |||||||||||||||||||||||||||||||||||||||||
| 1833 | 0 | setLabel($end); | |||||||||||||||||||||||||||||||||||||||||
| 1834 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1835 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1836 | |||||||||||||||||||||||||||||||||||||||||||
| 1837 | sub IfFalse($%) # Execute then clause if the specified memory address is zero representing false. | ||||||||||||||||||||||||||||||||||||||||||
| 1838 | 0 | ▶ | {my ($a, %options) = @_; # Memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfFalse: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1839 | 0 | Ifx(\&Jne, $a, 0, %options); | |||||||||||||||||||||||||||||||||||||||||
| 1840 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||||||||||||||||
| 1842 | sub IfTrue($%) # Execute then clause if the specified memory address is not zero representing true. | ||||||||||||||||||||||||||||||||||||||||||
| 1843 | 0 | ▶ | {my ($a, %options) = @_; # Memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfTrue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1844 | 0 | Ifx(\&Jeq, $a, 0, %options); | |||||||||||||||||||||||||||||||||||||||||
| 1845 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1846 | |||||||||||||||||||||||||||||||||||||||||||
| 1847 | sub IfEq($$%) # Execute then or else clause depending on whether two memory locations are equal.. | ||||||||||||||||||||||||||||||||||||||||||
| 1848 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfEq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1849 | 0 | Ifx(\&Jne, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 1850 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||||||||||||
| 1852 | sub IfNe($$%) # Execute then or else clause depending on whether two memory locations are not equal.. | ||||||||||||||||||||||||||||||||||||||||||
| 1853 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfNe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1854 | 0 | Ifx(\&Jeq, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 1855 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1856 | |||||||||||||||||||||||||||||||||||||||||||
| 1857 | sub IfLt($$%) # Execute then or else clause depending on whether two memory locations are less than.. | ||||||||||||||||||||||||||||||||||||||||||
| 1858 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfLt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1859 | 0 | Ifx(\&Jge, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 1860 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||||||||||||||||
| 1862 | sub IfLe($$%) # Execute then or else clause depending on whether two memory locations are less than or equal.. | ||||||||||||||||||||||||||||||||||||||||||
| 1863 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfLe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1864 | 0 | Ifx(\&Jgt, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 1865 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1866 | |||||||||||||||||||||||||||||||||||||||||||
| 1867 | sub IfGt($$%) # Execute then or else clause depending on whether two memory locations are greater than.. | ||||||||||||||||||||||||||||||||||||||||||
| 1868 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfGt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1869 | 0 | Ifx(\&Jle, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 1870 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1871 | |||||||||||||||||||||||||||||||||||||||||||
| 1872 | sub IfGe($$%) # Execute then or else clause depending on whether two memory locations are greater than or equal.. | ||||||||||||||||||||||||||||||||||||||||||
| 1873 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address, then block, else block | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IfGe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1874 | 0 | Ifx(\&Jlt, $a, $b, %options); | |||||||||||||||||||||||||||||||||||||||||
| 1875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1876 | |||||||||||||||||||||||||||||||||||||||||||
| 1877 | sub AssertOp($$$) #P Assert operation. | ||||||||||||||||||||||||||||||||||||||||||
| 1878 | 0 | ▶ | {my ($op, $a, $b) = @_; # Operation, First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertOp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1879 | 0 | $assembly->instruction(action=>"assert$op", | |||||||||||||||||||||||||||||||||||||||||
| 1880 | xSource($a), xSource2($b), level=>2); | ||||||||||||||||||||||||||||||||||||||||||
| 1881 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1882 | |||||||||||||||||||||||||||||||||||||||||||
| 1883 | sub Assert(%) # Assert regardless. | ||||||||||||||||||||||||||||||||||||||||||
| 1884 | 0 | ▶ | {my (%options) = @_; # Options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Assert: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1885 | 0 | $assembly->instruction(action=>"assert"); | |||||||||||||||||||||||||||||||||||||||||
| 1886 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1887 | |||||||||||||||||||||||||||||||||||||||||||
| 1888 | sub AssertEq($$%) # Assert two memory locations are equal.. | ||||||||||||||||||||||||||||||||||||||||||
| 1889 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertEq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1890 | 0 | AssertOp("Eq", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 1891 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1892 | |||||||||||||||||||||||||||||||||||||||||||
| 1893 | sub AssertNe($$%) # Assert two memory locations are not equal.. | ||||||||||||||||||||||||||||||||||||||||||
| 1894 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertNe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1895 | 0 | AssertOp("Ne", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 1896 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1897 | |||||||||||||||||||||||||||||||||||||||||||
| 1898 | sub AssertLt($$%) # Assert two memory locations are less than.. | ||||||||||||||||||||||||||||||||||||||||||
| 1899 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertLt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1900 | 0 | AssertOp("Lt", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 1901 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1902 | |||||||||||||||||||||||||||||||||||||||||||
| 1903 | sub AssertLe($$%) # Assert two memory locations are less than or equal.. | ||||||||||||||||||||||||||||||||||||||||||
| 1904 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertLe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1905 | 0 | AssertOp("Le", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 1906 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1907 | |||||||||||||||||||||||||||||||||||||||||||
| 1908 | sub AssertGt($$%) # Assert two memory locations are greater than.. | ||||||||||||||||||||||||||||||||||||||||||
| 1909 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertGt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1910 | 0 | AssertOp("Gt", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 1911 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1912 | |||||||||||||||||||||||||||||||||||||||||||
| 1913 | sub AssertGe($$%) # Assert are greater than or equal.. | ||||||||||||||||||||||||||||||||||||||||||
| 1914 | 0 | ▶ | {my ($a, $b, %options) = @_; # First memory address, second memory address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssertGe: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1915 | 0 | AssertOp("Ge", $a, $b); | |||||||||||||||||||||||||||||||||||||||||
| 1916 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||||||||||||||||
| 1918 | sub For(&$%) # For loop 0..range-1 or in reverse. | ||||||||||||||||||||||||||||||||||||||||||
| 1919 | 0 | ▶ | {my ($block, $range, %options) = @_; # Block, limit, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
For: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1920 | 0 | ▶ | if (!exists $options{reverse}) # Ascending order | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1921 | 0 | {my $s = 0; my $e = $range; # Start, end | |||||||||||||||||||||||||||||||||||||||||
| 1922 | 0 | ▶ | ($s, $e) = @$range if ref($e) =~ m(ARRAY); # Start, end as a reference | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1923 | |||||||||||||||||||||||||||||||||||||||||||
| 1924 | 0 | my ($Start, $Check, $Next, $End) = (label, label, label, label); | |||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||
| 1926 | 0 | setLabel($Start); # Start | |||||||||||||||||||||||||||||||||||||||||
| 1927 | 0 | my $i = Mov $s; | |||||||||||||||||||||||||||||||||||||||||
| 1928 | 0 | setLabel($Check); # Check | |||||||||||||||||||||||||||||||||||||||||
| 1929 | 0 | Jge $End, $i, $e; | |||||||||||||||||||||||||||||||||||||||||
| 1930 | 0 | TracePoint level=>2; | |||||||||||||||||||||||||||||||||||||||||
| 1931 | 0 | &$block($i, $Check, $Next, $End); # Block | |||||||||||||||||||||||||||||||||||||||||
| 1932 | 0 | setLabel($Next); | |||||||||||||||||||||||||||||||||||||||||
| 1933 | 0 | Inc $i; # Next | |||||||||||||||||||||||||||||||||||||||||
| 1934 | 0 | Jmp $Check; | |||||||||||||||||||||||||||||||||||||||||
| 1935 | 0 | setLabel($End); # End | |||||||||||||||||||||||||||||||||||||||||
| 1936 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1937 | else | ||||||||||||||||||||||||||||||||||||||||||
| 1938 | 0 | {my $s = $range; my $e = 0; # Start, end | |||||||||||||||||||||||||||||||||||||||||
| 1939 | 0 | ▶ | ($e, $s) = @$range if ref($e) =~ m(ARRAY); # End, start as a reference | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1940 | |||||||||||||||||||||||||||||||||||||||||||
| 1941 | 0 | my ($Start, $Check, $Next, $End) = (label, label, label, label); | |||||||||||||||||||||||||||||||||||||||||
| 1942 | |||||||||||||||||||||||||||||||||||||||||||
| 1943 | 0 | setLabel($Start); # Start | |||||||||||||||||||||||||||||||||||||||||
| 1944 | 0 | my $i = Subtract $s, 1; | |||||||||||||||||||||||||||||||||||||||||
| 1945 | 0 | Subtract $i, $s; | |||||||||||||||||||||||||||||||||||||||||
| 1946 | 0 | setLabel($Check); # Check | |||||||||||||||||||||||||||||||||||||||||
| 1947 | 0 | Jlt $End, $i, $e; | |||||||||||||||||||||||||||||||||||||||||
| 1948 | 0 | TracePoint level=>2; | |||||||||||||||||||||||||||||||||||||||||
| 1949 | 0 | &$block($i, $Check, $Next, $End); # Block | |||||||||||||||||||||||||||||||||||||||||
| 1950 | 0 | setLabel($Next); | |||||||||||||||||||||||||||||||||||||||||
| 1951 | 0 | Dec $i; # Next | |||||||||||||||||||||||||||||||||||||||||
| 1952 | 0 | Jmp $Check; | |||||||||||||||||||||||||||||||||||||||||
| 1953 | 0 | setLabel($End); # End | |||||||||||||||||||||||||||||||||||||||||
| 1954 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1955 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1956 | |||||||||||||||||||||||||||||||||||||||||||
| 1957 | sub ForArray(&$$%) # For loop to process each element of the named area. | ||||||||||||||||||||||||||||||||||||||||||
| 1958 | 0 | ▶ | {my ($block, $area, $name, %options) = @_; # Block of code, area, area name, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ForArray: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1959 | 0 | my $e = AreaSize $area, $name; # End | |||||||||||||||||||||||||||||||||||||||||
| 1960 | 0 | my $s = 0; # Start | |||||||||||||||||||||||||||||||||||||||||
| 1961 | |||||||||||||||||||||||||||||||||||||||||||
| 1962 | 0 | my ($Start, $Check, $Next, $End) = (label, label, label, label); | |||||||||||||||||||||||||||||||||||||||||
| 1963 | |||||||||||||||||||||||||||||||||||||||||||
| 1964 | 0 | setLabel($Start); # Start | |||||||||||||||||||||||||||||||||||||||||
| 1965 | 0 | my $i = Mov $s; | |||||||||||||||||||||||||||||||||||||||||
| 1966 | 0 | setLabel($Check); # Check | |||||||||||||||||||||||||||||||||||||||||
| 1967 | 0 | Jge $End, $i, $e; | |||||||||||||||||||||||||||||||||||||||||
| 1968 | 0 | TracePoint level=>2; | |||||||||||||||||||||||||||||||||||||||||
| 1969 | 0 | my $a = Mov [$area, \$i, $name]; | |||||||||||||||||||||||||||||||||||||||||
| 1970 | 0 | &$block($i, $a, $Check, $Next, $End); # Block | |||||||||||||||||||||||||||||||||||||||||
| 1971 | 0 | setLabel($Next); | |||||||||||||||||||||||||||||||||||||||||
| 1972 | 0 | Inc $i; # Next | |||||||||||||||||||||||||||||||||||||||||
| 1973 | 0 | Jmp $Check; | |||||||||||||||||||||||||||||||||||||||||
| 1974 | 0 | setLabel($End); # End | |||||||||||||||||||||||||||||||||||||||||
| 1975 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1976 | |||||||||||||||||||||||||||||||||||||||||||
| 1977 | sub Good(&) # A good ending. | ||||||||||||||||||||||||||||||||||||||||||
| 1978 | 0 | ▶ | {my ($good) = @_; # What to do on a good ending | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Good: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1979 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1980 | 0 | (good=> $good) | |||||||||||||||||||||||||||||||||||||||||
| 1981 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1982 | |||||||||||||||||||||||||||||||||||||||||||
| 1983 | sub Bad(&) # A bad ending. | ||||||||||||||||||||||||||||||||||||||||||
| 1984 | 0 | ▶ | {my ($bad) = @_; # What to do on a bad ending | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Bad: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1985 | 0 | ▶ | @_ == 1 or confess "One parameter"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1986 | 0 | (bad=> $bad) | |||||||||||||||||||||||||||||||||||||||||
| 1987 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1988 | |||||||||||||||||||||||||||||||||||||||||||
| 1989 | sub Block(&%) # Block of code that can either be restarted or come to a good or a bad ending. | ||||||||||||||||||||||||||||||||||||||||||
| 1990 | 0 | ▶ | {my ($block, %options) = @_; # Block, options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Block: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1991 | 0 | my ($Start, $Good, $Bad, $End) = (label, label, label, label); | |||||||||||||||||||||||||||||||||||||||||
| 1992 | |||||||||||||||||||||||||||||||||||||||||||
| 1993 | 0 | my $g = $options{good}; | |||||||||||||||||||||||||||||||||||||||||
| 1994 | 0 | my $b = $options{bad}; | |||||||||||||||||||||||||||||||||||||||||
| 1995 | |||||||||||||||||||||||||||||||||||||||||||
| 1996 | 0 | setLabel($Start); # Start | |||||||||||||||||||||||||||||||||||||||||
| 1997 | |||||||||||||||||||||||||||||||||||||||||||
| 1998 | 0 | TracePoint level=>2; | |||||||||||||||||||||||||||||||||||||||||
| 1999 | 0 | &$block($Start, $Good, $Bad, $End); # Code of block | |||||||||||||||||||||||||||||||||||||||||
| 2000 | |||||||||||||||||||||||||||||||||||||||||||
| 2001 | 0 | ▶ | if ($g) # Good | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2002 | 0 | {Jmp $End; | |||||||||||||||||||||||||||||||||||||||||
| 2003 | 0 | setLabel($Good); | |||||||||||||||||||||||||||||||||||||||||
| 2004 | 0 | TracePoint level=>2; | |||||||||||||||||||||||||||||||||||||||||
| 2005 | 0 | &$g; | |||||||||||||||||||||||||||||||||||||||||
| 2006 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2007 | |||||||||||||||||||||||||||||||||||||||||||
| 2008 | 0 | ▶ | if ($b) # Bad | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2009 | 0 | {Jmp $End; | |||||||||||||||||||||||||||||||||||||||||
| 2010 | 0 | setLabel($Bad); | |||||||||||||||||||||||||||||||||||||||||
| 2011 | 0 | TracePoint level=>2; | |||||||||||||||||||||||||||||||||||||||||
| 2012 | 0 | &$b; | |||||||||||||||||||||||||||||||||||||||||
| 2013 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2014 | 0 | setLabel($End); # End | |||||||||||||||||||||||||||||||||||||||||
| 2015 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2016 | |||||||||||||||||||||||||||||||||||||||||||
| 2017 | sub Var(;$) #P Create a variable initialized to the specified value. | ||||||||||||||||||||||||||||||||||||||||||
| 2018 | 0 | ▶ | {my ($value) = @_; # Value | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Var: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2019 | 0 | my $i = $assembly->registers; | |||||||||||||||||||||||||||||||||||||||||
| 2020 | 0 | my $a = $assembly->variables; | |||||||||||||||||||||||||||||||||||||||||
| 2021 | 0 | my $v = $a->count-1; | |||||||||||||||||||||||||||||||||||||||||
| 2022 | 0 | my $c = $assembly->code->@*; | |||||||||||||||||||||||||||||||||||||||||
| 2023 | # $a->instructions->[$v] = $c; | ||||||||||||||||||||||||||||||||||||||||||
| 2024 | |||||||||||||||||||||||||||||||||||||||||||
| 2025 | 0 | ▶ | Mov $i, $value if defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2026 | 0 | $i | |||||||||||||||||||||||||||||||||||||||||
| 2027 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2028 | |||||||||||||||||||||||||||||||||||||||||||
| 2029 | sub Execute(%) # Execute the current assembly. | ||||||||||||||||||||||||||||||||||||||||||
| 2030 | 0 | ▶ | {my (%options) = @_; # Options | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Execute: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2031 | 0 | my $r = $assembly->execute(%options); # Execute the code in the current assembly | |||||||||||||||||||||||||||||||||||||||||
| 2032 | 0 | ▶ | if (my $out = $options{out}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2033 | 0 | {my $c = compareArraysAndExplain $r->out, $out; | |||||||||||||||||||||||||||||||||||||||||
| 2034 | 0 | ▶ | lll $c if $c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2035 | 0 | ▶ | say STDERR dump($r->out) if $c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2036 | 0 | ▶ | return 0 if $c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2037 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2038 | 0 | ▶ | if (my $memory = $options{memory}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2039 | 0 | {my $E = dump $memory; | |||||||||||||||||||||||||||||||||||||||||
| 2040 | 0 | my $G = dump $r->memory; | |||||||||||||||||||||||||||||||||||||||||
| 2041 | 0 | my $e = [split "\n", $E]; | |||||||||||||||||||||||||||||||||||||||||
| 2042 | 0 | my $g = [split "\n", $G]; | |||||||||||||||||||||||||||||||||||||||||
| 2043 | 0 | my $c = compareArraysAndExplain $g, $e; | |||||||||||||||||||||||||||||||||||||||||
| 2044 | 0 | ▶ | lll "$c\n$G\n" if $c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2045 | 0 | ▶ | return 0 if $c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2046 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2047 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||
| 2048 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2049 | |||||||||||||||||||||||||||||||||||||||||||
| 2050 | 1 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2051 | 1 | ▶ | use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2052 | |||||||||||||||||||||||||||||||||||||||||||
| 2053 | 1 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 2054 | 1 | @EXPORT = qw(); | |||||||||||||||||||||||||||||||||||||||||
| 2055 | 1 | @EXPORT_OK = qw(Add AreaStructure Array Assert AssertEq AssertGe AssertGt AssertLe AssertLt AssertNe Bad Block Call Clear Confess Dec Dump DumpArray Else Execute For ForArray Free Good IfEq IfFalse IfGe IfGt IfLe IfLt IfNe IfTrue Ifx Inc Jeq Jge Jgt Jle Jlt Jmp Jne Label Mov Nop Not Out ParamsGet ParamsPut Pop Procedure Push Resize Return ReturnGet ReturnPut ShiftDown ShiftLeft ShiftRight ShiftUp Start Subtract Tally Then Trace TracePoints Var Watch); | |||||||||||||||||||||||||||||||||||||||||
| 2056 | #say STDERR '@EXPORT_OK = qw(', (join ' ', sort @EXPORT_OK), ')'; exit; | ||||||||||||||||||||||||||||||||||||||||||
| 2057 | 1 | %EXPORT_TAGS = (all=>[@EXPORT, @EXPORT_OK]); | |||||||||||||||||||||||||||||||||||||||||
| 2058 | |||||||||||||||||||||||||||||||||||||||||||
| 2059 | 1 | ▶ | return 1 if caller; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2060 | |||||||||||||||||||||||||||||||||||||||||||
| 2061 | 0 | Test::More->builder->output("/dev/null"); # Reduce number of confirmation messages during testing | |||||||||||||||||||||||||||||||||||||||||
| 2062 | |||||||||||||||||||||||||||||||||||||||||||
| 2063 | 0 | eval {goto latest}; | |||||||||||||||||||||||||||||||||||||||||
| 2064 | sub is_deeply; | ||||||||||||||||||||||||||||||||||||||||||
| 2065 | sub ok($;$); | ||||||||||||||||||||||||||||||||||||||||||
| 2066 | |||||||||||||||||||||||||||||||||||||||||||
| 2067 | #D1 Tests | ||||||||||||||||||||||||||||||||||||||||||
| 2068 | |||||||||||||||||||||||||||||||||||||||||||
| 2069 | 0 | if (1) # Address dereferencing | |||||||||||||||||||||||||||||||||||||||||
| 2070 | 0 | {my $e = execute->createInitialStackEntry->setMemoryType(1, 'aaa'); | |||||||||||||||||||||||||||||||||||||||||
| 2071 | 0 | my $s = $e->stackArea; | |||||||||||||||||||||||||||||||||||||||||
| 2072 | |||||||||||||||||||||||||||||||||||||||||||
| 2073 | 0 | $e->set(RefLeft([ 1, 1, 'aaa']), 99); | |||||||||||||||||||||||||||||||||||||||||
| 2074 | 0 | $e->set(RefLeft([$s, 2, $s]), 1); | |||||||||||||||||||||||||||||||||||||||||
| 2075 | |||||||||||||||||||||||||||||||||||||||||||
| 2076 | 0 | is_deeply $e->right(RefRight [1, \1, 'aaa']), 99; | |||||||||||||||||||||||||||||||||||||||||
| 2077 | 0 | is_deeply $e->right(RefRight [1, \\2, 'aaa']), 99; | |||||||||||||||||||||||||||||||||||||||||
| 2078 | |||||||||||||||||||||||||||||||||||||||||||
| 2079 | 0 | is_deeply $e->left (RefLeft [1, \1, 'aaa']), {address=>1, area=>1, name=>"aaa"}; | |||||||||||||||||||||||||||||||||||||||||
| 2080 | 0 | is_deeply $e->left (RefLeft [1, \\2, 'aaa']), {address=>1, area=>1, name=>"aaa"}; | |||||||||||||||||||||||||||||||||||||||||
| 2081 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2082 | |||||||||||||||||||||||||||||||||||||||||||
| 2083 | #D1 Examples | ||||||||||||||||||||||||||||||||||||||||||
| 2084 | |||||||||||||||||||||||||||||||||||||||||||
| 2085 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2086 | 0 | if (1) #TOut #TStart #TExecute | |||||||||||||||||||||||||||||||||||||||||
| 2087 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2088 | 0 | Out "hello World"; | |||||||||||||||||||||||||||||||||||||||||
| 2089 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2090 | 0 | is_deeply $e->out, ["hello World"]; | |||||||||||||||||||||||||||||||||||||||||
| 2091 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2092 | |||||||||||||||||||||||||||||||||||||||||||
| 2093 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2094 | 0 | if (1) #TNop | |||||||||||||||||||||||||||||||||||||||||
| 2095 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2096 | 0 | Nop; | |||||||||||||||||||||||||||||||||||||||||
| 2097 | 0 | ok Execute(out=>[]); | |||||||||||||||||||||||||||||||||||||||||
| 2098 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2099 | |||||||||||||||||||||||||||||||||||||||||||
| 2100 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2101 | 0 | if (1) #TMov | |||||||||||||||||||||||||||||||||||||||||
| 2102 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2103 | 0 | my $a = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 2104 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2105 | |||||||||||||||||||||||||||||||||||||||||||
| 2106 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2107 | 0 | is_deeply $e->out, [2]; | |||||||||||||||||||||||||||||||||||||||||
| 2108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2109 | |||||||||||||||||||||||||||||||||||||||||||
| 2110 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2111 | 0 | if (1) | |||||||||||||||||||||||||||||||||||||||||
| 2112 | 0 | {Start 1; #TMov | |||||||||||||||||||||||||||||||||||||||||
| 2113 | 0 | my $a = Mov 3; | |||||||||||||||||||||||||||||||||||||||||
| 2114 | 0 | my $b = Mov $$a; | |||||||||||||||||||||||||||||||||||||||||
| 2115 | 0 | my $c = Mov \$b; | |||||||||||||||||||||||||||||||||||||||||
| 2116 | 0 | Out $c; | |||||||||||||||||||||||||||||||||||||||||
| 2117 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2118 | 0 | is_deeply $e->out, [3]; | |||||||||||||||||||||||||||||||||||||||||
| 2119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||||||||||||||||
| 2121 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2122 | 0 | if (1) #TAdd | |||||||||||||||||||||||||||||||||||||||||
| 2123 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2124 | 0 | my $a = Add 3, 2; | |||||||||||||||||||||||||||||||||||||||||
| 2125 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2126 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2127 | 0 | is_deeply $e->out, [5]; | |||||||||||||||||||||||||||||||||||||||||
| 2128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2129 | |||||||||||||||||||||||||||||||||||||||||||
| 2130 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2131 | 0 | if (1) #TAdd #TSubtract | |||||||||||||||||||||||||||||||||||||||||
| 2132 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2133 | 0 | my $a = Subtract 4, 2; | |||||||||||||||||||||||||||||||||||||||||
| 2134 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2135 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2136 | 0 | is_deeply $e->out, [2]; | |||||||||||||||||||||||||||||||||||||||||
| 2137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||||||||||||||||
| 2139 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2140 | 0 | if (1) #TDec | |||||||||||||||||||||||||||||||||||||||||
| 2141 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2142 | 0 | my $a = Mov 3; | |||||||||||||||||||||||||||||||||||||||||
| 2143 | 0 | Dec $a; | |||||||||||||||||||||||||||||||||||||||||
| 2144 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2145 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2146 | 0 | is_deeply $e->out, [2]; | |||||||||||||||||||||||||||||||||||||||||
| 2147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2148 | |||||||||||||||||||||||||||||||||||||||||||
| 2149 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2150 | 0 | if (1) #TInc | |||||||||||||||||||||||||||||||||||||||||
| 2151 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2152 | 0 | my $a = Mov 3; | |||||||||||||||||||||||||||||||||||||||||
| 2153 | 0 | Inc $a; | |||||||||||||||||||||||||||||||||||||||||
| 2154 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2155 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2156 | 0 | is_deeply $e->out, [4]; | |||||||||||||||||||||||||||||||||||||||||
| 2157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2158 | |||||||||||||||||||||||||||||||||||||||||||
| 2159 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2160 | 0 | if (1) #TNot | |||||||||||||||||||||||||||||||||||||||||
| 2161 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2162 | 0 | my $a = Mov 3; | |||||||||||||||||||||||||||||||||||||||||
| 2163 | 0 | my $b = Not $a; | |||||||||||||||||||||||||||||||||||||||||
| 2164 | 0 | my $c = Not $b; | |||||||||||||||||||||||||||||||||||||||||
| 2165 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2166 | 0 | Out $b; | |||||||||||||||||||||||||||||||||||||||||
| 2167 | 0 | Out $c; | |||||||||||||||||||||||||||||||||||||||||
| 2168 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2169 | 0 | is_deeply $e->out, [3, "", 1]; | |||||||||||||||||||||||||||||||||||||||||
| 2170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2171 | |||||||||||||||||||||||||||||||||||||||||||
| 2172 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2173 | 0 | if (1) #TShiftLeft | |||||||||||||||||||||||||||||||||||||||||
| 2174 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2175 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 2176 | 0 | ShiftLeft $a, $a; | |||||||||||||||||||||||||||||||||||||||||
| 2177 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2178 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2179 | 0 | is_deeply $e->out, [2]; | |||||||||||||||||||||||||||||||||||||||||
| 2180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2181 | |||||||||||||||||||||||||||||||||||||||||||
| 2182 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2183 | 0 | if (1) #TShiftRight | |||||||||||||||||||||||||||||||||||||||||
| 2184 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2185 | 0 | my $a = Mov 4; | |||||||||||||||||||||||||||||||||||||||||
| 2186 | 0 | ShiftRight $a, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2187 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2188 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2189 | 0 | is_deeply $e->out, [2]; | |||||||||||||||||||||||||||||||||||||||||
| 2190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2191 | |||||||||||||||||||||||||||||||||||||||||||
| 2192 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2193 | 0 | if (1) #TJmp | |||||||||||||||||||||||||||||||||||||||||
| 2194 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2195 | 0 | Jmp (my $a = label); | |||||||||||||||||||||||||||||||||||||||||
| 2196 | 0 | Out 1; | |||||||||||||||||||||||||||||||||||||||||
| 2197 | 0 | Jmp (my $b = label); | |||||||||||||||||||||||||||||||||||||||||
| 2198 | 0 | setLabel($a); | |||||||||||||||||||||||||||||||||||||||||
| 2199 | 0 | Out 2; | |||||||||||||||||||||||||||||||||||||||||
| 2200 | 0 | setLabel($b); | |||||||||||||||||||||||||||||||||||||||||
| 2201 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2202 | 0 | is_deeply $e->out, [2]; | |||||||||||||||||||||||||||||||||||||||||
| 2203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2204 | |||||||||||||||||||||||||||||||||||||||||||
| 2205 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2206 | 0 | if (1) #TJLt #TLabel | |||||||||||||||||||||||||||||||||||||||||
| 2207 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2208 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2209 | 0 | Jlt ((my $a = label), \0, 2); | |||||||||||||||||||||||||||||||||||||||||
| 2210 | 0 | Out 1; | |||||||||||||||||||||||||||||||||||||||||
| 2211 | 0 | Jmp (my $b = label); | |||||||||||||||||||||||||||||||||||||||||
| 2212 | 0 | setLabel($a); | |||||||||||||||||||||||||||||||||||||||||
| 2213 | 0 | Out 2; | |||||||||||||||||||||||||||||||||||||||||
| 2214 | 0 | setLabel($b); | |||||||||||||||||||||||||||||||||||||||||
| 2215 | |||||||||||||||||||||||||||||||||||||||||||
| 2216 | 0 | Jgt ((my $c = label), \0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 2217 | 0 | Out 1; | |||||||||||||||||||||||||||||||||||||||||
| 2218 | 0 | Jmp (my $d = label); | |||||||||||||||||||||||||||||||||||||||||
| 2219 | 0 | setLabel($c); | |||||||||||||||||||||||||||||||||||||||||
| 2220 | 0 | Out 2; | |||||||||||||||||||||||||||||||||||||||||
| 2221 | 0 | setLabel($d); | |||||||||||||||||||||||||||||||||||||||||
| 2222 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2223 | 0 | is_deeply $e->out, [2,1]; | |||||||||||||||||||||||||||||||||||||||||
| 2224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2225 | |||||||||||||||||||||||||||||||||||||||||||
| 2226 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2227 | 0 | if (1) #TLabel | |||||||||||||||||||||||||||||||||||||||||
| 2228 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2229 | 0 | Mov 0, 0; | |||||||||||||||||||||||||||||||||||||||||
| 2230 | 0 | my $a = setLabel; | |||||||||||||||||||||||||||||||||||||||||
| 2231 | 0 | Out \0; | |||||||||||||||||||||||||||||||||||||||||
| 2232 | 0 | Inc \0; | |||||||||||||||||||||||||||||||||||||||||
| 2233 | 0 | Jlt $a, \0, 10; | |||||||||||||||||||||||||||||||||||||||||
| 2234 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2235 | 0 | is_deeply $e->out, [0..9]; | |||||||||||||||||||||||||||||||||||||||||
| 2236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2237 | |||||||||||||||||||||||||||||||||||||||||||
| 2238 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2239 | 0 | if (1) #TMov | |||||||||||||||||||||||||||||||||||||||||
| 2240 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2241 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 2242 | 0 | Mov [$a, 1, "aaa"], 11; | |||||||||||||||||||||||||||||||||||||||||
| 2243 | 0 | Mov 1, [$a, \1, "aaa"]; | |||||||||||||||||||||||||||||||||||||||||
| 2244 | 0 | Out \1; | |||||||||||||||||||||||||||||||||||||||||
| 2245 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2246 | 0 | is_deeply $e->out, [11]; | |||||||||||||||||||||||||||||||||||||||||
| 2247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2248 | |||||||||||||||||||||||||||||||||||||||||||
| 2249 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2250 | 0 | if (1) #TCall #TReturn | |||||||||||||||||||||||||||||||||||||||||
| 2251 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2252 | my $w = Procedure 'write', sub | ||||||||||||||||||||||||||||||||||||||||||
| 2253 | 0 | ▶ | {Out 'aaa'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2254 | 0 | Return; | |||||||||||||||||||||||||||||||||||||||||
| 2255 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2256 | 0 | Call $w; | |||||||||||||||||||||||||||||||||||||||||
| 2257 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2258 | 0 | is_deeply $e->out, ["aaa"]; | |||||||||||||||||||||||||||||||||||||||||
| 2259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2260 | |||||||||||||||||||||||||||||||||||||||||||
| 2261 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2262 | 0 | if (1) #TCall | |||||||||||||||||||||||||||||||||||||||||
| 2263 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2264 | my $w = Procedure 'write', sub | ||||||||||||||||||||||||||||||||||||||||||
| 2265 | 0 | ▶ | {my $a = ParamsGet 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2266 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2267 | 0 | Return; | |||||||||||||||||||||||||||||||||||||||||
| 2268 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2269 | 0 | ParamsPut 0, 'bbb'; | |||||||||||||||||||||||||||||||||||||||||
| 2270 | 0 | Call $w; | |||||||||||||||||||||||||||||||||||||||||
| 2271 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2272 | 0 | is_deeply $e->out, ["bbb"]; | |||||||||||||||||||||||||||||||||||||||||
| 2273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2274 | |||||||||||||||||||||||||||||||||||||||||||
| 2275 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2276 | 0 | if (1) #TCall #TReturnPut #TReturnGet | |||||||||||||||||||||||||||||||||||||||||
| 2277 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2278 | my $w = Procedure 'write', sub | ||||||||||||||||||||||||||||||||||||||||||
| 2279 | 0 | ▶ | {ReturnPut 0, "ccc"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2280 | 0 | Return; | |||||||||||||||||||||||||||||||||||||||||
| 2281 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2282 | 0 | Call $w; | |||||||||||||||||||||||||||||||||||||||||
| 2283 | 0 | ReturnGet \0, 0; | |||||||||||||||||||||||||||||||||||||||||
| 2284 | 0 | Out \0; | |||||||||||||||||||||||||||||||||||||||||
| 2285 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2286 | 0 | is_deeply $e->out, ["ccc"]; | |||||||||||||||||||||||||||||||||||||||||
| 2287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2288 | |||||||||||||||||||||||||||||||||||||||||||
| 2289 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2290 | 0 | if (1) #TProcedure | |||||||||||||||||||||||||||||||||||||||||
| 2291 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2292 | my $add = Procedure 'add2', sub | ||||||||||||||||||||||||||||||||||||||||||
| 2293 | 0 | ▶ | {my $a = ParamsGet 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2294 | 0 | my $b = Add $a, 2; | |||||||||||||||||||||||||||||||||||||||||
| 2295 | 0 | ReturnPut 0, $b; | |||||||||||||||||||||||||||||||||||||||||
| 2296 | 0 | Return; | |||||||||||||||||||||||||||||||||||||||||
| 2297 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2298 | 0 | ParamsPut 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 2299 | 0 | Call $add; | |||||||||||||||||||||||||||||||||||||||||
| 2300 | 0 | my $c = ReturnGet 0; | |||||||||||||||||||||||||||||||||||||||||
| 2301 | 0 | Out $c; | |||||||||||||||||||||||||||||||||||||||||
| 2302 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2303 | 0 | is_deeply $e->out, [4]; | |||||||||||||||||||||||||||||||||||||||||
| 2304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2305 | |||||||||||||||||||||||||||||||||||||||||||
| 2306 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2307 | 0 | if (1) #TConfess | |||||||||||||||||||||||||||||||||||||||||
| 2308 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2309 | my $c = Procedure 'confess', sub | ||||||||||||||||||||||||||||||||||||||||||
| 2310 | 0 | ▶ | {Confess; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2311 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2312 | 0 | Call $c; | |||||||||||||||||||||||||||||||||||||||||
| 2313 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2314 | 0 | is_deeply $e->out, ["Confess at:", " 2 3 confess", " 1 6 call"]; | |||||||||||||||||||||||||||||||||||||||||
| 2315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2316 | |||||||||||||||||||||||||||||||||||||||||||
| 2317 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2318 | 0 | if (1) #TPush #TPop | |||||||||||||||||||||||||||||||||||||||||
| 2319 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2320 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 2321 | 0 | Push $a, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2322 | 0 | Push $a, 2; | |||||||||||||||||||||||||||||||||||||||||
| 2323 | 0 | my $c = Pop $a; | |||||||||||||||||||||||||||||||||||||||||
| 2324 | 0 | my $d = Pop $a; | |||||||||||||||||||||||||||||||||||||||||
| 2325 | |||||||||||||||||||||||||||||||||||||||||||
| 2326 | 0 | Out $c; | |||||||||||||||||||||||||||||||||||||||||
| 2327 | 0 | Out $d; | |||||||||||||||||||||||||||||||||||||||||
| 2328 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2329 | 0 | is_deeply $e->out, [2, 1]; | |||||||||||||||||||||||||||||||||||||||||
| 2330 | 0 | is_deeply $e->memory, { 1=> []}; | |||||||||||||||||||||||||||||||||||||||||
| 2331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2332 | |||||||||||||||||||||||||||||||||||||||||||
| 2333 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2334 | 0 | if (1) #TAlloc #TMov | |||||||||||||||||||||||||||||||||||||||||
| 2335 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2336 | 0 | my $a = Array "alloc"; | |||||||||||||||||||||||||||||||||||||||||
| 2337 | 0 | my $b = Mov 99; | |||||||||||||||||||||||||||||||||||||||||
| 2338 | 0 | my $c = Mov $a; | |||||||||||||||||||||||||||||||||||||||||
| 2339 | 0 | Mov [$a, 0, 'alloc'], $b; | |||||||||||||||||||||||||||||||||||||||||
| 2340 | 0 | Mov [$c, 1, 'alloc'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 2341 | 0 | ok Execute(memory=> { 1=> bless([99, 2], "alloc") }); | |||||||||||||||||||||||||||||||||||||||||
| 2342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2343 | |||||||||||||||||||||||||||||||||||||||||||
| 2344 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2345 | 0 | if (1) #TFree | |||||||||||||||||||||||||||||||||||||||||
| 2346 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2347 | 0 | my $a = Array "node"; | |||||||||||||||||||||||||||||||||||||||||
| 2348 | 0 | Free $a, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 2349 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2350 | |||||||||||||||||||||||||||||||||||||||||||
| 2351 | 0 | is_deeply $e->out, [ | |||||||||||||||||||||||||||||||||||||||||
| 2352 | "Wrong name: aaa for area with name: node", | ||||||||||||||||||||||||||||||||||||||||||
| 2353 | " 1 2 free", | ||||||||||||||||||||||||||||||||||||||||||
| 2354 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 2355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2356 | |||||||||||||||||||||||||||||||||||||||||||
| 2357 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2358 | 0 | if (1) #TFree #TDump | |||||||||||||||||||||||||||||||||||||||||
| 2359 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2360 | 0 | my $a = Array "node"; | |||||||||||||||||||||||||||||||||||||||||
| 2361 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2362 | 0 | Mov [$a, 1, 'node'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 2363 | 0 | Mov [$a, 2, 'node'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 2364 | 0 | Mov 1, [$a, \1, 'node']; | |||||||||||||||||||||||||||||||||||||||||
| 2365 | 0 | Dump "dddd"; | |||||||||||||||||||||||||||||||||||||||||
| 2366 | 0 | Free $a, "node"; | |||||||||||||||||||||||||||||||||||||||||
| 2367 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2368 | |||||||||||||||||||||||||||||||||||||||||||
| 2369 | 0 | is_deeply $e->out, [ | |||||||||||||||||||||||||||||||||||||||||
| 2370 | 1, | ||||||||||||||||||||||||||||||||||||||||||
| 2371 | "dddd", | ||||||||||||||||||||||||||||||||||||||||||
| 2372 | "-2=bless([], \"return\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2373 | "-1=bless([], \"params\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2374 | "0=bless([1, 1], \"stackArea\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2375 | "1=bless([undef, 1, 2], \"node\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2376 | "Stack trace", | ||||||||||||||||||||||||||||||||||||||||||
| 2377 | " 1 6 dump", | ||||||||||||||||||||||||||||||||||||||||||
| 2378 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 2379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2380 | |||||||||||||||||||||||||||||||||||||||||||
| 2381 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2382 | 0 | if (1) # Layout | |||||||||||||||||||||||||||||||||||||||||
| 2383 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2384 | 0 | my $a = Mov 'A'; | |||||||||||||||||||||||||||||||||||||||||
| 2385 | 0 | my $b = Mov 'B'; | |||||||||||||||||||||||||||||||||||||||||
| 2386 | 0 | my $c = Mov 'C'; | |||||||||||||||||||||||||||||||||||||||||
| 2387 | 0 | Out $c; | |||||||||||||||||||||||||||||||||||||||||
| 2388 | 0 | Out $b; | |||||||||||||||||||||||||||||||||||||||||
| 2389 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2390 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2391 | 0 | is_deeply $e->out, [qw(C B A)]; | |||||||||||||||||||||||||||||||||||||||||
| 2392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2393 | |||||||||||||||||||||||||||||||||||||||||||
| 2394 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2395 | 0 | if (1) #TIfEq #TIfNe #TIfLt #TIfLe #TIfGt #TIfGe | |||||||||||||||||||||||||||||||||||||||||
| 2396 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2397 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 2398 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 2399 | 0 | ▶ | IfEq $a, $a, Then {Out "Eq"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2400 | 0 | ▶ | IfNe $a, $a, Then {Out "Ne"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2401 | 0 | ▶ | IfLe $a, $a, Then {Out "Le"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2402 | 0 | ▶ | IfLt $a, $a, Then {Out "Lt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2403 | 0 | ▶ | IfGe $a, $a, Then {Out "Ge"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2404 | 0 | ▶ | IfGt $a, $a, Then {Out "Gt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2405 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2406 | 0 | is_deeply $e->out, ["Eq", "Le", "Ge"]; | |||||||||||||||||||||||||||||||||||||||||
| 2407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2408 | |||||||||||||||||||||||||||||||||||||||||||
| 2409 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2410 | 0 | if (1) #TIfEq #TIfNe #TIfLt #TIfLe #TIfGt #TIfGe | |||||||||||||||||||||||||||||||||||||||||
| 2411 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2412 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 2413 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 2414 | 0 | ▶ | IfEq $a, $b, Then {Out "Eq"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2415 | 0 | ▶ | IfNe $a, $b, Then {Out "Ne"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2416 | 0 | ▶ | IfLe $a, $b, Then {Out "Le"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2417 | 0 | ▶ | IfLt $a, $b, Then {Out "Lt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2418 | 0 | ▶ | IfGe $a, $b, Then {Out "Ge"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2419 | 0 | ▶ | IfGt $a, $b, Then {Out "Gt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2420 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2421 | 0 | is_deeply $e->out, ["Ne", "Le", "Lt"]; | |||||||||||||||||||||||||||||||||||||||||
| 2422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2423 | |||||||||||||||||||||||||||||||||||||||||||
| 2424 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2425 | 0 | if (1) #TIfEq #TIfNe #TIfLt #TIfLe #TIfGt #TIfGe | |||||||||||||||||||||||||||||||||||||||||
| 2426 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2427 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 2428 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 2429 | 0 | ▶ | IfEq $b, $a, Then {Out "Eq"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2430 | 0 | ▶ | IfNe $b, $a, Then {Out "Ne"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2431 | 0 | ▶ | IfLe $b, $a, Then {Out "Le"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2432 | 0 | ▶ | IfLt $b, $a, Then {Out "Lt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2433 | 0 | ▶ | IfGe $b, $a, Then {Out "Ge"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2434 | 0 | ▶ | IfGt $b, $a, Then {Out "Gt"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2435 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2436 | 0 | is_deeply $e->out, ["Ne", "Ge", "Gt"]; | |||||||||||||||||||||||||||||||||||||||||
| 2437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2438 | |||||||||||||||||||||||||||||||||||||||||||
| 2439 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2440 | 0 | if (1) #TIfTrue | |||||||||||||||||||||||||||||||||||||||||
| 2441 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2442 | IfTrue 1, | ||||||||||||||||||||||||||||||||||||||||||
| 2443 | Then | ||||||||||||||||||||||||||||||||||||||||||
| 2444 | 0 | ▶ | {Out 1 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2445 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2446 | Else | ||||||||||||||||||||||||||||||||||||||||||
| 2447 | 0 | ▶ | {Out 0 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2448 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2449 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2450 | 0 | is_deeply $e->out, [1]; | |||||||||||||||||||||||||||||||||||||||||
| 2451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2452 | |||||||||||||||||||||||||||||||||||||||||||
| 2453 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2454 | 0 | if (1) #TIfFalse #TTrue #TFalse | |||||||||||||||||||||||||||||||||||||||||
| 2455 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2456 | IfFalse 1, | ||||||||||||||||||||||||||||||||||||||||||
| 2457 | Then | ||||||||||||||||||||||||||||||||||||||||||
| 2458 | 0 | ▶ | {Out 1 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2459 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2460 | Else | ||||||||||||||||||||||||||||||||||||||||||
| 2461 | 0 | ▶ | {Out 0 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2462 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2463 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2464 | 0 | is_deeply $e->out, [0]; | |||||||||||||||||||||||||||||||||||||||||
| 2465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2466 | |||||||||||||||||||||||||||||||||||||||||||
| 2467 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2468 | 0 | if (1) #TForLoop | |||||||||||||||||||||||||||||||||||||||||
| 2469 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2470 | For | ||||||||||||||||||||||||||||||||||||||||||
| 2471 | 0 | ▶ | {my ($i) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2472 | 0 | Out $i; | |||||||||||||||||||||||||||||||||||||||||
| 2473 | 0 | } 10; | |||||||||||||||||||||||||||||||||||||||||
| 2474 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2475 | 0 | is_deeply $e->out, [0..9]; | |||||||||||||||||||||||||||||||||||||||||
| 2476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2477 | |||||||||||||||||||||||||||||||||||||||||||
| 2478 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2479 | 0 | if (1) #TForLoop | |||||||||||||||||||||||||||||||||||||||||
| 2480 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2481 | For | ||||||||||||||||||||||||||||||||||||||||||
| 2482 | 0 | ▶ | {my ($i) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2483 | 0 | Out $i; | |||||||||||||||||||||||||||||||||||||||||
| 2484 | 0 | } 10, reverse=>1; | |||||||||||||||||||||||||||||||||||||||||
| 2485 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2486 | 0 | is_deeply $e->out, [reverse 0..9]; | |||||||||||||||||||||||||||||||||||||||||
| 2487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2488 | |||||||||||||||||||||||||||||||||||||||||||
| 2489 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2490 | 0 | if (1) #TForLoop | |||||||||||||||||||||||||||||||||||||||||
| 2491 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2492 | For | ||||||||||||||||||||||||||||||||||||||||||
| 2493 | 0 | ▶ | {my ($i) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2494 | 0 | Out $i; | |||||||||||||||||||||||||||||||||||||||||
| 2495 | 0 | } [2, 10]; | |||||||||||||||||||||||||||||||||||||||||
| 2496 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2497 | 0 | is_deeply $e->out, [2..9]; | |||||||||||||||||||||||||||||||||||||||||
| 2498 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2499 | |||||||||||||||||||||||||||||||||||||||||||
| 2500 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2501 | 0 | if (1) #TAssert | |||||||||||||||||||||||||||||||||||||||||
| 2502 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2503 | 0 | Assert; | |||||||||||||||||||||||||||||||||||||||||
| 2504 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2505 | 0 | is_deeply $e->out, ["Assert failed", " 1 1 assert"]; | |||||||||||||||||||||||||||||||||||||||||
| 2506 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2507 | |||||||||||||||||||||||||||||||||||||||||||
| 2508 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2509 | 0 | if (1) #TAssertEq | |||||||||||||||||||||||||||||||||||||||||
| 2510 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2511 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2512 | 0 | AssertEq \0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 2513 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2514 | 0 | is_deeply $e->out, ["Assert 1 == 2 failed", " 1 2 assertEq"]; | |||||||||||||||||||||||||||||||||||||||||
| 2515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2516 | |||||||||||||||||||||||||||||||||||||||||||
| 2517 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2518 | 0 | if (1) #TAssertNe | |||||||||||||||||||||||||||||||||||||||||
| 2519 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2520 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2521 | 0 | AssertNe \0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2522 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2523 | 0 | is_deeply $e->out, ["Assert 1 != 1 failed", " 1 2 assertNe"]; | |||||||||||||||||||||||||||||||||||||||||
| 2524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2525 | |||||||||||||||||||||||||||||||||||||||||||
| 2526 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2527 | 0 | if (1) #TAssertLt | |||||||||||||||||||||||||||||||||||||||||
| 2528 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2529 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2530 | 0 | AssertLt \0, 0; | |||||||||||||||||||||||||||||||||||||||||
| 2531 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2532 | 0 | is_deeply $e->out, ["Assert 1 < 0 failed", " 1 2 assertLt"]; | |||||||||||||||||||||||||||||||||||||||||
| 2533 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2534 | |||||||||||||||||||||||||||||||||||||||||||
| 2535 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2536 | 0 | if (1) #TAssertLe | |||||||||||||||||||||||||||||||||||||||||
| 2537 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2538 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2539 | 0 | AssertLe \0, 0; | |||||||||||||||||||||||||||||||||||||||||
| 2540 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2541 | 0 | is_deeply $e->out, ["Assert 1 <= 0 failed", " 1 2 assertLe"]; | |||||||||||||||||||||||||||||||||||||||||
| 2542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2543 | |||||||||||||||||||||||||||||||||||||||||||
| 2544 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2545 | 0 | if (1) #TAssertGt | |||||||||||||||||||||||||||||||||||||||||
| 2546 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2547 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2548 | 0 | AssertGt \0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 2549 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2550 | 0 | is_deeply $e->out, ["Assert 1 > 2 failed", " 1 2 assertGt"]; | |||||||||||||||||||||||||||||||||||||||||
| 2551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2552 | |||||||||||||||||||||||||||||||||||||||||||
| 2553 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2554 | 0 | if (1) #TAssertGe | |||||||||||||||||||||||||||||||||||||||||
| 2555 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2556 | 0 | Mov 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2557 | 0 | AssertGe \0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 2558 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2559 | 0 | is_deeply $e->out, ["Assert 1 >= 2 failed", " 1 2 assertGe"]; | |||||||||||||||||||||||||||||||||||||||||
| 2560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2561 | |||||||||||||||||||||||||||||||||||||||||||
| 2562 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2563 | 0 | if (1) # Temporary variable | |||||||||||||||||||||||||||||||||||||||||
| 2564 | 0 | {my $s = Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2565 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 2566 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 2567 | 0 | Out $a; | |||||||||||||||||||||||||||||||||||||||||
| 2568 | 0 | Out $b; | |||||||||||||||||||||||||||||||||||||||||
| 2569 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2570 | 0 | is_deeply $e->out, [1..2]; | |||||||||||||||||||||||||||||||||||||||||
| 2571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2572 | |||||||||||||||||||||||||||||||||||||||||||
| 2573 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2574 | 0 | if (1) #TAlloc #TMov #TCall | |||||||||||||||||||||||||||||||||||||||||
| 2575 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2576 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 2577 | 0 | Dump "dddd"; | |||||||||||||||||||||||||||||||||||||||||
| 2578 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2579 | 0 | is_deeply $e->out, [ | |||||||||||||||||||||||||||||||||||||||||
| 2580 | "dddd", | ||||||||||||||||||||||||||||||||||||||||||
| 2581 | "-2=bless([], \"return\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2582 | "-1=bless([], \"params\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2583 | "0=bless([1], \"stackArea\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2584 | "1=bless([], \"aaa\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2585 | "Stack trace", | ||||||||||||||||||||||||||||||||||||||||||
| 2586 | " 1 2 dump", | ||||||||||||||||||||||||||||||||||||||||||
| 2587 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 2588 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2589 | |||||||||||||||||||||||||||||||||||||||||||
| 2590 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2591 | 0 | if (1) #TAlloc #TMov #TCall #TParamsPut #TParamsGet | |||||||||||||||||||||||||||||||||||||||||
| 2592 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2593 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 2594 | 0 | my $i = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 2595 | 0 | my $v = Mov 11; | |||||||||||||||||||||||||||||||||||||||||
| 2596 | 0 | ParamsPut 0, $a; | |||||||||||||||||||||||||||||||||||||||||
| 2597 | 0 | ParamsPut 1, $i; | |||||||||||||||||||||||||||||||||||||||||
| 2598 | 0 | ParamsPut 2, $v; | |||||||||||||||||||||||||||||||||||||||||
| 2599 | my $set = Procedure 'set', sub | ||||||||||||||||||||||||||||||||||||||||||
| 2600 | 0 | ▶ | {my $a = ParamsGet 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2601 | 0 | my $i = ParamsGet 1; | |||||||||||||||||||||||||||||||||||||||||
| 2602 | 0 | my $v = ParamsGet 2; | |||||||||||||||||||||||||||||||||||||||||
| 2603 | 0 | Mov [$a, \$i, 'aaa'], $v; | |||||||||||||||||||||||||||||||||||||||||
| 2604 | 0 | Return; | |||||||||||||||||||||||||||||||||||||||||
| 2605 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2606 | 0 | Call $set; | |||||||||||||||||||||||||||||||||||||||||
| 2607 | 0 | my $V = Mov [$a, \$i, 'aaa']; | |||||||||||||||||||||||||||||||||||||||||
| 2608 | 0 | AssertEq $v, $V; | |||||||||||||||||||||||||||||||||||||||||
| 2609 | 0 | Out [$a, \$i, 'aaa']; | |||||||||||||||||||||||||||||||||||||||||
| 2610 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2611 | 0 | is_deeply $e->out, [11]; | |||||||||||||||||||||||||||||||||||||||||
| 2612 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2613 | |||||||||||||||||||||||||||||||||||||||||||
| 2614 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2615 | 0 | if (1) #TAlloc #TClear | |||||||||||||||||||||||||||||||||||||||||
| 2616 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2617 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 2618 | 0 | Clear [$a, 10, 'aaa']; | |||||||||||||||||||||||||||||||||||||||||
| 2619 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2620 | 0 | is_deeply $e->memory->{1}, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | |||||||||||||||||||||||||||||||||||||||||
| 2621 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2622 | |||||||||||||||||||||||||||||||||||||||||||
| 2623 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2624 | 0 | if (1) #TBlock #TGood #TBad | |||||||||||||||||||||||||||||||||||||||||
| 2625 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2626 | Block | ||||||||||||||||||||||||||||||||||||||||||
| 2627 | 0 | ▶ | {my ($start, $good, $bad, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2628 | 0 | Out 1; | |||||||||||||||||||||||||||||||||||||||||
| 2629 | 0 | Jmp $good; | |||||||||||||||||||||||||||||||||||||||||
| 2630 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2631 | Good | ||||||||||||||||||||||||||||||||||||||||||
| 2632 | 0 | ▶ | {Out 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2633 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2634 | Bad | ||||||||||||||||||||||||||||||||||||||||||
| 2635 | 0 | ▶ | {Out 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2636 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2637 | 0 | Out 4; | |||||||||||||||||||||||||||||||||||||||||
| 2638 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2639 | 0 | is_deeply $e->out, [1,2,4]; | |||||||||||||||||||||||||||||||||||||||||
| 2640 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2641 | |||||||||||||||||||||||||||||||||||||||||||
| 2642 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2643 | 0 | if (1) #TBlock | |||||||||||||||||||||||||||||||||||||||||
| 2644 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2645 | Block | ||||||||||||||||||||||||||||||||||||||||||
| 2646 | 0 | ▶ | {my ($start, $good, $bad, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2647 | 0 | Out 1; | |||||||||||||||||||||||||||||||||||||||||
| 2648 | 0 | Jmp $bad; | |||||||||||||||||||||||||||||||||||||||||
| 2649 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2650 | Good | ||||||||||||||||||||||||||||||||||||||||||
| 2651 | 0 | ▶ | {Out 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2652 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2653 | Bad | ||||||||||||||||||||||||||||||||||||||||||
| 2654 | 0 | ▶ | {Out 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2655 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2656 | 0 | Out 4; | |||||||||||||||||||||||||||||||||||||||||
| 2657 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2658 | 0 | is_deeply $e->out, [1,3,4]; | |||||||||||||||||||||||||||||||||||||||||
| 2659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2660 | |||||||||||||||||||||||||||||||||||||||||||
| 2661 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2662 | 0 | if (1) #TProcedure | |||||||||||||||||||||||||||||||||||||||||
| 2663 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2664 | 0 | for my $i(1..10) | |||||||||||||||||||||||||||||||||||||||||
| 2665 | 0 | {Out $i; | |||||||||||||||||||||||||||||||||||||||||
| 2666 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 2667 | IfTrue 0, | ||||||||||||||||||||||||||||||||||||||||||
| 2668 | Then | ||||||||||||||||||||||||||||||||||||||||||
| 2669 | 0 | ▶ | {Out 99; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2670 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2671 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2672 | 0 | is_deeply $e->out, [1..10]; | |||||||||||||||||||||||||||||||||||||||||
| 2673 | 0 | ok $e->analyzeExecutionResults(analyze=>3) =~ m(# 12 instructions executed); | |||||||||||||||||||||||||||||||||||||||||
| 2674 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2675 | |||||||||||||||||||||||||||||||||||||||||||
| 2676 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2677 | 0 | if (1) # Double write | |||||||||||||||||||||||||||||||||||||||||
| 2678 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2679 | 0 | Mov 1, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2680 | 0 | Mov 2, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2681 | 0 | Mov 3, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2682 | 0 | Mov 3, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2683 | 0 | Mov 1, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2684 | 0 | my $e = Execute(suppressOutput=>0); | |||||||||||||||||||||||||||||||||||||||||
| 2685 | 0 | is_deeply keys($e->doubleWrite->%*), 1; # In area 0, variable 1 was first written by instruction 0 then again by instruction 1 once. | |||||||||||||||||||||||||||||||||||||||||
| 2686 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2687 | |||||||||||||||||||||||||||||||||||||||||||
| 2688 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2689 | 0 | if (1) # Pointless assign | |||||||||||||||||||||||||||||||||||||||||
| 2690 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2691 | 0 | Add 2, 1, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2692 | 0 | Add 2, \2, 0; | |||||||||||||||||||||||||||||||||||||||||
| 2693 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2694 | 0 | is_deeply $e->pointlessAssign, { 1=> 1 }; | |||||||||||||||||||||||||||||||||||||||||
| 2695 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2696 | |||||||||||||||||||||||||||||||||||||||||||
| 2697 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2698 | 0 | if (0) # Not read | |||||||||||||||||||||||||||||||||||||||||
| 2699 | {Start 1; | ||||||||||||||||||||||||||||||||||||||||||
| 2700 | my $a = Mov 1; | ||||||||||||||||||||||||||||||||||||||||||
| 2701 | my $b = Mov $a; | ||||||||||||||||||||||||||||||||||||||||||
| 2702 | my $e = Execute(suppressOutput=>1); | ||||||||||||||||||||||||||||||||||||||||||
| 2703 | ok $e->notRead->{0}{1} == 1; # Area 0 == stack, variable 1 == $b generated by instruction 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2705 | |||||||||||||||||||||||||||||||||||||||||||
| 2706 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2707 | 0 | if (1) #TAlloc #TMov #TCall | |||||||||||||||||||||||||||||||||||||||||
| 2708 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2709 | my $set = Procedure 'set', sub | ||||||||||||||||||||||||||||||||||||||||||
| 2710 | 0 | ▶ | {my $a = ParamsGet 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2711 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2712 | 0 | ParamsPut 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2713 | 0 | Call $set; | |||||||||||||||||||||||||||||||||||||||||
| 2714 | 0 | ParamsPut 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2715 | 0 | Call $set; | |||||||||||||||||||||||||||||||||||||||||
| 2716 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2717 | 0 | is_deeply $e->out, []; | |||||||||||||||||||||||||||||||||||||||||
| 2718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2719 | |||||||||||||||||||||||||||||||||||||||||||
| 2720 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2721 | 0 | if (1) # Invalid address | |||||||||||||||||||||||||||||||||||||||||
| 2722 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2723 | 0 | Mov 1, \0; | |||||||||||||||||||||||||||||||||||||||||
| 2724 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2725 | 0 | my $t = join "\n", $e->out->@*; | |||||||||||||||||||||||||||||||||||||||||
| 2726 | 0 | ok $t =~ m"Cannot assign an undefined value"; | |||||||||||||||||||||||||||||||||||||||||
| 2727 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2728 | |||||||||||||||||||||||||||||||||||||||||||
| 2729 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2730 | 0 | if (1) #TLeArea #TLeAddress | |||||||||||||||||||||||||||||||||||||||||
| 2731 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2732 | 0 | my $a = Array "array"; | |||||||||||||||||||||||||||||||||||||||||
| 2733 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 2734 | 0 | my $c = Mov 5; | |||||||||||||||||||||||||||||||||||||||||
| 2735 | 0 | my $d = LeAddress $c; | |||||||||||||||||||||||||||||||||||||||||
| 2736 | 0 | my $f = LeArea [$a, \0, 'array']; | |||||||||||||||||||||||||||||||||||||||||
| 2737 | 0 | Out $d; | |||||||||||||||||||||||||||||||||||||||||
| 2738 | 0 | Out $f; | |||||||||||||||||||||||||||||||||||||||||
| 2739 | 0 | Mov [$a, \$b, 'array'], 22; | |||||||||||||||||||||||||||||||||||||||||
| 2740 | 0 | Mov [$a, \$c, 'array'], 33; | |||||||||||||||||||||||||||||||||||||||||
| 2741 | 0 | Mov [$f, \$d, 'array'], 44; | |||||||||||||||||||||||||||||||||||||||||
| 2742 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2743 | 0 | is_deeply $e->out, [2,1]; | |||||||||||||||||||||||||||||||||||||||||
| 2744 | 0 | is_deeply $e->memory, {1=>[undef, undef, 44, undef, undef, 33]}; | |||||||||||||||||||||||||||||||||||||||||
| 2745 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2746 | |||||||||||||||||||||||||||||||||||||||||||
| 2747 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2748 | 0 | if (1) #TShiftUp | |||||||||||||||||||||||||||||||||||||||||
| 2749 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2750 | 0 | my $a = Array "array"; | |||||||||||||||||||||||||||||||||||||||||
| 2751 | 0 | Mov [$a, 0, 'array'], 0; | |||||||||||||||||||||||||||||||||||||||||
| 2752 | 0 | Mov [$a, 1, 'array'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 2753 | 0 | Mov [$a, 2, 'array'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 2754 | 0 | ShiftUp [$a, 1, 'array'], 99; | |||||||||||||||||||||||||||||||||||||||||
| 2755 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2756 | 0 | is_deeply $e->memory, {1=>[0, 99, 1, 2]}; | |||||||||||||||||||||||||||||||||||||||||
| 2757 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2758 | |||||||||||||||||||||||||||||||||||||||||||
| 2759 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2760 | 0 | if (1) #TShiftDown | |||||||||||||||||||||||||||||||||||||||||
| 2761 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2762 | 0 | my $a = Array "array"; | |||||||||||||||||||||||||||||||||||||||||
| 2763 | 0 | Mov [$a, 0, 'array'], 0; | |||||||||||||||||||||||||||||||||||||||||
| 2764 | 0 | Mov [$a, 1, 'array'], 99; | |||||||||||||||||||||||||||||||||||||||||
| 2765 | 0 | Mov [$a, 2, 'array'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 2766 | 0 | my $b = ShiftDown [$a, \1, 'array']; | |||||||||||||||||||||||||||||||||||||||||
| 2767 | 0 | Out $b; | |||||||||||||||||||||||||||||||||||||||||
| 2768 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2769 | 0 | is_deeply $e->memory, {1=>[0, 2]}; | |||||||||||||||||||||||||||||||||||||||||
| 2770 | 0 | is_deeply $e->out, [99]; | |||||||||||||||||||||||||||||||||||||||||
| 2771 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2772 | |||||||||||||||||||||||||||||||||||||||||||
| 2773 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2774 | 0 | if (1) #TAlloc #TMov #TJeq #TJne #TJle #TJlt #TJge #TJgt | |||||||||||||||||||||||||||||||||||||||||
| 2775 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2776 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 2777 | 0 | my $b = Array "bbb"; | |||||||||||||||||||||||||||||||||||||||||
| 2778 | 0 | Mov [$a, 0, 'aaa'], $b; | |||||||||||||||||||||||||||||||||||||||||
| 2779 | 0 | Mov [$b, 0, 'bbb'], 99; | |||||||||||||||||||||||||||||||||||||||||
| 2780 | For | ||||||||||||||||||||||||||||||||||||||||||
| 2781 | 0 | ▶ | {my ($i, $check, $next, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2782 | 0 | my $c = Mov [$a, \0, 'aaa']; | |||||||||||||||||||||||||||||||||||||||||
| 2783 | 0 | my $d = Mov [$c, \0, 'bbb']; | |||||||||||||||||||||||||||||||||||||||||
| 2784 | 0 | Jeq $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 2785 | 0 | Jne $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 2786 | 0 | Jle $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 2787 | 0 | Jlt $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 2788 | 0 | Jge $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 2789 | 0 | Jgt $next, $d, $d; | |||||||||||||||||||||||||||||||||||||||||
| 2790 | 0 | } 3; | |||||||||||||||||||||||||||||||||||||||||
| 2791 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2792 | 0 | is_deeply $e->analyzeExecutionResults(doubleWrite=>3), "# 36 instructions executed"; | |||||||||||||||||||||||||||||||||||||||||
| 2793 | 0 | is_deeply $e->memory, { 1=> bless([2], "aaa"), 2=> bless([99], "bbb") }; | |||||||||||||||||||||||||||||||||||||||||
| 2794 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2795 | |||||||||||||||||||||||||||||||||||||||||||
| 2796 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2797 | 0 | if (1) #TAlloc #TMov | |||||||||||||||||||||||||||||||||||||||||
| 2798 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2799 | 0 | my $a = Array 'aaa'; | |||||||||||||||||||||||||||||||||||||||||
| 2800 | 0 | my $b = Mov 2; # Location to move to in a | |||||||||||||||||||||||||||||||||||||||||
| 2801 | For | ||||||||||||||||||||||||||||||||||||||||||
| 2802 | 0 | ▶ | {my ($i, $check, $next, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2803 | 0 | Mov [$a, \$b, 'aaa'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 2804 | 0 | Jeq $next, [$a, \$b, 'aaa'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 2805 | 0 | } 3; | |||||||||||||||||||||||||||||||||||||||||
| 2806 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2807 | 0 | is_deeply $e->analyzeExecutionResults(doubleWrite=>3), "# 31 instructions executed"; | |||||||||||||||||||||||||||||||||||||||||
| 2808 | 0 | is_deeply $e->memory, {1=> bless([undef, undef, 1], "aaa")}; | |||||||||||||||||||||||||||||||||||||||||
| 2809 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2810 | |||||||||||||||||||||||||||||||||||||||||||
| 2811 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2812 | 0 | if (1) #TResize | |||||||||||||||||||||||||||||||||||||||||
| 2813 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2814 | 0 | my $a = Array 'aaa'; | |||||||||||||||||||||||||||||||||||||||||
| 2815 | 0 | Mov [$a, 0, 'aaa'], 1; | |||||||||||||||||||||||||||||||||||||||||
| 2816 | 0 | Mov [$a, 1, 'aaa'], 2; | |||||||||||||||||||||||||||||||||||||||||
| 2817 | 0 | Mov [$a, 2, 'aaa'], 3; | |||||||||||||||||||||||||||||||||||||||||
| 2818 | 0 | Resize $a, 2; | |||||||||||||||||||||||||||||||||||||||||
| 2819 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2820 | 0 | is_deeply $e->memory, {1=> [1, 2]}; | |||||||||||||||||||||||||||||||||||||||||
| 2821 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2822 | |||||||||||||||||||||||||||||||||||||||||||
| 2823 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2824 | 0 | if (1) #TTrace #TThen #TElse | |||||||||||||||||||||||||||||||||||||||||
| 2825 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2826 | 0 | Trace 1; | |||||||||||||||||||||||||||||||||||||||||
| 2827 | IfEq 1, 2, | ||||||||||||||||||||||||||||||||||||||||||
| 2828 | Then | ||||||||||||||||||||||||||||||||||||||||||
| 2829 | 0 | ▶ | {Mov 1, 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2830 | 0 | Mov 2, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2831 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2832 | Else | ||||||||||||||||||||||||||||||||||||||||||
| 2833 | 0 | ▶ | {Mov 3, 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2834 | 0 | Mov 4, 4; | |||||||||||||||||||||||||||||||||||||||||
| 2835 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2836 | IfEq 2, 2, | ||||||||||||||||||||||||||||||||||||||||||
| 2837 | Then | ||||||||||||||||||||||||||||||||||||||||||
| 2838 | 0 | ▶ | {Mov 1, 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2839 | 0 | Mov 2, 1; | |||||||||||||||||||||||||||||||||||||||||
| 2840 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 2841 | Else | ||||||||||||||||||||||||||||||||||||||||||
| 2842 | 0 | ▶ | {Mov 3, 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2843 | 0 | Mov 4, 4; | |||||||||||||||||||||||||||||||||||||||||
| 2844 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2845 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2846 | 0 | is_deeply scalar($e->out->@*), 14; | |||||||||||||||||||||||||||||||||||||||||
| 2847 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2848 | |||||||||||||||||||||||||||||||||||||||||||
| 2849 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2850 | 0 | if (1) #TWatch | |||||||||||||||||||||||||||||||||||||||||
| 2851 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2852 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 2853 | 0 | my $b = Mov 2; | |||||||||||||||||||||||||||||||||||||||||
| 2854 | 0 | my $c = Mov 3; | |||||||||||||||||||||||||||||||||||||||||
| 2855 | 0 | Watch $b; | |||||||||||||||||||||||||||||||||||||||||
| 2856 | 0 | Mov $a, 4; | |||||||||||||||||||||||||||||||||||||||||
| 2857 | 0 | Mov $b, 5; | |||||||||||||||||||||||||||||||||||||||||
| 2858 | 0 | Mov $c, 6; | |||||||||||||||||||||||||||||||||||||||||
| 2859 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2860 | 0 | is_deeply $e->out, | |||||||||||||||||||||||||||||||||||||||||
| 2861 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 2862 | "Change at watched area: 0 (stackArea), address: 1\n", | ||||||||||||||||||||||||||||||||||||||||||
| 2863 | " 1 6 mov", | ||||||||||||||||||||||||||||||||||||||||||
| 2864 | "Current value: 2", | ||||||||||||||||||||||||||||||||||||||||||
| 2865 | "New value: 5", | ||||||||||||||||||||||||||||||||||||||||||
| 2866 | "-2=bless([], \"return\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2867 | "-1=bless([], \"params\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2868 | "0=bless([4, 2, 3], \"stackArea\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2869 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 2870 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2871 | |||||||||||||||||||||||||||||||||||||||||||
| 2872 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2873 | 0 | if (1) #TAreaSize #TForArray #TArray | |||||||||||||||||||||||||||||||||||||||||
| 2874 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2875 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 2876 | 0 | Mov [$a, 0, "aaa"], 1; | |||||||||||||||||||||||||||||||||||||||||
| 2877 | 0 | Mov [$a, 1, "aaa"], 22; | |||||||||||||||||||||||||||||||||||||||||
| 2878 | 0 | Mov [$a, 2, "aaa"], 333; | |||||||||||||||||||||||||||||||||||||||||
| 2879 | 0 | my $n = AreaSize $a, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 2880 | 0 | Out $n; | |||||||||||||||||||||||||||||||||||||||||
| 2881 | |||||||||||||||||||||||||||||||||||||||||||
| 2882 | ForArray | ||||||||||||||||||||||||||||||||||||||||||
| 2883 | 0 | ▶ | {my ($i, $e, $check, $next, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2884 | IfGt $i, 1, | ||||||||||||||||||||||||||||||||||||||||||
| 2885 | Then | ||||||||||||||||||||||||||||||||||||||||||
| 2886 | 0 | ▶ | {Trace 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2887 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 2888 | 0 | Out $i; Out $e; | |||||||||||||||||||||||||||||||||||||||||
| 2889 | 0 | } $a, "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 2890 | |||||||||||||||||||||||||||||||||||||||||||
| 2891 | 0 | Nop; | |||||||||||||||||||||||||||||||||||||||||
| 2892 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2893 | 0 | is_deeply $e->memory, {1=>[1, 22, 333]}; | |||||||||||||||||||||||||||||||||||||||||
| 2894 | |||||||||||||||||||||||||||||||||||||||||||
| 2895 | 0 | is_deeply $e->out, | |||||||||||||||||||||||||||||||||||||||||
| 2896 | [3, 0, 1, 1, 22, | ||||||||||||||||||||||||||||||||||||||||||
| 2897 | "Trace: 1", | ||||||||||||||||||||||||||||||||||||||||||
| 2898 | " 37 14 1 trace \n", | ||||||||||||||||||||||||||||||||||||||||||
| 2899 | " 38 15 3 label \n", | ||||||||||||||||||||||||||||||||||||||||||
| 2900 | 2, | ||||||||||||||||||||||||||||||||||||||||||
| 2901 | " 39 16 3 out \n", | ||||||||||||||||||||||||||||||||||||||||||
| 2902 | 333, | ||||||||||||||||||||||||||||||||||||||||||
| 2903 | " 40 17 3 out \n", | ||||||||||||||||||||||||||||||||||||||||||
| 2904 | " 41 18 3 label \n", | ||||||||||||||||||||||||||||||||||||||||||
| 2905 | " 42 19 3 inc [0, 3, stackArea] = 3 was 2\n", | ||||||||||||||||||||||||||||||||||||||||||
| 2906 | " 43 20 3 jmp \n", | ||||||||||||||||||||||||||||||||||||||||||
| 2907 | " 44 9 4 label \n", | ||||||||||||||||||||||||||||||||||||||||||
| 2908 | " 45 10 4 jGe \n", | ||||||||||||||||||||||||||||||||||||||||||
| 2909 | " 46 21 1 label \n", | ||||||||||||||||||||||||||||||||||||||||||
| 2910 | " 47 22 1 nop \n", | ||||||||||||||||||||||||||||||||||||||||||
| 2911 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 2912 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2913 | |||||||||||||||||||||||||||||||||||||||||||
| 2914 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2915 | 0 | if (1) #TDumpArray #TMov | |||||||||||||||||||||||||||||||||||||||||
| 2916 | 0 | {Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2917 | 0 | my $a = Array "aaa"; | |||||||||||||||||||||||||||||||||||||||||
| 2918 | 0 | Mov [$a, 0, "aaa"], 1; | |||||||||||||||||||||||||||||||||||||||||
| 2919 | 0 | Mov [$a, 1, "aaa"], 22; | |||||||||||||||||||||||||||||||||||||||||
| 2920 | 0 | Mov [$a, 2, "aaa"], 333; | |||||||||||||||||||||||||||||||||||||||||
| 2921 | 0 | DumpArray $a, "AAAA"; | |||||||||||||||||||||||||||||||||||||||||
| 2922 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2923 | |||||||||||||||||||||||||||||||||||||||||||
| 2924 | 0 | is_deeply $e->out, | |||||||||||||||||||||||||||||||||||||||||
| 2925 | ["AAAA", | ||||||||||||||||||||||||||||||||||||||||||
| 2926 | "bless([1, 22, 333], \"aaa\")", | ||||||||||||||||||||||||||||||||||||||||||
| 2927 | "Stack trace", | ||||||||||||||||||||||||||||||||||||||||||
| 2928 | " 1 5 dumpArray", | ||||||||||||||||||||||||||||||||||||||||||
| 2929 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 2930 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2931 | |||||||||||||||||||||||||||||||||||||||||||
| 2932 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2933 | 0 | if (1) #TTally #TFor | |||||||||||||||||||||||||||||||||||||||||
| 2934 | 0 | {my $N = 5; | |||||||||||||||||||||||||||||||||||||||||
| 2935 | 0 | Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2936 | For | ||||||||||||||||||||||||||||||||||||||||||
| 2937 | 0 | ▶ | {Tally 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2938 | 0 | my $a = Mov 1; | |||||||||||||||||||||||||||||||||||||||||
| 2939 | 0 | Tally 2; | |||||||||||||||||||||||||||||||||||||||||
| 2940 | 0 | Inc $a; | |||||||||||||||||||||||||||||||||||||||||
| 2941 | 0 | Tally 0; | |||||||||||||||||||||||||||||||||||||||||
| 2942 | 0 | } $N; | |||||||||||||||||||||||||||||||||||||||||
| 2943 | 0 | my $e = Execute; | |||||||||||||||||||||||||||||||||||||||||
| 2944 | |||||||||||||||||||||||||||||||||||||||||||
| 2945 | 0 | is_deeply $e->tallyCount, 2 * $N; | |||||||||||||||||||||||||||||||||||||||||
| 2946 | 0 | is_deeply $e->tallyCounts,{ 1 => {mov => $N}, 2 => {inc => $N}}; | |||||||||||||||||||||||||||||||||||||||||
| 2947 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2948 | |||||||||||||||||||||||||||||||||||||||||||
| 2949 | #latest:; | ||||||||||||||||||||||||||||||||||||||||||
| 2950 | 0 | if (1) #TTracePoints | |||||||||||||||||||||||||||||||||||||||||
| 2951 | 0 | {my $N = 5; | |||||||||||||||||||||||||||||||||||||||||
| 2952 | 0 | Start 1; | |||||||||||||||||||||||||||||||||||||||||
| 2953 | 0 | TracePoints 1; | |||||||||||||||||||||||||||||||||||||||||
| 2954 | For | ||||||||||||||||||||||||||||||||||||||||||
| 2955 | 0 | ▶ | {my $a = Mov 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2956 | 0 | Inc $a; | |||||||||||||||||||||||||||||||||||||||||
| 2957 | 0 | } $N; | |||||||||||||||||||||||||||||||||||||||||
| 2958 | 0 | my $e = Execute(suppressOutput=>1); | |||||||||||||||||||||||||||||||||||||||||
| 2959 | 0 | is_deeply $e->out, [ | |||||||||||||||||||||||||||||||||||||||||
| 2960 | "TracePoints: 1", | ||||||||||||||||||||||||||||||||||||||||||
| 2961 | "Trace", | ||||||||||||||||||||||||||||||||||||||||||
| 2962 | " 1 6 tracePoint", | ||||||||||||||||||||||||||||||||||||||||||
| 2963 | "Trace", | ||||||||||||||||||||||||||||||||||||||||||
| 2964 | " 1 6 tracePoint", | ||||||||||||||||||||||||||||||||||||||||||
| 2965 | "Trace", | ||||||||||||||||||||||||||||||||||||||||||
| 2966 | " 1 6 tracePoint", | ||||||||||||||||||||||||||||||||||||||||||
| 2967 | "Trace", | ||||||||||||||||||||||||||||||||||||||||||
| 2968 | " 1 6 tracePoint", | ||||||||||||||||||||||||||||||||||||||||||
| 2969 | "Trace", | ||||||||||||||||||||||||||||||||||||||||||
| 2970 | " 1 6 tracePoint", | ||||||||||||||||||||||||||||||||||||||||||
| 2971 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 2972 | } | ||||||||||||||||||||||||||||||||||||||||||