blib/lib/Nasm/X86.pm

filter: Statementstmt 7.4% 592 / 7979 Branchbran 4.4% 99 / 2224 Conditioncond 9.0% 32 / 352 MC/DCmcdc 1.4% 3 / 203 Subroutinesub 4.3% 83 / 1891 Podpod 26.5% 256 / 966 totaltotal 7.8% 1065 / 13615 CC 1351 SCAR 47.3
CC
1351
Cov
7%
Assemble
2903.0
w
1560.0
BEGIN
736.5
CRAP 113.3
↑ Summary
1 #!/usr/bin/perl -I/home/phil/perl/cpan/DataTableText/lib/ -I. -Ilib/ -I/home/phil/perl/cpan/AsmC/lib/
2 #-------------------------------------------------------------------------------
3 # Generate X86 assembler code using Perl as a macro pre-processor.
4 # Philip R Brenan at appaapps dot com, Appa Apps Ltd Inc., 2021-2022
5 #-------------------------------------------------------------------------------
6 # podDocumentation (\A.{80})\s+(#.*\Z) \1\2 (^sub.*#.*[^.]$) \1.
7 # 0x401000 from sde-mix-out addresses to get offsets in z.txt
8 # tree::print - speed up decision as to whether we are on a tree or not
9 # Make hash accept parameters at: #THash
10 # Document that V > 0 is required to create a boolean test
11 # Make sure that we are using bts and bzhi as much as possible in mask situations
12 # Replace calls to Tree::position with Tree::down
13 # Do not use r11 over extended ranges because Linux sets it to the flags register on syscalls. Free: rsi rdi, r11, rbx, rcx, rdx, likewise the mmx registers mm0-7, zmm 0..15 and k0..3.
14 # Make a tree read only - collapse all nodes possible, remove all leaf node arrays
15 # Jump forwarding
16 # All options checking immediately after parameters
17 # Which subs do we actually need SaveFirst four on?
18 # Binary search tighten up register saves
19 # github.com/<username>/<repo_name>/compare/<commit1>...<commit2>
20 # https://github.com/philiprbrenan/NasmX86/compare/9bb6e05..09d1ec9
21 # Variable::at to replace addrExpr
22 package Nasm::X86;
23 1 our $VERSION = "20220712";
24 1 ▶use warnings FATAL => qw(all);
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Carp qw(confess cluck);
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use Data::Dump qw(dump);
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use Data::Table::Text qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 ▶use Time::HiRes qw(time);
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use feature qw(say current_sub);
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 1 ▶makeDieConfess unless &onGitHub;
Branch: 1 branch
BranchTrueFalseTotal
unless &onGitHub 1 0 1
34  
35 1 my %rodata; # Read only data already written
36 my %rodatas; # Read only string already written
37 1 my %subroutines; # Subroutines generated
38 1 my @rodata; # Read only data
39 1 my @data; # Data
40 1 my @bss; # Block started by symbol
41 1 my @text; # Code
42 1 my @extern; # External symbols imports for linking with C libraries
43 1 my @link; # Specify libraries which to link against in the final assembly stage
44 1 my $interpreter = q(-I /usr/lib64/ld-linux-x86-64.so.2); # The ld command needs an interpreter if we are linking with C.
45 1 our $sdeMixOut = q(sde-mix-out.txt); # Emulator hot spot output file
46 1 our $sdeTraceOut = q(sde-debugtrace-out.txt); # Emulator trace output file
47 1 our $sdePtrCheck = q(sde-ptr-check.out.txt); # Emulator pointer check file
48 1 our $traceBack = q(zzzTraceBack.txt); # Trace back of last error observed in emulator trace file if tracing is on
49 1 our $programErr = q(zzzErr.txt); # Program error file
50 1 our $programOut = q(zzzOut.txt); # Program output file
51 1 our $sourceFile = q(z.asm); # Source file
52  
53 1 our $stdin = 0; # File descriptor for standard input
54 1 our $stdout = 1; # File descriptor for standard output
55 1 our $stderr = 2; # File descriptor for standard error
56  
57 1 our $TraceMode = 0; # 1: writes trace data into rax after every instruction to show the call stack by line number in this file for the instruction being executed. This information is then visible in the sde trace from whence it is easily extracted to give a trace back for instructions executed in this mode. This mode assumes that you will not be using the mm0 register (most people are not)and that you have any IDE like Geany that can interpret a Perl error line number and position on that line in this file.
58 1 our $DebugMode = 0; # 1: enables checks that take time and sometimes catch programming errors.
59 1 our $LibraryMode = 0; # 1: we are building a library so constants must appear in line in the text section rather than in a block in the data section
60  
61 1 my %Registers; # The names of all the registers
62 my %RegisterContaining; # The largest register containing a register
63 1 my @GeneralPurposeRegisters = qw(rax rbx rcx rdx rsi rdi), map {"r$_"} 8..15; # General purpose registers
64 1 my $bitsInByte; # The number of bits in a byte
65 my @declarations; # Register and instruction declarations
66 1 my %loadAreaIntoAssembly; # Areas already loaded by file name
67  
68 1 ▶BEGIN{
Subroutine BEGIN: called CC=31 SCAR=66.0
69 1 $bitsInByte = 8; # The number of bits in a byte
70 1 my %r = ( map {$_=>[ 8, '8' ]} qw(al bl cl dl r8b r9b r10b r11b r12b r13b r14b r15b r8l r9l r10l r11l r12l r13l r14l r15l sil dil spl bpl ah bh ch dh));
71 1 %r = (%r, map {$_=>[16, 's' ]} qw(cs ds es fs gs ss));
72 1 %r = (%r, map {$_=>[16, '16' ]} qw(ax bx cx dx r8w r9w r10w r11w r12w r13w r14w r15w si di sp bp));
73 1 %r = (%r, map {$_=>[32, '32a']} qw(eax ebx ecx edx esi edi esp ebp));
74 1 %r = (%r, map {$_=>[32, '32b']} qw(r8d r9d r10d r11d r12d r13d r14d r15d));
75 1 %r = (%r, map {$_=>[80, 'f' ]} qw(st0 st1 st2 st3 st4 st5 st6 st7));
76 1 %r = (%r, map {$_=>[64, '64' ]} qw(rax rbx rcx rdx r8 r9 r10 r11 r12 r13 r14 r15 rsi rdi rsp rbp rip rflags));
77 1 %r = (%r, map {$_=>[64, '64m']} qw(mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7));
78 1 %r = (%r, map {$_=>[128, '128']} qw(xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7 xmm8 xmm9 xmm10 xmm11 xmm12 xmm13 xmm14 xmm15 xmm16 xmm17 xmm18 xmm19 xmm20 xmm21 xmm22 xmm23 xmm24 xmm25 xmm26 xmm27 xmm28 xmm29 xmm30 xmm31));
79 1 %r = (%r, map {$_=>[256, '256']} qw(ymm0 ymm1 ymm2 ymm3 ymm4 ymm5 ymm6 ymm7 ymm8 ymm9 ymm10 ymm11 ymm12 ymm13 ymm14 ymm15 ymm16 ymm17 ymm18 ymm19 ymm20 ymm21 ymm22 ymm23 ymm24 ymm25 ymm26 ymm27 ymm28 ymm29 ymm30 ymm31));
80 1 %r = (%r, map {$_=>[512, '512']} qw(zmm0 zmm1 zmm2 zmm3 zmm4 zmm5 zmm6 zmm7 zmm8 zmm9 zmm10 zmm11 zmm12 zmm13 zmm14 zmm15 zmm16 zmm17 zmm18 zmm19 zmm20 zmm21 zmm22 zmm23 zmm24 zmm25 zmm26 zmm27 zmm28 zmm29 zmm30 zmm31));
81 1 %r = (%r, map {$_=>[64, 'm' ]} qw(k0 k1 k2 k3 k4 k5 k6 k7));
82  
83 1 %Registers = %r; # Register names
84  
85 my sub registerContaining($@)
86 56 ▶ {my ($r, @r) = @_; # Register, contents
Subroutine registerContaining: called CC=2 SCAR=6.9
87 56 $RegisterContaining{$r} = $r; # A register contains itself
88 56 $RegisterContaining{$_} = $r for @r; # Registers contained by a register
89 }
90  
91 1 registerContaining("k$_") for 0..7;
92 1 registerContaining("zmm$_", "ymm$_", "xmm$_") for 0..31;
93 1 registerContaining("r${_}x", "e${_}x", "${_}x", "${_}l", "${_}h") for qw(a b c d);
94 1 registerContaining("r${_}", "r${_}l", "r${_}w", "r${_}b", "r${_}d") for 8..15;
95 1 registerContaining("r${_}p", "e${_}p", "${_}p", "${_}pl") for qw(s b);
96 1 registerContaining("r${_}i", "e${_}i", "${_}i", "${_}il") for qw(s d);
97 1 my @i0 = qw(cpuid lahf leave popfq pushfq rdtsc ret syscall); # Zero operand instructions
98  
99 1 my @i1 = split /\s+/, <<END; # Single operand instructions
100 align bswap call dec div idiv inc jmp ja jae jb jbe jc jcxz je jecxz jg jge jl jle
101 jna jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp jns jnz jo jp jpe jpo jrcxz
102 js jz loop neg not seta setae setb setbe setc sete setg setge setl setle setna setnae
103 setnb setnbe setnc setne setng setnge setnl setno setnp setns setnz seto setp
104 setpe setpo sets setz pop push
105 include
106 incbin
107 END
108  
109 1 my @i2 = split /\s+/, <<END; # Double operand instructions
110 add and bsf bsr bt btc btr bts
111 cmova cmovae cmovb cmovbe cmovc cmove cmovg cmovge cmovl cmovle
112 cmovna cmovnae cmovnb cmovne cmp
113 enter
114 imul
115 kmov knot kortest ktest lea lzcnt mov movd movq movw movdqa
116 or popcnt sal sar shl shr sub test tzcnt
117 vcvtudq2pd vcvtuqq2pd vcvtudq2ps vmovdqu vmovdqu32 vmovdqu64 vmovdqu8
118 vpcompressd vpcompressq vpexpandd vpexpandq xchg xor
119 vmovd vmovq
120 mulpd
121 pslldq psrldq
122 vpgatherqd vpgatherqq
123 vpmovb2m vpmovw2m Vpmovd2m vpmovq2m
124  
125 vsqrtpd
126 vmovdqa32 vmovdqa64
127 END
128 # print STDERR join ' ', sort @i2; exit;
129  
130 1 my @i2qdwb = split /\s+/, <<END; # Double operand instructions which have qdwb versions
131 vpmovm2
132 vpbroadcast
133 END
134  
135 1 my @i3 = split /\s+/, <<END; # Triple operand instructions
136 andn
137 bzhi
138 imul3
139 kadd kand kandn kor kshiftl kshiftr kunpck kxnor kxor
140 pdep pext
141 vdpps
142 vprolq
143 vgetmantps
144 vaddd
145 vmulpd vaddpd
146 END
147  
148 1 my @i3qdwb = split /\s+/, <<END; # Triple operand instructions which have qdwb versions
149 pinsr pextr valign vpand vpandn vpcmpeq vpor vpxor vptest vporvpcmpeq vpinsr vpextr vpadd vpsub vpmull
150 END
151  
152 1 my @i4 = split /\s+/, <<END; # Quadruple operand instructions
153 END
154  
155 1 my @i4qdwb = split /\s+/, <<END; # Quadruple operand instructions which have qdwb versions
156 vpcmpu
157 END
158  
159 1 if (1) # Add variants to mask instructions
160 1 {my @k2 = grep {m/\Ak/} @i2; @i2 = grep {!m/\Ak/} @i2;
161 1 my @k3 = grep {m/\Ak/} @i3; @i3 = grep {!m/\Ak/} @i3;
162 1 for my $s(qw(b w d q))
163 4 {push @i2, $_.$s for grep {m/\Ak/} @k2;
164 4 push @i3, $_.$s for grep {m/\Ak/} @k3;
165 }
166 }
167  
168 1 if (1) # Add qdwb versions of instructions
169 1 {for my $o(@i2qdwb)
170 2 {push @i2, $o.$_ for qw(b w d q);
171 }
172 1 for my $o(@i3qdwb)
173 15 {push @i3, $o.$_ for qw(b w d q);
174 }
175 1 for my $o(@i4qdwb)
176 1 {push @i4, $o.$_ for qw(b w d q);
177 }
178 }
179  
180 1 for my $r(sort keys %r) # Create register definitions
181 204 {if (1)
182 204 {my $s = "sub $r\{q($r)\}";
183 204 push @declarations, $r;
184 0 ▶ eval $s;
Subroutine ah: not called CC=1 SCAR=6.4
Subroutine al: not called CC=1 SCAR=6.4
Subroutine ax: not called CC=1 SCAR=6.4
Subroutine bh: not called CC=1 SCAR=6.4
Subroutine bl: not called CC=1 SCAR=6.4
Subroutine bp: not called CC=1 SCAR=6.4
Subroutine bpl: not called CC=1 SCAR=6.4
Subroutine bx: not called CC=1 SCAR=6.4
Subroutine ch: not called CC=1 SCAR=6.4
Subroutine cl: not called CC=1 SCAR=6.4
Subroutine cs: not called CC=1 SCAR=6.4
Subroutine cx: not called CC=1 SCAR=6.4
Subroutine dh: not called CC=1 SCAR=6.4
Subroutine di: not called CC=1 SCAR=6.4
Subroutine dil: not called CC=1 SCAR=6.4
Subroutine dl: not called CC=1 SCAR=6.4
Subroutine ds: not called CC=1 SCAR=6.4
Subroutine dx: not called CC=1 SCAR=6.4
Subroutine eax: not called CC=1 SCAR=6.4
Subroutine ebp: not called CC=1 SCAR=6.4
Subroutine ebx: not called CC=1 SCAR=6.4
Subroutine ecx: not called CC=1 SCAR=6.4
Subroutine edi: not called CC=1 SCAR=6.4
Subroutine edx: not called CC=1 SCAR=6.4
Subroutine es: not called CC=1 SCAR=6.4
Subroutine esi: not called CC=1 SCAR=6.4
Subroutine esp: not called CC=1 SCAR=6.4
Subroutine fs: not called CC=1 SCAR=6.4
Subroutine gs: not called CC=1 SCAR=6.4
Subroutine k0: not called CC=1 SCAR=6.4
Subroutine k1: not called CC=1 SCAR=6.4
Subroutine k2: not called CC=1 SCAR=6.4
Subroutine k3: not called CC=1 SCAR=6.4
Subroutine k4: not called CC=1 SCAR=6.4
Subroutine k5: not called CC=1 SCAR=6.4
Subroutine k6: not called CC=1 SCAR=6.4
Subroutine k7: not called CC=1 SCAR=6.4
Subroutine mm0: not called CC=1 SCAR=6.4
Subroutine mm1: not called CC=1 SCAR=6.4
Subroutine mm2: not called CC=1 SCAR=6.4
Subroutine mm3: not called CC=1 SCAR=6.4
Subroutine mm4: not called CC=1 SCAR=6.4
Subroutine mm5: not called CC=1 SCAR=6.4
Subroutine mm6: not called CC=1 SCAR=6.4
Subroutine mm7: not called CC=1 SCAR=6.4
Subroutine r10: not called CC=1 SCAR=6.4
Subroutine r10b: not called CC=1 SCAR=6.4
Subroutine r10d: not called CC=1 SCAR=6.4
Subroutine r10l: not called CC=1 SCAR=6.4
Subroutine r10w: not called CC=1 SCAR=6.4
Subroutine r11: not called CC=1 SCAR=6.4
Subroutine r11b: not called CC=1 SCAR=6.4
Subroutine r11d: not called CC=1 SCAR=6.4
Subroutine r11l: not called CC=1 SCAR=6.4
Subroutine r11w: not called CC=1 SCAR=6.4
Subroutine r12: not called CC=1 SCAR=6.4
Subroutine r12b: not called CC=1 SCAR=6.4
Subroutine r12d: not called CC=1 SCAR=6.4
Subroutine r12l: not called CC=1 SCAR=6.4
Subroutine r12w: not called CC=1 SCAR=6.4
Subroutine r13: not called CC=1 SCAR=6.4
Subroutine r13b: not called CC=1 SCAR=6.4
Subroutine r13d: not called CC=1 SCAR=6.4
Subroutine r13l: not called CC=1 SCAR=6.4
Subroutine r13w: not called CC=1 SCAR=6.4
Subroutine r14: not called CC=1 SCAR=6.4
Subroutine r14b: not called CC=1 SCAR=6.4
Subroutine r14d: not called CC=1 SCAR=6.4
Subroutine r14l: not called CC=1 SCAR=6.4
Subroutine r14w: not called CC=1 SCAR=6.4
Subroutine r15: called CC=1 SCAR=6.4
Subroutine r15b: not called CC=1 SCAR=6.4
Subroutine r15d: not called CC=1 SCAR=6.4
Subroutine r15l: not called CC=1 SCAR=6.4
Subroutine r15w: not called CC=1 SCAR=6.4
Subroutine r8: not called CC=1 SCAR=6.4
Subroutine r8b: not called CC=1 SCAR=6.4
Subroutine r8d: not called CC=1 SCAR=6.4
Subroutine r8l: not called CC=1 SCAR=6.4
Subroutine r8w: not called CC=1 SCAR=6.4
Subroutine r9: not called CC=1 SCAR=6.4
Subroutine r9b: not called CC=1 SCAR=6.4
Subroutine r9d: not called CC=1 SCAR=6.4
Subroutine r9l: not called CC=1 SCAR=6.4
Subroutine r9w: not called CC=1 SCAR=6.4
Subroutine rax: called CC=1 SCAR=6.4
Subroutine rbp: not called CC=1 SCAR=6.4
Subroutine rbx: not called CC=1 SCAR=6.4
Subroutine rcx: not called CC=1 SCAR=6.4
Subroutine rdi: called CC=1 SCAR=6.4
Subroutine rdx: called CC=1 SCAR=6.4
Subroutine rflags: not called CC=1 SCAR=6.4
Subroutine rip: not called CC=1 SCAR=6.4
Subroutine rsi: called CC=1 SCAR=6.4
Subroutine rsp: not called CC=1 SCAR=6.4
Subroutine si: not called CC=1 SCAR=6.4
Subroutine sil: not called CC=1 SCAR=6.4
Subroutine sp: not called CC=1 SCAR=6.4
Subroutine spl: not called CC=1 SCAR=6.4
Subroutine ss: not called CC=1 SCAR=6.4
Subroutine st0: not called CC=1 SCAR=6.4
Subroutine st1: not called CC=1 SCAR=6.4
Subroutine st2: not called CC=1 SCAR=6.4
Subroutine st3: not called CC=1 SCAR=6.4
Subroutine st4: not called CC=1 SCAR=6.4
Subroutine st5: not called CC=1 SCAR=6.4
Subroutine st6: not called CC=1 SCAR=6.4
Subroutine st7: not called CC=1 SCAR=6.4
Subroutine xmm0: not called CC=1 SCAR=6.4
Subroutine xmm1: not called CC=1 SCAR=6.4
Subroutine xmm10: not called CC=1 SCAR=6.4
Subroutine xmm11: not called CC=1 SCAR=6.4
Subroutine xmm12: not called CC=1 SCAR=6.4
Subroutine xmm13: not called CC=1 SCAR=6.4
Subroutine xmm14: not called CC=1 SCAR=6.4
Subroutine xmm15: not called CC=1 SCAR=6.4
Subroutine xmm16: not called CC=1 SCAR=6.4
Subroutine xmm17: not called CC=1 SCAR=6.4
Subroutine xmm18: not called CC=1 SCAR=6.4
Subroutine xmm19: not called CC=1 SCAR=6.4
Subroutine xmm2: not called CC=1 SCAR=6.4
Subroutine xmm20: not called CC=1 SCAR=6.4
Subroutine xmm21: not called CC=1 SCAR=6.4
Subroutine xmm22: not called CC=1 SCAR=6.4
Subroutine xmm23: not called CC=1 SCAR=6.4
Subroutine xmm24: not called CC=1 SCAR=6.4
Subroutine xmm25: not called CC=1 SCAR=6.4
Subroutine xmm26: not called CC=1 SCAR=6.4
Subroutine xmm27: not called CC=1 SCAR=6.4
Subroutine xmm28: not called CC=1 SCAR=6.4
Subroutine xmm29: not called CC=1 SCAR=6.4
Subroutine xmm3: not called CC=1 SCAR=6.4
Subroutine xmm30: not called CC=1 SCAR=6.4
Subroutine xmm31: not called CC=1 SCAR=6.4
Subroutine xmm4: not called CC=1 SCAR=6.4
Subroutine xmm5: not called CC=1 SCAR=6.4
Subroutine xmm6: not called CC=1 SCAR=6.4
Subroutine xmm7: not called CC=1 SCAR=6.4
Subroutine xmm8: not called CC=1 SCAR=6.4
Subroutine xmm9: not called CC=1 SCAR=6.4
Subroutine ymm0: not called CC=1 SCAR=6.4
Subroutine ymm1: not called CC=1 SCAR=6.4
Subroutine ymm10: not called CC=1 SCAR=6.4
Subroutine ymm11: not called CC=1 SCAR=6.4
Subroutine ymm12: not called CC=1 SCAR=6.4
Subroutine ymm13: not called CC=1 SCAR=6.4
Subroutine ymm14: not called CC=1 SCAR=6.4
Subroutine ymm15: not called CC=1 SCAR=6.4
Subroutine ymm16: not called CC=1 SCAR=6.4
Subroutine ymm17: not called CC=1 SCAR=6.4
Subroutine ymm18: not called CC=1 SCAR=6.4
Subroutine ymm19: not called CC=1 SCAR=6.4
Subroutine ymm2: not called CC=1 SCAR=6.4
Subroutine ymm20: not called CC=1 SCAR=6.4
Subroutine ymm21: not called CC=1 SCAR=6.4
Subroutine ymm22: not called CC=1 SCAR=6.4
Subroutine ymm23: not called CC=1 SCAR=6.4
Subroutine ymm24: not called CC=1 SCAR=6.4
Subroutine ymm25: not called CC=1 SCAR=6.4
Subroutine ymm26: not called CC=1 SCAR=6.4
Subroutine ymm27: not called CC=1 SCAR=6.4
Subroutine ymm28: not called CC=1 SCAR=6.4
Subroutine ymm29: not called CC=1 SCAR=6.4
Subroutine ymm3: not called CC=1 SCAR=6.4
Subroutine ymm30: not called CC=1 SCAR=6.4
Subroutine ymm31: not called CC=1 SCAR=6.4
Subroutine ymm4: not called CC=1 SCAR=6.4
Subroutine ymm5: not called CC=1 SCAR=6.4
Subroutine ymm6: not called CC=1 SCAR=6.4
Subroutine ymm7: not called CC=1 SCAR=6.4
Subroutine ymm8: not called CC=1 SCAR=6.4
Subroutine ymm9: not called CC=1 SCAR=6.4
Subroutine zmm0: called CC=1 SCAR=6.4
Subroutine zmm1: not called CC=1 SCAR=6.4
Subroutine zmm10: not called CC=1 SCAR=6.4
Subroutine zmm11: not called CC=1 SCAR=6.4
Subroutine zmm12: not called CC=1 SCAR=6.4
Subroutine zmm13: not called CC=1 SCAR=6.4
Subroutine zmm14: not called CC=1 SCAR=6.4
Subroutine zmm15: not called CC=1 SCAR=6.4
Subroutine zmm16: not called CC=1 SCAR=6.4
Subroutine zmm17: not called CC=1 SCAR=6.4
Subroutine zmm18: not called CC=1 SCAR=6.4
Subroutine zmm19: not called CC=1 SCAR=6.4
Subroutine zmm2: not called CC=1 SCAR=6.4
Subroutine zmm20: not called CC=1 SCAR=6.4
Subroutine zmm21: not called CC=1 SCAR=6.4
Subroutine zmm22: not called CC=1 SCAR=6.4
Subroutine zmm23: not called CC=1 SCAR=6.4
Subroutine zmm24: not called CC=1 SCAR=6.4
Subroutine zmm25: not called CC=1 SCAR=6.4
Subroutine zmm26: not called CC=1 SCAR=6.4
Subroutine zmm27: not called CC=1 SCAR=6.4
Subroutine zmm28: not called CC=1 SCAR=6.4
Subroutine zmm29: not called CC=1 SCAR=6.4
Subroutine zmm3: not called CC=1 SCAR=6.4
Subroutine zmm30: not called CC=1 SCAR=6.4
Subroutine zmm31: not called CC=1 SCAR=6.4
Subroutine zmm4: not called CC=1 SCAR=6.4
Subroutine zmm5: not called CC=1 SCAR=6.4
Subroutine zmm6: not called CC=1 SCAR=6.4
Subroutine zmm7: not called CC=1 SCAR=6.4
Subroutine zmm8: not called CC=1 SCAR=6.4
Subroutine zmm9: not called CC=1 SCAR=6.4
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
185 204 ▶ confess "$s$@ "if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 204 204
186 }
187 204 if (1)
188 204 {my $b = $r{$r}[0] / $bitsInByte;
189 204 my $s = "sub ${r}Size\{$b}";
190 0 ▶ eval $s;
Subroutine ahSize: not called CC=1 SCAR=6.4
Subroutine alSize: not called CC=1 SCAR=6.4
Subroutine axSize: not called CC=1 SCAR=6.4
Subroutine bhSize: not called CC=1 SCAR=6.4
Subroutine blSize: not called CC=1 SCAR=6.4
Subroutine bpSize: not called CC=1 SCAR=6.4
Subroutine bplSize: not called CC=1 SCAR=6.4
Subroutine bxSize: not called CC=1 SCAR=6.4
Subroutine chSize: not called CC=1 SCAR=6.4
Subroutine clSize: not called CC=1 SCAR=6.4
Subroutine csSize: not called CC=1 SCAR=6.4
Subroutine cxSize: not called CC=1 SCAR=6.4
Subroutine dhSize: not called CC=1 SCAR=6.4
Subroutine diSize: not called CC=1 SCAR=6.4
Subroutine dilSize: not called CC=1 SCAR=6.4
Subroutine dlSize: not called CC=1 SCAR=6.4
Subroutine dsSize: not called CC=1 SCAR=6.4
Subroutine dxSize: not called CC=1 SCAR=6.4
Subroutine eaxSize: not called CC=1 SCAR=6.4
Subroutine ebpSize: not called CC=1 SCAR=6.4
Subroutine ebxSize: not called CC=1 SCAR=6.4
Subroutine ecxSize: not called CC=1 SCAR=6.4
Subroutine ediSize: not called CC=1 SCAR=6.4
Subroutine edxSize: not called CC=1 SCAR=6.4
Subroutine esSize: not called CC=1 SCAR=6.4
Subroutine esiSize: not called CC=1 SCAR=6.4
Subroutine espSize: not called CC=1 SCAR=6.4
Subroutine fsSize: not called CC=1 SCAR=6.4
Subroutine gsSize: not called CC=1 SCAR=6.4
Subroutine k0Size: not called CC=1 SCAR=6.4
Subroutine k1Size: not called CC=1 SCAR=6.4
Subroutine k2Size: not called CC=1 SCAR=6.4
Subroutine k3Size: not called CC=1 SCAR=6.4
Subroutine k4Size: not called CC=1 SCAR=6.4
Subroutine k5Size: not called CC=1 SCAR=6.4
Subroutine k6Size: not called CC=1 SCAR=6.4
Subroutine k7Size: not called CC=1 SCAR=6.4
Subroutine mm0Size: not called CC=1 SCAR=6.4
Subroutine mm1Size: not called CC=1 SCAR=6.4
Subroutine mm2Size: not called CC=1 SCAR=6.4
Subroutine mm3Size: not called CC=1 SCAR=6.4
Subroutine mm4Size: not called CC=1 SCAR=6.4
Subroutine mm5Size: not called CC=1 SCAR=6.4
Subroutine mm6Size: not called CC=1 SCAR=6.4
Subroutine mm7Size: not called CC=1 SCAR=6.4
Subroutine r10Size: not called CC=1 SCAR=6.4
Subroutine r10bSize: not called CC=1 SCAR=6.4
Subroutine r10dSize: not called CC=1 SCAR=6.4
Subroutine r10lSize: not called CC=1 SCAR=6.4
Subroutine r10wSize: not called CC=1 SCAR=6.4
Subroutine r11Size: not called CC=1 SCAR=6.4
Subroutine r11bSize: not called CC=1 SCAR=6.4
Subroutine r11dSize: not called CC=1 SCAR=6.4
Subroutine r11lSize: not called CC=1 SCAR=6.4
Subroutine r11wSize: not called CC=1 SCAR=6.4
Subroutine r12Size: not called CC=1 SCAR=6.4
Subroutine r12bSize: not called CC=1 SCAR=6.4
Subroutine r12dSize: not called CC=1 SCAR=6.4
Subroutine r12lSize: not called CC=1 SCAR=6.4
Subroutine r12wSize: not called CC=1 SCAR=6.4
Subroutine r13Size: not called CC=1 SCAR=6.4
Subroutine r13bSize: not called CC=1 SCAR=6.4
Subroutine r13dSize: not called CC=1 SCAR=6.4
Subroutine r13lSize: not called CC=1 SCAR=6.4
Subroutine r13wSize: not called CC=1 SCAR=6.4
Subroutine r14Size: not called CC=1 SCAR=6.4
Subroutine r14bSize: not called CC=1 SCAR=6.4
Subroutine r14dSize: not called CC=1 SCAR=6.4
Subroutine r14lSize: not called CC=1 SCAR=6.4
Subroutine r14wSize: not called CC=1 SCAR=6.4
Subroutine r15Size: called CC=1 SCAR=6.4
Subroutine r15bSize: not called CC=1 SCAR=6.4
Subroutine r15dSize: not called CC=1 SCAR=6.4
Subroutine r15lSize: not called CC=1 SCAR=6.4
Subroutine r15wSize: not called CC=1 SCAR=6.4
Subroutine r8Size: not called CC=1 SCAR=6.4
Subroutine r8bSize: not called CC=1 SCAR=6.4
Subroutine r8dSize: not called CC=1 SCAR=6.4
Subroutine r8lSize: not called CC=1 SCAR=6.4
Subroutine r8wSize: not called CC=1 SCAR=6.4
Subroutine r9Size: not called CC=1 SCAR=6.4
Subroutine r9bSize: not called CC=1 SCAR=6.4
Subroutine r9dSize: not called CC=1 SCAR=6.4
Subroutine r9lSize: not called CC=1 SCAR=6.4
Subroutine r9wSize: not called CC=1 SCAR=6.4
Subroutine raxSize: called CC=1 SCAR=6.4
Subroutine rbpSize: not called CC=1 SCAR=6.4
Subroutine rbxSize: not called CC=1 SCAR=6.4
Subroutine rcxSize: not called CC=1 SCAR=6.4
Subroutine rdiSize: called CC=1 SCAR=6.4
Subroutine rdxSize: called CC=1 SCAR=6.4
Subroutine rflagsSize: not called CC=1 SCAR=6.4
Subroutine ripSize: not called CC=1 SCAR=6.4
Subroutine rsiSize: called CC=1 SCAR=6.4
Subroutine rspSize: not called CC=1 SCAR=6.4
Subroutine siSize: not called CC=1 SCAR=6.4
Subroutine silSize: not called CC=1 SCAR=6.4
Subroutine spSize: not called CC=1 SCAR=6.4
Subroutine splSize: not called CC=1 SCAR=6.4
Subroutine ssSize: not called CC=1 SCAR=6.4
Subroutine st0Size: not called CC=1 SCAR=6.4
Subroutine st1Size: not called CC=1 SCAR=6.4
Subroutine st2Size: not called CC=1 SCAR=6.4
Subroutine st3Size: not called CC=1 SCAR=6.4
Subroutine st4Size: not called CC=1 SCAR=6.4
Subroutine st5Size: not called CC=1 SCAR=6.4
Subroutine st6Size: not called CC=1 SCAR=6.4
Subroutine st7Size: not called CC=1 SCAR=6.4
Subroutine xmm0Size: not called CC=1 SCAR=6.4
Subroutine xmm10Size: not called CC=1 SCAR=6.4
Subroutine xmm11Size: not called CC=1 SCAR=6.4
Subroutine xmm12Size: not called CC=1 SCAR=6.4
Subroutine xmm13Size: not called CC=1 SCAR=6.4
Subroutine xmm14Size: not called CC=1 SCAR=6.4
Subroutine xmm15Size: not called CC=1 SCAR=6.4
Subroutine xmm16Size: not called CC=1 SCAR=6.4
Subroutine xmm17Size: not called CC=1 SCAR=6.4
Subroutine xmm18Size: not called CC=1 SCAR=6.4
Subroutine xmm19Size: not called CC=1 SCAR=6.4
Subroutine xmm1Size: not called CC=1 SCAR=6.4
Subroutine xmm20Size: not called CC=1 SCAR=6.4
Subroutine xmm21Size: not called CC=1 SCAR=6.4
Subroutine xmm22Size: not called CC=1 SCAR=6.4
Subroutine xmm23Size: not called CC=1 SCAR=6.4
Subroutine xmm24Size: not called CC=1 SCAR=6.4
Subroutine xmm25Size: not called CC=1 SCAR=6.4
Subroutine xmm26Size: not called CC=1 SCAR=6.4
Subroutine xmm27Size: not called CC=1 SCAR=6.4
Subroutine xmm28Size: not called CC=1 SCAR=6.4
Subroutine xmm29Size: not called CC=1 SCAR=6.4
Subroutine xmm2Size: not called CC=1 SCAR=6.4
Subroutine xmm30Size: not called CC=1 SCAR=6.4
Subroutine xmm31Size: not called CC=1 SCAR=6.4
Subroutine xmm3Size: not called CC=1 SCAR=6.4
Subroutine xmm4Size: not called CC=1 SCAR=6.4
Subroutine xmm5Size: not called CC=1 SCAR=6.4
Subroutine xmm6Size: not called CC=1 SCAR=6.4
Subroutine xmm7Size: not called CC=1 SCAR=6.4
Subroutine xmm8Size: not called CC=1 SCAR=6.4
Subroutine xmm9Size: not called CC=1 SCAR=6.4
Subroutine ymm0Size: not called CC=1 SCAR=6.4
Subroutine ymm10Size: not called CC=1 SCAR=6.4
Subroutine ymm11Size: not called CC=1 SCAR=6.4
Subroutine ymm12Size: not called CC=1 SCAR=6.4
Subroutine ymm13Size: not called CC=1 SCAR=6.4
Subroutine ymm14Size: not called CC=1 SCAR=6.4
Subroutine ymm15Size: not called CC=1 SCAR=6.4
Subroutine ymm16Size: not called CC=1 SCAR=6.4
Subroutine ymm17Size: not called CC=1 SCAR=6.4
Subroutine ymm18Size: not called CC=1 SCAR=6.4
Subroutine ymm19Size: not called CC=1 SCAR=6.4
Subroutine ymm1Size: not called CC=1 SCAR=6.4
Subroutine ymm20Size: not called CC=1 SCAR=6.4
Subroutine ymm21Size: not called CC=1 SCAR=6.4
Subroutine ymm22Size: not called CC=1 SCAR=6.4
Subroutine ymm23Size: not called CC=1 SCAR=6.4
Subroutine ymm24Size: not called CC=1 SCAR=6.4
Subroutine ymm25Size: not called CC=1 SCAR=6.4
Subroutine ymm26Size: not called CC=1 SCAR=6.4
Subroutine ymm27Size: not called CC=1 SCAR=6.4
Subroutine ymm28Size: not called CC=1 SCAR=6.4
Subroutine ymm29Size: not called CC=1 SCAR=6.4
Subroutine ymm2Size: not called CC=1 SCAR=6.4
Subroutine ymm30Size: not called CC=1 SCAR=6.4
Subroutine ymm31Size: not called CC=1 SCAR=6.4
Subroutine ymm3Size: not called CC=1 SCAR=6.4
Subroutine ymm4Size: not called CC=1 SCAR=6.4
Subroutine ymm5Size: not called CC=1 SCAR=6.4
Subroutine ymm6Size: not called CC=1 SCAR=6.4
Subroutine ymm7Size: not called CC=1 SCAR=6.4
Subroutine ymm8Size: not called CC=1 SCAR=6.4
Subroutine ymm9Size: not called CC=1 SCAR=6.4
Subroutine zmm0Size: called CC=1 SCAR=6.4
Subroutine zmm10Size: not called CC=1 SCAR=6.4
Subroutine zmm11Size: not called CC=1 SCAR=6.4
Subroutine zmm12Size: not called CC=1 SCAR=6.4
Subroutine zmm13Size: not called CC=1 SCAR=6.4
Subroutine zmm14Size: not called CC=1 SCAR=6.4
Subroutine zmm15Size: not called CC=1 SCAR=6.4
Subroutine zmm16Size: not called CC=1 SCAR=6.4
Subroutine zmm17Size: not called CC=1 SCAR=6.4
Subroutine zmm18Size: not called CC=1 SCAR=6.4
Subroutine zmm19Size: not called CC=1 SCAR=6.4
Subroutine zmm1Size: not called CC=1 SCAR=6.4
Subroutine zmm20Size: not called CC=1 SCAR=6.4
Subroutine zmm21Size: not called CC=1 SCAR=6.4
Subroutine zmm22Size: not called CC=1 SCAR=6.4
Subroutine zmm23Size: not called CC=1 SCAR=6.4
Subroutine zmm24Size: not called CC=1 SCAR=6.4
Subroutine zmm25Size: not called CC=1 SCAR=6.4
Subroutine zmm26Size: not called CC=1 SCAR=6.4
Subroutine zmm27Size: not called CC=1 SCAR=6.4
Subroutine zmm28Size: not called CC=1 SCAR=6.4
Subroutine zmm29Size: not called CC=1 SCAR=6.4
Subroutine zmm2Size: not called CC=1 SCAR=6.4
Subroutine zmm30Size: not called CC=1 SCAR=6.4
Subroutine zmm31Size: not called CC=1 SCAR=6.4
Subroutine zmm3Size: not called CC=1 SCAR=6.4
Subroutine zmm4Size: not called CC=1 SCAR=6.4
Subroutine zmm5Size: not called CC=1 SCAR=6.4
Subroutine zmm6Size: not called CC=1 SCAR=6.4
Subroutine zmm7Size: not called CC=1 SCAR=6.4
Subroutine zmm8Size: not called CC=1 SCAR=6.4
Subroutine zmm9Size: not called CC=1 SCAR=6.4
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
191 204 ▶ confess "$s$@ "if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 204 204
192 }
193 }
194  
195 1 my %v = map {$$_[1]=>1} values %r;
196 1 for my $v(sort keys %v) # Types of register
197 12 {my @r = grep {$r{$_}[1] eq $v} sort keys %r;
198 12 my $s = "sub registers_$v\{".dump(\@r)."}";
199 0 ▶ eval $s;
Subroutine registers_128: not called CC=1 SCAR=5.8
Subroutine registers_16: not called CC=1 SCAR=5.8
Subroutine registers_256: not called CC=1 SCAR=5.8
Subroutine registers_32a: not called CC=1 SCAR=5.8
Subroutine registers_32b: not called CC=1 SCAR=5.8
Subroutine registers_512: not called CC=1 SCAR=5.8
Subroutine registers_64: not called CC=1 SCAR=5.8
Subroutine registers_64m: not called CC=1 SCAR=5.8
Subroutine registers_8: not called CC=1 SCAR=5.8
Subroutine registers_f: not called CC=1 SCAR=5.8
Subroutine registers_m: not called CC=1 SCAR=5.8
Subroutine registers_s: not called CC=1 SCAR=5.8
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
200 12 ▶ confess "$s$@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 12 12
201 }
202  
203 1 if (1) # Instructions that take zero operands
204 1 {my $s = '';
205 1 for my $i(@i0)
206 8 {my $I = ucfirst $i;
207 8 push @declarations, $I;
208 8 $s .= <<END;
209 sub $I()
210 {\@_ == 0 or confess "No arguments allowed";
211 push \@text, qq($i\\n);
212 }
213 END
214 }
215 0 ▶ eval $s;
Subroutine Cpuid: not called CC=2 SCAR=12.1
Subroutine Lahf: not called CC=2 SCAR=12.1
Subroutine Leave: called CC=2 SCAR=12.1
Subroutine Popfq: not called CC=2 SCAR=12.1
Subroutine Pushfq: not called CC=2 SCAR=12.1
Subroutine Rdtsc: not called CC=2 SCAR=12.1
Subroutine Ret: called CC=2 SCAR=12.1
Subroutine Syscall: called CC=2 SCAR=12.1
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 8 branches
BranchTrueFalseTotal
@_ == 0 or confess("No arguments allowed") 0 0 0
@_ == 0 or confess("No arguments allowed") 0 0 0
@_ == 0 or confess("No arguments allowed") 8 0 8
@_ == 0 or confess("No arguments allowed") 0 0 0
@_ == 0 or confess("No arguments allowed") 0 0 0
@_ == 0 or confess("No arguments allowed") 0 0 0
@_ == 0 or confess("No arguments allowed") 8 0 8
@_ == 0 or confess("No arguments allowed") 14 0 14
216 1 ▶ confess "$s$@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
217 }
218  
219 1 if (1) # Instructions that take one operand
220 1 {my $s = '';
221 1 for my $i(@i1)
222 77 {my $I = ucfirst $i;
223 77 push @declarations, $I;
224 77 $s .= <<END;
225 sub $I
226 {my (\$target) = \@_;
227 \@_ == 1 or confess "One argument required, not ".scalar(\@_);
228 push \@text, qq($i \$target\\n);
229 }
230 END
231 }
232 0 ▶ eval $s;
Subroutine Align: not called CC=2 SCAR=17.0
Subroutine Bswap: not called CC=2 SCAR=17.0
Subroutine Call: called CC=2 SCAR=17.0
Subroutine Dec: not called CC=2 SCAR=17.0
Subroutine Div: not called CC=2 SCAR=17.0
Subroutine Idiv: not called CC=2 SCAR=17.0
Subroutine Inc: not called CC=2 SCAR=17.0
Subroutine Incbin: not called CC=2 SCAR=17.0
Subroutine Include: not called CC=2 SCAR=17.0
Subroutine Ja: not called CC=2 SCAR=17.0
Subroutine Jae: not called CC=2 SCAR=17.0
Subroutine Jb: not called CC=2 SCAR=17.0
Subroutine Jbe: not called CC=2 SCAR=17.0
Subroutine Jc: not called CC=2 SCAR=17.0
Subroutine Jcxz: not called CC=2 SCAR=17.0
Subroutine Je: not called CC=2 SCAR=17.0
Subroutine Jecxz: not called CC=2 SCAR=17.0
Subroutine Jg: not called CC=2 SCAR=17.0
Subroutine Jge: not called CC=2 SCAR=17.0
Subroutine Jl: not called CC=2 SCAR=17.0
Subroutine Jle: not called CC=2 SCAR=17.0
Subroutine Jmp: called CC=2 SCAR=17.0
Subroutine Jna: not called CC=2 SCAR=17.0
Subroutine Jnae: not called CC=2 SCAR=17.0
Subroutine Jnb: not called CC=2 SCAR=17.0
Subroutine Jnbe: not called CC=2 SCAR=17.0
Subroutine Jnc: not called CC=2 SCAR=17.0
Subroutine Jne: not called CC=2 SCAR=17.0
Subroutine Jng: not called CC=2 SCAR=17.0
Subroutine Jnge: not called CC=2 SCAR=17.0
Subroutine Jnl: not called CC=2 SCAR=17.0
Subroutine Jnle: not called CC=2 SCAR=17.0
Subroutine Jno: not called CC=2 SCAR=17.0
Subroutine Jnp: not called CC=2 SCAR=17.0
Subroutine Jns: not called CC=2 SCAR=17.0
Subroutine Jnz: not called CC=2 SCAR=17.0
Subroutine Jo: not called CC=2 SCAR=17.0
Subroutine Jp: not called CC=2 SCAR=17.0
Subroutine Jpe: not called CC=2 SCAR=17.0
Subroutine Jpo: not called CC=2 SCAR=17.0
Subroutine Jrcxz: not called CC=2 SCAR=17.0
Subroutine Js: not called CC=2 SCAR=17.0
Subroutine Jz: not called CC=2 SCAR=17.0
Subroutine Loop: not called CC=2 SCAR=17.0
Subroutine Neg: not called CC=2 SCAR=17.0
Subroutine Not: not called CC=2 SCAR=17.0
Subroutine Pop: called CC=2 SCAR=17.0
Subroutine Push: called CC=2 SCAR=17.0
Subroutine Seta: not called CC=2 SCAR=17.0
Subroutine Setae: not called CC=2 SCAR=17.0
Subroutine Setb: not called CC=2 SCAR=17.0
Subroutine Setbe: not called CC=2 SCAR=17.0
Subroutine Setc: not called CC=2 SCAR=17.0
Subroutine Sete: not called CC=2 SCAR=17.0
Subroutine Setg: not called CC=2 SCAR=17.0
Subroutine Setge: not called CC=2 SCAR=17.0
Subroutine Setl: not called CC=2 SCAR=17.0
Subroutine Setle: not called CC=2 SCAR=17.0
Subroutine Setna: not called CC=2 SCAR=17.0
Subroutine Setnae: not called CC=2 SCAR=17.0
Subroutine Setnb: not called CC=2 SCAR=17.0
Subroutine Setnbe: not called CC=2 SCAR=17.0
Subroutine Setnc: not called CC=2 SCAR=17.0
Subroutine Setne: not called CC=2 SCAR=17.0
Subroutine Setng: not called CC=2 SCAR=17.0
Subroutine Setnge: not called CC=2 SCAR=17.0
Subroutine Setnl: not called CC=2 SCAR=17.0
Subroutine Setno: not called CC=2 SCAR=17.0
Subroutine Setnp: not called CC=2 SCAR=17.0
Subroutine Setns: not called CC=2 SCAR=17.0
Subroutine Setnz: not called CC=2 SCAR=17.0
Subroutine Seto: not called CC=2 SCAR=17.0
Subroutine Setp: not called CC=2 SCAR=17.0
Subroutine Setpe: not called CC=2 SCAR=17.0
Subroutine Setpo: not called CC=2 SCAR=17.0
Subroutine Sets: not called CC=2 SCAR=17.0
Subroutine Setz: not called CC=2 SCAR=17.0
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod documented
Pod documented
Pod documented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 77 branches
BranchTrueFalseTotal
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 10 0 10
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 10 0 10
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 69 0 69
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 69 0 69
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
@_ == 1 or confess('One argument required, not ' . scalar(@_)) 0 0 0
233 1 ▶ confess "$s$@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
234 }
235  
236 1 if (1) # Instructions that take two operands
237 1 {my $s = '';
238 1 for my $i(@i2)
239 92 {my $I = ucfirst $i;
240 92 push @declarations, $I;
241 92 $s .= <<END;
242 sub $I(\@)
243 {my (\$target, \$source) = \@_;
244 \@_ == 2 or confess "Two arguments required, not ".scalar(\@_);
245 &traceInstruction(q($i), \$source, \$target);
246 push \@text, qq($i \$target, \$source\\n);
247 }
248 END
249 }
250 0 ▶ eval $s;
Subroutine Add: called CC=2 SCAR=16.6
Subroutine And: not called CC=2 SCAR=16.6
Subroutine Bsf: not called CC=2 SCAR=16.6
Subroutine Bsr: not called CC=2 SCAR=16.6
Subroutine Bt: not called CC=2 SCAR=16.6
Subroutine Btc: not called CC=2 SCAR=16.6
Subroutine Btr: not called CC=2 SCAR=16.6
Subroutine Bts: not called CC=2 SCAR=16.6
Subroutine Cmova: not called CC=2 SCAR=16.6
Subroutine Cmovae: not called CC=2 SCAR=16.6
Subroutine Cmovb: not called CC=2 SCAR=16.6
Subroutine Cmovbe: not called CC=2 SCAR=16.6
Subroutine Cmovc: not called CC=2 SCAR=16.6
Subroutine Cmove: not called CC=2 SCAR=16.6
Subroutine Cmovg: not called CC=2 SCAR=16.6
Subroutine Cmovge: not called CC=2 SCAR=16.6
Subroutine Cmovl: not called CC=2 SCAR=16.6
Subroutine Cmovle: not called CC=2 SCAR=16.6
Subroutine Cmovna: not called CC=2 SCAR=16.6
Subroutine Cmovnae: not called CC=2 SCAR=16.6
Subroutine Cmovnb: not called CC=2 SCAR=16.6
Subroutine Cmovne: not called CC=2 SCAR=16.6
Subroutine Cmp: called CC=2 SCAR=16.6
Subroutine Enter: called CC=2 SCAR=16.6
Subroutine Imul: not called CC=2 SCAR=16.6
Subroutine Kmovb: not called CC=2 SCAR=16.6
Subroutine Kmovd: not called CC=2 SCAR=16.6
Subroutine Kmovq: not called CC=2 SCAR=16.6
Subroutine Kmovw: not called CC=2 SCAR=16.6
Subroutine Knotb: not called CC=2 SCAR=16.6
Subroutine Knotd: not called CC=2 SCAR=16.6
Subroutine Knotq: not called CC=2 SCAR=16.6
Subroutine Knotw: not called CC=2 SCAR=16.6
Subroutine Kortestb: not called CC=2 SCAR=16.6
Subroutine Kortestd: not called CC=2 SCAR=16.6
Subroutine Kortestq: not called CC=2 SCAR=16.6
Subroutine Kortestw: not called CC=2 SCAR=16.6
Subroutine Ktestb: not called CC=2 SCAR=16.6
Subroutine Ktestd: not called CC=2 SCAR=16.6
Subroutine Ktestq: not called CC=2 SCAR=16.6
Subroutine Ktestw: not called CC=2 SCAR=16.6
Subroutine Lea: called CC=2 SCAR=16.6
Subroutine Lzcnt: not called CC=2 SCAR=16.6
Subroutine Mov: called CC=2 SCAR=16.6
Subroutine Movd: not called CC=2 SCAR=16.6
Subroutine Movdqa: not called CC=2 SCAR=16.6
Subroutine Movq: not called CC=2 SCAR=16.6
Subroutine Movw: not called CC=2 SCAR=16.6
Subroutine Mulpd: not called CC=2 SCAR=16.6
Subroutine Or: not called CC=2 SCAR=16.6
Subroutine Popcnt: not called CC=2 SCAR=16.6
Subroutine Pslldq: not called CC=2 SCAR=16.6
Subroutine Psrldq: not called CC=2 SCAR=16.6
Subroutine Sal: not called CC=2 SCAR=16.6
Subroutine Sar: not called CC=2 SCAR=16.6
Subroutine Shl: called CC=2 SCAR=16.6
Subroutine Shr: called CC=2 SCAR=16.6
Subroutine Sub: not called CC=2 SCAR=16.6
Subroutine Test: not called CC=2 SCAR=16.6
Subroutine Tzcnt: not called CC=2 SCAR=16.6
Subroutine Vcvtudq2pd: not called CC=2 SCAR=16.6
Subroutine Vcvtudq2ps: not called CC=2 SCAR=16.6
Subroutine Vcvtuqq2pd: not called CC=2 SCAR=16.6
Subroutine Vmovd: not called CC=2 SCAR=16.6
Subroutine Vmovdqa32: not called CC=2 SCAR=16.6
Subroutine Vmovdqa64: not called CC=2 SCAR=16.6
Subroutine Vmovdqu: not called CC=2 SCAR=16.6
Subroutine Vmovdqu32: not called CC=2 SCAR=16.6
Subroutine Vmovdqu64: not called CC=2 SCAR=16.6
Subroutine Vmovdqu8: not called CC=2 SCAR=16.6
Subroutine Vmovq: not called CC=2 SCAR=16.6
Subroutine Vpbroadcastb: not called CC=2 SCAR=16.6
Subroutine Vpbroadcastd: not called CC=2 SCAR=16.6
Subroutine Vpbroadcastq: not called CC=2 SCAR=16.6
Subroutine Vpbroadcastw: not called CC=2 SCAR=16.6
Subroutine Vpcompressd: not called CC=2 SCAR=16.6
Subroutine Vpcompressq: not called CC=2 SCAR=16.6
Subroutine Vpexpandd: not called CC=2 SCAR=16.6
Subroutine Vpexpandq: not called CC=2 SCAR=16.6
Subroutine Vpgatherqd: not called CC=2 SCAR=16.6
Subroutine Vpgatherqq: not called CC=2 SCAR=16.6
Subroutine Vpmovb2m: not called CC=2 SCAR=16.6
Subroutine Vpmovd2m: not called CC=2 SCAR=16.6
Subroutine Vpmovm2b: not called CC=2 SCAR=16.6
Subroutine Vpmovm2d: not called CC=2 SCAR=16.6
Subroutine Vpmovm2q: not called CC=2 SCAR=16.6
Subroutine Vpmovm2w: not called CC=2 SCAR=16.6
Subroutine Vpmovq2m: not called CC=2 SCAR=16.6
Subroutine Vpmovw2m: not called CC=2 SCAR=16.6
Subroutine Vsqrtpd: not called CC=2 SCAR=16.6
Subroutine Xchg: not called CC=2 SCAR=16.6
Subroutine Xor: not called CC=2 SCAR=16.6
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod documented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 92 branches
BranchTrueFalseTotal
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 8 0 8
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 2 0 2
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 8 0 8
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 13 0 13
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 81 0 81
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 16 0 16
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 8 0 8
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
@_ == 2 or confess('Two arguments required, not ' . scalar(@_)) 0 0 0
251 1 ▶ confess "$s$@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
252 }
253  
254 1 if (1) # Instructions that take three operands
255 1 {my $s = '';
256 1 for my $i(@i3)
257 107 {my $I = ucfirst $i;
258 107 push @declarations, $I;
259 107 my $j = $i =~ s(\d\Z) ()r; # Remove number of parameters designated
260 107 $s .= <<END;
261 sub $I(\@)
262 {my (\$target, \$source, \$bits) = \@_;
263 \@_ == 3 or confess "Three arguments required, not ".scalar(\@_);
264 push \@text, qq($j \$target, \$source, \$bits\\n);
265 }
266 END
267 }
268 0 ▶ eval "$s$@";
Subroutine Andn: not called CC=2 SCAR=17.9
Subroutine Bzhi: not called CC=2 SCAR=17.9
Subroutine Imul3: not called CC=2 SCAR=17.9
Subroutine Kaddb: not called CC=2 SCAR=17.9
Subroutine Kaddd: not called CC=2 SCAR=17.9
Subroutine Kaddq: not called CC=2 SCAR=17.9
Subroutine Kaddw: not called CC=2 SCAR=17.9
Subroutine Kandb: not called CC=2 SCAR=17.9
Subroutine Kandd: not called CC=2 SCAR=17.9
Subroutine Kandnb: not called CC=2 SCAR=17.9
Subroutine Kandnd: not called CC=2 SCAR=17.9
Subroutine Kandnq: not called CC=2 SCAR=17.9
Subroutine Kandnw: not called CC=2 SCAR=17.9
Subroutine Kandq: not called CC=2 SCAR=17.9
Subroutine Kandw: not called CC=2 SCAR=17.9
Subroutine Korb: not called CC=2 SCAR=17.9
Subroutine Kord: not called CC=2 SCAR=17.9
Subroutine Korq: not called CC=2 SCAR=17.9
Subroutine Korw: not called CC=2 SCAR=17.9
Subroutine Kshiftlb: not called CC=2 SCAR=17.9
Subroutine Kshiftld: not called CC=2 SCAR=17.9
Subroutine Kshiftlq: not called CC=2 SCAR=17.9
Subroutine Kshiftlw: not called CC=2 SCAR=17.9
Subroutine Kshiftrb: not called CC=2 SCAR=17.9
Subroutine Kshiftrd: not called CC=2 SCAR=17.9
Subroutine Kshiftrq: not called CC=2 SCAR=17.9
Subroutine Kshiftrw: not called CC=2 SCAR=17.9
Subroutine Kunpckb: not called CC=2 SCAR=17.9
Subroutine Kunpckd: not called CC=2 SCAR=17.9
Subroutine Kunpckq: not called CC=2 SCAR=17.9
Subroutine Kunpckw: not called CC=2 SCAR=17.9
Subroutine Kxnorb: not called CC=2 SCAR=17.9
Subroutine Kxnord: not called CC=2 SCAR=17.9
Subroutine Kxnorq: not called CC=2 SCAR=17.9
Subroutine Kxnorw: not called CC=2 SCAR=17.9
Subroutine Kxorb: not called CC=2 SCAR=17.9
Subroutine Kxord: not called CC=2 SCAR=17.9
Subroutine Kxorq: not called CC=2 SCAR=17.9
Subroutine Kxorw: not called CC=2 SCAR=17.9
Subroutine Pdep: not called CC=2 SCAR=17.9
Subroutine Pext: not called CC=2 SCAR=17.9
Subroutine Pextrb: not called CC=2 SCAR=17.9
Subroutine Pextrd: not called CC=2 SCAR=17.9
Subroutine Pextrq: not called CC=2 SCAR=17.9
Subroutine Pextrw: not called CC=2 SCAR=17.9
Subroutine Pinsrb: not called CC=2 SCAR=17.9
Subroutine Pinsrd: not called CC=2 SCAR=17.9
Subroutine Pinsrq: not called CC=2 SCAR=17.9
Subroutine Pinsrw: not called CC=2 SCAR=17.9
Subroutine Vaddd: not called CC=2 SCAR=17.9
Subroutine Vaddpd: not called CC=2 SCAR=17.9
Subroutine Valignb: not called CC=2 SCAR=17.9
Subroutine Valignd: not called CC=2 SCAR=17.9
Subroutine Valignq: not called CC=2 SCAR=17.9
Subroutine Valignw: not called CC=2 SCAR=17.9
Subroutine Vdpps: not called CC=2 SCAR=17.9
Subroutine Vgetmantps: not called CC=2 SCAR=17.9
Subroutine Vmulpd: not called CC=2 SCAR=17.9
Subroutine Vpaddb: not called CC=2 SCAR=17.9
Subroutine Vpaddd: not called CC=2 SCAR=17.9
Subroutine Vpaddq: not called CC=2 SCAR=17.9
Subroutine Vpaddw: not called CC=2 SCAR=17.9
Subroutine Vpandb: not called CC=2 SCAR=17.9
Subroutine Vpandd: not called CC=2 SCAR=17.9
Subroutine Vpandnb: not called CC=2 SCAR=17.9
Subroutine Vpandnd: not called CC=2 SCAR=17.9
Subroutine Vpandnq: not called CC=2 SCAR=17.9
Subroutine Vpandnw: not called CC=2 SCAR=17.9
Subroutine Vpandq: not called CC=2 SCAR=17.9
Subroutine Vpandw: not called CC=2 SCAR=17.9
Subroutine Vpcmpeqb: not called CC=2 SCAR=17.9
Subroutine Vpcmpeqd: not called CC=2 SCAR=17.9
Subroutine Vpcmpeqq: not called CC=2 SCAR=17.9
Subroutine Vpcmpeqw: not called CC=2 SCAR=17.9
Subroutine Vpextrb: not called CC=2 SCAR=17.9
Subroutine Vpextrd: not called CC=2 SCAR=17.9
Subroutine Vpextrq: not called CC=2 SCAR=17.9
Subroutine Vpextrw: not called CC=2 SCAR=17.9
Subroutine Vpinsrb: not called CC=2 SCAR=17.9
Subroutine Vpinsrd: not called CC=2 SCAR=17.9
Subroutine Vpinsrq: not called CC=2 SCAR=17.9
Subroutine Vpinsrw: not called CC=2 SCAR=17.9
Subroutine Vpmullb: not called CC=2 SCAR=17.9
Subroutine Vpmulld: not called CC=2 SCAR=17.9
Subroutine Vpmullq: not called CC=2 SCAR=17.9
Subroutine Vpmullw: not called CC=2 SCAR=17.9
Subroutine Vporb: not called CC=2 SCAR=17.9
Subroutine Vpord: not called CC=2 SCAR=17.9
Subroutine Vporq: not called CC=2 SCAR=17.9
Subroutine Vporvpcmpeqb: not called CC=2 SCAR=17.9
Subroutine Vporvpcmpeqd: not called CC=2 SCAR=17.9
Subroutine Vporvpcmpeqq: not called CC=2 SCAR=17.9
Subroutine Vporvpcmpeqw: not called CC=2 SCAR=17.9
Subroutine Vporw: not called CC=2 SCAR=17.9
Subroutine Vprolq: not called CC=2 SCAR=17.9
Subroutine Vpsubb: not called CC=2 SCAR=17.9
Subroutine Vpsubd: not called CC=2 SCAR=17.9
Subroutine Vpsubq: not called CC=2 SCAR=17.9
Subroutine Vpsubw: not called CC=2 SCAR=17.9
Subroutine Vptestb: not called CC=2 SCAR=17.9
Subroutine Vptestd: not called CC=2 SCAR=17.9
Subroutine Vptestq: not called CC=2 SCAR=17.9
Subroutine Vptestw: not called CC=2 SCAR=17.9
Subroutine Vpxorb: not called CC=2 SCAR=17.9
Subroutine Vpxord: not called CC=2 SCAR=17.9
Subroutine Vpxorq: not called CC=2 SCAR=17.9
Subroutine Vpxorw: not called CC=2 SCAR=17.9
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 107 branches
BranchTrueFalseTotal
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
@_ == 3 or confess('Three arguments required, not ' . scalar(@_)) 0 0 0
269 1 ▶ confess $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
270 }
271  
272 1 if (1) # Instructions that take four operands
273 1 {my $s = '';
274 1 for my $i(@i4)
275 4 {my $I = ucfirst $i;
276 4 push @declarations, $I;
277 4 $s .= <<END;
278 sub $I(\@)
279 {my (\$target, \$source, \$bits, \$zero) = \@_;
280 \@_ == 4 or confess "Four arguments required, not ".scalar(\@_);
281 push \@text, qq($i \$target, \$source, \$bits, \$zero\\n);
282 }
283 END
284 }
285 0 ▶ eval "$s$@";
Subroutine Vpcmpub: not called CC=2 SCAR=17.0
Subroutine Vpcmpud: not called CC=2 SCAR=17.0
Subroutine Vpcmpuq: not called CC=2 SCAR=17.0
Subroutine Vpcmpuw: not called CC=2 SCAR=17.0
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 4 branches
BranchTrueFalseTotal
@_ == 4 or confess('Four arguments required, not ' . scalar(@_)) 0 0 0
@_ == 4 or confess('Four arguments required, not ' . scalar(@_)) 0 0 0
@_ == 4 or confess('Four arguments required, not ' . scalar(@_)) 0 0 0
@_ == 4 or confess('Four arguments required, not ' . scalar(@_)) 0 0 0
286 1 ▶ confess $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
287 }
288  
289 sub traceInstruction($$$) # Trace the location of this instruction in the source code
290 136 ▶ {my ($i, $source, $target) = @_; # Instruction
Subroutine traceInstruction: called CC=6 SCAR=32.2
Pod undocumented
291 136 ▶ return unless $TraceMode and $i =~ m(\Amov\Z); # Trace just these instructions and only when tracing is enabled
Branch: 1 branch
BranchTrueFalseTotal
unless $Nasm::X86::TraceMode and $i =~ /\Amov\Z/ 136 0 136
Condition33%1/3
$Nasm::X86::TraceMode and $i =~ /\Amov\Z/
!ll&&!rl&&r
13600
MC/DC0%0/2
$Nasm::X86::TraceMode and $i =~ /\Amov\Z/
$Nasm::X86::TraceMode $i =~ /\Amov\Z/
Truth table33%1/3
A and B
A= $Nasm::X86::TraceModeB= $i =~ /\Amov\Z/
ABresult
0X0
100
111
292 0 my @c;
293 0 ▶ confess "zmm register in mov" if $source =~ m(\Azmm); # A particularly difficult error to track down
Branch: 1 branch
BranchTrueFalseTotal
if $source =~ /\Azmm/ 0 0 0
294  
295 0 push @text, <<END; # Tracing destroys mm0 so that we can use r11
296 movq mm0, r11;
297 END
298  
299 0 for(1..100) # Write line numbers of traceback
300 0 {my @c = caller $_;
301 0 ▶ last unless @c;
Branch: 1 branch
BranchTrueFalseTotal
unless @c 0 0 0
302 0 $c[3] =~ s(Nasm::X86::) ();
303 0 my (undef, undef, $line, $file) = @c;
304 0 push @text, <<END;
305 mov r11, $line;
306 END
307 }
308  
309 0 push @text, <<END; # Restore r11 from destroyed mm0
310 movq r11, mm0;
311 END
312 }
313 }
314  
315 sub byteRegister($) # The byte register corresponding to a full size register.
316 0 ▶ {my ($r) = @_; # Full size register
Subroutine byteRegister: not called CC=4 SCAR=30.0
Pod undocumented
317 0 ▶ if ($r =~ m(\Ar([abcd])x\Z)) {return $1."l"};
Branch: 1 branch
BranchTrueFalseTotal
if ($r =~ /\Ar([abcd])x\Z/) 0 0 0
318 0 ▶ return dil if $r eq rdi;
Branch: 1 branch
BranchTrueFalseTotal
if $r eq rdi() 0 0 0
319 0 ▶ return sil if $r eq rsi;
Branch: 1 branch
BranchTrueFalseTotal
if $r eq rsi() 0 0 0
320 0 $r."b"
321 }
322  
323 sub wordRegister($) # The word register corresponding to a full size register.
324 0 ▶ {my ($r) = @_; # Full size register
Subroutine wordRegister: not called CC=4 SCAR=30.0
Pod undocumented
325 0 ▶ if ($r =~ m(\Ar([abcd])x\Z)) {return $1."x"};
Branch: 1 branch
BranchTrueFalseTotal
if ($r =~ /\Ar([abcd])x\Z/) 0 0 0
326 0 ▶ return di if $r eq rdi;
Branch: 1 branch
BranchTrueFalseTotal
if $r eq rdi() 0 0 0
327 0 ▶ return si if $r eq rsi;
Branch: 1 branch
BranchTrueFalseTotal
if $r eq rsi() 0 0 0
328 0 $r."w"
329 }
330  
331 sub dWordRegister($) # The double word register corresponding to a full size register.
332 0 ▶ {my ($r) = @_; # Full size register
Subroutine dWordRegister: not called CC=4 SCAR=30.0
Pod undocumented
333 0 ▶ if ($r =~ m(\Ar([abcd])x\Z)) {return "e".$1."x"};
Branch: 1 branch
BranchTrueFalseTotal
if ($r =~ /\Ar([abcd])x\Z/) 0 0 0
334 0 ▶ return edi if $r eq rdi;
Branch: 1 branch
BranchTrueFalseTotal
if $r eq rdi() 0 0 0
335 0 ▶ return esi if $r eq rsi;
Branch: 1 branch
BranchTrueFalseTotal
if $r eq rsi() 0 0 0
336 0 $r."d"
337 }
338  
339 #D1 Labels # Create and set labels.
340  
341 1 my $Labels = 0;
342  
343 sub Label() # Create a unique label. Useful for constructing for and if statements.
344 32 ▶ {"l".++$Labels unless @_; # Generate a label
Subroutine Label: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 32 0 32
345 }
346  
347 sub SetLabel(;$) # Create (if necessary) and set a label in the code section returning the label so set.
348 19 ▶ {my ($l) = @_; # Label
Subroutine SetLabel: called CC=2 SCAR=7.0
Pod documented
349 19 ▶ $l //= Label;
Condition66%2/3
$l //= &Label()
l!l&&r!l&&!r
1180
MC/DC0%0/2
$l //= &Label()
$l &Label()
Truth table66%2/3
A //= B
A= $lB= &Label()
ABresult
1X1
011
000
350 19 push @text, <<END; # Define bytes
351 $l:
352 END
353 19 $l # Return label name
354 }
355  
356 #D1 Data # Layout data
357  
358  
359 #D2 Global variables # Create variables in the data segment if you are willing to make your program non reentrant.
360  
361 sub Ds(@) # Layout bytes in memory and return their label.
362 0 ▶ {my (@d) = @_; # Data to be laid out
Subroutine Ds: not called CC=1 SCAR=6.9
Pod documented
363 0 my $d = join '', @_;
364 0 $d =~ s(') (\')gs;
365 0 my $l = Label;
366 0 push @data, <<END; # Define bytes
367 $l: db '$d';
368 END
369 0 $l # Return label
370 }
371  
372 sub Dbwdq($@) #P Layout data.
373 0 ▶ {my ($s, @d) = @_; # Element size, data to be laid out
Subroutine Dbwdq: not called CC=3 SCAR=24.8
Pod documented
374 0 my $d = join ', ', @d;
375 0 ▶confess "AAAA" if $s eq "q" and $d =~ m(zmm31);
Branch: 1 branch
BranchTrueFalseTotal
if $s eq "q" and $d =~ /zmm31/ 0 0 0
Condition0%0/3
$s eq "q" and $d =~ /zmm31/
!ll&&!rl&&r
000
MC/DC0%0/2
$s eq "q" and $d =~ /zmm31/
$s eq "q" $d =~ /zmm31/
Truth table0%0/3
A and B
A= $s eq "q"B= $d =~ /zmm31/
ABresult
0X0
100
111
376 0 my $l = Label;
377 0 push @data, <<END;
378 $l: d$s $d
379 END
380 0 $l # Return label
381 }
382  
383 sub Db(@) # Layout bytes in the data segment and return their label.
384 0 ▶ {my (@bytes) = @_; # Bytes to layout
Subroutine Db: not called CC=1 SCAR=6.9
Pod documented
385 0 Dbwdq 'b', @_;
386 }
387 sub Dw(@) # Layout words in the data segment and return their label.
388 0 ▶ {my (@words) = @_; # Words to layout
Subroutine Dw: not called CC=1 SCAR=6.9
Pod documented
389 0 Dbwdq 'w', @_;
390 }
391 sub Dd(@) # Layout double words in the data segment and return their label.
392 0 ▶ {my (@dwords) = @_; # Double words to layout
Subroutine Dd: not called CC=1 SCAR=6.9
Pod documented
393 0 Dbwdq 'd', @_;
394 }
395 sub Dq(@) # Layout quad words in the data segment and return their label.
396 0 ▶ {my (@qwords) = @_; # Quad words to layout
Subroutine Dq: not called CC=1 SCAR=6.9
Pod documented
397 0 Dbwdq 'q', @_;
398 }
399  
400 #D2 Global constants # Create constants in read only memory,
401  
402 sub Rbwdq($@) #P Layout data.
403 0 ▶ {my ($s, @d) = @_; # Element size, data to be laid out
Subroutine Rbwdq: not called CC=4 SCAR=30.0
Pod documented
404 0 ▶ my $d = join ', ', map {$_ =~ m(\A\d+\Z) ? sprintf "0x%x", $_ : $_} @d; # Data to be laid out
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ /\A\d+\Z/ ? : 0 0 0
405 0 ▶ if (my $c = $rodata{$s}{$d}) # Data already exists so return it
Branch: 1 branch
BranchTrueFalseTotal
if (my $c = $rodata{$s}{$d}) 0 0 0
406 0 {return $c
407 }
408 0 ▶ if ($LibraryMode) # Create data in a library - we put it inline so that is copied with the position independent subroutine after optimizing the jumps just before assembly.
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::LibraryMode) { } 0 0 0
409 0 {my $l = Label; my $x = Label; # New data - create a label for the data and then jump over it as it is in the code section -- we will have to optimize jumps later
410 0 push @text, <<END; # Save in read only data
411 Jmp $x;
412 $l: d$s $d
413 $x:
414 END
415 0 $rodata{$s}{$d} = $l; # Record label
416 0 return $l;
417 }
418 else
419 0 {my $l = Label; # New data - create a label
420 0 push @rodata, <<END; # Save in read only data
421 $l: d$s $d
422 END
423 0 $rodata{$s}{$d} = $l; # Record label
424 0 return $l;
425 }
426 }
427  
428 sub Rb(@) # Layout bytes in the data segment and return their label.
429 0 ▶ {my (@bytes) = @_; # Bytes to layout
Subroutine Rb: not called CC=1 SCAR=6.9
Pod documented
430 0 Rbwdq 'b', @_;
431 }
432 sub Rw(@) # Layout words in the data segment and return their label.
433 0 ▶ {my (@words) = @_; # Words to layout
Subroutine Rw: not called CC=1 SCAR=6.9
Pod documented
434 0 Rbwdq 'w', @_;
435 }
436 sub Rd(@) # Layout double words in the data segment and return their label.
437 0 ▶ {my (@dwords) = @_; # Double words to layout
Subroutine Rd: not called CC=1 SCAR=6.9
Pod documented
438 0 Rbwdq 'd', @_;
439 }
440 sub Rq(@) # Layout quad words in the data segment and return their label.
441 0 ▶ {my (@qwords) = @_; # Quad words to layout
Subroutine Rq: not called CC=1 SCAR=6.9
Pod documented
442 0 Rbwdq 'q', @_;
443 }
444  
445 sub Rs(@) # Layout bytes in read only memory and return their label.
446 17 ▶ {my (@d) = @_; # Data to be laid out
Subroutine Rs: called CC=5 SCAR=16.7
Pod documented
447 17 my $d = join '', @_;
448 17 my @e;
449 17 for my $e(split //, $d)
450 758 ▶ {if ($e !~ m([A-Z0-9])i) {push @e, sprintf("0x%x", ord($e))} else {push @e, qq('$e')}
Branch: 1 branch
BranchTrueFalseTotal
if (not $e =~ /[A-Z0-9]/i) { } 121 637 758
451 }
452 17 my $e = join ', ', @e;
453 17 my $L = $rodatas{$e};
454 17 ▶ return $L if defined $L; # Data already exists so return it
Branch: 1 branch
BranchTrueFalseTotal
if defined $L 4 13 17
455  
456 13 ▶ if ($LibraryMode) # Create data in a library - we put it inline so that is copied with the position independent subroutine after optimizing the jumps just before assembly.
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::LibraryMode) { } 0 13 13
457 0 {my $l = Label; my $x = Label; # New label for new data
458 0 $rodatas{$e} = $l; # Record label
459 0 push @text, <<END; # Define bytes
460 Jmp $x;
461 $l: db $e, 0;
462 $x:
463 END
464 0 return $l; # Return label
465 }
466 else
467 13 {my $l = Label; # New label for new data
468 13 $rodatas{$e} = $l; # Record label
469 13 push @rodata, <<END; # Define bytes
470 $l: db $e, 0;
471 END
472 13 return $l # Return label
473 }
474 }
475  
476 sub Rutf8(@) # Layout a utf8 encoded string as bytes in read only memory and return their label.
477 0 ▶ {my (@d) = @_; # Data to be laid out
Subroutine Rutf8: not called CC=7 SCAR=40.3
Pod documented
478 0 ▶ confess unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
479 0 my $d = join '', @_;
480 0 my @e;
481 0 for my $e(split //, $d)
482 0 {my $o = ord $e; # Effectively the utf32 encoding of each character
483 0 my $u = convertUtf32ToUtf8($o);
484 0 my $x = sprintf("%08x", $u);
485 0 my $o1 = substr($x, 0, 2);
486 0 my $o2 = substr($x, 2, 2);
487 0 my $o3 = substr($x, 4, 2);
488 0 my $o4 = substr($x, 6, 2);
489  
490 0 ▶ if ($o <= (1 << 7)) {push @e, $o4}
Branch: 3 branches
BranchTrueFalseTotal
if ($o <= 128) { } 0 0 0
elsif ($o <= 2048) { } 0 0 0
elsif ($o <= 65536) { } 0 0 0
491 0 elsif ($o <= (1 << 11)) {push @e, $o3, $o4}
492 0 elsif ($o <= (1 << 16)) {push @e, $o2, $o3, $o4}
493 0 else {push @e, $o1, $o2, $o3, $o4}
494 }
495  
496 0 my $e = join ', ',map {"0x$_"} @e;
497 0 my $L = $rodatas{$e};
498 0 ▶ return $L if defined $L; # Data already exists so return it
Branch: 1 branch
BranchTrueFalseTotal
if defined $L 0 0 0
499 0 my $l = Label; # New label for new data
500 0 $rodatas{$e} = $l; # Record label
501 0 push @rodata, <<END; # Define bytes
502 $l: db $e, 0;
503 END
504 0 $l # Return label
505 }
506  
507 1 my $Pi = "3.141592653589793238462";
508  
509 0 ▶sub Pi32 {Rd("__float32__($Pi)")} #P Pi as a 32 bit float.
Subroutine Pi32: not called CC=1 SCAR=6.9
Pod documented
510 0 ▶sub Pi64 {Rq("__float32__($Pi)")} #P Pi as a 64 bit float.
Subroutine Pi64: not called CC=1 SCAR=6.9
Pod documented
511  
512 #D1 Registers # Operations on registers
513  
514 #D2 Size # Sizes of each register
515  
516 sub RegisterSize($) # Return the size of a register.
517 399 ▶ {my ($R) = @_; # Register
Subroutine RegisterSize: called CC=3 SCAR=11.3
Pod documented
518 399 my $r = &registerNameFromNumber($R);
519 399 ▶ defined($r) or confess;
Branch: 1 branch
BranchTrueFalseTotal
defined $r or confess() 399 0 399
520 399 ▶ defined($Registers{$r}) or confess "No such registers as: $r";
Branch: 1 branch
BranchTrueFalseTotal
defined $Registers{$r} or confess("No such registers as: $r") 399 0 399
521 399 eval "${r}Size()";
522 }
523  
524 0 ▶sub qSize {8} # Size of a quad word in bytes
Subroutine qSize: not called CC=1 SCAR=6.9
Pod documented
525 0 ▶sub dSize {4} # Size of a double word in bytes
Subroutine dSize: not called CC=1 SCAR=6.9
Pod documented
526 0 ▶sub wSize {2} # Size of a word in bytes
Subroutine wSize: not called CC=1 SCAR=6.9
Pod documented
527 0 ▶sub bSize {1} # Size of a byte in bytes
Subroutine bSize: not called CC=1 SCAR=6.9
Pod documented
528  
529 #D2 Push and Pop # Generic versions of push and pop with pop popping the last push.
530  
531 sub PushRR(@) #P Push registers onto the stack without tracking.
532 68 ▶ {my (@r) = @_; # Register
Subroutine PushRR: called CC=8 SCAR=25.9
Pod documented
533 68 my $w = RegisterSize rax;
534 68 my @p; # Non zmm registers
535 my @z; # Zmm registers
536 68 for my $r(map {&registerNameFromNumber($_)} @r)
537 69 ▶ {if ($r =~ m(\Azmm)) # Do zmm's last as they can be optimized
Branch: 1 branch
BranchTrueFalseTotal
if ($r =~ /\Azmm/) { } 0 69 69
538 0 {unshift @z, $r;
539 }
540 else # Non zmm registers
541 69 {push @p, $r;
542 69 my $size = RegisterSize $r;
543 69 ▶ $size or confess "No such register: $r";
Branch: 1 branch
BranchTrueFalseTotal
$size or confess("No such register: $r") 69 0 69
544 69 ▶ if ($size > $w) # Wide registers
Branch: 2 branches
BranchTrueFalseTotal
if ($size > $w) { } 0 69 69
elsif ($r =~ /\Ak/) { } 0 69 69
545 0 {Sub rsp, $size;
546 0 Vmovdqu64 "[rsp]", $r;
547 }
548 elsif ($r =~ m(\Ak)) # Mask as they do not respond to push
549 0 {Sub rsp, $size;
550 0 Kmovq "[rsp]", $r;
551 }
552 else # Normal register
553 69 {Push $r;
554 }
555 }
556 }
557 68 ▶ if (@z) # Zmm registers
Branch: 1 branch
BranchTrueFalseTotal
if (@z) 0 68 68
558 0 {my $w = RegisterSize(zmm0); # Register width
559 0 Sub rsp, $w * @z; # Reduce stack to make room for zmm registers being pushed
560 0 for my $i(keys @z) # Copy each zmm register being pushed to the stack
561 0 {Vmovdqu64 "[rsp+$i*$w]", $z[$i];
562 }
563 }
564 68 my @R = (@p, reverse @z); # Actual push sequence - for some strange reason we have to put it in a variable first
565 }
566  
567 1 my @PushR; # Track pushes
568  
569 sub PushR(@) # Push registers onto the stack.
570 12 ▶ {my (@r) = @_; # Registers
Subroutine PushR: called CC=1 SCAR=0.0
Pod documented
571 12 my @p = PushRR @r; # Push
572 12 push @PushR, [@p]; # Registers pushed we can pop them in order
573 12 scalar(@PushR) # Stack depth
574 }
575  
576 sub PopRR(@) #P Pop registers from the stack without tracking.
577 68 ▶ {my (@r) = @_; # Register
Subroutine PopRR: called CC=8 SCAR=24.4
Pod documented
578 68 my $w = RegisterSize rax;
579 68 my $W = RegisterSize zmm0;
580 68 my $z = 0; # Offset in stack of zmm register
581 68 @r = reverse map{&registerNameFromNumber($_)} @r; # Pop registers in reverse order- any zmm registers will be first
582  
583 68 for my $r(@r) # Pop registers in reverse order- any zmm registers will be first
584 69 ▶ {if ($r =~ m(\Azmm)) # The zmm registers come first and are popped by offset
Branch: 1 branch
BranchTrueFalseTotal
if ($r =~ /\Azmm/) 0 69 69
585 0 {Vmovdqu64 $r, "[rsp+$z]";
586 0 $z += $W;
587 }
588 }
589 68 ▶ Add rsp, $z if $z; # Move up over any zmm registers
Branch: 1 branch
BranchTrueFalseTotal
if $z 0 68 68
590  
591 68 for my $r(@r) # Pop non zmm registers in reverse order
592 69 {my $size = RegisterSize $r;
593 69 ▶ if ($size == $W) {} # The zmm registers have already been popped
Branch: 3 branches
BranchTrueFalseTotal
if ($size == $W) { } 0 69 69
elsif ($size > $w) { } 0 69 69
elsif ($r =~ /\Ak/) { } 0 69 69
594 elsif ($size > $w) # Xmm, ymm
595 0 {Vmovdqu64 $r, "[rsp]";
596 0 Add rsp, $size;
597 }
598 elsif ($r =~ m(\Ak)) # Mask registers
599 0 {Kmovq $r, "[rsp]";
600 0 Add rsp, $size;
601 }
602 else # General purpose registers
603 69 {Pop $r;
604 }
605 }
606 }
607  
608 sub PopR(@) # Pop registers from the stack. Use the last stored set if none explicitly supplied. Pops are done in reverse order to match the original pushing order.
609 12 ▶ {my (@r) = @_; # Register
Subroutine PopR: called CC=4 SCAR=15.9
Pod documented
610 12 ▶ @PushR or confess "No stacked registers";
Branch: 1 branch
BranchTrueFalseTotal
@PushR or confess("No stacked registers") 12 0 12
611 12 my $r = pop @PushR;
612 12 ▶ dump(\@r) eq dump($r) or confess "Mismatched registers:\n".dump($r, \@r) if @r;
Branch: 1 branch
BranchTrueFalseTotal
if @r 0 12 12
Condition25%1/4
@r && (Nasm::X86::dump(\@r) eq Nasm::X86::dump($r) || confess("Mismatched registers:\n" . Nasm::X86::dump($r, \@r)))
!ll
120
Nasm::X86::dump(\@r) eq Nasm::X86::dump($r) or confess("Mismatched registers:\n" . Nasm::X86::dump($r, \@r))
l!l
00
MC/DC0%0/2
@r && (Nasm::X86::dump(\@r) eq Nasm::X86::dump($r) || confess("Mismatched registers:\n" . Nasm::X86::dump($r, \@r)))
@r Nasm::X86::dump(\@r) eq Nasm::X86::dump($r)
Truth table33%1/3
A && B
A= @rB= Nasm::X86::dump(\@r) eq Nasm::X86::dump($r)
ABresult
0X0
100
111
613 12 PopRR @$r; # Pop registers from the stack without tracking
614 }
615  
616 sub registerNameFromNumber($) #P Register name from number where possible.
617 538 ▶ {my ($r) = @_; # Register number
Subroutine registerNameFromNumber: called CC=4 SCAR=14.1
Pod documented
618 538 ▶ return "zmm$r" if $r =~ m(\A(16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $r =~ /\A(16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)\Z/ 0 538 538
619 538 ▶ return "r$r" if $r =~ m(\A(8|9|10|11|12|13|14|15)\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $r =~ /\A(8|9|10|11|12|13|14|15)\Z/ 10 528 538
620 528 ▶ return "k$r" if $r =~ m(\A(0|1|2|3|4|5|6|7)\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $r =~ /\A(0|1|2|3|4|5|6|7)\Z/ 0 528 528
621 528 $r
622 }
623  
624 sub ChooseRegisters($@) #P Choose the specified numbers of registers excluding those on the specified list.
625 0 ▶ {my ($number, @registers) = @_; # Number of registers needed, Registers not to choose
Subroutine ChooseRegisters: not called CC=3 SCAR=24.8
Pod documented
626 0 my %r = (map {$_=>1} map {"r$_"} 8..15);
627 0 delete $r{$_} for @registers;
628 0 ▶ $number <= keys %r or confess "Not enough registers available";
Branch: 1 branch
BranchTrueFalseTotal
$number <= keys %r or confess("Not enough registers available") 0 0 0
629 0 sort keys %r
630 }
631  
632 #D2 Save and Restore # Saving and restoring registers via the stack
633  
634 1 my @syscallSequence = qw(rax rdi rsi rdx r10 r8 r9); # The parameter list sequence for system calls
635  
636 sub SaveFirstFour(@) # Save the first 4 parameter registers making any parameter registers read only.
637 14 ▶ {my (@keep) = @_; # Registers to mark as read only
Subroutine SaveFirstFour: called CC=2 SCAR=6.9
Pod documented
638 14 my $N = 4;
639 14 PushRR $_ for @syscallSequence[0..$N-1];
640 14 $N * &RegisterSize(rax); # Space occupied by push
641 }
642  
643 sub RestoreFirstFour() # Restore the first 4 parameter registers.
644 14 ▶ {my $N = 4;
Subroutine RestoreFirstFour: called CC=2 SCAR=6.9
Pod documented
645 14 PopRR $_ for reverse @syscallSequence[0..$N-1];
646 }
647  
648 sub RestoreFirstFourExceptRax() # Restore the first 4 parameter registers except rax so it can return its value.
649 0 ▶ {my $N = 4;
Subroutine RestoreFirstFourExceptRax: not called CC=2 SCAR=17.9
Pod documented
650 0 PopRR $_ for reverse @syscallSequence[1..$N-1];
651 0 Add rsp, 1*RegisterSize(rax);
652 }
653  
654 sub SaveFirstSeven() # Save the first 7 parameter registers.
655 0 ▶ {my $N = 7;
Subroutine SaveFirstSeven: not called CC=2 SCAR=17.9
Pod documented
656 0 PushRR $_ for @syscallSequence[0..$N-1];
657 0 $N * 1*RegisterSize(rax); # Space occupied by push
658 }
659  
660 sub RestoreFirstSeven() # Restore the first 7 parameter registers.
661 0 ▶ {my $N = 7;
Subroutine RestoreFirstSeven: not called CC=2 SCAR=17.9
Pod documented
662 0 PopRR $_ for reverse @syscallSequence[0..$N-1];
663 }
664  
665 sub RestoreFirstSevenExceptRax() # Restore the first 7 parameter registers except rax which is being used to return the result.
666 0 ▶ {my $N = 7;
Subroutine RestoreFirstSevenExceptRax: not called CC=2 SCAR=17.9
Pod documented
667 0 PopRR $_ for reverse @syscallSequence[1..$N-1];
668 0 Add rsp, 1*RegisterSize(rax);
669 }
670  
671 sub ClearRegisters(@) # Clear registers by setting them to zero.
672 0 ▶ {my (@registers) = @_; # Registers
Subroutine ClearRegisters: not called CC=7 SCAR=40.3
Pod documented
673 0 my $w = RegisterSize rax;
674 0 for my $r(map{registerNameFromNumber $_} @registers) # Each register
675 0 {my $size = RegisterSize $r;
676 0 ▶ Xor $r, $r if $size == $w and $r !~ m(\Ak);
Branch: 1 branch
BranchTrueFalseTotal
if $size == $w and not $r =~ /\Ak/ 0 0 0
Condition0%0/3
$size == $w and not $r =~ /\Ak/
!ll&&!rl&&r
000
MC/DC0%0/2
$size == $w and not $r =~ /\Ak/
$size == $w not $r =~ /\Ak/
Truth table0%0/3
A and not(B)
A= $size == $wB= not $r =~ /\Ak/
ABresult
0X0
100
111
677 0 ▶ Kxorq $r, $r, $r if $size == $w and $r =~ m(\Ak);
Branch: 1 branch
BranchTrueFalseTotal
if $size == $w and $r =~ /\Ak/ 0 0 0
Condition0%0/3
$size == $w and $r =~ /\Ak/
!ll&&!rl&&r
000
MC/DC0%0/2
$size == $w and $r =~ /\Ak/
$size == $w $r =~ /\Ak/
Truth table0%0/3
A and B
A= $size == $wB= $r =~ /\Ak/
ABresult
0X0
100
111
678 0 ▶ Vpxorq $r, $r, $r if $size > $w;
Branch: 1 branch
BranchTrueFalseTotal
if $size > $w 0 0 0
679 }
680 }
681  
682 #D2 Zero flag # Actions on the Zero Flag.
683  
684 sub SetZF() # Set the zero flag.
685 0 ▶ {Cmp rax, rax;
Subroutine SetZF: not called CC=1 SCAR=6.9
Pod documented
686 }
687  
688 sub ClearZF() # Clear the zero flag.
689 0 ▶ {PushR rax;
Subroutine ClearZF: not called CC=1 SCAR=6.9
Pod documented
690 0 Mov rax, 1;
691 0 Cmp rax, 0;
692 0 PopR rax;
693 }
694  
695 #D2 x, y, zmm # Actions specific to mm registers
696  
697 sub xmm(@) # Add xmm to the front of a list of register expressions.
698 0 ▶ {my (@r) = @_; # Register numbers
Subroutine xmm: not called CC=1 SCAR=6.9
Pod documented
699 0 map {"xmm$_"} @_;
700 }
701  
702 sub ymm(@) # Add ymm to the front of a list of register expressions.
703 0 ▶ {my (@r) = @_; # Register numbers
Subroutine ymm: not called CC=1 SCAR=6.9
Pod documented
704 0 map {"ymm$_"} @_;
705 }
706  
707 sub zmm(@) # Add zmm to the front of a list of register expressions.
708 0 ▶ {my (@r) = @_; # Register numbers
Subroutine zmm: not called CC=2 SCAR=17.9
Pod documented
709 0 ▶ map {m/\Azmm/ ? $_ : "zmm$_"} @_;
Branch: 1 branch
BranchTrueFalseTotal
/\Azmm/ ? : 0 0 0
710 }
711  
712 sub zmmM($$) # Add zmm to the front of a register number and a mask after it.
713 0 ▶ {my ($z, $m) = @_; # Zmm number, mask register
Subroutine zmmM: not called CC=9 SCAR=45.0
Pod documented
714 0 ▶ return "zmm$z\{k$m}" if $z =~ m(\A\d+\Z) && $m =~ m(\A\d\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $z =~ /\A\d+\Z/ and $m =~ /\A\d\Z/ 0 0 0
Condition0%0/3
$z =~ /\A\d+\Z/ and $m =~ /\A\d\Z/
!ll&&!rl&&r
000
MC/DC0%0/2
$z =~ /\A\d+\Z/ and $m =~ /\A\d\Z/
$z =~ /\A\d+\Z/ $m =~ /\A\d\Z/
Truth table0%0/3
A and B
A= $z =~ /\A\d+\Z/B= $m =~ /\A\d\Z/
ABresult
0X0
100
111
715 0 ▶ return "zmm$z\{$m}" if $z =~ m(\A\d+\Z) && $m =~ m(\Ak\d\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $z =~ /\A\d+\Z/ and $m =~ /\Ak\d\Z/ 0 0 0
Condition0%0/3
$z =~ /\A\d+\Z/ and $m =~ /\Ak\d\Z/
!ll&&!rl&&r
000
MC/DC0%0/2
$z =~ /\A\d+\Z/ and $m =~ /\Ak\d\Z/
$z =~ /\A\d+\Z/ $m =~ /\Ak\d\Z/
Truth table0%0/3
A and B
A= $z =~ /\A\d+\Z/B= $m =~ /\Ak\d\Z/
ABresult
0X0
100
111
716 0 ▶ return "$z\{k$m}" if $z =~ m(\Azmm\d+\Z) && $m =~ m(\A\d\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $z =~ /\Azmm\d+\Z/ and $m =~ /\A\d\Z/ 0 0 0
Condition0%0/3
$z =~ /\Azmm\d+\Z/ and $m =~ /\A\d\Z/
!ll&&!rl&&r
000
MC/DC0%0/2
$z =~ /\Azmm\d+\Z/ and $m =~ /\A\d\Z/
$z =~ /\Azmm\d+\Z/ $m =~ /\A\d\Z/
Truth table0%0/3
A and B
A= $z =~ /\Azmm\d+\Z/B= $m =~ /\A\d\Z/
ABresult
0X0
100
111
717 0 ▶ return "$z\{$m}" if $z =~ m(\Azmm\d+\Z) && $m =~ m(\Ak\d\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $z =~ /\Azmm\d+\Z/ and $m =~ /\Ak\d\Z/ 0 0 0
Condition0%0/3
$z =~ /\Azmm\d+\Z/ and $m =~ /\Ak\d\Z/
!ll&&!rl&&r
000
MC/DC0%0/2
$z =~ /\Azmm\d+\Z/ and $m =~ /\Ak\d\Z/
$z =~ /\Azmm\d+\Z/ $m =~ /\Ak\d\Z/
Truth table0%0/3
A and B
A= $z =~ /\Azmm\d+\Z/B= $m =~ /\Ak\d\Z/
ABresult
0X0
100
111
718 0 confess "Bad zmm and mask specification: $z $m";
719 }
720  
721 sub zmmMZ($$) # Add zmm to the front of a register number and mask and zero after it.
722 0 ▶ {my ($z, $m) = @_; # Zmm number, mask register number
Subroutine zmmMZ: not called CC=9 SCAR=45.0
Pod documented
723 0 ▶ return "zmm$z\{k$m}\{z}" if $z =~ m(\A\d+\Z) && $m =~ m(\A\d\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $z =~ /\A\d+\Z/ and $m =~ /\A\d\Z/ 0 0 0
Condition0%0/3
$z =~ /\A\d+\Z/ and $m =~ /\A\d\Z/
!ll&&!rl&&r
000
MC/DC0%0/2
$z =~ /\A\d+\Z/ and $m =~ /\A\d\Z/
$z =~ /\A\d+\Z/ $m =~ /\A\d\Z/
Truth table0%0/3
A and B
A= $z =~ /\A\d+\Z/B= $m =~ /\A\d\Z/
ABresult
0X0
100
111
724 0 ▶ return "zmm$z\{$m}\{z}" if $z =~ m(\A\d+\Z) && $m =~ m(\Ak\d\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $z =~ /\A\d+\Z/ and $m =~ /\Ak\d\Z/ 0 0 0
Condition0%0/3
$z =~ /\A\d+\Z/ and $m =~ /\Ak\d\Z/
!ll&&!rl&&r
000
MC/DC0%0/2
$z =~ /\A\d+\Z/ and $m =~ /\Ak\d\Z/
$z =~ /\A\d+\Z/ $m =~ /\Ak\d\Z/
Truth table0%0/3
A and B
A= $z =~ /\A\d+\Z/B= $m =~ /\Ak\d\Z/
ABresult
0X0
100
111
725 0 ▶ return "$z\{k$m}\{z}" if $z =~ m(\Azmm\d+\Z) && $m =~ m(\A\d\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $z =~ /\Azmm\d+\Z/ and $m =~ /\A\d\Z/ 0 0 0
Condition0%0/3
$z =~ /\Azmm\d+\Z/ and $m =~ /\A\d\Z/
!ll&&!rl&&r
000
MC/DC0%0/2
$z =~ /\Azmm\d+\Z/ and $m =~ /\A\d\Z/
$z =~ /\Azmm\d+\Z/ $m =~ /\A\d\Z/
Truth table0%0/3
A and B
A= $z =~ /\Azmm\d+\Z/B= $m =~ /\A\d\Z/
ABresult
0X0
100
111
726 0 ▶ return "$z\{$m}\{z}" if $z =~ m(\Azmm\d+\Z) && $m =~ m(\Ak\d\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $z =~ /\Azmm\d+\Z/ and $m =~ /\Ak\d\Z/ 0 0 0
Condition0%0/3
$z =~ /\Azmm\d+\Z/ and $m =~ /\Ak\d\Z/
!ll&&!rl&&r
000
MC/DC0%0/2
$z =~ /\Azmm\d+\Z/ and $m =~ /\Ak\d\Z/
$z =~ /\Azmm\d+\Z/ $m =~ /\Ak\d\Z/
Truth table0%0/3
A and B
A= $z =~ /\Azmm\d+\Z/B= $m =~ /\Ak\d\Z/
ABresult
0X0
100
111
727 0 confess "Bad zmm and mask with zero specification: $z $m";
728 }
729  
730 #D3 Via general purpose registers # Load zmm registers from data held in the general purpose registers.
731  
732 sub LoadZmm($@) # Load a numbered zmm with the specified bytes.
733 0 ▶ {my ($zmm, @bytes) = @_; # Numbered zmm, bytes
Subroutine LoadZmm: not called CC=1 SCAR=6.9
Pod documented
734 0 my $b = Rb(@bytes);
735 0 Vmovdqu8 zmm($zmm), "[$b]";
736 }
737  
738 sub checkZmmRegister($) #P Check that a register is a zmm register.
739 0 ▶ {my ($z) = @_; # Parameters
Subroutine checkZmmRegister: not called CC=2 SCAR=17.9
Pod documented
740 0 ▶ $z =~ m(\A(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)\Z) or confess "$z is not the number of a zmm register";
Branch: 1 branch
BranchTrueFalseTotal
$z =~ /\A(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)\Z/ or confess("$z is not the number of a zmm register") 0 0 0
741 }
742  
743 sub bRegFromZmm($$$) # Load the specified register from the byte at the specified offset located in the numbered zmm.
744 0 ▶ {my ($register, $zmm, $offset) = @_; # Register to load, numbered zmm register to load from, constant offset in bytes
Subroutine bRegFromZmm: not called CC=3 SCAR=24.8
Pod documented
745  
746 0 ▶ $offset >= 0 && $offset <= RegisterSize zmm0 or
Branch: 1 branch
BranchTrueFalseTotal
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0()) or confess("Offset $offset Out of range") 0 0 0
Condition0%0/3
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
!ll&&!rl&&r
000
MC/DC0%0/2
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
$offset >= 0 $offset <= &RegisterSize(scalar zmm0())
Truth table0%0/3
A and B
A= $offset >= 0B= $offset <= &RegisterSize(scalar zmm0())
ABresult
0X0
100
111
747 confess "Offset $offset Out of range";
748  
749 0 my $b = byteRegister $register; # Corresponding byte register
750 0 my $W = RegisterSize zmm0; # Register size
751 0 Vmovdqu32 "[rsp-$W]", zmm $zmm;
752 0 Mov $b, "[rsp-$W+$offset]"; # Load byte register from offset
753 }
754  
755 sub bRegIntoZmm($$$) # Put the byte content of the specified register into the byte in the numbered zmm at the specified offset in the zmm.
756 0 ▶ {my ($register, $zmm, $offset) = @_; # Register to load, numbered zmm register to load from, constant offset in bytes
Subroutine bRegIntoZmm: not called CC=3 SCAR=24.8
Pod documented
757  
758 0 ▶ $offset >= 0 && $offset <= RegisterSize zmm0 or confess "Out of range";
Branch: 1 branch
BranchTrueFalseTotal
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0()) or confess("Out of range") 0 0 0
Condition0%0/3
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
!ll&&!rl&&r
000
MC/DC0%0/2
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
$offset >= 0 $offset <= &RegisterSize(scalar zmm0())
Truth table0%0/3
A and B
A= $offset >= 0B= $offset <= &RegisterSize(scalar zmm0())
ABresult
0X0
100
111
759  
760 0 my $b = byteRegister $register; # Corresponding byte register
761 0 my $W = RegisterSize zmm0; # Register size
762 0 Vmovdqu32 "[rsp-$W]", zmm $zmm;
763 0 Mov "[rsp-$W+$offset]", $b; # Save byte at specified offset
764 0 Vmovdqu32 zmm($zmm), "[rsp-$W]";
765 }
766  
767 sub wRegFromZmm($$$) # Load the specified register from the word at the specified offset located in the numbered zmm.
768 0 ▶ {my ($register, $zmm, $offset) = @_; # Register to load, numbered zmm register to load from, constant offset in bytes
Subroutine wRegFromZmm: not called CC=3 SCAR=24.8
Pod documented
769  
770 0 ▶ $offset >= 0 && $offset <= RegisterSize zmm0 or confess "Out of range";
Branch: 1 branch
BranchTrueFalseTotal
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0()) or confess("Out of range") 0 0 0
Condition0%0/3
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
!ll&&!rl&&r
000
MC/DC0%0/2
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
$offset >= 0 $offset <= &RegisterSize(scalar zmm0())
Truth table0%0/3
A and B
A= $offset >= 0B= $offset <= &RegisterSize(scalar zmm0())
ABresult
0X0
100
111
771  
772 0 my $W = RegisterSize zmm0; # Register size
773 0 my $w = wordRegister $register; # Corresponding word register
774 0 Vmovdqu32 "[rsp-$W]", zmm $zmm;
775 0 Mov $w, "[rsp-$W+$offset]"; # Load word register from offset
776 }
777  
778 sub wRegIntoZmm($$$) # Put the specified register into the word in the numbered zmm at the specified offset in the zmm.
779 0 ▶ {my ($register, $zmm, $offset) = @_; # Register to load, numbered zmm register to load from, constant offset in bytes
Subroutine wRegIntoZmm: not called CC=3 SCAR=24.8
Pod documented
780  
781 0 ▶ $offset >= 0 && $offset <= RegisterSize zmm0 or confess "Out of range";
Branch: 1 branch
BranchTrueFalseTotal
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0()) or confess("Out of range") 0 0 0
Condition0%0/3
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
!ll&&!rl&&r
000
MC/DC0%0/2
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
$offset >= 0 $offset <= &RegisterSize(scalar zmm0())
Truth table0%0/3
A and B
A= $offset >= 0B= $offset <= &RegisterSize(scalar zmm0())
ABresult
0X0
100
111
782  
783 0 my $w = wordRegister $register; # Corresponding word register
784 0 my $W = RegisterSize zmm0; # Register size
785 0 Vmovdqu32 "[rsp-$W]", zmm $zmm;
786 0 Mov "[rsp-$W+$offset]", $w; # Save word at specified offset
787 0 Vmovdqu32 zmm($zmm), "[rsp-$W]";
788 }
789  
790 sub dRegFromZmm($$$) # Load the specified register from the double word at the specified offset located in the numbered zmm.
791 0 ▶ {my ($register, $zmm, $offset) = @_; # Register to load, numbered zmm register to load from, constant offset in bytes
Subroutine dRegFromZmm: not called CC=3 SCAR=24.8
Pod documented
792  
793 0 ▶ $offset >= 0 && $offset <= RegisterSize zmm0 or confess "Out of range";
Branch: 1 branch
BranchTrueFalseTotal
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0()) or confess("Out of range") 0 0 0
Condition0%0/3
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
!ll&&!rl&&r
000
MC/DC0%0/2
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
$offset >= 0 $offset <= &RegisterSize(scalar zmm0())
Truth table0%0/3
A and B
A= $offset >= 0B= $offset <= &RegisterSize(scalar zmm0())
ABresult
0X0
100
111
794  
795 0 my $W = RegisterSize zmm0; # Register size
796 0 my $w = dWordRegister $register; # Corresponding double word register
797 0 Vmovdqu32 "[rsp-$W]", zmm $zmm;
798 0 Mov $w, "[rsp-$W+$offset]"; # Load double word register from offset
799 }
800  
801 sub dRegIntoZmm($$$) # Put the specified register into the double word in the numbered zmm at the specified offset in the zmm.
802 0 ▶ {my ($register, $zmm, $offset) = @_; # Register to load, numbered zmm register to load from, constant offset in bytes
Subroutine dRegIntoZmm: not called CC=3 SCAR=24.8
Pod documented
803  
804 0 ▶ $offset >= 0 && $offset <= RegisterSize zmm0 or confess "Out of range";
Branch: 1 branch
BranchTrueFalseTotal
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0()) or confess("Out of range") 0 0 0
Condition0%0/3
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
!ll&&!rl&&r
000
MC/DC0%0/2
$offset >= 0 and $offset <= &RegisterSize(scalar zmm0())
$offset >= 0 $offset <= &RegisterSize(scalar zmm0())
Truth table0%0/3
A and B
A= $offset >= 0B= $offset <= &RegisterSize(scalar zmm0())
ABresult
0X0
100
111
805  
806 0 my $w = dWordRegister $register; # Corresponding word register
807 0 my $W = RegisterSize zmm0; # Register size
808 0 Vmovdqu32 "[rsp-$W]", zmm $zmm;
809 0 Mov "[rsp-$W+$offset]", $w; # Save double word at specified offset
810 0 Vmovdqu32 zmm($zmm), "[rsp-$W]";
811 }
812  
813 sub LoadRegFromMm($$$) #P Load the specified register from the numbered zmm at the quad offset specified as a constant number.
814 0 ▶ {my ($mm, $offset, $reg) = @_; # Mm register, offset in quads, general purpose register to load
Subroutine LoadRegFromMm: not called CC=1 SCAR=6.9
Pod documented
815  
816 0 my $w = RegisterSize rax; # Size of rax
817 0 my $W = RegisterSize $mm; # Size of mm register
818 0 Vmovdqu64 "[rsp-$W]", $mm; # Write below the stack
819 0 Mov $reg, "[rsp+$w*$offset-$W]"; # Load register from offset
820 }
821  
822 sub SaveRegIntoMm($$$) # Save the specified register into the numbered zmm at the quad offset specified as a constant number.
823 0 ▶ {my ($mm, $offset, $reg) = @_; # Mm register, offset in quads, general purpose register to load
Subroutine SaveRegIntoMm: not called CC=1 SCAR=6.9
Pod documented
824  
825 0 my $w = RegisterSize rax; # Size of rax
826 0 my $W = RegisterSize $mm; # Size of mm register
827 0 Vmovdqu64 "[rsp-$W]", $mm; # Write below the stack
828 0 Mov "[rsp+$w*$offset-$W]", $reg; # Save register into offset
829 0 Vmovdqu64 $mm, "[rsp-$W]"; # Reload from the stack
830 }
831  
832 #D3 Via variables # Load zmm registers from data held in variables
833  
834 sub extractRegisterNumberFromMM($) #P Extract the register number from an *mm register.
835 0 ▶ {my ($mm) = @_; # Mmm register
Subroutine extractRegisterNumberFromMM: not called CC=2 SCAR=17.9
Pod documented
836 0 ▶ $mm =~ m(\A([zyx]mm)?(\d{1,2})\Z) ? $2 : confess "Not an mm register";
Branch: 1 branch
BranchTrueFalseTotal
$mm =~ /\A([zyx]mm)?(\d{1,2})\Z/ ? : 0 0 0
837 }
838  
839 sub getBwdqFromMm($$$$%) #P Get the numbered byte|word|double word|quad word from the numbered zmm register and return it in a variable.
840 0 ▶ {my ($xyz, $size, $mm, $offset, %options) = @_; # Size of mm, size of get, mm register, offset in bytes either as a constant or as a variable, options
Subroutine getBwdqFromMm: not called CC=17 SCAR=57.2
Pod documented
841 0 my $set = $options{set}; # Optionally set this register or variable rather than returning a new variable
842 0 ▶ my $setVar = $set && ref($set) =~ m(Variable); # Set a this variable to the result
Condition0%0/3
$set && ref($set) =~ /Variable/
!ll&&!rl&&r
000
MC/DC0%0/2
$set && ref($set) =~ /Variable/
$set ref($set) =~ /Variable/
Truth table0%0/3
A && B
A= $setB= ref($set) =~ /Variable/
ABresult
0X0
100
111
843  
844 0 my $n = extractRegisterNumberFromMM $mm; # Register number or fail if not an mm register
845 0 my $m = $xyz.'mm'.$n; # Full name of register
846 0 ▶ if (!ref($offset) and $offset == 0 and $set and !$setVar) # Use Pextr in this special circumstance - need to include other such
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $offset and $offset == 0 and $set and not $setVar) 0 0 0
Condition0%0/9
not ref $offset and $offset == 0 and $set and not $setVar
!ll&&!rl&&r
000
not ref $offset and $offset == 0 and $set
!ll&&!rl&&r
000
not ref $offset and $offset == 0
!ll&&!rl&&r
000
MC/DC0%0/4
not ref $offset and $offset == 0 and $set and not $setVar
not ref $offset $offset == 0 $set not $setVar
Truth table0%0/5
not(A) and B and C and not(D)
A= not ref $offsetB= $offset == 0C= $setD= not $setVar
ABCDresult
0XXX0
10XX0
110X0
11100
11111
847 0 {my $d = dWordRegister $set; # Target a dword register as set is not a variable
848 0 push @text, <<END;
849 vpextr$size $d, xmm$n, 0
850 END
851 0 return;
852 }
853  
854 0 ▶ my $r = $setVar ? rdi : ($set // rdi); # Choose a work register
Branch: 1 branch
BranchTrueFalseTotal
$setVar ? : 0 0 0
Condition0%0/3
$set // rdi()
l!l&&r!l&&!r
000
MC/DC0%0/2
$set // rdi()
$set rdi()
Truth table0%0/3
A // B
A= $setB= rdi()
ABresult
1X1
011
000
855  
856 0 my $o; # The offset into the mm register
857 0 ▶ if (ref($offset)) # The offset is being passed in a variable
Branch: 1 branch
BranchTrueFalseTotal
if (ref $offset) { } 0 0 0
858 0 {$offset->setReg($o = rsi);
859 0 ▶ confess "Cannot use rsi" if $r eq rsi; # Rsi is the offset to apply if a variable offset is supplied so we cannot use rsi in these circumstances as the target register
Branch: 1 branch
BranchTrueFalseTotal
if $r eq rsi() 0 0 0
860 }
861 else # The offset is being passed as a register expression
862 0 {$o = $offset;
863 }
864  
865 0 my $w = RegisterSize $m; # Size of mm register
866 0 Vmovdqu32 "[rsp-$w]", $m; # Write below the stack
867  
868 0 ▶ ClearRegisters $r if $size !~ m(q|d); # Clear the register if necessary
Branch: 1 branch
BranchTrueFalseTotal
unless $size =~ /q|d/ 0 0 0
869 0 ▶ Mov byteRegister($r), "[rsp+$o-$w]" if $size =~ m(b); # Load byte register from offset
Branch: 1 branch
BranchTrueFalseTotal
if $size =~ /b/ 0 0 0
870 0 ▶ Mov wordRegister($r), "[rsp+$o-$w]" if $size =~ m(w); # Load word register from offset
Branch: 1 branch
BranchTrueFalseTotal
if $size =~ /w/ 0 0 0
871 0 ▶ Mov dWordRegister($r), "[rsp+$o-$w]" if $size =~ m(d); # Load double word register from offset
Branch: 1 branch
BranchTrueFalseTotal
if $size =~ /d/ 0 0 0
872 0 ▶ Mov $r, "[rsp+$o-$w]" if $size =~ m(q); # Load register from offset
Branch: 1 branch
BranchTrueFalseTotal
if $size =~ /q/ 0 0 0
873  
874 0 ▶ if ($setVar) # Set the supplied variable
Branch: 1 branch
BranchTrueFalseTotal
if ($setVar) 0 0 0
875 0 {$set->copy($r);
876 0 return;
877 }
878  
879 0 ▶ V("$size at offset $offset in $m", $r) unless $set; # Create variable unless a target register has been supplied
Branch: 1 branch
BranchTrueFalseTotal
unless $set 0 0 0
880 }
881  
882 sub bFromX($$) # Get the byte from the numbered xmm register and return it in a variable.
883 0 ▶ {my ($xmm, $offset) = @_; # Numbered xmm, offset in bytes
Subroutine bFromX: not called CC=1 SCAR=6.9
Pod documented
884 0 getBwdqFromMm('x', 'b', "xmm$xmm", $offset) # Get the numbered byte|word|double word|quad word from the numbered xmm register and return it in a variable
885 }
886  
887 sub wFromX($$) # Get the word from the numbered xmm register and return it in a variable.
888 0 ▶ {my ($xmm, $offset) = @_; # Numbered xmm, offset in bytes
Subroutine wFromX: not called CC=1 SCAR=6.9
Pod documented
889 0 getBwdqFromMm('x', 'w', "xmm$xmm", $offset) # Get the numbered byte|word|double word|quad word from the numbered xmm register and return it in a variable
890 }
891  
892 sub dFromX($$) # Get the double word from the numbered xmm register and return it in a variable.
893 0 ▶ {my ($xmm, $offset) = @_; # Numbered xmm, offset in bytes
Subroutine dFromX: not called CC=1 SCAR=6.9
Pod documented
894 0 getBwdqFromMm('x', 'd', "xmm$xmm", $offset) # Get the numbered byte|word|double word|quad word from the numbered xmm register and return it in a variable
895 }
896  
897 sub qFromX($$) # Get the quad word from the numbered xmm register and return it in a variable.
898 0 ▶ {my ($xmm, $offset) = @_; # Numbered xmm, offset in bytes
Subroutine qFromX: not called CC=1 SCAR=6.9
Pod documented
899 0 getBwdqFromMm('x', 'q', "xmm$xmm", $offset) # Get the numbered byte|word|double word|quad word from the numbered xmm register and return it in a variable
900 }
901  
902 sub bFromZ($$%) # Get the byte from the numbered zmm register and return it in a variable.
903 0 ▶ {my ($zmm, $offset, %options) = @_; # Numbered zmm, offset in bytes, options
Subroutine bFromZ: not called CC=1 SCAR=6.9
Pod documented
904 # my $z = registerNameFromNumber $zmm;
905 0 getBwdqFromMm('z', 'b', $zmm, $offset, %options) # Get the numbered byte|word|double word|quad word from the numbered zmm register and return it in a variable
906 }
907  
908 sub wFromZ($$%) # Get the word from the numbered zmm register and return it in a variable.
909 0 ▶ {my ($zmm, $offset, %options) = @_; # Numbered zmm, offset in bytes,options
Subroutine wFromZ: not called CC=1 SCAR=6.9
Pod documented
910 # my $z = registerNameFromNumber $zmm;
911 0 getBwdqFromMm('z', 'w', $zmm, $offset, %options) # Get the numbered byte|word|double word|quad word from the numbered zmm register and return it in a variable
912 }
913  
914 sub dFromZ($$%) # Get the double word from the numbered zmm register and return it in a variable.
915 0 ▶ {my ($zmm, $offset, %options) = @_; # Numbered zmm, offset in bytes, options
Subroutine dFromZ: not called CC=1 SCAR=6.9
Pod documented
916 # my $z = extractRegisterNumberFromMM $zmm;
917 0 getBwdqFromMm('z', 'd', $zmm, $offset, %options) # Get the numbered byte|word|double word|quad word from the numbered zmm register and return it in a variable
918 }
919  
920 sub qFromZ($$%) # Get the quad word from the numbered zmm register and return it in a variable.
921 0 ▶ {my ($zmm, $offset, %options) = @_; # Numbered zmm, offset in bytes, options
Subroutine qFromZ: not called CC=1 SCAR=6.9
Pod documented
922 # my $z = registerNameFromNumber $zmm;
923 0 getBwdqFromMm('z', 'q', $zmm, $offset, %options) # Get the numbered byte|word|double word|quad word from the numbered zmm register and return it in a variable
924 }
925  
926 #D2 Mask # Operations on mask registers
927  
928 sub SetMaskRegister($$$) # Set the mask register to ones starting at the specified position for the specified length and zeroes elsewhere.
929 0 ▶ {my ($mask, $start, $length) = @_; # Number of mask register to set, register containing start position or 0 for position 0, register containing end position
Subroutine SetMaskRegister: not called CC=4 SCAR=30.0
Pod documented
930 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
931 0 ▶ $mask =~ m(\Ak?[0-7]\Z) or confess "Not a mask register: $mask";
Branch: 1 branch
BranchTrueFalseTotal
$mask =~ /\Ak?[0-7]\Z/ or confess("Not a mask register: $mask") 0 0 0
932  
933 0 PushR 15, 14;
934 0 Mov r15, -1;
935 0 ▶ if ($start) # Non zero start
Branch: 1 branch
BranchTrueFalseTotal
if ($start) { } 0 0 0
936 0 {Mov r14, $start;
937 0 Bzhi r15, r15, r14;
938 0 Not r15;
939 0 Add r14, $length;
940 }
941 else # Starting at zero
942 0 {Mov r14, $length;
943 }
944 0 Bzhi r15, r15, r14;
945 0 Kmovq "k$mask", r15;
946 0 PopR;
947 }
948  
949 sub LoadConstantIntoMaskRegister($$) #P Set a mask register equal to a constant.
950 0 ▶ {my ($mask, $value) = @_; # Number of mask register to load, constant to load
Subroutine LoadConstantIntoMaskRegister: not called CC=3 SCAR=24.8
Pod documented
951 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
952 0 ▶ $mask =~ m(\Ak?[0-7]\Z) or confess "Not the number of a mask register: $mask";
Branch: 1 branch
BranchTrueFalseTotal
$mask =~ /\Ak?[0-7]\Z/ or confess("Not the number of a mask register: $mask") 0 0 0
953 0 my $m = registerNameFromNumber $mask;
954 0 Mov rdi, $value; # Load mask into a general purpose register
955 0 Kmovq $m, rdi; # Load mask register from general purpose register
956 }
957  
958 sub createBitNumberFromAlternatingPattern($@) #P Create a number from a bit pattern.
959 0 ▶ {my ($prefix, @values) = @_; # Prefix bits, +n 1 bits -n 0 bits
Subroutine createBitNumberFromAlternatingPattern: not called CC=12 SCAR=50.5
Pod documented
960 0 ▶ @_ > 1 or confess "Four or more parameters required"; # Must have some values
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 or confess("Four or more parameters required") 0 0 0
961  
962 0 ▶ $prefix =~ m(\A[01]*\Z) or confess "Prefix must be binary"; # Prefix must be binary
Branch: 1 branch
BranchTrueFalseTotal
$prefix =~ /\A[01]*\Z/ or confess("Prefix must be binary") 0 0 0
963 0 @values = grep {$_ != 0} @values; # Remove zeroes as they would produce no string
964  
965 0 for my $i(0..$#values-1) # Check each value alternates with the following values
966 0 ▶ {($values[$i] > 0 && $values[$i+1] > 0 or
Branch: 1 branch
BranchTrueFalseTotal
$values[$i] > 0 && $values[$i + 1] > 0 || $values[$i] < 0 && $values[$i + 1] < 0 and confess("Signs must alternate") 0 0 0
Condition0%0/9
$values[$i] > 0 and $values[$i + 1] > 0 or $values[$i] < 0 and $values[$i + 1] < 0
l!l&&r!l&&!r
000
$values[$i] > 0 and $values[$i + 1] > 0
!ll&&!rl&&r
000
$values[$i] < 0 and $values[$i + 1] < 0
!ll&&!rl&&r
000
MC/DC0%0/4
$values[$i] > 0 and $values[$i + 1] > 0 or $values[$i] < 0 and $values[$i + 1] < 0
$values[$i] > 0 $values[$i + 1] > 0 $values[$i] < 0 $values[$i + 1] < 0
Truth table0%0/7
A and B or C and D
A= $values[$i] > 0B= $values[$i + 1] > 0C= $values[$i] < 0D= $values[$i + 1] < 0
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
967 $values[$i] < 0 && $values[$i+1] < 0) and confess "Signs must alternate";
968 }
969  
970 0 my $b = "0b$prefix";
971 0 for my $v(@values) # String representation of bit string
972 0 ▶ {$b .= '1' x +$v if $v > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $v > 0 0 0 0
973 0 ▶ $b .= '0' x -$v if $v < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $v < 0 0 0 0
974 }
975  
976 0 my $n = eval $b;
977 0 ▶ confess $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
978 0 $n
979 }
980  
981 sub LoadBitsIntoMaskRegister($$@) # Load a bit string specification into a mask register in two clocks.
982 0 ▶ {my ($mask, $prefix, @values) = @_; # Number of mask register to load, prefix bits, +n 1 bits -n 0 bits
Subroutine LoadBitsIntoMaskRegister: not called CC=2 SCAR=17.9
Pod documented
983 0 ▶ @_ > 2 or confess "Three or more parameters required"; # Must have some values
Branch: 1 branch
BranchTrueFalseTotal
@_ > 2 or confess("Three or more parameters required") 0 0 0
984  
985 0 LoadConstantIntoMaskRegister # Load the specified binary constant into a mask register
986 ($mask, createBitNumberFromAlternatingPattern $prefix, @values)
987 }
988  
989 #D3 At a point # Load data into a zmm register at the indoicated point and retrieve data fromn a zmm regisiter at the indicated ppint.
990  
991 sub InsertZeroIntoRegisterAtPoint($$) # Insert a zero into the specified register at the point indicated by another general purpose or mask register moving the higher bits one position to the left.
992 0 ▶ {my ($point, $in) = @_; # Register with a single 1 at the insertion point, register to be inserted into.
Subroutine InsertZeroIntoRegisterAtPoint: not called CC=3 SCAR=24.8
Pod documented
993  
994 0 ▶ ref($point) and confess "Point must be a register";
Branch: 1 branch
BranchTrueFalseTotal
ref $point and confess("Point must be a register") 0 0 0
995  
996 0 my $mask = rdi, my $low = rsi, my $high = rbx; # Choose three work registers and push them
997 0 ▶ if ($point =~ m(\Ak?[0-7]\Z)) # Mask register showing point
Branch: 1 branch
BranchTrueFalseTotal
if ($point =~ /\Ak?[0-7]\Z/) { } 0 0 0
998 0 {Kmovq $mask, $point;
999 }
1000 else # General purpose register showing point
1001 0 {Mov $mask, $point;
1002 }
1003  
1004 0 Dec $mask; # Fill mask to the right of point with ones
1005 0 Andn $high, $mask, $in; # Part of in be shifted
1006 0 Shl $high, 1; # Shift high part
1007 0 And $in, $mask; # Clear high part of target
1008 0 Or $in, $high; # Or in new shifted high part
1009 }
1010  
1011 sub InsertOneIntoRegisterAtPoint($$) # Insert a one into the specified register at the point indicated by another register.
1012 0 ▶ {my ($point, $in) = @_; # Register with a single 1 at the insertion point, register to be inserted into.
Subroutine InsertOneIntoRegisterAtPoint: not called CC=2 SCAR=17.9
Pod documented
1013 0 InsertZeroIntoRegisterAtPoint($point, $in); # Insert a zero
1014 0 ▶ if ($point =~ m(\Ak?[0-7]\Z)) # Mask register showing point
Branch: 1 branch
BranchTrueFalseTotal
if ($point =~ /\Ak?[0-7]\Z/) { } 0 0 0
1015 0 {my ($r) = ChooseRegisters(1, $in); # Choose a general purpose register to place the mask in
1016 0 Kmovq rsi, $point;
1017 0 Or $in, rsi; # Make the zero a one
1018 }
1019 else # General purpose register showing point
1020 0 {Or $in, $point; # Make the zero a one
1021 }
1022 }
1023  
1024 #D1 Comparison codes # The codes used to specify what sort of comparison to perform
1025  
1026 1 my $Vpcmp = genHash("Nasm::X86::CompareCodes", # Compare codes for "Vpcmp"
1027 eq=>0, # Equal
1028 lt=>1, # Less than
1029 le=>2, # Less than or equals
1030 ne=>4, # Not equals
1031 ge=>5, # Greater than or equal
1032 gt=>6, # Greater than
1033 );
1034  
1035 # Forward declarations
1036  
1037 sub BinarySearchD(%);
1038 sub Comment(@);
1039 sub CreateArea(%);
1040 sub K($$);
1041 sub PrintErrStringNL(@);
1042 sub Subroutine(&%);
1043 sub V($;$);
1044  
1045 #D1 Structured Programming # Structured programming constructs
1046  
1047 #D2 If # If statements
1048  
1049 sub If($$;$) # If statement.
1050 2 ▶ {my ($jump, $then, $else) = @_; # Jump op code of variable, then - required , else - optional
Subroutine If: called CC=8 SCAR=30.8
Pod documented
1051 2 ▶ @_ >= 2 && @_ <= 3 or confess;
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 and @_ <= 3 or confess() 2 0 2
Condition33%1/3
@_ >= 2 and @_ <= 3
!ll&&!rl&&r
002
MC/DC0%0/2
@_ >= 2 and @_ <= 3
@_ >= 2 @_ <= 3
Truth table33%1/3
A and B
A= @_ >= 2B= @_ <= 3
ABresult
0X0
100
111
1052  
1053 2 ▶ ref($jump) or $jump =~ m(\AJ(c|e|g|ge|h|l|le|nc|ne|ns|nz|s|z)\Z)
Branch: 1 branch
BranchTrueFalseTotal
ref $jump or $jump =~ /\AJ(c|e|g|ge|h|l|le|nc|ne|ns|nz|s|z)\Z/ or confess("Invalid jump: $jump") 2 0 2
Condition33%1/3
ref $jump or $jump =~ /\AJ(c|e|g|ge|h|l|le|nc|ne|ns|nz|s|z)\Z/
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $jump or $jump =~ /\AJ(c|e|g|ge|h|l|le|nc|ne|ns|nz|s|z)\Z/
ref $jump $jump =~ /\AJ(c|e|g|ge|h|l|le|nc|ne|ns|nz|s|z)\Z/
Truth table33%1/3
A or B
A= ref $jumpB= $jump =~ /\AJ(c|e|g|ge|h|l|le|nc|ne|ns|nz|s|z)\Z/
ABresult
1X1
011
000
1054 or confess "Invalid jump: $jump";
1055  
1056 2 ▶ if (ref($jump)) # Variable expression, if it is non zero perform the then block else the else block
Branch: 2 branches
BranchTrueFalseTotal
if (ref $jump) { } 0 2 2
elsif (not $else) { } 2 0 2
1057 0 ▶ {if (ref($jump) =~ m(scalar)i) # Type of jump opposes the boolean operator
Branch: 1 branch
BranchTrueFalseTotal
if (ref($jump) =~ /scalar/i) { } 0 0 0
1058 0 { __SUB__->($$jump, $then, $else);
1059 }
1060 else # Anything other than a scalar reference indicates that the 'If' statement was handed something other than a Boolean expression
1061 0 {confess "Not a boolean expression";
1062 }
1063 }
1064 elsif (!$else) # No else
1065 2 {my $end = Label;
1066 2 push @text, <<END;
1067 $jump $end;
1068 END
1069 2 &$then;
1070 2 SetLabel $end;
1071 }
1072 else # With else
1073 0 {my $endIf = Label;
1074 0 my $startElse = Label;
1075 0 push @text, <<END;
1076 $jump $startElse
1077 END
1078 0 &$then;
1079 0 Jmp $endIf;
1080 0 SetLabel $startElse;
1081 0 &$else;
1082 0 SetLabel $endIf;
1083 }
1084 }
1085  
1086 sub Then(&) # Then block for an If statement.
1087 2 ▶ {my ($block) = @_; # Then block
Subroutine Then: called CC=1 SCAR=0.0
Pod documented
1088 2 $block;
1089 }
1090  
1091 sub Else(&) # Else block for an If statement.
1092 0 ▶ {my ($block) = @_; # Else block
Subroutine Else: not called CC=1 SCAR=6.9
Pod documented
1093 0 $block;
1094 }
1095  
1096 sub opposingJump($) #P Return the opposite of a jump.
1097 0 ▶ {my ($j) = @_; # Jump
Subroutine opposingJump: not called CC=2 SCAR=17.9
Pod documented
1098 0 my %j = qw(Je Jne Jl Jge Jle Jg Jne Je Jge Jl Jg Jle); # Branch possibilities
1099 0 my $o = $j{$j};
1100 0 ▶ confess "Invalid jump $j" unless $o;
Branch: 1 branch
BranchTrueFalseTotal
unless $o 0 0 0
1101 0 $o
1102 }
1103  
1104 sub ifOr($$;$) # Execute then or else block based on a multiplicity of OR conditions executed until one succeeds.
1105 0 ▶ {my ($conditions, $Then, $Else) = @_; # Array of conditions, then sub, else sub
Subroutine ifOr: not called CC=4 SCAR=30.0
Pod documented
1106  
1107 0 my $test = Label; # Start of test block
1108 0 my $then = Label; # Start of then block
1109 0 my $else = Label; # Start of else block
1110 0 my $end = Label; # End of block
1111  
1112 0 Jmp $test; # Jump over then and else
1113 0 SetLabel $then; # Then block
1114 0 &$Then;
1115 0 Jmp $end;
1116 0 SetLabel $else;
1117 0 ▶ &$Else if $Else;
Branch: 1 branch
BranchTrueFalseTotal
if $Else 0 0 0
1118 0 Jmp $end;
1119  
1120 0 SetLabel $test; # Start of tests
1121  
1122 0 for my $c(@$conditions)
1123 0 {my $j = opposingJump ${&$c};
1124 0 push @text, qq($j $then\n);
1125 }
1126 0 ▶ Jmp $else if $Else;
Branch: 1 branch
BranchTrueFalseTotal
if $Else 0 0 0
1127 0 SetLabel $end;
1128 }
1129  
1130 sub ifAnd($$;$) # Execute then or else block based on a multiplicity of AND conditions executed until one fails.
1131 0 ▶ {my ($conditions, $Then, $Else) = @_; # Array of conditions, then sub, else sub
Subroutine ifAnd: not called CC=5 SCAR=34.0
Pod documented
1132  
1133 0 my $test = Label; # Start of test block
1134 0 my $then = Label; # Start of then block
1135 0 my $else = Label; # Start of else block
1136 0 my $end = Label; # End of block
1137  
1138 0 Jmp $test; # Jump over then and else
1139 0 SetLabel $then; # Then block
1140 0 &$Then;
1141 0 Jmp $end;
1142 0 SetLabel $else;
1143 0 ▶ &$Else if $Else;
Branch: 1 branch
BranchTrueFalseTotal
if $Else 0 0 0
1144 0 Jmp $end;
1145  
1146 0 SetLabel $test; # Start of tests
1147  
1148 0 for my $c(@$conditions)
1149 0 {my $j = ${&$c};
1150 0 ▶ push @text, qq($j $else\n) if $Else;
Branch: 1 branch
BranchTrueFalseTotal
if $Else 0 0 0
1151 0 ▶ push @text, qq($j $end\n) unless $Else;
Branch: 1 branch
BranchTrueFalseTotal
unless $Else 0 0 0
1152 }
1153 0 Jmp $then;
1154 0 SetLabel $end;
1155 }
1156  
1157 sub Ef(&$;$) # Else if block for an If statement.
1158 0 ▶ {my ($condition, $then, $else) = @_; # Condition, then block, else block
Subroutine Ef: not called CC=1 SCAR=6.9
Pod documented
1159 sub
1160 0 ▶ {If (&$condition, $then, $else);
Subroutine __ANON__: not called CC=1 SCAR=6.9
1161 }
1162 0 }
1163  
1164 #D3 Via flags # If depending on the flags register.
1165  
1166 sub IfEq($;$) # If equal execute the then block else the else block.
1167 2 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfEq: called CC=1 SCAR=0.0
Pod documented
1168 2 If(q(Jne), $then, $else); # Opposite code
1169 }
1170  
1171 sub IfNe($;$) # If not equal execute the then block else the else block.
1172 0 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfNe: not called CC=1 SCAR=6.9
Pod documented
1173 0 If(q(Je), $then, $else); # Opposite code
1174 }
1175  
1176 sub IfNz($;$) # If the zero flag is not set then execute the then block else the else block.
1177 0 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfNz: not called CC=1 SCAR=6.9
Pod documented
1178 0 If(q(Jz), $then, $else); # Opposite code
1179 }
1180  
1181 sub IfZ($;$) # If the zero flag is set then execute the then block else the else block.
1182 0 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfZ: not called CC=1 SCAR=6.9
Pod documented
1183 0 If(q(Jnz), $then, $else); # Opposite code
1184 }
1185  
1186 sub IfC($;$) # If the carry flag is set then execute the then block else the else block.
1187 0 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfC: not called CC=1 SCAR=6.9
Pod documented
1188 0 If(q(Jnc), $then, $else); # Opposite code
1189 }
1190  
1191 sub IfNc($;$) # If the carry flag is not set then execute the then block else the else block.
1192 0 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfNc: not called CC=1 SCAR=6.9
Pod documented
1193 0 If(q(Jc), $then, $else); # Opposite code
1194 }
1195  
1196 sub IfLt($;$) # If less than execute the then block else the else block.
1197 0 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfLt: not called CC=1 SCAR=6.9
Pod documented
1198 0 If(q(Jge), $then, $else); # Opposite code
1199 }
1200  
1201 sub IfLe($;$) # If less than or equal execute the then block else the else block.
1202 0 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfLe: not called CC=1 SCAR=6.9
Pod documented
1203 0 If(q(Jg), $then, $else); # Opposite code
1204 }
1205  
1206 sub IfGt($;$) # If greater than execute the then block else the else block.
1207 0 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfGt: not called CC=1 SCAR=6.9
Pod documented
1208 0 If(q(Jle), $then, $else); # Opposite code
1209 }
1210  
1211 sub IfGe($;$) # If greater than or equal execute the then block else the else block.
1212 0 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfGe: not called CC=1 SCAR=6.9
Pod documented
1213 0 If(q(Jl), $then, $else); # Opposite code
1214 }
1215  
1216 sub IfS($;$) #P If signed greater than or equal execute the then block else the else block.
1217 0 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfS: not called CC=1 SCAR=6.9
Pod documented
1218 0 If(q(Jns), $then, $else); # Opposite code
1219 }
1220  
1221 sub IfNs($;$) #P If signed less than execute the then block else the else block.
1222 0 ▶ {my ($then, $else) = @_; # Then - required , else - optional
Subroutine IfNs: not called CC=1 SCAR=6.9
Pod documented
1223 0 If(q(Js), $then, $else); # Opposite code
1224 }
1225  
1226 #D2 Boolean Blocks # Perform blocks depending on boolean conditions
1227  
1228 sub Pass(&) # Pass block for an L<OrBlock>.
1229 0 ▶ {my ($block) = @_; # Block
Subroutine Pass: not called CC=1 SCAR=6.9
Pod documented
1230 0 $block;
1231 }
1232  
1233 sub Fail(&) # Fail block for an L<AndBlock>.
1234 0 ▶ {my ($block) = @_; # Block
Subroutine Fail: not called CC=1 SCAR=6.9
Pod documented
1235 0 $block;
1236 }
1237  
1238 sub Block(&) # Execute a block of code with labels supplied for the start and end of this code.
1239 0 ▶ {my ($code) = @_; # Block of code
Subroutine Block: not called CC=2 SCAR=17.9
Pod documented
1240 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
1241 0 SetLabel(my $start = Label); # Start of block
1242 0 my $end = Label; # End of block
1243 0 &$code($end, $start); # Code with labels supplied
1244 0 SetLabel $end; # End of block
1245 }
1246  
1247 sub AndBlock(&;$) # Short circuit B<and>: execute a block of code to test conditions which, if all of them pass, allows the first block to continue successfully else if one of the conditions fails we execute the optional fail block.
1248 0 ▶ {my ($test, $fail) = @_; # Block, optional failure block
Subroutine AndBlock: not called CC=6 SCAR=37.4
Pod documented
1249 0 ▶ @_ == 1 or @_ == 2 or confess "One or two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or @_ == 2 or confess("One or two parameters") 0 0 0
Condition0%0/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table0%0/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
1250 0 SetLabel(my $start = Label); # Start of test block
1251 0 ▶ my $Fail = @_ == 2 ? Label : undef; # Start of fail block
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 ? : 0 0 0
1252 0 my $end = Label; # End of both blocks
1253 0 ▶ &$test(($Fail // $end), $end, $start); # Test code plus success code
Condition0%0/3
$Fail // $end
l!l&&r!l&&!r
000
MC/DC0%0/2
$Fail // $end
$Fail $end
Truth table0%0/3
A // B
A= $FailB= $end
ABresult
1X1
011
000
1254 0 ▶ if ($fail)
Branch: 1 branch
BranchTrueFalseTotal
if ($fail) 0 0 0
1255 0 {Jmp $end; # Skip the fail block if we succeed in reaching the end of the test block which is the expected behavior for short circuited B<and>.
1256 0 SetLabel $Fail;
1257 0 &$fail($end, $Fail, $start); # Execute when true
1258 }
1259 0 SetLabel $end; # Exit block
1260 }
1261  
1262 sub OrBlock(&;$) # Short circuit B<or>: execute a block of code to test conditions which, if one of them is met, leads on to the execution of the pass block, if all of the tests fail we continue withe the test block.
1263 0 ▶ {my ($test, $pass) = @_; # Tests, optional block to execute on success
Subroutine OrBlock: not called CC=6 SCAR=37.4
Pod documented
1264 0 ▶ @_ == 1 or @_ == 2 or confess "One or two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or @_ == 2 or confess("One or two parameters") 0 0 0
Condition0%0/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table0%0/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
1265 0 SetLabel(my $start = Label); # Start of test block
1266 0 ▶ my $Pass = @_ == 2 ? Label : undef; # Start of pass block
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 ? : 0 0 0
1267 0 my $end = Label; # End of both blocks
1268 0 ▶ &$test(($Pass // $end), $end, $start); # Test code plus fail code
Condition0%0/3
$Pass // $end
l!l&&r!l&&!r
000
MC/DC0%0/2
$Pass // $end
$Pass $end
Truth table0%0/3
A // B
A= $PassB= $end
ABresult
1X1
011
000
1269 0 ▶ if ($pass)
Branch: 1 branch
BranchTrueFalseTotal
if ($pass) 0 0 0
1270 0 {Jmp $end; # Skip the pass block if we succeed in reaching the end of the test block which is the expected behavior for short circuited B<or>.
1271 0 SetLabel $Pass;
1272 0 &$pass($end, $Pass, $start); # Execute when true
1273 }
1274 0 SetLabel $end; # Exit block
1275 }
1276  
1277 #D2 Iteration # Iterate with for loops
1278  
1279 sub For(&$$;$) # For - iterate the block as long as register is less than limit incrementing by increment each time. Nota Bene: The register is not explicitly set to zero as you might want to start at some other number.
1280 0 ▶ {my ($block, $register, $limit, $increment) = @_; # Block, register, limit on loop, increment on each iteration
Subroutine For: not called CC=5 SCAR=34.0
Pod documented
1281 0 ▶ @_ == 3 or @_ == 4 or confess;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or @_ == 4 or confess() 0 0 0
Condition0%0/3
@_ == 3 or @_ == 4
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 3 or @_ == 4
@_ == 3 @_ == 4
Truth table0%0/3
A or B
A= @_ == 3B= @_ == 4
ABresult
1X1
011
000
1282 0 ▶ $increment //= 1; # Default increment
Condition0%0/2
$increment //= 1
l!l
00
MC/DC0%0/1
$increment //= 1
$increment
Truth table0%0/2
A
A= $increment
Aresult
11
00
1283 0 my $next = Label; # Next iteration
1284 0 Comment "For $register $limit";
1285 0 my $start = Label;
1286 0 my $end = Label;
1287 0 SetLabel $start;
1288 0 Cmp $register, $limit;
1289 0 Jge $end;
1290  
1291 0 &$block($start, $end, $next); # Start, end and next labels
1292  
1293 0 SetLabel $next; # Next iteration starting with after incrementing
1294 0 ▶ if ($increment == 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($increment == 1) { } 0 0 0
1295 0 {Inc $register;
1296 }
1297 else
1298 0 {Add $register, $increment;
1299 }
1300 0 Jmp $start; # Restart loop
1301 0 SetLabel $end; # Exit loop
1302 }
1303  
1304 sub ToZero(&$) # Iterate a block the number of times specified in the register which is decremented to zero.
1305 0 ▶ {my ($block, $register) = @_; # Block, limit register
Subroutine ToZero: not called CC=2 SCAR=17.9
Pod documented
1306 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
1307 0 my $end = Label; # Next iteration
1308 0 my $start = SetLabel;
1309 0 Cmp $register, 0;
1310 0 Je $end;
1311 0 &$block($end, $start); # End and start labels
1312 0 Dec $register;
1313 0 Jne $start;
1314 0 SetLabel $end;
1315 }
1316  
1317 sub ForIn(&$$$$) # For - iterate the full block as long as register plus increment is less than than limit incrementing by increment each time then perform the last block with the remainder which might be of length zero.
1318 0 ▶ {my ($full, $last, $register, $limitRegister, $increment) = @_; # Block for full block, block for last block , register, register containing upper limit of loop, increment on each iteration
Subroutine ForIn: not called CC=1 SCAR=6.9
Pod documented
1319  
1320 0 my $start = Label;
1321 0 my $end = Label;
1322  
1323 0 SetLabel $start; # Start of loop
1324 0 PushR $register; # Save the register so we can test that there is still room
1325 0 Add $register, $increment; # Add increment
1326 0 Cmp $register, $limitRegister; # Test that we have room for increment
1327 0 PopR $register; # Remove increment
1328 0 Jg $end;
1329  
1330 0 &$full;
1331  
1332 0 Add $register, $increment; # Increment for real
1333 0 Jmp $start;
1334 0 SetLabel $end;
1335  
1336 0 Sub $limitRegister, $register; # Size of remainder
1337 # IfNz
1338 # Then # Execute remainder
1339 0 {&$last; # Register shows position of remainder while $limit register shows amount left to process
1340 }
1341 }
1342  
1343 sub uptoNTimes(&$$) # Execute a block of code up to a constant number of times controlled by the named register.
1344 0 ▶ {my ($code, $register, $limit) = @_; # Block of code, register controlling loop, constant limit
Subroutine uptoNTimes: not called CC=3 SCAR=24.8
Pod documented
1345 0 ▶ confess "Limit must be a positive integer constant" # Check for a specific limit
Branch: 1 branch
BranchTrueFalseTotal
unless $limit =~ /\A\d+\Z/ and $limit > 0 0 0 0
Condition0%0/3
$limit =~ /\A\d+\Z/ and $limit > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$limit =~ /\A\d+\Z/ and $limit > 0
$limit =~ /\A\d+\Z/ $limit > 0
Truth table0%0/3
A and B
A= $limit =~ /\A\d+\Z/B= $limit > 0
ABresult
0X0
100
111
1346 unless $limit =~ m(\A\d+\Z) and $limit > 0;
1347  
1348 0 Mov $register, $limit; # Set the limit
1349 0 SetLabel(my $start = Label); # Start of block
1350 0 my $end = Label; # End of block
1351 0 &$code($end, $start); # Code with labels supplied
1352 0 Sub $register, 1; # Set flags
1353 0 Jnz $start; # Continue if count still greater than zero
1354 0 SetLabel $end; # End of block
1355 }
1356  
1357 sub ForEver(&) # Iterate for ever.
1358 0 ▶ {my ($block) = @_; # Block to iterate
Subroutine ForEver: not called CC=1 SCAR=6.9
Pod documented
1359  
1360 0 my $start = Label; # Start label
1361 0 my $end = Label; # End label
1362  
1363 0 SetLabel $start; # Start of loop
1364  
1365 0 &$block($start, $end); # End of loop
1366  
1367 0 Jmp $start; # Restart loop
1368 0 SetLabel $end; # End of loop
1369 }
1370  
1371 #D2 Subroutine # Create and call subroutines with the option of placing them into an area that can be writtento a file and reloaded and executed by another process.
1372  
1373 1 my @VariableStack = (1); # Counts the number of parameters and variables on the stack in each invocation of L<Subroutine>. There is at least one variable - the first holds the traceback.
1374  
1375 sub SubroutineStartStack() #P Initialize a new stack frame. The first quad of each frame has the address of the name of the sub in the low dword, and the parameter count in the upper byte of the quad. This field is all zeroes in the initial frame.
1376 8 ▶ {push @VariableStack, 1; # Counts the number of variables on the stack in each invocation of L<Subroutine>. The first quad provides the traceback.
Subroutine SubroutineStartStack: called CC=1 SCAR=0.0
Pod documented
1377 }
1378  
1379 sub copyStructureMinusVariables($) #P Copy a non recursive structure ignoring variables.
1380 0 ▶ {my ($s) = @_; # Structure to copy
Subroutine copyStructureMinusVariables: not called CC=4 SCAR=30.0
Pod documented
1381  
1382 0 my %s = %$s;
1383 0 for my $k(sort keys %s) # Look for sub structures
1384 0 ▶ {if (my $r = ref($s{$k}))
Branch: 1 branch
BranchTrueFalseTotal
if (my $r = ref $s{$k}) 0 0 0
1385 0 ▶ {$s{$k} = __SUB__->($s{$k}) unless $r =~ m(\AVariable\Z); # We do not want to copy the variables yet because we are going to make them into references.
Branch: 1 branch
BranchTrueFalseTotal
unless $r =~ /\AVariable\Z/ 0 0 0
1386 }
1387 }
1388  
1389 0 bless \%s, ref $s; # Return a copy of the structure
1390 }
1391  
1392 sub Subroutine(&%) # Create a subroutine that can be called in assembler code.
1393 10 ▶ {my ($block, %options) = @_; # Block of code as a sub, options
Subroutine Subroutine: called CC=19 SCAR=36.9
Pod documented
1394 10 my $export = $options{export}; # File to export this subroutine to and all its contained subroutines
1395 10 my $name = $options{name}; # Subroutine name
1396 10 my $parameters = $options{parameters}; # Parameters block
1397 10 my $structures = $options{structures}; # Structures provided as parameters
1398 10 my $trace = $options{trace}; # If we are tracing and this subroutine is marked as traceable we always generate a new version of it so that we can trace each specific instance to get the exact context in which this subroutine was called rather than the context in which the original copy was called.
1399  
1400 10 if (1) # Validate options
1401 10 {my %o = %options;
1402 10 delete $o{$_} for qw(export name parameters structures trace);
1403 10 ▶ if (my @i = sort keys %o)
Branch: 1 branch
BranchTrueFalseTotal
if (my(@i) = sort(keys %o)) 0 10 10
1404 0 {confess "Invalid parameters: ".join(', ',@i);
1405 }
1406 }
1407  
1408 10 my %subroutinesSaved; # Current set of subroutine definitions
1409 my %rodataSaved; # Current set of read only elements
1410 10 my %rodatasSaved; # Current set of read only strings
1411  
1412 10 ▶ if ($export) # Create a new set of subroutines for this routine and all of its sub routines
Branch: 1 branch
BranchTrueFalseTotal
if ($export) 0 10 10
1413 0 {%subroutinesSaved = %subroutines; # Save current set of subroutines
1414 0 %subroutines = (); # New set of subroutines
1415 0 %rodataSaved = %rodata; # Current set of read only elements
1416 0 %rodata = (); # New set of read only elements
1417 0 %rodatasSaved = %rodatas; # Current set of read only strings
1418 0 %rodatas = (); # New set of read only strings
1419 0 $LibraryMode = 1; # Please do not try to create a library while creating another library - create them one after the other in separate processes.
1420 }
1421  
1422 # $name or confess "Name required for subroutine, use name=>";
1423 10 ▶ if ($name and my $s = $subroutines{$name}) # Return the label of a pre-existing copy of the code possibly after running the subroutine. Make sure that the subroutine name is different for different subs as otherwise the unexpected results occur.
Branch: 1 branch
BranchTrueFalseTotal
if ($name and my $s = $subroutines{$name}) 2 8 10
Condition66%2/3
$name and my $s = $subroutines{$name}
!ll&&!rl&&r
082
MC/DC50%1/2
$name and my $s = $subroutines{$name}
$name my $s = $subroutines{$name}
Truth table66%2/3
A and B
A= $nameB= my $s = $subroutines{$name}
ABresult
0X0
100
111
1424 2 ▶ {return $s unless $TraceMode and $trace and !$export; # If we are tracing and this subroutine is marked as traceable we always generate a new version of it so that we can trace each specific instance to get the exact context in which this subroutine was called rather than the context in which the original copy was called.
Branch: 1 branch
BranchTrueFalseTotal
unless $Nasm::X86::TraceMode and $trace and not $export 2 0 2
Condition33%2/6
$Nasm::X86::TraceMode and $trace and not $export
!ll&&!rl&&r
200
$Nasm::X86::TraceMode and $trace
!ll&&!rl&&r
200
MC/DC0%0/3
$Nasm::X86::TraceMode and $trace and not $export
$Nasm::X86::TraceMode $trace not $export
Truth table25%1/4
A and B and not(C)
A= $Nasm::X86::TraceModeB= $traceC= not $export
ABCresult
0XX0
10X0
1100
1111
1425 }
1426  
1427 8 if (1) # Check for duplicate parameters
1428 8 {my %c;
1429 8 ▶ $c{$_}++ && confess "Duplicate parameter $_" for @$parameters;
Branch: 1 branch
BranchTrueFalseTotal
$c{$_}++ and confess("Duplicate parameter $_") 0 0 0
1430 }
1431  
1432 8 SubroutineStartStack; # Open new stack layout with references to parameters
1433 0 my %parameters = map {$_ => R($_)} @$parameters; # Create a reference for each parameter.
1434  
1435 8 my %structureCopies; # Copies of the structures being passed that can be use inside the subroutine to access their variables in the stack frame of the subroutine
1436 8 ▶ if ($structures) # Structure provided in the parameter list
Branch: 1 branch
BranchTrueFalseTotal
if ($structures) 0 8 8
1437 0 {for my $n(sort keys %$structures) # Each structure passed
1438 0 {$structureCopies{$n} = copyStructureMinusVariables($$structures{$n}) # A new copy of the structure with its variables left in place
1439 }
1440 }
1441  
1442 8 my $end = Label; Jmp $end; # End label. Subroutines are only ever called - they are not executed in-line so we jump over the implementation of the subroutine. This can cause several forward jumps in a row if a number of subroutines are defined together.
1443 8 my $start = SetLabel; # Start label
1444  
1445 8 my $s = genHash(__PACKAGE__."::Subroutine", # Subroutine definition. If we are creating a library the outer sub is also included in the library.
1446 block => $block, # Block used to generate this subroutine
1447 end => $end, # End label for this subroutine
1448 export => $export, # File this subroutine was exported to if any
1449 name => $name, # Name of the subroutine from which the entry label is located
1450 offset => undef, # The offset of this routine in its library if it is in a library
1451 options => \%options, # Options used by the author of the subroutine
1452 parameters => $parameters, # Parameters definitions supplied by the author of the subroutine which get mapped in to parameter variables.
1453 start => $start, # Start label for this subroutine which includes the enter instruction used to create a new stack frame
1454 structureCopies => \%structureCopies, # Copies of the structures passed to this subroutine with their variables replaced with references
1455 structureVariables => {}, # Map structure variables to references at known positions in the sub
1456 variables => {%parameters}, # Map parameters to references at known positions in the sub
1457 vars => $VariableStack[-1], # Number of variables in subroutine
1458 );
1459  
1460 8 ▶ $subroutines{$name} = $s if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 8 0 8
1461  
1462 8 ▶ $s->mapStructureVariables(\%structureCopies) if $structures; # Map structures before we generate code so that we can put the parameters first in the new stack frame
Branch: 1 branch
BranchTrueFalseTotal
if $structures 0 8 8
1463 8 my $E = @text; # Code entry that will contain the Enter instruction
1464  
1465 8 Enter 0, 0; # The Enter instruction is 4 bytes long
1466 8 &$block({%parameters}, {%structureCopies}, $s); # Code with parameters and structures
1467  
1468 8 my $V = pop @VariableStack; # Number of variables in subroutine stack frame. As parameters and structures are mapped into variables in the subroutine stack frame these variables will be included in the count as well.
1469 8 $V += RegisterSize(zmm0) / RegisterSize rax; # Ensures that we can save the parameter list using a full zmm register without the necessity o loading a mask register
1470 8 ▶ Leave if $V; # Remove frame if there was one
Branch: 1 branch
BranchTrueFalseTotal
if $V 8 0 8
1471 8 Ret; # Return from the sub
1472 8 SetLabel $end; # The end point of the sub where we return to normal code
1473 8 my $w = RegisterSize rax;
1474 8 ▶ $text[$E] = $V ? <<END : ''; # Rewrite enter instruction now that we know how much stack space, in bytes, that we need
Branch: 1 branch
BranchTrueFalseTotal
$V ? : 8 0 8
1475 Enter $V*$w, 0
1476 END
1477  
1478 8 ▶ if ($export) # Create a new set of subroutines for this routine and all of its sub routines
Branch: 1 branch
BranchTrueFalseTotal
if ($export) 0 8 8
1479 0 {$s->writeLibraryToArea({%subroutines}); # Place the subroutine in an area then write the area containing the subroutine and its contained routines to a file
1480 0 %subroutines = %subroutinesSaved; # Save current set of subroutines
1481 0 %rodata = %rodataSaved; # Restore current set of read only elements
1482 0 %rodatas = %rodatasSaved; # Restore current set of read only strings
1483 0 ▶ $subroutines{$name} = $s if $name; # Save current subroutine so we do not regenerate it
Branch: 1 branch
BranchTrueFalseTotal
if $name 0 0 0
1484 0 $LibraryMode = 0; # Please do not try to create a library while creating another library - create them one after the other.
1485 }
1486  
1487 $s # Return subroutine definition
1488 8 }
1489  
1490 sub Nasm::X86::Subroutine::writeLibraryToArea($$) #P Write a subroutine library to an area then save the area in a file so that the subroutine can be reloaded at a later date either as separate file or via incorporation into a thing. A thing was originally an assembly of people as in "The Allthing" or the "Stort Thing".
1491 0 ▶ {my ($s, $subs) = @_; # Sub definition of containing subroutine, definitions of contained subroutines
Subroutine writeLibraryToArea: not called CC=2 SCAR=17.9
1492 0 my $a = CreateArea;
1493 0 my $address = K address => $s->start;
1494 0 my $size = K size => "$$s{end}-$$s{start}";
1495 0 my $off = $a->appendMemory($address, $size); # Copy the containing subroutine into the area
1496  
1497 0 my %offsets; my %saved; # Contained subroutine name to offset mapping. Contained subroutine definitions
1498 0 for my $sub(sort keys %$subs) # Each sub routine definition contained in the containing subroutine
1499 0 {my $r = $$subs{$sub}; # A routine within the subroutine
1500 0 $offsets{$r->name} = $off + K delta => "$$r{start}-$$s{start}"; # Offset to this sub routine within the subroutine
1501 0 $saved {$r->name} = $$subs{$sub}; # Saved this subroutine definition as the sub is included in the area. The subroutine definition enables us to format the parameter list to the subroutine and so call it correctly.
1502 }
1503  
1504 0 my $h = $a->writeLibraryHeader({%offsets}); # Save the library header which tells us where each routine is and what it is called
1505  
1506 0 my $y = $a->yggdrasil;
1507 0 $y->put(&Nasm::X86::Yggdrasil::SubroutineOffsets, $h); # Record the location of the library header
1508  
1509 0 if (1) # Save the definitions of the subs in this area
1510 0 {my $s = "SubroutineDefinitions:".dump(\%saved)."ZZZZ"; # String to save
1511 0 my $d = $a->appendMemory(constantString($s)); # Offset of string containing subroutine definition
1512 0 $y->put(&Nasm::X86::Yggdrasil::SubroutineDefinitions, $d); # Record the offset of the subroutine definition under the unique string number for this subroutine
1513 }
1514  
1515 0 $a->write(V file => Rs $s->export); # Save the area to the named file
1516 0 $a->free;
1517 }
1518  
1519 sub Nasm::X86::Area::writeLibraryHeader($$) # Load a hash of subroutine names and offsets into an area
1520 0 ▶ {my ($area, $subs) = @_; # area to load into, hash of subroutine names to offsets
Subroutine writeLibraryHeader: not called CC=5 SCAR=28.4
1521 0 my $w = RegisterSize(rax);
1522  
1523 0 my $a = $area;
1524 0 my %s = %$subs;
1525 0 my $l = $w * (1 + 2 * scalar keys %s); # Number of quads required
1526  
1527 0 if (1) # Length of concatenated names
1528 1 ▶ {use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
1529 0 $l += length $_ for sort keys %s;
1530 }
1531 0 $l = int(($l + 8) / 8) * 8; # Enough room in bytes for quads and names
1532  
1533 0 Sub rsp, $l; # make space in stack
1534 0 my $p = 0;
1535 0 Mov "qword[rsp+$p]", scalar keys %s; $p += $w; # Number of subroutines
1536  
1537 0 for my $s(sort keys %s) # Subroutine offsets and name lengths
1538 1 ▶ {use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
1539  
1540 my $o = sub # Either a variable or a constant
1541 0 ▶ {my $O = $s{$s}; # Subroutine offset
Subroutine __ANON__: not called CC=2 SCAR=17.9
1542 0 ▶ return $O unless ref($O); # Constant for easier testing
Branch: 1 branch
BranchTrueFalseTotal
unless ref $O 0 0 0
1543 0 $O->setReg(rsi); # Variable - place value in a free register
1544 0 rsi
1545 0 }->();
1546  
1547 0 Mov "qword[rsp+$p]", $o; $p += $w; # Subroutine offsets
1548 0 Mov "qword[rsp+$p]", length $s; $p += $w; # Subroutine name lengths
1549 }
1550  
1551 0 for my $s(sort keys %s) # Subroutine names as one long string
1552 1 ▶ {use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
1553 0 for my $i(1..length $s)
1554 0 {Mov "byte[rsp+$p]", ord substr($s, $i-1, 1); $p += 1; # Load each byte of the names
1555 }
1556 }
1557  
1558 0 my $y = $a->yggdrasil; # Establish Yggdrasil
1559 0 my $o = $a->appendMemory(V(address => rsp), V size => $l); # Load stack into area
1560 0 $y->put(&Nasm::X86::Yggdrasil::SubroutineOffsets, $o); # Save subroutine offsets
1561  
1562 0 Add rsp, $l; # Restores stack
1563  
1564 0 $o # Return the offset of the library header in the area
1565 }
1566  
1567 sub Nasm::X86::Area::readLibraryHeader($$;$) #P Create a tree mapping the numbers assigned to subroutine names to the offsets of the corresponding routines in a library returning the intersection so formed mapping the lexical item numbers (not names) encountered during parsing with the matching routines in the library. Optionally a subroutine (like Nasm::X86::Unisyn::Lex::letterToNumber) can be provided that returns details of an array that maps a single utf32 character to a smaller number which will be assumed to be the number of the routine with that single letter as its name.
1568 0 ▶ {my ($area, $uniqueStrings, $singleLetterArray) = @_; # Area containing subroutine library, unique strings from parse, subroutine returning details of a single character mapping array
Subroutine readLibraryHeader: not called CC=2 SCAR=17.9
1569 0 ▶ @_ >= 2 or confess "At least two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("At least two parameters") 0 0 0
1570  
1571 0 my $a = $area;
1572 0 my $u = $uniqueStrings; # Unique strings from parse
1573 0 my $y = $a->yggdrasil; # Establish Yggdrasil
1574 0 $y->find(&Nasm::X86::Yggdrasil::SubroutineOffsets); # Find subroutine offsets
1575  
1576 If $y->found == 0, # If there are no subroutine offsets then this is not a library
1577 Then
1578 0 ▶ {&PrintErrTraceBack("Not a library");
Subroutine __ANON__: not called CC=1 SCAR=6.9
1579 0 };
1580  
1581 0 PushR my $count = r15, my $sub = r14, my $name = r13, my $library = r12; # Number of subroutines, offset and name length block, name address
1582 0 my $w = RegisterSize $count;
1583 0 ($a->address + $y->data)->setReg($library);
1584 0 Mov $count, "[$library]"; # The number of subroutines
1585 0 Lea $sub, "[$library+$w]"; # Address of offset, name length array
1586 0 Add $library, $w; # Skip count field
1587 0 Mov $name, $count;
1588 0 Shl $name, 4; # Size of offset, name block
1589 0 Add $name, $library; # Address in library of first name - they are all concatenated together one after the other
1590  
1591 0 my $A = CreateArea; # Area to contain mapping
1592 0 my $t = $A->CreateTree; # Resulting mapping
1593 0 my $s = $A->CreateTree(stringTree=>1); # String keys tree mapping routine names to offsets
1594  
1595 ToZero # Each subroutine
1596 0 ▶ {$s->putKeyString( # Routine name to subroutine offset mapping
Subroutine __ANON__: not called CC=2 SCAR=17.9
1597 (my $n = V address => $name),
1598 (my $l = V length => "[$sub+$w]"),
1599 my $o = V offset =>"[$sub]");
1600  
1601 0 ▶ if ($singleLetterArray) # Include single character routines if they are in the optional mapping array
Branch: 1 branch
BranchTrueFalseTotal
if ($singleLetterArray) 0 0 0
1602 0 {my ($char, $size, $fail) = &GetNextUtf8CharAsUtf32($n); # Get the next UTF-8 encoded character from the addressed memory and return it as a UTF-32 char.
1603  
1604 If $l == $size, # Did we read all of the name as one unicode character despite the fact that it occupied several bytes?
1605 Then # Single character name
1606 0 ▶ {my ($n, $l) = &$singleLetterArray;
Subroutine __ANON__: not called CC=1 SCAR=6.9
1607 If $char < $n,
1608 Then # The single character is in the domain of the mapping array
1609 0 ▶ {$l->setReg(rax); # Address array of single letters
Subroutine __ANON__: not called CC=1 SCAR=6.9
1610 0 $char->setReg(rsi); # The character we want to test as utf32
1611 0 Mov edx, "[rax+4*rsi]"; # The smaller number representing the letter
1612 0 Cmp edx, -1;
1613 IfNe
1614 Then # The found smaller number is valid
1615 0 ▶ {Neg rdx; # Count down from zero rather then up to avoid immediate collisions with routines with multiple letters in their names
Subroutine __ANON__: not called CC=1 SCAR=6.9
1616 0 $t->put(V(key => rdx), V offset => "[$sub]"); # Access routine via a single character operator name
1617 0 };
1618 0 };
1619 0 };
1620 }
1621  
1622 0 $u->getKeyString(V(address => $name), V(length => "[$sub+$w]")); # Check whether the subroutine name matches any string in the key string tree.
1623 If $u->found > 0,
1624 Then # Subroutine name matches a unique string so record the mapping between string number and subroutine offset
1625 0 ▶ {$t->put($u->data, V offset => "[$sub]");
Subroutine __ANON__: not called CC=1 SCAR=6.9
1626 0 };
1627 0 Add $name, "[$sub+$w]";
1628 0 Add $sub, 2 * $w;
1629 0 } $count;
1630  
1631 0 PopR;
1632  
1633 0 ($t, $s) # Tree mapping subroutine assigned numbers to subroutine offsets in the library area
1634 }
1635  
1636 sub Nasm::X86::Subroutine::subroutineDefinition($$$) #P Get the definition of a subroutine from an area.
1637 0 ▶ {my ($area, $file, $name) = @_; # Area - but only to get easy access to this routine, file containing area, name of subroutine whose details we want
Subroutine subroutineDefinition: not called CC=3 SCAR=24.8
1638 0 my $a = readBinaryFile $file; # Reload the area
1639 0 ▶ my $b = $a =~ m(SubroutineDefinitions:(.*)ZZZZ)s ? $1 : ''; # Extract Perl subroutine definition code from area as a string
Branch: 1 branch
BranchTrueFalseTotal
$a =~ /SubroutineDefinitions:(.*)ZZZZ/s ? : 0 0 0
1640 0 my $c = eval $b; # Convert to Perl data structure
1641 0 ▶ confess "Cannot extract subroutine definition from file $file\n$@\n" if $@; # Complain if the eval failed
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1642 0 $$c{a}; # Extract subroutine definition
1643 }
1644  
1645 sub Nasm::X86::Subroutine::mapStructureVariables($$@) #P Find the paths to variables in the copies of the structures passed as parameters and replace those variables with references so that in the subroutine we can refer to these variables regardless of where they are actually defined.
1646 0 ▶ {my ($sub, $S, @P) = @_; # Sub definition, copies of source structures, path through copies of source structures to a variable that becomes a reference
Subroutine mapStructureVariables: not called CC=4 SCAR=30.0
1647 0 for my $s(sort keys %$S) # Source keys
1648 0 {my $e = $$S{$s};
1649 0 my $r = ref $e;
1650 0 ▶ next unless $r;
Branch: 1 branch
BranchTrueFalseTotal
unless $r 0 0 0
1651  
1652 0 ▶ if ($r =~ m(Variable)i) # Replace a variable with a reference in the copy of a structure passed in as a parameter
Branch: 1 branch
BranchTrueFalseTotal
if ($r =~ /Variable/i) { } 0 0 0
1653 0 {push @P, $s;
1654 0 my $R = $sub->structureVariables->{dump([@P])} = $$S{$s} = R($e->name); # Path to a reference in the copy of a structure passed as as a parameter
1655 0 pop @P;
1656 }
1657 else # A reference to something else - for the moment we assume that structures are built from non recursive hash references
1658 0 {push @P, $s; # Extend path
1659 0 $sub->mapStructureVariables($e, @P); # Map structure variable
1660 0 pop @P;
1661 }
1662 }
1663 }
1664  
1665 sub Nasm::X86::Subroutine::uploadStructureVariablesToNewStackFrame($$$@) #P Create references to variables in parameter structures from variables in the stack frame of the subroutine.
1666 0 ▶ {my ($sub, $sv, $S, @P) = @_; # Sub definition, Structure variables, Source tree of input structures, path through source structures tree
Subroutine uploadStructureVariablesToNewStackFrame: not called CC=5 SCAR=34.0
1667  
1668 0 for my $s(sort keys %$S) # Source keys
1669 0 {my $e = $$S{$s};
1670 0 my $r = ref $e;
1671 0 ▶ next unless $r; # Element in structure is not a variable or another hash describing a sub structure
Branch: 1 branch
BranchTrueFalseTotal
unless $r 0 0 0
1672 0 ▶ if ($r =~ m(Variable)i) # Variable located
Branch: 1 branch
BranchTrueFalseTotal
if ($r =~ /Variable/i) { } 0 0 0
1673 0 {push @P, $s; # Extend path
1674 0 my $p = dump([@P]); # Path as string
1675 0 my $R = $sub->structureVariables->{$p}; # Reference
1676 0 ▶ if (defined($R))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $R) { } 0 0 0
1677 0 {$sub->uploadToNewStackFrame($sv, $e, $R); # Reference to structure variable from subroutine stack frame
1678 }
1679 else # Unable to locate the corresponding reference
1680 0 {confess "No entry for $p in structure variables";
1681 }
1682 0 pop @P;
1683 }
1684 else # A hash that is not a variable and is therefore assumed to be a non recursive substructure
1685 0 {push @P, $s;
1686 0 $sub->uploadStructureVariablesToNewStackFrame($sv, $e, @P);
1687 0 pop @P;
1688 }
1689 }
1690 }
1691  
1692 sub Nasm::X86::Subroutine::uploadToNewStackFrame($$$$) #P Map a variable in the current stack into a reference in the next stack frame being the one that will be used by this sub.
1693 0 ▶ {my ($sub, $sv, $source, $target) = @_; # Subroutine descriptor, structure variables, source variable in the current stack frame, the reference in the new stack frame
Subroutine uploadToNewStackFrame: not called CC=3 SCAR=24.8
1694 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
1695  
1696 0 my $label = $source->label; # Source in current frame
1697  
1698 0 ▶ if ($source->reference) # Source is a reference
Branch: 1 branch
BranchTrueFalseTotal
if ($source->reference) { } 0 0 0
1699 0 {Mov r15, "[$label]";
1700 0 push @$sv, [$source, $target, 1]; # Source to target mapping and target is a reference
1701 }
1702 else # Source is not a reference
1703 0 {Lea r15, "[$label]";
1704 0 push @$sv, [$source, $target, 0]; # Source to target mapping and target is not a reference
1705 }
1706  
1707 0 my $q = $target->label;
1708 0 $q =~ s(rbp) (rsp); # Labels are based off the stack frame but we are building a new stack frame here so we must rename the stack pointer.
1709 0 my $w = RegisterSize r15;
1710 0 Mov "[$q-$w*2]", r15; # Step over subroutine name pointer and previous frame pointer.
1711 }
1712  
1713 sub Nasm::X86::Subroutine::validateParameters($%) #P Check that the parameters and structures presented in a call to a subroutine math those defined for the subroutine.
1714 10 ▶ {my ($sub, %options) = @_; # Subroutine descriptor, options
Subroutine validateParameters: called CC=23 SCAR=53.7
1715  
1716 10 my %o = %options; # Validate options
1717 10 delete $o{$_} for qw(parameters structures override library); # Parameters are variables, structures are Perl data structures with variables embedded in them, override is a variable that contains the actual address of the subroutine
1718  
1719 10 ▶ if (my @i = sort keys %o)
Branch: 1 branch
BranchTrueFalseTotal
if (my(@i) = sort(keys %o)) 0 10 10
1720 0 {confess "Invalid parameters: ".join(', ',@i);
1721 }
1722  
1723 10 my $parameters = $options{parameters}; # Parameters hash
1724 10 ▶ !$parameters or ref($parameters) =~ m(hash)i or confess
Branch: 1 branch
BranchTrueFalseTotal
not $parameters or ref($parameters) =~ /hash/i or confess("Parameters must be formatted as a hash") 10 0 10
Condition33%1/3
not $parameters or ref($parameters) =~ /hash/i
l!l&&r!l&&!r
1000
MC/DC0%0/2
not $parameters or ref($parameters) =~ /hash/i
not $parameters ref($parameters) =~ /hash/i
Truth table33%1/3
not(A) or B
A= not $parametersB= ref($parameters) =~ /hash/i
ABresult
1X1
011
000
1725 "Parameters must be formatted as a hash";
1726  
1727 10 my $structures = $options{structures}; # Structures hash
1728 10 ▶ !$structures or ref($structures) =~ m(hash)i or confess
Branch: 1 branch
BranchTrueFalseTotal
not $structures or ref($structures) =~ /hash/i or confess("Structures must be formatted as a hash") 10 0 10
Condition33%1/3
not $structures or ref($structures) =~ /hash/i
l!l&&r!l&&!r
1000
MC/DC0%0/2
not $structures or ref($structures) =~ /hash/i
not $structures ref($structures) =~ /hash/i
Truth table33%1/3
not(A) or B
A= not $structuresB= ref($structures) =~ /hash/i
ABresult
1X1
011
000
1729 "Structures must be formatted as a hash";
1730  
1731 10 ▶ if ($parameters) # Check for invalid or missing parameters
Branch: 2 branches
BranchTrueFalseTotal
if ($parameters) { } 0 10 10
elsif (@{$sub->parameters}) { } 0 10 10
1732 0 {my %p = map {$_=>1} $sub->parameters->@*;
1733 0 my @m;
1734 0 for my $p(sort keys %$parameters)
1735 0 ▶ {push @m, "Invalid parameter: '$p'" unless $p{$p};
Branch: 1 branch
BranchTrueFalseTotal
unless $p{$p} 0 0 0
1736 }
1737 0 for my $p(sort keys %p)
1738 0 ▶ {push @m, "Missing parameter: '$p'" unless defined $$parameters{$p};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $parameters->{$p} 0 0 0
1739 }
1740 0 ▶ if (@m)
Branch: 1 branch
BranchTrueFalseTotal
if (@m) 0 0 0
1741 0 {push @m, "Valid parameters : ";
1742 0 $m[-1] .= join ", ", map {"'$_'"} sort $sub->parameters->@*;
1743 0 confess join '', map {"$_\n"} @m;
1744 }
1745 }
1746 elsif ($sub->parameters->@*) # Complain about a lack of parameters if parameters have been defined for this subroutine
1747 0 {confess "Parameters required";
1748 }
1749  
1750 10 ▶ if ($structures) # Check for invalid or missing structures
Branch: 2 branches
BranchTrueFalseTotal
if ($structures) { } 0 10 10
elsif ($sub->options and $sub->options->{'structures'} and %{$sub->options->{'structures'}}) { } 0 20 20
1751 0 {my %s = $sub->options->{structures}->%*;
1752 0 my @m;
1753 0 for my $s(sort keys %$structures)
1754 0 ▶ {push @m, "Invalid structure: '$s'" unless $s{$s};
Branch: 1 branch
BranchTrueFalseTotal
unless $s{$s} 0 0 0
1755 }
1756 0 for my $s(sort keys %s)
1757 0 ▶ {push @m, "Missing structure: '$s'" unless $$structures{$s};
Branch: 1 branch
BranchTrueFalseTotal
unless $structures->{$s} 0 0 0
1758 }
1759 0 ▶ if (@m)
Branch: 1 branch
BranchTrueFalseTotal
if (@m) 0 0 0
1760 0 {push @m, "Valid structures : ";
1761 0 $m[-1] .= join ", ", map {"'$_'"} sort keys %s;
1762 0 confess join '', map {"$_\n"} @m;
1763 }
1764 }
1765 ▶ elsif ($sub->options and # Complain about a lack of structures if structures have been defined for this subroutine
Condition33%2/6
$sub->options and $sub->options->{"structures"} and %{$sub->options->{"structures"}}
!ll&&!rl&&r
1000
$sub->options and $sub->options->{"structures"}
!ll&&!rl&&r
0100
MC/DC0%0/3
$sub->options and $sub->options->{"structures"} and %{$sub->options->{"structures"}}
$sub->options $sub->options->{"structures"} %{$sub->options->{"structures"}}
Truth table25%1/4
A and B and C
A= $sub->optionsB= $sub->options->{"structures"}C= %{$sub->options->{"structures"}}
ABCresult
0XX0
10X0
1100
1111
1766 $sub->options->{structures} and $sub->options->{structures}->%*)
1767 0 {confess "Structures required";
1768 }
1769  
1770 10 ($parameters, $structures)
1771 }
1772  
1773 sub Nasm::X86::Subroutine::call($%) # Call a sub optionally passing it parameters.
1774 10 ▶ {my ($sub, %options) = @_; # Subroutine descriptor, options
Subroutine call: called CC=25 SCAR=58.7
1775  
1776 10 my ($parameters, $structures) = $sub->validateParameters(%options); # Validate the supplied parameters and structures against the specification defining this subroutine
1777  
1778 my $new = sub # Regenerate the subroutine if we are tracing in general and this subroutine is specifically traceable. We do not trace all subroutines because the generated asm code would be big.
1779 10 ▶ {if ($sub->options->{trace} and $TraceMode) # Call the latest version of this subroutine not the original version in case the latest version fails so we can see the exact call stack of the latest version than the call stack of the original version in the context in which it was originally called.
Subroutine __ANON__: called CC=3 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
if ($sub->options->{"trace"} and $Nasm::X86::TraceMode) 0 10 10
Condition33%1/3
$sub->options->{"trace"} and $Nasm::X86::TraceMode
!ll&&!rl&&r
1000
MC/DC0%0/2
$sub->options->{"trace"} and $Nasm::X86::TraceMode
$sub->options->{"trace"} $Nasm::X86::TraceMode
Truth table33%1/3
A and B
A= $sub->options->{"trace"}B= $Nasm::X86::TraceMode
ABresult
0X0
100
111
1780 0 ▶ {return Subroutine(sub{$$sub{block}->&*}, $sub->options->%*);
Subroutine __ANON__: not called CC=1 SCAR=6.9
1781 }
1782 undef
1783 10 }->();
1784  
1785 10 my $w = RegisterSize r15; # Size of a parameter
1786 10 PushR 15; # Use this register to transfer between the current frame and the next frame
1787 10 ▶ Mov "dword[rsp -$w*3]", Rs($sub->name // 'anon'); # Point to subroutine name
Condition50%1/2
$sub->name // "anon"
l!l
100
MC/DC0%0/1
$sub->name // "anon"
$sub->name
Truth table50%1/2
A
A= $sub->name
Aresult
11
00
1788 10 Mov "byte [rsp-1-$w*2]", $sub->vars; # Number of parameters to enable trace back with parameters
1789  
1790 10 for my $name(sort keys $parameters->%*) # Upload the variables referenced by the parameters to the new stack frame
1791 0 {my $s = $$parameters{$name};
1792 0 my $t = $sub->variables->{$name};
1793 0 $sub->uploadToNewStackFrame(my $structureVariables = [], $s, $t);
1794 }
1795  
1796 10 my $name = $$sub{name}; # The name of the sub
1797  
1798 10 ▶ if ($structures) # Upload the variables of each referenced structure to the new stack frame
Branch: 1 branch
BranchTrueFalseTotal
if ($structures) 0 10 10
1799 0 {push @text, <<END; # A comment we can reverse up to if we decide to use a zmm to transfer the parameters
1800 ;AAAAAAAA
1801 END
1802 0 $sub->uploadStructureVariablesToNewStackFrame
1803 (my $structureVariables = [], $structures);
1804 # Use zmm registers, if possible, to reduce the number of instructions required to zap the parameter list
1805 0 my %st; my $nr = 0; my $nd = 0; # Target to source mapping for parameters. Number of references, number of direct parameters.
1806 0 for my $v(@$structureVariables) # Each source to target pair
1807 0 {my $s = $$v[0]->position; # Source position in old stack frame
1808 0 ▶ my $r = $$v[0]->reference ? 1 : 0; # Reference parameter or direct parameter
Branch: 1 branch
BranchTrueFalseTotal
$v->[0]->reference ? : 0 0 0
1809 0 my $t = $$v[1]->position; # Target position in the new stack frame
1810 0 my $k = sprintf "%08d", $t; # Normalize the target position so it can be sorted
1811 0 $st{$k} = $s; # Target from source mapping
1812 0 ▶ $r ? ++$nr : ++$nd; # Number of references versus number of direct parameters
Branch: 1 branch
BranchTrueFalseTotal
$r ? : 0 0 0
1813 }
1814  
1815 0 my @st = map{[$_+0, $st{$_}]} sort keys %st; # Parameters in stack frame order
1816  
1817 0 ▶ if (1 and (!$nr && $nd or $nr && !$nd) and # The mapping is compact so we can do the whole thing without masking - and - the mapping is big enough to use zmm registers. Further we are either doing everything by reference or everything directly - we do not have a mixture of references and directs require more instructions to handle - the goal here is, after all, to reduce the number of instructions required to construct a parameter list.
Branch: 1 branch
BranchTrueFalseTotal
if (!$nr && $nd || $nr && !$nd and @st >= 4 and 1 + $st[-1][0] - $st[0][0] == @st) 0 0 0
Condition0%0/15
!$nr && $nd || $nr && !$nd and @st >= 4 and 1 + $st[-1][0] - $st[0][0] == @st
!ll&&!rl&&r
000
!$nr && $nd || $nr && !$nd and @st >= 4
!ll&&!rl&&r
000
not $nr and $nd or $nr and not $nd
l!l&&r!l&&!r
000
not $nr and $nd
!ll&&!rl&&r
000
$nr and not $nd
!ll&&!rl&&r
000
MC/DC0%0/6
!$nr && $nd || $nr && !$nd and @st >= 4 and 1 + $st[-1][0] - $st[0][0] == @st
not $nr $nd $nr not $nd @st >= 4 1 + $st[-1][0] - $st[0][0] == @st
Truth table0%0/13
not(A) and B or C and not(D) and E and F
A= not $nrB= $ndC= $nrD= not $ndE= @st >= 4F= 1 + $st[-1][0] - $st[0][0] == @st
ABCDEFresult
0X0XXX0
0X10XX0
100XXX0
1010XX0
11XX0X0
0X110X0
10110X0
11XX100
0X11100
1011100
11XX111
0X11111
1011111
1818 @st >= 4 and 1 + $st[-1][0] - $st[0][0] == @st)
1819 0 ▶ {pop @text while @text and $text[-1] !~ m(\;AAAAAAAA); # Back up to the start of the structure parameters
Branch: 1 branch
BranchTrueFalseTotal
@text and not $text[-1] =~ /\;AAAAAAAA/ and do { pop @text } 0 0 0
Condition0%0/3
@text and not $text[-1] =~ /\;AAAAAAAA/
!ll&&!rl&&r
000
MC/DC0%0/2
@text and not $text[-1] =~ /\;AAAAAAAA/
@text not $text[-1] =~ /\;AAAAAAAA/
Truth table0%0/3
A and not(B)
A= @textB= not $text[-1] =~ /\;AAAAAAAA/
ABresult
0X0
100
111
1820 0 my $w = RegisterSize rax; # Size of one parameter
1821 0 my $W = RegisterSize zmm0; # Space in parameter block
1822 0 my $b = $W / $w; # Number of parameters per block
1823 0 my @o; # The offsets to load into one zmm register at a time to zap the parameter list.
1824  
1825 0 ▶ Vpbroadcastq zmm0, rbp if $nd; # Direct parameters: Load the value of the stack base pointer into every cell to compute the address of each source parameter
Branch: 1 branch
BranchTrueFalseTotal
if $nd 0 0 0
1826  
1827 0 my $stackOffsetForParameterBlock = 1 + $st[0][0]; # We start to load the parameters into the new stack (first) at this location
1828 0 for my $i(keys @st) # Each source to target mapping
1829 0 {push @o, $st[$i][1]; # Offset of source
1830 0 ▶ if (@o == $b or $i == $#st) # Dump the latest block of parameters
Branch: 1 branch
BranchTrueFalseTotal
if (@o == $b or $i == $#st) 0 0 0
Condition0%0/3
@o == $b or $i == $#st
l!l&&r!l&&!r
000
MC/DC0%0/2
@o == $b or $i == $#st
@o == $b $i == $#st
Truth table0%0/3
A or B
A= @o == $bB= $i == $#st
ABresult
1X1
011
000
1831 0 ▶ {push @o, 0 while @o < $b; # Pad to a full block
Branch: 1 branch
BranchTrueFalseTotal
@o < $b and do { push @o, 0 } 0 0 0
1832 0 my $o = Rq map {$w * -$_} reverse @o; # Offsets for this zap block
1833 0 ▶ if ($nd) # All direct parameters
Branch: 1 branch
BranchTrueFalseTotal
if ($nd) { } 0 0 0
1834 0 {Vpaddq zmm1, zmm0, "[$o]"; # Add the offsets of the base of the stack frame to get the address of each parameter
1835 }
1836 else # All direct parameters
1837 0 {Vmovdqu8 zmm0, qq([$o]); # Load offsets from zap table
1838 0 Kxnorq k1, k1, k1; # Reference parameters: Set mask to all ones - we can safely load offsets of zero as they will simply load the value of rbp. Mask register set to zero at all bits where it loaded successfully.
1839 0 Vpgatherqq zmmM(1, 1), "[rbp+zmm0]"; # Load the contents of memory at these offsets from rbp
1840 }
1841 0 my $p = $w * $stackOffsetForParameterBlock + $W; # Offset at which we start the layout of the latest parameter block
1842 0 Vmovdqu8 qq([rsp-$p]), zmm1; # Layout the parameter zap table
1843 0 $stackOffsetForParameterBlock += $b; # Next block of parameters
1844 0 @o = (); # Clear parameter block to accept new parameters
1845 }
1846 }
1847 }
1848 }
1849  
1850 10 ▶ if (my $l = $options{library}) # A variable containing the start address of a library
Branch: 2 branches
BranchTrueFalseTotal
if (my $l = $options{'library'}) { } 0 10 10
elsif (my $o = $options{'override'}) { } 0 10 10
1851 0 {$l->setReg(rdi);
1852 0 ▶ if (my $o = $sub->offset) # The offset of the entry point into the library
Branch: 1 branch
BranchTrueFalseTotal
if (my $o = $sub->offset) { } 0 0 0
1853 0 {$o->setReg(rsi);
1854 0 Add rdi, rsi;
1855 0 Call rdi;
1856 }
1857 else
1858 0 {confess "Supply the address of the containing library";
1859 }
1860 }
1861 elsif (my $o = $options{override}) # A variable containing the address of the subroutine to call
1862 {#$o->setReg(rdi);
1863 #Call rdi;
1864 0 Call $o->addressExpr;
1865 }
1866 else # Call via label
1867 10 ▶ {if ($new) # Call new generation created for tracing
Branch: 1 branch
BranchTrueFalseTotal
if ($new) { } 0 10 10
1868 0 {Call $new->start;
1869 }
1870 else # Call original generation
1871 10 {Call $sub->start;
1872 }
1873 }
1874 10 PopR;
1875 }
1876  
1877 sub Nasm::X86::Subroutine::inline($%) # Call a sub by in-lining it, optionally passing it parameters.
1878 0 ▶ {my ($sub, %options) = @_; # Subroutine descriptor, options
Subroutine inline: not called CC=1 SCAR=6.9
1879  
1880 0 my ($parameters, $structures) = $sub->validateParameters(%options); # Validate the supplied parameters and structures against the specification defining this subroutine
1881  
1882 0 $sub->block->($parameters, $structures, $sub); # Generate code using the supplied parameters and structures
1883 }
1884  
1885 #D2 Trace back # Generate a subroutine calll trace back
1886  
1887 sub PrintTraceBack($) #P Trace the call stack.
1888 0 ▶ {my ($channel) = @_; # Channel to write on
Subroutine PrintTraceBack: not called CC=1 SCAR=6.9
Pod documented
1889  
1890 my $s = Subroutine
1891 0 ▶ {PushR my @save = (rax, rdi, r9, r10, r8, r12, r13, r14, r15);
Subroutine __ANON__: not called CC=1 SCAR=6.9
1892 0 my $stack = r15;
1893 0 my $count = r14;
1894 0 my $index = r13;
1895 0 my $parameter = r12; # Number of parameters
1896 0 my $maxCount = r8; # Maximum number of parameters - should be r11 but r11 is free in linux and does not survive syscalls.
1897 0 my $depth = r10; # Depth of trace back
1898 0 ClearRegisters @save;
1899  
1900 0 Mov $stack, rbp; # Current stack frame
1901 AndBlock # Each level
1902 0 ▶ {my ($fail, $end, $start) = @_; # Fail block, end of fail block, start of test block
Subroutine __ANON__: not called CC=1 SCAR=6.9
1903 0 Mov $stack, "[$stack]"; # Up one level
1904 0 Mov rax, "[$stack-8]";
1905 0 Mov $count, rax;
1906 0 Shr $count, 56; # Top byte contains the parameter count
1907 0 Cmp $count, $maxCount; # Compare this count with maximum so far
1908 0 Cmovg $maxCount, $count; # Update count if greater
1909 0 Shl rax, 8; Shr rax, 8; # Remove parameter count
1910 0 Je $end; # Reached top of stack if rax is zero
1911 0 Inc $depth; # Depth of trace back
1912 0 Jmp $start; # Next level
1913 0 };
1914  
1915 0 Mov $stack, rbp; # Current stack frame
1916 0 &PrintNL($channel); # Print title
1917 0 &PrintString($channel, "Subroutine trace back, depth: ");
1918 0 PushR rax;
1919 0 Mov rax, $depth;
1920 0 &PrintRaxRightInDec(V(width=>2), $channel);
1921 0 PopR rax;
1922 0 &PrintNL($channel);
1923  
1924 AndBlock # Each level
1925 0 ▶ {my ($fail, $end, $start) = @_; # Fail block, end of fail block, start of test block
Subroutine __ANON__: not called CC=1 SCAR=6.9
1926 0 Mov $stack, "[$stack]"; # Up one level
1927 0 Mov rax, "[$stack-8]";
1928 0 Mov $count, rax;
1929 0 Shr $count, 56; # Top byte contains the parameter count
1930 0 Shl rax, 8; Shr rax, 8; # Remove parameter count
1931 0 Je $end; # Reached top of stack
1932 0 Cmp $count, 0; # Check for parameters
1933 IfGt
1934 Then # One or more parameters
1935 0 ▶ {Mov $index, 0;
Subroutine __ANON__: not called CC=1 SCAR=6.9
1936 For
1937 0 ▶ {my ($start, $end, $next) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
1938 0 Mov $parameter, $index;
1939 0 Add $parameter, 2; # Skip traceback
1940 0 Shl $parameter, 3; # Each parameter is a quad
1941 0 Neg $parameter; # Offset from stack
1942 0 Add $parameter, $stack; # Position on stack
1943 0 Mov $parameter, "[$parameter]"; # Parameter reference to variable
1944 0 Push rax;
1945 0 Mov rax, "[$parameter]"; # Variable content
1946 0 &PrintRaxInHex($channel);
1947 0 Pop rax;
1948 0 &PrintSpace($channel, 4);
1949 0 } $index, $count;
1950 For # Vertically align subroutine names
1951 0 ▶ {my ($start, $end, $next) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
1952 0 &PrintSpace($channel, 23);
1953 0 } $index, $maxCount;
1954 0 };
1955  
1956 0 StringLength(&V(string => rax))->setReg(rdi); # Length of name of subroutine
1957 0 &PrintMemoryNL($channel); # Print name of subroutine
1958 0 Jmp $start; # Next level
1959 0 };
1960 0 &PrintNL($channel);
1961 0 PopR;
1962 0 } name => "SubroutineTraceBack_$channel";
1963  
1964 0 $s->call;
1965 }
1966  
1967 sub PrintErrTraceBack($) #P Print sub routine track back on stderr and then exit with a message.
1968 0 ▶ {my ($message) = @_; # Reason why we are printing the trace back and then stopping
Subroutine PrintErrTraceBack: not called CC=1 SCAR=6.9
Pod documented
1969 0 my ($p, $f, $l) = caller(0);
1970 0 PrintStringNL($stderr, "$message at $0 line $l");
1971 0 PrintTraceBack($stderr);
1972 0 Exit(1);
1973 }
1974  
1975 sub PrintOutTraceBack($) # Print sub routine track back on stdout and then exit with a message.
1976 0 ▶ {my ($message) = @_; # Reason why we are printing the trace back and then stopping
Subroutine PrintOutTraceBack: not called CC=1 SCAR=6.9
Pod documented
1977 0 &PrintOutStringNL($message);
1978 0 PrintTraceBack($stdout);
1979 0 Exit(1);
1980 }
1981  
1982 sub OnSegv() # Request a trace back followed by exit on a B<segv> signal.
1983 0 ▶ {my $s = Subroutine # Subroutine that will cause an error to occur to force a trace back to be printed
Subroutine OnSegv: not called CC=1 SCAR=6.9
Pod documented
1984 0 ▶ {my $end = Label;
Subroutine __ANON__: not called CC=2 SCAR=17.9
1985 0 Jmp $end; # Jump over subroutine definition
1986 0 my $start = SetLabel;
1987 0 Enter 0, 0; # Inline code of signal handler
1988 0 Mov r15, rbp; # Preserve the new stack frame
1989 0 Mov rbp, "[rbp]"; # Restore our last stack frame
1990 0 PrintOutTraceBack 'Segmentation error'; # Print our trace back
1991 0 Mov rbp, r15; # Restore supplied stack frame
1992 0 Exit(0); # Exit so we do not trampoline. Exit with code zero to show that the program is functioning correctly, else L<Assemble> will report an error.
1993 0 Leave;
1994 0 Ret;
1995 0 SetLabel $end;
1996  
1997 0 Mov r15, 0; # Push sufficient zeros onto the stack to make a structure B<sigaction> as described in: https://www.man7.org/linux/man-pages/man2/sigaction.2.html
1998 0 Push r15 for 1..16;
1999  
2000 0 Mov r15, $start; # Actual signal handler
2001 0 Mov "[rsp]", r15; # Show as signal handler
2002 0 Mov "[rsp+0x10]", r15; # Add as trampoline as well - which is fine because we exit in the handler so this will never be called
2003 0 Mov r15, 0x4000000; # Mask to show we have a trampoline which is, apparently, required on x86
2004 0 Mov "[rsp+0x8]", r15; # Confirm we have a trampoline
2005  
2006 0 Mov rax, 13; # B<Sigaction> from B<kill -l>
2007 0 Mov rdi, 11; # Confirmed B<SIGSEGV = 11> from B<kill -l> and tracing with B<sde64>
2008 0 Mov rsi, rsp; # Structure B<sigaction> structure on stack
2009 0 Mov rdx, 0; # Confirmed by trace
2010 0 Mov r10, 8; # Found by tracing B<signal.c> with B<sde64> it is the width of the signal set and mask. B<signal.c> is reproduced below.
2011 0 Syscall;
2012 0 Add rsp, 128;
2013 0 } [], name=>"on segv";
2014  
2015 0 $s->call;
2016 }
2017  
2018 #D2 Comments # Inserts comments into the generated assember code.
2019  
2020 sub Comment(@) # Insert a comment into the assembly code.
2021 1 ▶ {my (@comment) = @_; # Text of comment
Subroutine Comment: called CC=1 SCAR=0.0
Pod documented
2022 1 my $c = join "", @comment;
2023 1 my ($p, $f, $l) = caller;
2024 1 push @text, <<END;
2025 ; $c at $f line $l
2026 END
2027 }
2028  
2029 #D1 Print # Print the values of registers and memory interspersed with constant strings. The print commands do not overwrite the free registers as doing so would make debugging difficult.
2030  
2031 #D2 Strings # Print constant and variable strings
2032  
2033 sub PrintNL($) #P Print a new line to stdout or stderr.
2034 1 ▶ {my ($channel) = @_; # Channel to write on
Subroutine PrintNL: called CC=2 SCAR=6.9
Pod documented
2035 1 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 1 0 1
2036  
2037 my $s = Subroutine
2038 1 ▶ {SaveFirstFour;
Subroutine __ANON__: called CC=1 SCAR=0.0
2039 1 Mov rax, 1;
2040 1 Mov rdi, $channel; # Write below stack
2041 1 my $w = RegisterSize rax;
2042 1 Lea rsi, "[rsp-$w]";
2043 1 Mov "QWORD[rsi]", 10;
2044 1 Mov rdx, 1;
2045 1 Syscall;
2046 1 RestoreFirstFour
2047 1 } name => qq(PrintNL_$channel);
2048  
2049 1 $s->call;
2050 }
2051  
2052 sub PrintErrNL() #P Print a new line to stderr.
2053 0 ▶ {@_ == 0 or confess;
Subroutine PrintErrNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2054 0 PrintNL($stderr);
2055 }
2056  
2057 sub PrintOutNL() # Print a new line to stderr.
2058 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2059 0 PrintNL($stdout);
2060 }
2061  
2062 sub PrintString($@) #P Print a constant string to the specified channel.
2063 6 ▶ {my ($channel, @string) = @_; # Channel, Strings
Subroutine PrintString: called CC=2 SCAR=6.9
Pod documented
2064 6 ▶ @_ >= 2 or confess "Two or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("Two or more parameters") 6 0 6
2065  
2066 6 my $c = join ' ', @string;
2067 6 my $l = length($c);
2068 6 my $a = Rs($c);
2069  
2070 my $s = Subroutine
2071 4 ▶ {SaveFirstFour;
Subroutine __ANON__: called CC=1 SCAR=0.0
2072 4 Mov rax, 1;
2073 4 Mov rdi, $channel;
2074 4 Lea rsi, "[$a]";
2075 4 Mov rdx, $l;
2076 4 Syscall;
2077 4 RestoreFirstFour;
2078 6 } name => "PrintString_${channel}_${c}";
2079  
2080 6 $s->call;
2081 }
2082  
2083 sub PrintStringNL($@) #P Print a constant string to the specified channel followed by a new line.
2084 0 ▶ {my ($channel, @string) = @_; # Channel, Strings
Subroutine PrintStringNL: not called CC=1 SCAR=6.9
Pod documented
2085 0 PrintString($channel, @string);
2086 0 PrintNL ($channel);
2087 }
2088  
2089 sub PrintErrString(@) #P Print a constant string to stderr.
2090 0 ▶ {my (@string) = @_; # String
Subroutine PrintErrString: not called CC=1 SCAR=6.9
Pod documented
2091 0 PrintString($stderr, @string);
2092 }
2093  
2094 sub PrintErrStringNL(@) #P Print a constant string to stderr followed by a new line.
2095 0 ▶ {my (@string) = @_; # String
Subroutine PrintErrStringNL: not called CC=1 SCAR=6.9
Pod documented
2096 0 PrintErrString(@string);
2097 0 my @c = caller 0;
2098 0 my (undef, $file, $line) = @c;
2099 0 PrintErrString " called at $file line $line";
2100 0 PrintErrNL;
2101 }
2102  
2103 sub PrintOutString(@) # Print a constant string to stdout.
2104 0 ▶ {my (@string) = @_; # String
Subroutine PrintOutString: not called CC=1 SCAR=6.9
Pod documented
2105 0 PrintString($stdout, @string);
2106 }
2107  
2108 sub PrintOutStringNL(@) # Print a constant string to stdout followed by a new line.
2109 0 ▶ {my (@string) = @_; # String
Subroutine PrintOutStringNL: not called CC=1 SCAR=6.9
Pod documented
2110 0 PrintOutString(@string);
2111 0 PrintOutNL;
2112 }
2113  
2114 sub PrintCString($$) #P Print a zero terminated C style string addressed by a variable on the specified channel.
2115 0 ▶ {my ($channel, $string) = @_; # Channel, String
Subroutine PrintCString: not called CC=1 SCAR=6.9
Pod documented
2116  
2117 0 PushR rax, rdi;
2118 0 my $length = &StringLength($string); # Length of string
2119 0 $string->setReg(rax);
2120 0 $length->setReg(rdi);
2121 0 &PrintOutMemory(); # Print string
2122 0 PopR;
2123 }
2124  
2125 sub PrintCStringNL($$) #P Print a zero terminated C style string addressed by a variable on the specified channel followed by a new line.
2126 0 ▶ {my ($channel, $string) = @_; # Channel, Strings
Subroutine PrintCStringNL: not called CC=1 SCAR=6.9
Pod documented
2127 0 PrintCString($channel, $string);
2128 0 PrintNL ($channel);
2129 }
2130  
2131 sub PrintSpace($;$) #P Print a constant number of spaces to the specified channel.
2132 0 ▶ {my ($channel, $spaces) = @_; # Channel, number of spaces if not one.
Subroutine PrintSpace: not called CC=2 SCAR=17.9
Pod documented
2133 0 ▶ PrintString($channel, ' ' x ($spaces // 1));
Condition0%0/2
$spaces // 1
l!l
00
MC/DC0%0/1
$spaces // 1
$spaces
Truth table0%0/2
A
A= $spaces
Aresult
11
00
2134 }
2135  
2136 sub PrintErrSpace(;$) #P Print a constant number of spaces to stderr.
2137 0 ▶ {my ($spaces) = @_; # Number of spaces if not one.
Subroutine PrintErrSpace: not called CC=1 SCAR=6.9
Pod documented
2138 0 PrintErrString(' ', $spaces);
2139 }
2140  
2141 sub PrintOutSpace(;$) # Print a constant number of spaces to stdout.
2142 0 ▶ {my ($spaces) = @_; # Number of spaces if not one.
Subroutine PrintOutSpace: not called CC=2 SCAR=17.9
Pod documented
2143 0 ▶ PrintOutString ' ' x ($spaces//1);
Condition0%0/2
$spaces // 1
l!l
00
MC/DC0%0/1
$spaces // 1
$spaces
Truth table0%0/2
A
A= $spaces
Aresult
11
00
2144 }
2145  
2146 #D2 Registers # Print selected registers in a variety of formats.
2147  
2148 sub hexTranslateTable #P Create/address a hex translate table and return its label.
2149 1 ▶ {my $h = '0123456789ABCDEF';
Subroutine hexTranslateTable: called CC=3 SCAR=11.0
Pod documented
2150 1 my @t;
2151 1 for my $i(split //, $h)
2152 16 {for my $j(split //, $h)
2153 256 {my $h = "$i$j";
2154 256 $h =~ s(\A00) (..);
2155 256 $h =~ s(\A0) (.);
2156 256 push @t, $h;
2157 }
2158 }
2159 Rs @t # Constant strings are only saved if they are unique, else a read only copy is returned.
2160 1 }
2161  
2162 sub PrintRaxInHex($;$) #P Write the content of register rax in hexadecimal in big endian notation to the specified channel.
2163 1 ▶ {my ($channel, $end) = @_; # Channel, optional end byte
Subroutine PrintRaxInHex: called CC=4 SCAR=13.9
Pod documented
2164 1 ▶ @_ == 1 or @_ == 2 or confess "One or two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or @_ == 2 or confess("One or two parameters") 1 0 1
Condition33%1/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
100
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table33%1/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
2165 1 my $hexTranslateTable = hexTranslateTable;
2166 1 ▶ $end //= 7; # Default end byte
Condition50%1/2
$end //= 7
l!l
01
MC/DC0%0/1
$end //= 7
$end
Truth table50%1/2
A
A= $end
Aresult
11
00
2167  
2168 my $s = Subroutine
2169 1 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: called CC=4 SCAR=13.9
2170  
2171 1 my $success = Label; # End of subroutine
2172 1 Cmp rax, 0;
2173 IfEq # Rax is zero - special case
2174 Then
2175 1 ▶ {PrintString($channel, ".... .... .... ...0");
Subroutine __ANON__: called CC=1 SCAR=0.0
2176 1 Jmp $success;
2177 1 };
2178 1 Cmp rax, -1;
2179 IfEq # Rax is minus one - special case
2180 Then
2181 1 ▶ {PrintString($channel, ".... .... .... ..-1");
Subroutine __ANON__: called CC=1 SCAR=0.0
2182 1 Jmp $success;
2183 1 };
2184  
2185 1 SaveFirstFour; # Rax is a parameter
2186 1 Mov rdx, rax; # Content to be printed
2187 1 Mov rdi, 2; # Length of a byte in hex
2188  
2189 1 for my $i((7-$end)..7) # Each byte
2190 8 {my $s = $bitsInByte*$i;
2191 8 Mov rax, rdx;
2192 8 Shl rax, $s; # Push selected byte high
2193 8 Shr rax, (RegisterSize(rax) - 1) * $bitsInByte; # Push select byte low
2194 8 Shl rax, 1; # Multiply by two because each entry in the translation table is two bytes long
2195 8 Lea rsi, "[$hexTranslateTable]";
2196 8 Add rax, rsi;
2197 8 PrintMemory($channel); # Print memory addressed by rax for length specified by rdi
2198 8 ▶ PrintString($channel, ' ') if $i % 2 and $i < 7;
Branch: 1 branch
BranchTrueFalseTotal
if $i % 2 and $i < 7 3 5 8
Condition100%3/3
$i % 2 and $i < 7
!ll&&!rl&&r
413
MC/DC100%2/2
$i % 2 and $i < 7
$i % 2 $i < 7
Truth table100%3/3
A and B
A= $i % 2B= $i < 7
ABresult
0X0
100
111
2199 }
2200 1 RestoreFirstFour;
2201  
2202 1 SetLabel $success;
2203 1 } name => "PrintOutRaxInHexOn-$channel-$end";
2204  
2205 1 $s->call;
2206 }
2207  
2208 sub PrintErrRaxInHex() #P Write the content of register rax in hexadecimal in big endian notation to stderr.
2209 0 ▶ {@_ == 0 or confess;
Subroutine PrintErrRaxInHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2210 0 PrintRaxInHex($stderr);
2211 }
2212  
2213 sub PrintErrRaxInHexNL() #P Write the content of register rax in hexadecimal in big endian notation to stderr followed by a new line.
2214 0 ▶ {@_ == 0 or confess;
Subroutine PrintErrRaxInHexNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2215 0 PrintRaxInHex($stderr);
2216 0 PrintErrNL;
2217 }
2218  
2219 sub PrintOutRaxInHex() # Write the content of register rax in hexadecimal in big endian notation to stout.
2220 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutRaxInHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2221 0 PrintRaxInHex($stdout);
2222 }
2223  
2224 sub PrintOutRaxInHexNL() # Write the content of register rax in hexadecimal in big endian notation to stdout followed by a new line.
2225 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutRaxInHexNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2226 0 PrintRaxInHex($stdout);
2227 0 PrintOutNL;
2228 }
2229  
2230 sub PrintRax_InHex($;$) #P Write the content of register rax in hexadecimal in big endian notation to the specified channel replacing zero bytes with __.
2231 0 ▶ {my ($channel, $end) = @_; # Channel, optional end byte
Subroutine PrintRax_InHex: not called CC=4 SCAR=30.0
Pod documented
2232 0 ▶ @_ == 1 or @_ == 2 or confess "One or two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or @_ == 2 or confess("One or two parameters") 0 0 0
Condition0%0/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table0%0/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
2233 0 my $hexTranslateTable = hexTranslateTable;
2234 0 ▶ $end //= 7; # Default end byte
Condition0%0/2
$end //= 7
l!l
00
MC/DC0%0/1
$end //= 7
$end
Truth table0%0/2
A
A= $end
Aresult
11
00
2235  
2236 my $s = Subroutine
2237 0 ▶ {SaveFirstFour; # Rax is a parameter
Subroutine __ANON__: not called CC=4 SCAR=30.0
2238 0 Mov rdx, rax; # Content to be printed
2239 0 Mov rdi, 2; # Length of a byte in hex
2240  
2241 0 for my $i((7-$end)..7) # Each byte
2242 0 {my $s = $bitsInByte*$i;
2243 0 Mov rax, rdx;
2244 0 Shl rax, $s; # Push selected byte high
2245 0 Shr rax, (RegisterSize(rax) - 1) * $bitsInByte; # Push select byte low
2246 0 Cmp rax, 0;
2247 IfEq # Print __ for zero bytes
2248 Then
2249 0 ▶ {PrintString($channel, "__");
Subroutine __ANON__: not called CC=1 SCAR=6.9
2250 },
2251 Else # Print byte in hexadecimal otherwise
2252 0 ▶ {Shl rax, 1; # Multiply by two because each entry in the translation table is two bytes long
Subroutine __ANON__: not called CC=1 SCAR=6.9
2253 0 Lea rsi, "[$hexTranslateTable]";
2254 0 Add rax, rsi;
2255 0 PrintMemory($channel); # Print memory addressed by rax for length specified by rdi
2256 0 };
2257 0 ▶ PrintString($channel, ' ') if $i % 2 and $i < 7;
Branch: 1 branch
BranchTrueFalseTotal
if $i % 2 and $i < 7 0 0 0
Condition0%0/3
$i % 2 and $i < 7
!ll&&!rl&&r
000
MC/DC0%0/2
$i % 2 and $i < 7
$i % 2 $i < 7
Truth table0%0/3
A and B
A= $i % 2B= $i < 7
ABresult
0X0
100
111
2258 }
2259 0 RestoreFirstFour;
2260 0 } name => "PrintOutRax_InHexOn-$channel-$end";
2261  
2262 0 $s->call;
2263 }
2264  
2265 sub PrintErrRax_InHex() #P Write the content of register rax in hexadecimal in big endian notation to stderr.
2266 0 ▶ {@_ == 0 or confess;
Subroutine PrintErrRax_InHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2267 0 PrintRax_InHex($stderr);
2268 }
2269  
2270 sub PrintErrRax_InHexNL() #P Write the content of register rax in hexadecimal in big endian notation to stderr followed by a new line.
2271 0 ▶ {@_ == 0 or confess;
Subroutine PrintErrRax_InHexNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2272 0 PrintRax_InHex($stderr);
2273 0 PrintErrNL;
2274 }
2275  
2276 sub PrintOutRax_InHex() # Write the content of register rax in hexadecimal in big endian notation to stout.
2277 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutRax_InHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2278 0 PrintRax_InHex($stdout);
2279 }
2280  
2281 sub PrintOutRax_InHexNL() # Write the content of register rax in hexadecimal in big endian notation to stdout followed by a new line.
2282 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutRax_InHexNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2283 0 PrintRax_InHex($stdout);
2284 0 PrintOutNL;
2285 }
2286  
2287 sub PrintOutRaxInReverseInHex # Write the content of register rax to stderr in hexadecimal in little endian notation.
2288 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutRaxInReverseInHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2289 0 Comment "Print Rax In Reverse In Hex";
2290 0 Push rax;
2291 0 Bswap rax;
2292 0 PrintOutRaxInHex;
2293 0 Pop rax;
2294 }
2295  
2296 sub PrintOneRegisterInHex($$) #P Print the named register as a hex string.
2297 1 ▶ {my ($channel, $r) = @_; # Channel to print on, register to print
Subroutine PrintOneRegisterInHex: called CC=2 SCAR=13.9
Pod documented
2298 1 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 1 0 1
2299  
2300 my $s = Subroutine
2301 1 ▶ {if ($r =~ m(\Ar)) # General purpose register
Subroutine __ANON__: called CC=7 SCAR=37.6
Branch: 5 branches
BranchTrueFalseTotal
if ($r =~ /\Ar/) { } 1 0 1
elsif ($r =~ /\Ak/) { } 0 0 0
elsif ($r =~ /\Axmm/) { } 0 0 0
elsif ($r =~ /\Aymm/) { } 0 0 0
elsif ($r =~ /\Azmm/) { } 0 0 0
2302 1 ▶ {if ($r =~ m(\Arax\Z)) # General purpose register - rax
Branch: 1 branch
BranchTrueFalseTotal
if ($r =~ /\Arax\Z/) { } 1 0 1
2303 1 {PrintRaxInHex($channel);
2304 }
2305 else # General purpose register not rax
2306 0 {PushR rax;
2307 0 Mov rax, $r;
2308 0 PrintRaxInHex($channel);
2309 0 PopR;
2310 }
2311 }
2312 elsif ($r =~ m(\Ak)) # Mask register
2313 0 {PushR rax;
2314 0 Kmovq rax, $r;
2315 0 PrintRaxInHex($channel);
2316 0 PopR;
2317 }
2318 elsif ($r =~ m(\Axmm)) # Xmm register
2319 0 {PushR rax, $r, 7;
2320 0 Mov rax, 0b10;
2321 0 Kmovq k7, rax;
2322 0 Vpcompressq "$r\{k7}", $r;
2323 0 Vmovq rax, $r;
2324 0 PrintRaxInHex($channel);
2325 0 PopR;
2326  
2327 0 PrintString($channel, " "); # Separate blocks of bytes with a space
2328 0 PushR rax;
2329 0 Vmovq rax, $r;
2330 0 PrintRaxInHex($channel);
2331 0 PopR;
2332 }
2333 elsif ($r =~ m(\Aymm)) # Ymm register
2334 0 {PushR rax, $r, 7;
2335 0 Mov rax, 0b1100;
2336 0 Kmovq k7, rax;
2337 0 Vpcompressq "$r\{k7}", $r;
2338 0 PrintOneRegisterInHex($channel, $r =~ s(\Ay) (x)r); # Upper half
2339 0 PopR;
2340  
2341 0 PrintString($channel, " - "); # Separate blocks of bytes with a space
2342  
2343 0 PrintOneRegisterInHex($channel, $r =~ s(\Ay) (x)r); # Lower half
2344 }
2345 elsif ($r =~ m(\Azmm)) # Zmm register
2346 0 {PushR rax, $r, 7;
2347 0 Mov rax, 0b11110000;
2348 0 Kmovq k7, rax;
2349 0 Vpcompressq "$r\{k7}", $r;
2350 0 PrintOneRegisterInHex($channel, $r =~ s(\Az) (y)r); # Upper half
2351 0 PopR;
2352  
2353 0 PrintString($channel, " + "); # Separate blocks of bytes with a space
2354 0 PrintOneRegisterInHex($channel, $r =~ s(\Az) (y)r); # Lower half
2355 }
2356 1 } name => "PrintOneRegister${r}InHexOn$channel"; # One routine per register printed
2357  
2358 1 PushR $r;
2359 1 $s->call;
2360 1 PopR;
2361 }
2362  
2363 sub PrintErrOneRegisterInHex($) #P Print the named register as a hex string on stderr.
2364 0 ▶ {my ($r) = @_; # Register to print
Subroutine PrintErrOneRegisterInHex: not called CC=2 SCAR=17.9
Pod documented
2365 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
2366 0 PrintOneRegisterInHex($stderr, $r)
2367 }
2368  
2369 sub PrintErrOneRegisterInHexNL($) #P Print the named register as a hex string on stderr followed by new line.
2370 0 ▶ {my ($r) = @_; # Register to print
Subroutine PrintErrOneRegisterInHexNL: not called CC=2 SCAR=17.9
Pod documented
2371 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
2372 0 PrintOneRegisterInHex($stderr, $r);
2373 0 PrintErrNL;
2374 }
2375  
2376 sub PrintOutOneRegisterInHex($) # Print the named register as a hex string on stdout.
2377 0 ▶ {my ($r) = @_; # Register to print
Subroutine PrintOutOneRegisterInHex: not called CC=2 SCAR=17.9
Pod documented
2378 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
2379 0 PrintOneRegisterInHex($stdout, $r)
2380 }
2381  
2382 sub PrintOutOneRegisterInHexNL($) # Print the named register as a hex string on stdout followed by new line.
2383 0 ▶ {my ($r) = @_; # Register to print
Subroutine PrintOutOneRegisterInHexNL: not called CC=2 SCAR=17.9
Pod documented
2384 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
2385 0 PrintOneRegisterInHex($stdout, $r);
2386 0 PrintOutNL;
2387 }
2388  
2389 sub PrintRegisterInHex($@) #P Print the named registers as hex strings.
2390 1 ▶ {my ($channel, @r) = @_; # Channel to print on, names of the registers to print
Subroutine PrintRegisterInHex: called CC=4 SCAR=15.2
Pod documented
2391 1 ▶ @_ >= 2 or confess "Two or more parameters required";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("Two or more parameters required") 1 0 1
2392  
2393 1 for my $r(map{registerNameFromNumber $_} @r) # Each register to print
2394 1 {PrintString($channel, sprintf("%6s: ", $r)); # Register name
2395 1 PrintOneRegisterInHex $channel, $r;
2396 1 ▶ if ($channel == $stderr) # Print location in the source file in a format that Geany understands
Branch: 1 branch
BranchTrueFalseTotal
if ($channel == $Nasm::X86::stderr) 0 1 1
2397 0 {my @c = caller 1;
2398 0 my (undef, $file, $line) = @c;
2399 0 PrintString $channel, " called at $file line $line";
2400 }
2401 1 PrintNL($channel);
2402 }
2403 }
2404  
2405 sub PrintErrRegisterInHex(@) #P Print the named registers as hex strings on stderr.
2406 0 ▶ {my (@r) = @_; # Names of the registers to print
Subroutine PrintErrRegisterInHex: not called CC=1 SCAR=6.9
Pod documented
2407 0 PrintRegisterInHex $stderr, @r;
2408 }
2409  
2410 sub PrintOutRegisterInHex(@) # Print the named registers as hex strings on stdout.
2411 1 ▶ {my (@r) = @_; # Names of the registers to print
Subroutine PrintOutRegisterInHex: called CC=1 SCAR=0.0
Pod documented
2412 1 PrintRegisterInHex $stdout, @r;
2413 }
2414  
2415 sub PrintOutRipInHex #P Print the instruction pointer in hex.
2416 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutRipInHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2417 0 my @regs = qw(rax);
2418  
2419 my $s = Subroutine
2420 0 ▶ {PushR @regs;
Subroutine __ANON__: not called CC=1 SCAR=6.9
2421 0 my $l = Label;
2422 0 push @text, <<END;
2423 $l:
2424 END
2425 0 Lea rax, "[$l]"; # Current instruction pointer
2426 0 PrintOutString "rip: ";
2427 0 PrintOutRaxInHex;
2428 0 PrintOutNL;
2429 0 PopR @regs;
2430 0 } name=> "PrintOutRipInHex";
2431  
2432 0 $s->call;
2433 }
2434  
2435 sub PrintOutRflagsInHex #P Print the flags register in hex.
2436 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutRflagsInHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2437 0 my @regs = qw(rax);
2438  
2439 my $s = Subroutine
2440 0 ▶ {PushR @regs;
Subroutine __ANON__: not called CC=1 SCAR=6.9
2441 0 Pushfq;
2442 0 Pop rax;
2443 0 PrintOutString "rfl: ";
2444 0 PrintOutRaxInHex;
2445 0 PrintOutNL;
2446 0 PopR @regs;
2447 0 } name=> "PrintOutRflagsInHex";
2448  
2449 0 $s->call;
2450 }
2451  
2452 sub PrintOutRegistersInHex # Print the general purpose registers in hex.
2453 0 ▶ {@_ == 0 or confess "No parameters required";
Subroutine PrintOutRegistersInHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("No parameters required") 0 0 0
2454  
2455 my $s = Subroutine
2456 0 ▶ {#PrintOutRipInHex;
Subroutine __ANON__: not called CC=4 SCAR=30.0
2457 0 PrintOutRflagsInHex;
2458  
2459 0 my @regs = qw(rax);
2460 0 PushR @regs;
2461  
2462 0 my $w = registers_64();
2463 0 for my $r(sort @$w)
2464 0 ▶ {next if $r =~ m(rip|rflags|rbp|rsp); # Modified by print routines so pointless to print
Branch: 1 branch
BranchTrueFalseTotal
if $r =~ /rip|rflags|rbp|rsp/ 0 0 0
2465 0 ▶ if ($r eq rax)
Branch: 1 branch
BranchTrueFalseTotal
if ($r eq rax()) 0 0 0
2466 0 {Pop rax;
2467 0 Push rax
2468 }
2469 0 PrintOutString reverse(pad(reverse($r), 3)).": ";
2470 0 Mov rax, $r;
2471 0 PrintOutRaxInHex;
2472 0 PrintOutNL;
2473 }
2474 0 PopR @regs;
2475 0 } name=> "PrintOutRegistersInHex";
2476  
2477 0 $s->call;
2478 }
2479  
2480 #D2 Zero Flag # Print zero flag
2481  
2482 sub PrintErrZF #P Print the zero flag without disturbing it on stderr.
2483 0 ▶ {@_ == 0 or confess;
Subroutine PrintErrZF: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
2484  
2485 0 Pushfq;
2486 0 ▶ IfNz Then {PrintErrStringNL "ZF=0"}, Else {PrintErrStringNL "ZF=1"};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
2487 0 Popfq;
2488 }
2489  
2490 sub PrintOutZF # Print the zero flag without disturbing it on stdout.
2491 0 ▶ {@_ == 0 or confess "No parameters";
Subroutine PrintOutZF: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("No parameters") 0 0 0
2492  
2493 0 Pushfq;
2494 0 ▶ IfNz Then {PrintOutStringNL "ZF=0"}, Else {PrintOutStringNL "ZF=1"};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
2495 0 Popfq;
2496 }
2497  
2498 #D2 Hexadecimal # Print numbers in hexadecimal right justified in a field
2499  
2500 sub PrintRightInHex($$$) #P Print out a number in hex right justified in a field of specified width on the specified channel.
2501 0 ▶ {my ($channel, $number, $width) = @_; # Channel, number as a variable or register, width of output field as a constant
Subroutine PrintRightInHex: not called CC=4 SCAR=30.0
Pod documented
2502  
2503 0 ▶ $channel =~ m(\A(1|2)\Z) or confess "Invalid channel should be stderr or stdout";
Branch: 1 branch
BranchTrueFalseTotal
$channel =~ /\A(1|2)\Z/ or confess("Invalid channel should be stderr or stdout") 0 0 0
2504  
2505 my $s = Subroutine
2506 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
2507  
2508 0 PushR rax, rdi, r14, r15, xmm0;
2509 0 ClearRegisters xmm0;
2510 0 $$p{number}->setReg(14);
2511  
2512 K(loop => 16)->for(sub
2513 0 ▶ {Mov r15, r14; # Load xmm0 with hexadecimal digits
Subroutine __ANON__: not called CC=1 SCAR=6.9
2514 0 And r15, 0xf;
2515 0 Cmp r15, 9;
2516 IfGt
2517 Then
2518 0 ▶ {Add r15, ord('A') - 10;
Subroutine __ANON__: not called CC=1 SCAR=6.9
2519 },
2520 Else
2521 0 ▶ {Add r15, ord('0');
Subroutine __ANON__: not called CC=1 SCAR=6.9
2522 0 };
2523 0 Pslldq xmm0, 1;
2524 0 Pinsrb xmm0, r15b, 0;
2525 0 Shr r14, 4;
2526 0 });
2527  
2528 Block ##IMPROVE # Translate leading zeros to spaces
2529 0 ▶ {my ($end) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
2530 0 for my $i(0..14)
2531 0 {Pextrb r15, xmm0, $i;
2532 0 Cmp r15b, ord('0');
2533 0 Jne $end;
2534 0 Mov r15, ord(' ');
2535 0 Pinsrb xmm0, r15b, $i;
2536 }
2537 0 };
2538  
2539 0 PushR xmm0; # Print xmm0 within the width of the field
2540 0 Mov rax, rsp;
2541 0 $$p{width}->setReg(rdi);
2542 0 And rdi, 0xff; # Limit field width to 16
2543 0 Add rax, 16;
2544 0 Sub rax, rdi;
2545 0 &PrintOutMemory();
2546 0 PopR;
2547 0 PopR;
2548 0 } name => "PrintRightInHex_${channel}",
2549 parameters=>[qw(width number)];
2550  
2551 0 ▶ $s->call(parameters =>
Branch: 2 branches
BranchTrueFalseTotal
ref $number ? : 0 0 0
ref $width ? : 0 0 0
2552 {number => ref($number) ? $number : V(number => $number),
2553 width => ref($width) ? $width : V width => $width});
2554 }
2555  
2556 sub PrintErrRightInHex($$) #P Write the specified variable in hexadecimal right justified in a field of specified width on stderr.
2557 0 ▶ {my ($number, $width) = @_; # Number as a variable, width of output field as a variable
Subroutine PrintErrRightInHex: not called CC=1 SCAR=6.9
Pod documented
2558 0 PrintRightInHex($stderr, $number, $width);
2559 }
2560  
2561 sub PrintErrRightInHexNL($$) #P Write the specified variable in hexadecimal right justified in a field of specified width on stderr followed by a new line.
2562 0 ▶ {my ($number, $width) = @_; # Number as a variable, width of output field as a variable
Subroutine PrintErrRightInHexNL: not called CC=1 SCAR=6.9
Pod documented
2563 0 PrintRightInHex($stderr, $number, $width);
2564 0 PrintErrNL;
2565 }
2566  
2567 sub PrintOutRightInHex($$) # Write the specified variable in hexadecimal right justified in a field of specified width on stdout.
2568 0 ▶ {my ($number, $width) = @_; # Number as a variable, width of output field as a variable
Subroutine PrintOutRightInHex: not called CC=1 SCAR=6.9
Pod documented
2569 0 PrintRightInHex($stdout, $number, $width);
2570 }
2571  
2572 sub PrintOutRightInHexNL($$) # Write the specified variable in hexadecimal right justified in a field of specified width on stdout followed by a new line.
2573 0 ▶ {my ($number, $width) = @_; # Number as a variable, width of output field as a variable
Subroutine PrintOutRightInHexNL: not called CC=1 SCAR=6.9
Pod documented
2574 0 PrintRightInHex($stdout, $number, $width);
2575 0 PrintOutNL;
2576 }
2577  
2578 #D2 Binary # Print numbers in binary right justified in a field
2579  
2580 sub PrintRightInBin($$$) #P Print out a number in binary right justified in a field of specified width on the specified channel.
2581 0 ▶ {my ($channel, $Number, $Width) = @_; # Channel, number as a variable or register, width of output field as a variable or constant
Subroutine PrintRightInBin: not called CC=5 SCAR=34.0
Pod documented
2582  
2583 0 ▶ $channel =~ m(\A(1|2)\Z) or confess "Channel should be stderr or stdout";
Branch: 1 branch
BranchTrueFalseTotal
$channel =~ /\A(1|2)\Z/ or confess("Channel should be stderr or stdout") 0 0 0
2584 0 ▶ my $number = ref($Number) ? $Number : V(number => $Number); # Variable or register
Branch: 1 branch
BranchTrueFalseTotal
ref $Number ? : 0 0 0
2585 0 ▶ my $width = ref($Width) ? $Width : K(width => ($Width//16)); # Promote constant
Branch: 1 branch
BranchTrueFalseTotal
ref $Width ? : 0 0 0
Condition0%0/2
$Width // 16
l!l
00
MC/DC0%0/1
$Width // 16
$Width
Truth table0%0/2
A
A= $Width
Aresult
11
00
2586  
2587 my $s = Subroutine
2588 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
2589  
2590 0 PushR rax, rdi, rsi, r14, r15;
2591 0 $$p{number}->setReg(rax);
2592 0 Mov rsi, rsp;
2593 0 my $bir = RegisterSize(rax) * $bitsInByte;
2594 0 Mov r14, rsi;
2595 0 Sub rsp, $bir; # Allocate space on the stack for the maximum length bit string written out as characters
2596  
2597 K(loop => $bir)->for(sub # Load bits onto stack as characters
2598 0 ▶ {Dec r14;
Subroutine __ANON__: not called CC=1 SCAR=6.9
2599 0 Mov r15, rax;
2600 0 And r15, 1;
2601 0 Cmp r15, 0;
2602 IfNe
2603 Then
2604 0 ▶ {Mov "byte[r14]", ord('1');
Subroutine __ANON__: not called CC=1 SCAR=6.9
2605 },
2606 Else
2607 0 ▶ {Mov "byte[r14]", ord('0');
Subroutine __ANON__: not called CC=1 SCAR=6.9
2608 0 };
2609 0 Shr rax, 1;
2610 0 });
2611  
2612 K(loop => $bir)->for(sub # Replace leading zeros with spaces
2613 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
2614 0 Cmp "byte[r14]",ord('0');
2615 IfEq
2616 Then
2617 0 ▶ {Mov "byte[r14]", ord(' ');
Subroutine __ANON__: not called CC=1 SCAR=6.9
2618 },
2619 Else
2620 0 ▶ {Jmp $end;
Subroutine __ANON__: not called CC=1 SCAR=6.9
2621 0 };
2622 0 Inc r14;
2623 0 });
2624  
2625 0 Mov rax, rsp; # Write stack in a field of specified width
2626 0 $$p{width}->setReg(rdi);
2627 0 Add rax, $bir;
2628 0 Sub rax, rdi;
2629 0 PrintMemory($channel);
2630 0 Mov rsp, rsi; # Restore stack
2631 0 PopR;
2632 0 } name => "PrintRightInBin_${channel}",
2633 parameters=>[qw(width number)];
2634  
2635 0 $s->call(parameters => {number => $number, width=>$width});
2636 }
2637  
2638 sub PrintErrRightInBin($$) #P Write the specified variable in binary right justified in a field of specified width on stderr.
2639 0 ▶ {my ($number, $width) = @_; # Number as a variable, width of output field as a variable
Subroutine PrintErrRightInBin: not called CC=1 SCAR=6.9
Pod documented
2640 0 PrintRightInBin($stderr, $number, $width);
2641 }
2642  
2643 sub PrintErrRightInBinNL($$) #P Write the specified variable in binary right justified in a field of specified width on stderr followed by a new line.
2644 0 ▶ {my ($number, $width) = @_; # Number as a variable, width of output field as a variable
Subroutine PrintErrRightInBinNL: not called CC=1 SCAR=6.9
Pod documented
2645 0 PrintRightInBin($stderr, $number, $width);
2646 0 PrintErrNL;
2647 }
2648  
2649 sub PrintOutRightInBin($$) # Write the specified variable in binary right justified in a field of specified width on stdout.
2650 0 ▶ {my ($number, $width) = @_; # Number as a variable, width of output field as a variable
Subroutine PrintOutRightInBin: not called CC=1 SCAR=6.9
Pod documented
2651 0 PrintRightInBin($stdout, $number, $width);
2652 }
2653  
2654 sub PrintOutRightInBinNL($;$) # Write the specified variable in binary right justified in a field of specified width on stdout followed by a new line.
2655 0 ▶ {my ($number, $width) = @_; # Number as a variable, width of output field as a variable
Subroutine PrintOutRightInBinNL: not called CC=2 SCAR=17.9
Pod documented
2656 0 ▶ PrintRightInBin $stdout, $number, ($width//16);
Condition0%0/2
$width // 16
l!l
00
MC/DC0%0/1
$width // 16
$width
Truth table0%0/2
A
A= $width
Aresult
11
00
2657 0 PrintOutNL;
2658 }
2659  
2660 #D2 Decimal # Print numbers in decimal right justified in fields of specified width.
2661  
2662 sub PrintRaxInDec($) #P Print rax in decimal on the specified channel.
2663 0 ▶ {my ($channel) = @_; # Channel to write on
Subroutine PrintRaxInDec: not called CC=1 SCAR=6.9
Pod documented
2664  
2665 my $s = Subroutine
2666 0 ▶ {PushR rax, rdi, rdx, r9, r10;
Subroutine __ANON__: not called CC=1 SCAR=6.9
2667 0 Mov r9, 0; # Number of decimal digits
2668 0 Mov r10, 10; # Base of number system
2669 0 my $convert = SetLabel;
2670 0 Mov rdx, 0; # Rdx must be clear to receive remainder
2671 0 Idiv r10; # Remainder after integer division by 10
2672 0 Add rdx, 48; # Convert remainder to ascii
2673 0 Push rdx; # Save remainder
2674 0 Inc r9; # Number of digits
2675 0 Cmp rax, 0;
2676 0 Jnz $convert;
2677  
2678 0 Mov rdi, 1; # Length of each write
2679  
2680 0 my $print = SetLabel; # Print digits
2681 0 Mov rax, rsp;
2682 0 PrintMemory($channel);
2683 0 Dec r9; # Number of digits
2684 0 Pop rax; # Remove digit from stack
2685 0 Jnz $print;
2686  
2687 0 PopR;
2688 0 } name => "PrintRaxInDec_$channel";
2689  
2690 0 $s->call;
2691 }
2692  
2693 sub PrintOutRaxInDec # Print rax in decimal on stdout.
2694 0 ▶ {PrintRaxInDec($stdout);
Subroutine PrintOutRaxInDec: not called CC=1 SCAR=6.9
Pod documented
2695 }
2696  
2697 sub PrintOutRaxInDecNL # Print rax in decimal on stdout followed by a new line.
2698 0 ▶ {PrintOutRaxInDec;
Subroutine PrintOutRaxInDecNL: not called CC=1 SCAR=6.9
Pod documented
2699 0 PrintOutNL;
2700 }
2701  
2702 sub PrintErrRaxInDec #P Print rax in decimal on stderr.
2703 0 ▶ {PrintRaxInDec($stderr);
Subroutine PrintErrRaxInDec: not called CC=1 SCAR=6.9
Pod documented
2704 }
2705  
2706 sub PrintErrRaxInDecNL #P Print rax in decimal on stderr followed by a new line.
2707 0 ▶ {PrintErrRaxInDec;
Subroutine PrintErrRaxInDecNL: not called CC=1 SCAR=6.9
Pod documented
2708 0 PrintErrNL;
2709 }
2710  
2711 sub PrintRaxRightInDec($$) #P Print rax in decimal right justified in a field of the specified width on the specified channel.
2712 0 ▶ {my ($Width, $channel) = @_; # Width as a variable or a constant, channel
Subroutine PrintRaxRightInDec: not called CC=4 SCAR=30.0
Pod documented
2713  
2714 0 ▶ my $width = ref($Width) ? $Width : K width => ($Width//16); # Promote constant
Branch: 1 branch
BranchTrueFalseTotal
ref $Width ? : 0 0 0
Condition0%0/2
$Width // 16
l!l
00
MC/DC0%0/1
$Width // 16
$Width
Truth table0%0/2
A
A= $Width
Aresult
11
00
2715  
2716 my $s = Subroutine
2717 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
2718 0 PushR rax, rdi, rdx, r9, r10;
2719 0 Mov r9, 0; # Number of decimal digits
2720 0 Mov r10, 10; # Base of number system used to divide rax
2721 0 my $convert = SetLabel;
2722 0 Mov rdx, 0; # Rdx must be clear to receive remainder
2723 0 Idiv r10; # Remainder after integer division of rax by 10
2724 0 Add rdx, 48; # Convert remainder to ascii
2725 0 Push rdx; # Save remainder
2726 0 Inc r9; # Number of digits
2727 0 Cmp rax, 0;
2728 0 Jnz $convert;
2729  
2730 0 Mov rdi, 1; # Length of each write
2731 0 $$p{width}->setReg(10); # Pad to this width if necessary
2732 0 Cmp r9, r10;
2733 IfLt
2734 Then # Padding required
2735 0 ▶ {(V(width => r10) - V(actual => r9))->spaces($channel);
Subroutine __ANON__: not called CC=1 SCAR=6.9
2736 0 };
2737  
2738 0 my $print = SetLabel; # Print digits
2739 0 Mov rax, rsp;
2740 0 PrintMemory($channel);
2741 0 Dec r9; # Number of digits
2742 0 Pop rax; # Remove digit from stack
2743 0 Jnz $print;
2744  
2745 0 PopR;
2746 0 } parameters=>[qw(width)], name => "PrintRaxRightInDec_${channel}";
2747  
2748 0 ▶ $s->call(parameters=>{width => ref($width) ? $width : V width => $width});
Branch: 1 branch
BranchTrueFalseTotal
ref $width ? : 0 0 0
2749 }
2750  
2751 sub PrintRightInDec($$$) #P Print out a number in decimal right justified in a field of specified width on the specified channel.
2752 0 ▶ {my ($channel, $Number, $width) = @_; # Channel, number as a variable or register, width of output field as a variable or constant
Subroutine PrintRightInDec: not called CC=2 SCAR=17.9
Pod documented
2753  
2754 0 ▶ my $number = ref($Number) ? $Number : V(number => $Number); # Variable or register
Branch: 1 branch
BranchTrueFalseTotal
ref $Number ? : 0 0 0
2755  
2756 0 PushR rax;
2757 0 $number->setReg(rax);
2758 0 PrintRaxRightInDec $width, $channel;
2759 0 PopR;
2760 }
2761  
2762 sub PrintErrRightInDec($$) #P Print a variable or register in decimal right justified in a field of the specified width on stderr.
2763 0 ▶ {my ($number, $width) = @_; # Number as a variable or a register, width as a variable or constant
Subroutine PrintErrRightInDec: not called CC=1 SCAR=6.9
Pod documented
2764 0 PrintRightInDec($stderr, $number, $width);
2765 }
2766  
2767 sub PrintErrRightInDecNL($$) #P Print a variable or register in decimal right justified in a field of the specified width on stderr followed by a new line.
2768 0 ▶ {my ($number, $width) = @_; # Number as a variable or a register, width as a variable or constant
Subroutine PrintErrRightInDecNL: not called CC=1 SCAR=6.9
Pod documented
2769 0 PrintErrRightInDec($number, $width);
2770 0 PrintErrNL;
2771 }
2772  
2773 sub PrintOutRightInDec($$) # Print a variable or register in decimal right justified in a field of the specified width on stdout.
2774 0 ▶ {my ($number, $width) = @_; # Number as a variable or a register, width as a variable or constant
Subroutine PrintOutRightInDec: not called CC=1 SCAR=6.9
Pod documented
2775 0 PrintRightInDec($stdout, $number, $width);
2776 }
2777  
2778 sub PrintOutRightInDecNL($$) # Print a variable or register in decimal right justified in a field of the specified width on stdout followed by a new line.
2779 0 ▶ {my ($number, $width) = @_; # Number as a variable or a register, width as a variable or constant
Subroutine PrintOutRightInDecNL: not called CC=1 SCAR=6.9
Pod documented
2780 0 PrintOutRightInDec($number, $width);
2781 0 PrintOutNL;
2782 }
2783  
2784 #D2 Text # Print the contents of a register as text.
2785  
2786 sub PrintRaxAsText($) #P Print the string in rax on the specified channel.
2787 0 ▶ {my ($channel) = @_; # Channel to write on
Subroutine PrintRaxAsText: not called CC=2 SCAR=17.9
Pod documented
2788 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
2789  
2790 0 my $w = RegisterSize rax;
2791 0 PushR rdi, rdx, rax;
2792 0 Lzcnt rdi, rax;
2793 0 Shr rdi, 3;
2794 0 Mov rdx, rdi;
2795 0 Mov rdi, 8;
2796 0 Sub rdi, rdx;
2797  
2798 0 Mov rax, rsp;
2799 0 PrintMemory($channel);
2800 0 PopR;
2801 }
2802  
2803 sub PrintOutRaxAsText # Print rax as text on stdout.
2804 0 ▶ {PrintRaxAsText($stdout);
Subroutine PrintOutRaxAsText: not called CC=1 SCAR=6.9
Pod documented
2805 }
2806  
2807 sub PrintOutRaxAsTextNL # Print rax as text on stdout followed by a new line.
2808 0 ▶ {PrintRaxAsText($stdout);
Subroutine PrintOutRaxAsTextNL: not called CC=1 SCAR=6.9
Pod documented
2809 0 PrintOutNL;
2810 }
2811  
2812 sub PrintErrRaxAsText #P Print rax as text on stderr.
2813 0 ▶ {PrintRaxAsText($stderr);
Subroutine PrintErrRaxAsText: not called CC=1 SCAR=6.9
Pod documented
2814 }
2815  
2816 sub PrintErrRaxAsTextNL #P Print rax as text on stderr followed by a new line.
2817 0 ▶ {PrintRaxAsText($stderr);
Subroutine PrintErrRaxAsTextNL: not called CC=1 SCAR=6.9
Pod documented
2818 0 PrintOutNL;
2819 }
2820  
2821 sub PrintRaxAsChar($) #P Print the ascii character in rax on the specified channel.
2822 0 ▶ {my ($channel) = @_; # Channel to write on
Subroutine PrintRaxAsChar: not called CC=2 SCAR=17.9
Pod documented
2823 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
2824  
2825 0 PushR rdi, rax;
2826 0 Mov rax, rsp;
2827 0 Mov rdi, 1;
2828 0 PrintMemory($channel);
2829 0 PopR;
2830 }
2831  
2832 sub PrintOutRaxAsChar # Print the character in rax on stdout.
2833 0 ▶ {PrintRaxAsChar($stdout);
Subroutine PrintOutRaxAsChar: not called CC=1 SCAR=6.9
Pod documented
2834 }
2835  
2836 sub PrintOutRaxAsCharNL # Print the character in rax on stdout followed by a new line.
2837 0 ▶ {PrintRaxAsChar($stdout);
Subroutine PrintOutRaxAsCharNL: not called CC=1 SCAR=6.9
Pod documented
2838 0 PrintOutNL;
2839 }
2840  
2841 sub PrintErrRaxAsChar #P Print the character in rax on stderr.
2842 0 ▶ {PrintRaxAsChar($stderr);
Subroutine PrintErrRaxAsChar: not called CC=1 SCAR=6.9
Pod documented
2843 }
2844  
2845 sub PrintErrRaxAsCharNL #P Print the character in rax on stderr followed by a new line.
2846 0 ▶ {PrintRaxAsChar($stderr);
Subroutine PrintErrRaxAsCharNL: not called CC=1 SCAR=6.9
Pod documented
2847 0 PrintOutNL;
2848 }
2849  
2850 #D1 Variables # Variable definitions and operations
2851  
2852 #D2 Definitions # Variable definitions
2853  
2854 sub Variable($;$%) #P Create a new variable with the specified name initialized via an optional expression.
2855 0 ▶ {my ($name, $expr, %options) = @_; # Name of variable, optional expression initializing variable, options
Subroutine Variable: not called CC=12 SCAR=50.5
Pod documented
2856 0 my $size = 3; # Size of variable in bytes as a power of 2
2857 0 my $width = 2**$size; # Size of variable in bytes
2858 0 ▶ my $const = $options{constant} // 0; # Constant
Condition0%0/2
$options{"constant"} // 0
l!l
00
MC/DC0%0/1
$options{"constant"} // 0
$options{"constant"}
Truth table0%0/2
A
A= $options{"constant"}
Aresult
11
00
2859 0 ▶ my $ref = $options{reference} // 0; # Reference
Condition0%0/2
$options{"reference"} // 0
l!l
00
MC/DC0%0/1
$options{"reference"} // 0
$options{"reference"}
Truth table0%0/2
A
A= $options{"reference"}
Aresult
11
00
2860  
2861 0 ▶ $ref and $const and confess "Reference to constant";
Branch: 1 branch
BranchTrueFalseTotal
$ref and $const and confess("Reference to constant") 0 0 0
Condition0%0/3
$ref and $const
!ll&&!rl&&r
000
MC/DC0%0/2
$ref and $const
$ref $const
Truth table0%0/3
A and B
A= $refB= $const
ABresult
0X0
100
111
2862  
2863 0 my $label; # Label associated with this variable
2864 my $position; # Position in stack frame or undef for a constant
2865 0 ▶ if ($const) # Constant variable
Branch: 1 branch
BranchTrueFalseTotal
if ($const) { } 0 0 0
2866 0 ▶ {defined($expr) or confess "Value required for constant";
Branch: 1 branch
BranchTrueFalseTotal
defined $expr or confess("Value required for constant") 0 0 0
2867 0 ▶ $expr =~ m(r) and confess
Branch: 1 branch
BranchTrueFalseTotal
$expr =~ /r/ and confess("Cannot use register expression $expr to initialize a constant") 0 0 0
2868 "Cannot use register expression $expr to initialize a constant";
2869 0 $label = Rq($expr);
2870 }
2871 else # Local variable: Position on stack of variable
2872 0 {my $stack = $position = ++$VariableStack[-1]; # Position in stack frame
2873 0 $label = "rbp-8*($stack)";
2874  
2875 0 ▶ if (defined $expr) # Initialize variable if an initializer was supplied
Branch: 1 branch
BranchTrueFalseTotal
if (defined $expr) 0 0 0
2876 0 ▶ {if ($Registers{$expr} and $expr =~ m(\Ar)) # Expression is ready to go
Branch: 2 branches
BranchTrueFalseTotal
if ($Registers{$expr} and $expr =~ /\Ar/) { } 0 0 0
elsif ($expr =~ /\A\d+\Z/) { } 0 0 0
Condition0%0/3
$Registers{$expr} and $expr =~ /\Ar/
!ll&&!rl&&r
000
MC/DC0%0/2
$Registers{$expr} and $expr =~ /\Ar/
$Registers{$expr} $expr =~ /\Ar/
Truth table0%0/3
A and B
A= $Registers{$expr}B= $expr =~ /\Ar/
ABresult
0X0
100
111
2877 0 {Mov "[$label]", $expr;
2878 }
2879 elsif ($expr =~ m(\A\d+\Z)) # Transfer constant expression
2880 0 {Mov "qword[$label]", $expr;
2881 }
2882 else # Transfer expression
2883 0 {PushR 15;
2884 0 Mov r15, $expr;
2885 0 Mov "[$label]", r15;
2886 0 PopR;
2887 }
2888 }
2889 }
2890  
2891 genHash(__PACKAGE__."::Variable", # Variable definition
2892 constant => $const, # Constant if true
2893 expr => $expr, # Expression that initializes the variable
2894 label => $label, # Address in memory
2895 name => $name, # Name of the variable
2896 position => $position, # Position in stack frame
2897 reference => $options{reference}, # Reference to another variable
2898 0 );
2899 }
2900  
2901 sub Nasm::X86::Variable::at($) # Return a "[register expression]" to address the data in the variable in the current stack frame.
2902 0 ▶ {my ($variable) = @_; # Variable descriptor
Subroutine at: not called CC=1 SCAR=6.9
2903 0 "[".$variable->label."]"
2904 }
2905  
2906 sub K($$) # Define a constant variable.
2907 0 ▶ {my ($name, $expr) = @_; # Name of variable, initializing expression
Subroutine K: not called CC=1 SCAR=6.9
Pod documented
2908 0 &Variable(@_, constant => 1)
2909 }
2910  
2911 sub R($) #P Define a reference variable.
2912 0 ▶ {my ($name) = @_; # Name of variable
Subroutine R: not called CC=1 SCAR=6.9
Pod documented
2913 0 my $r = &Variable($name); # The referring variable is 64 bits wide
2914 0 $r->reference = 1; # Mark variable as a reference
2915 0 $r # Size of the referenced variable
2916 }
2917  
2918 sub V($;$) # Define a variable.
2919 0 ▶ {my ($name, $expr) = @_; # Name of variable, initializing expression
Subroutine V: not called CC=1 SCAR=6.9
Pod documented
2920 0 &Variable(@_)
2921 }
2922  
2923 #D2 Print variables # Print the values of variables or the memory addressed by them
2924  
2925 sub Nasm::X86::Variable::dump($$$;$$) #P Dump the value of a variable to the specified channel adding an optional title and new line if requested.
2926 0 ▶ {my ($left, $channel, $newLine, $title1, $title2) = @_; # Left variable, channel, new line required, optional leading title, optional trailing title
Subroutine dump: not called CC=9 SCAR=45.0
2927 0 ▶ @_ >= 3 or confess;
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 3 or confess() 0 0 0
2928 0 PushR rax, rdi;
2929 0 my $label = $left->label; # Address in memory
2930 0 Mov rax, "[$label]";
2931 0 ▶ Mov rax, "[rax]" if $left->reference;
Branch: 1 branch
BranchTrueFalseTotal
if $left->reference 0 0 0
2932 0 ▶ PrintString ($channel, $title1//$left->name.": ") unless defined($title1) && $title1 eq '';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $title1 and $title1 eq "" 0 0 0
Condition0%0/5
defined $title1 and $title1 eq ""
!ll&&!rl&&r
000
$title1 // $left->name . ': '
l!l
00
MC/DC0%0/2
defined $title1 and $title1 eq ""
defined $title1 $title1 eq ""
MC/DC0%0/1
$title1 // $left->name . ': '
$title1
Truth table0%0/3
A and B
A= defined $title1B= $title1 eq ""
ABresult
0X0
100
111
Truth table0%0/2
A
A= $title1
Aresult
11
00
2933 0 PrintRaxInHex($channel);
2934 0 ▶ PrintString ($channel, $title2) if defined $title2;
Branch: 1 branch
BranchTrueFalseTotal
if defined $title2 0 0 0
2935  
2936 0 ▶ if ($newLine == 2) # Print location in the source file in a format that Geany understands
Branch: 1 branch
BranchTrueFalseTotal
if ($newLine == 2) 0 0 0
2937 0 {my @c = caller 1;
2938 0 my (undef, $file, $line) = @c;
2939 0 PrintString $channel, " called at $file line $line";
2940 }
2941  
2942 0 ▶ PrintNL($channel) if $newLine;
Branch: 1 branch
BranchTrueFalseTotal
if $newLine 0 0 0
2943 0 PopR;
2944 }
2945  
2946 sub Nasm::X86::Variable::err($;$$) #P Dump the value of a variable on stderr.
2947 0 ▶ {my ($left, $title1, $title2) = @_; # Left variable, optional leading title, optional trailing title
Subroutine err: not called CC=1 SCAR=6.9
2948 0 $left->dump($stderr, 0, $title1, $title2);
2949 }
2950  
2951 sub Nasm::X86::Variable::out($;$$) # Dump the value of a variable on stdout.
2952 0 ▶ {my ($left, $title1, $title2) = @_; # Left variable, optional leading title, optional trailing title
Subroutine out: not called CC=1 SCAR=6.9
2953 0 $left->dump($stdout, 0, $title1, $title2);
2954 }
2955  
2956 sub Nasm::X86::Variable::errNL($;$$) #P Dump the value of a variable on stderr and append a new line.
2957 0 ▶ {my ($left, $title1, $title2) = @_; # Left variable, optional leading title, optional trailing title
Subroutine errNL: not called CC=1 SCAR=6.9
2958 0 $left->dump($stderr, 1, $title1, $title2);
2959 }
2960  
2961 sub Nasm::X86::Variable::d($;$$) #P Dump the value of a variable on stderr and append the source file calling line in a format that Geany understands.
2962 0 ▶ {my ($left, $title1, $title2) = @_; # Left variable, optional leading title, optional trailing title
Subroutine d: not called CC=1 SCAR=6.9
2963 0 $left->dump($stderr, 2, $title1, $title2);
2964 }
2965  
2966 sub Nasm::X86::Variable::outNL($;$$) # Dump the value of a variable on stdout and append a new line.
2967 0 ▶ {my ($left, $title1, $title2) = @_; # Left variable, optional leading title, optional trailing title
Subroutine outNL: not called CC=1 SCAR=6.9
2968 0 $left->dump($stdout, 1, $title1, $title2);
2969 }
2970  
2971 #D3 Decimal representation # Print out a variable as a decimal number
2972  
2973 sub Nasm::X86::Variable::errInDec($;$$) #P Dump the value of a variable on stderr in decimal.
2974 0 ▶ {my ($number, $title1, $title2) = @_; # Number as variable, optional leading title, optional trailing title
Subroutine errInDec: not called CC=3 SCAR=24.8
2975 0 ▶ PrintErrString($title1 // $number->name.": ");
Condition0%0/2
$title1 // $number->name . ': '
l!l
00
MC/DC0%0/1
$title1 // $number->name . ': '
$title1
Truth table0%0/2
A
A= $title1
Aresult
11
00
2976 0 PushR rax;
2977 0 $number->setReg(rax);
2978 0 PrintRaxInDec($stderr);
2979 0 PopR;
2980 0 ▶ PrintErrString($title2) if $title2;
Branch: 1 branch
BranchTrueFalseTotal
if $title2 0 0 0
2981 }
2982  
2983 sub Nasm::X86::Variable::errInDecNL($;$$) #P Dump the value of a variable on stderr in decimal followed by a new line.
2984 0 ▶ {my ($number, $title1, $title2) = @_; # Number as variable, optional leading title, optional trailing title
Subroutine errInDecNL: not called CC=1 SCAR=6.9
2985 0 $number->errInDec($title1, $title2);
2986 0 PrintErrNL;
2987 }
2988  
2989 sub Nasm::X86::Variable::outInDec($;$$) # Dump the value of a variable on stdout in decimal.
2990 0 ▶ {my ($number, $title1, $title2) = @_; # Number as variable, optional leading title, optional trailing title
Subroutine outInDec: not called CC=3 SCAR=24.8
2991 0 ▶ PrintOutString($title1 // $number->name.": ");
Condition0%0/2
$title1 // $number->name . ': '
l!l
00
MC/DC0%0/1
$title1 // $number->name . ': '
$title1
Truth table0%0/2
A
A= $title1
Aresult
11
00
2992 0 PushR rax;
2993 0 $number->setReg(rax);
2994 0 PrintRaxInDec($stdout);
2995 0 PopR;
2996 0 ▶ PrintOutString($title2) if $title2;
Branch: 1 branch
BranchTrueFalseTotal
if $title2 0 0 0
2997 }
2998  
2999 sub Nasm::X86::Variable::outInDecNL($;$$) # Dump the value of a variable on stdout in decimal followed by a new line.
3000 0 ▶ {my ($number, $title1, $title2) = @_; # Number as variable, optional leading title, optional trailing title
Subroutine outInDecNL: not called CC=1 SCAR=6.9
3001 0 $number->outInDec($title1, $title2);
3002 0 PrintOutNL;
3003 }
3004  
3005 #D3 Decimal representation right justified # Print out a variable as a decimal number right adjusted in a field of specified width
3006  
3007 sub Nasm::X86::Variable::rightInDec($$;$) #P Dump the value of a variable on the specified channel as a decimal number right adjusted in a field of specified width.
3008 0 ▶ {my ($number, $channel, $width) = @_; # Number as variable, channel, width
Subroutine rightInDec: not called CC=2 SCAR=17.9
3009 0 ▶ @_ >= 2 or confess "At least two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("At least two parameters") 0 0 0
3010 0 PushR rax;
3011 0 $number->setReg(rax);
3012 0 PrintRaxRightInDec($width, $channel);
3013 0 PopR;
3014 }
3015  
3016 sub Nasm::X86::Variable::errRightInDec($;$) #P Dump the value of a variable on stderr as a decimal number right adjusted in a field of specified width.
3017 0 ▶ {my ($number, $width) = @_; # Number, width
Subroutine errRightInDec: not called CC=2 SCAR=17.9
3018 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3019 0 $number->rightInDec($stdout, $width);
3020 }
3021  
3022 sub Nasm::X86::Variable::errRightInDecNL($;$) #P Dump the value of a variable on stderr as a decimal number right adjusted in a field of specified width followed by a new line.
3023 0 ▶ {my ($number, $width) = @_; # Number, width
Subroutine errRightInDecNL: not called CC=2 SCAR=17.9
3024 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3025 0 $number->rightInDec($stdout, $width);
3026 0 PrintErrNL;
3027 }
3028  
3029 sub Nasm::X86::Variable::outRightInDec($;$) # Dump the value of a variable on stdout as a decimal number right adjusted in a field of specified width.
3030 0 ▶ {my ($number, $width) = @_; # Number, width
Subroutine outRightInDec: not called CC=2 SCAR=17.9
3031 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3032 0 $number->rightInDec($stdout, $width);
3033 }
3034  
3035 sub Nasm::X86::Variable::outRightInDecNL($;$) # Dump the value of a variable on stdout as a decimal number right adjusted in a field of specified width followed by a new line.
3036 0 ▶ {my ($number, $width) = @_; # Number, width
Subroutine outRightInDecNL: not called CC=2 SCAR=17.9
3037 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3038 0 $number->rightInDec($stdout, $width);
3039 0 PrintOutNL;
3040 }
3041  
3042 #D3 Hexadecimal representation, right justified # Print number variables in hexadecimal right justified in fields of specified width.
3043  
3044 sub Nasm::X86::Variable::rightInHex($$;$) #P Write the specified variable number in hexadecimal right justified in a field of specified width to the specified channel.
3045 0 ▶ {my ($number, $channel, $width) = @_; # Number to print as a variable, channel to print on, width of output field
Subroutine rightInHex: not called CC=2 SCAR=17.9
3046 0 ▶ @_ >= 2 or confess "At least two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("At least two parameters") 0 0 0
3047 0 PrintRightInHex($channel, $number, $width);
3048 }
3049  
3050 sub Nasm::X86::Variable::errRightInHex($;$) #P Write the specified variable number in hexadecimal right justified in a field of specified width to stderr.
3051 0 ▶ {my ($number, $width) = @_; # Number to print as a variable, width of output field
Subroutine errRightInHex: not called CC=2 SCAR=17.9
3052 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3053 0 PrintRightInHex($stderr, $number, $width);
3054 }
3055  
3056 sub Nasm::X86::Variable::errRightInHexNL($;$) #P Write the specified variable number in hexadecimal right justified in a field of specified width to stderr followed by a new line.
3057 0 ▶ {my ($number, $width) = @_; # Number to print as a variable, width of output field
Subroutine errRightInHexNL: not called CC=2 SCAR=17.9
3058 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3059 0 PrintRightInHex($stderr, $number, $width);
3060 0 PrintErrNL;
3061 }
3062  
3063 sub Nasm::X86::Variable::outRightInHex($;$) # Write the specified variable number in hexadecimal right justified in a field of specified width to stdout.
3064 0 ▶ {my ($number, $width) = @_; # Number to print as a variable, width of output field
Subroutine outRightInHex: not called CC=2 SCAR=17.9
3065 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3066 0 PrintRightInHex($stdout, $number, $width);
3067 }
3068  
3069 sub Nasm::X86::Variable::outRightInHexNL($;$) # Write the specified variable number in hexadecimal right justified in a field of specified width to stdout followed by a new line.
3070 0 ▶ {my ($number, $width) = @_; # Number to print as a variable, width of output field
Subroutine outRightInHexNL: not called CC=2 SCAR=17.9
3071 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3072 0 PrintRightInHex($stdout, $number, $width);
3073 0 PrintOutNL;
3074 }
3075  
3076 #D3 Binary representation, right justified # Print number variables in binary right justified in fields of specified width.
3077  
3078 sub Nasm::X86::Variable::rightInBin($$;$) #P Write the specified variable number in binary right justified in a field of specified width to the specified channel.
3079 0 ▶ {my ($number, $channel, $width) = @_; # Number to print as a variable, channel to print on, width of output field
Subroutine rightInBin: not called CC=2 SCAR=17.9
3080 0 ▶ @_ >= 2 or confess "At least two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("At least two parameters") 0 0 0
3081 0 PrintRightInBin($channel, $number, $width);
3082 }
3083  
3084 sub Nasm::X86::Variable::errRightInBin($;$) #P Write the specified variable number in binary right justified in a field of specified width to stderr.
3085 0 ▶ {my ($number, $width) = @_; # Number to print as a variable, width of output field
Subroutine errRightInBin: not called CC=2 SCAR=17.9
3086 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3087 0 PrintRightInBin($stderr, $number, $width);
3088 }
3089  
3090 sub Nasm::X86::Variable::errRightInBinNL($;$) #P Write the specified variable number in binary right justified in a field of specified width to stderr followed by a new line.
3091 0 ▶ {my ($number, $width) = @_; # Number to print as a variable, width of output field
Subroutine errRightInBinNL: not called CC=2 SCAR=17.9
3092 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3093 0 PrintRightInBin($stderr, $number, $width);
3094 0 PrintErrNL;
3095 }
3096  
3097 sub Nasm::X86::Variable::outRightInBin($;$) # Write the specified variable number in binary right justified in a field of specified width to stdout.
3098 0 ▶ {my ($number, $width) = @_; # Number to print as a variable, width of output field
Subroutine outRightInBin: not called CC=2 SCAR=17.9
3099 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3100 0 PrintRightInBin($stdout, $number, $width);
3101 }
3102  
3103 sub Nasm::X86::Variable::outRightInBinNL($;$) # Write the specified variable number in binary right justified in a field of specified width to stdout followed by a new line.
3104 0 ▶ {my ($number, $width) = @_; # Number to print as a variable, width of output field
Subroutine outRightInBinNL: not called CC=2 SCAR=17.9
3105 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
3106 0 PrintRightInBin($stdout, $number, $width);
3107 0 PrintOutNL;
3108 }
3109  
3110 #D3 Spaces # Print out a variable number of spaces.
3111  
3112 sub Nasm::X86::Variable::spaces($$) # Print the specified number of spaces to the specified channel.
3113 0 ▶ {my ($count, $channel) = @_; # Number of spaces, channel
Subroutine spaces: not called CC=2 SCAR=17.9
3114 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3115 0 ▶ $count->for(sub {PrintSpace $channel});
Subroutine __ANON__: not called CC=1 SCAR=6.9
3116 }
3117  
3118 sub Nasm::X86::Variable::errSpaces($) #P Print the specified number of spaces to stderr.
3119 0 ▶ {my ($count) = @_; # Number of spaces
Subroutine errSpaces: not called CC=2 SCAR=17.9
3120 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
3121 0 $count->spaces($stderr);
3122 }
3123  
3124 sub Nasm::X86::Variable::outSpaces($) # Print the specified number of spaces to stdout.
3125 0 ▶ {my ($count) = @_; # Number of spaces
Subroutine outSpaces: not called CC=2 SCAR=17.9
3126 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
3127 0 $count->spaces($stdout);
3128 }
3129  
3130 #D3 C style zero terminated strings # Print out C style zero terminated strings.
3131  
3132 sub Nasm::X86::Variable::errCString($) #P Print a zero terminated C style string addressed by a variable on stderr.
3133 0 ▶ {my ($string) = @_; # String
Subroutine errCString: not called CC=2 SCAR=17.9
3134 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
3135 0 PrintCString($stderr, $string);
3136 }
3137  
3138 sub Nasm::X86::Variable::errCStringNL($) #P Print a zero terminated C style string addressed by a variable on stderr followed by a new line.
3139 0 ▶ {my ($string) = @_; # String
Subroutine errCStringNL: not called CC=2 SCAR=17.9
3140 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
3141 0 $string->errCString($string);
3142 0 PrintErrNL;
3143 }
3144  
3145 sub Nasm::X86::Variable::outCString($) # Print a zero terminated C style string addressed by a variable on stdout.
3146 0 ▶ {my ($string) = @_; # String
Subroutine outCString: not called CC=2 SCAR=17.9
3147 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
3148 0 PrintCString($stdout, $string);
3149 }
3150  
3151 sub Nasm::X86::Variable::outCStringNL($) # Print a zero terminated C style string addressed by a variable on stdout followed by a new line.
3152 0 ▶ {my ($string) = @_; # String
Subroutine outCStringNL: not called CC=2 SCAR=17.9
3153 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
3154 0 $string->outCString;
3155 0 PrintOutNL;
3156 }
3157  
3158 #D2 Addressing # Create references to variables and dereference variables
3159  
3160 sub Nasm::X86::Variable::address($) # Create a variable that contains the address of another variable.
3161 0 ▶ {my ($source) = @_; # Source variable
Subroutine address: not called CC=2 SCAR=17.9
3162 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
3163 0 Lea rdi, $source->addressExpr; # Address of variable
3164 0 V("addr ".$source->name => rdi) # Return variable containing address of source
3165 }
3166  
3167 sub Nasm::X86::Variable::dereference($) # Create a variable that contains the contents of the variable addressed by the specified variable.
3168 0 ▶ {my ($address) = @_; # Source variable
Subroutine dereference: not called CC=2 SCAR=17.9
3169 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
3170 0 $address->setReg(rdi); # Address of referenced variable
3171 0 Mov rdi, "[rdi]"; # Content of referenced variable
3172 0 V "deref ".$address->name => rdi # Return variable containing content of addressed variable
3173 }
3174  
3175 sub Nasm::X86::Variable::update($$) # Update the content of the addressed variable with the content of the specified variable.
3176 0 ▶ {my ($address, $content) = @_; # Source variable, content
Subroutine update: not called CC=2 SCAR=17.9
3177 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3178 0 PushR 14, 15;
3179 0 $address->setReg(14); # Address of referenced variable
3180 0 $content->setReg(15); # Content
3181 0 Mov "[r14]", r15; # Move content to addressed variable;
3182 0 PopR;
3183 }
3184  
3185 sub constantString($) # Return the address and length of a constant string as two variables.
3186 0 ▶ {my ($string) = @_; # Constant utf8 string
Subroutine constantString: not called CC=2 SCAR=12.6
Pod documented
3187 1 ▶ use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
3188 0 my $L = length($string);
3189 0 my $l = K length => $L;
3190 0 ▶ return ($l, $l) unless $L;
Branch: 1 branch
BranchTrueFalseTotal
unless $L 0 0 0
3191 0 my $s = V string => Rutf8 $string;
3192 0 ($s, $l)
3193 }
3194  
3195 #D2 Operations # Variable operations
3196  
3197 1 if (1) # Define operator overloading for Variables
3198 {package Nasm::X86::Variable;
3199 use overload
3200 1 ▶ '+' => \&add,
Subroutine BEGIN: called CC=1 SCAR=0.0
3201 '-' => \&sub,
3202 '*' => \&times,
3203 '/' => \&divide,
3204 '%' => \&mod,
3205 '==' => \&eq,
3206 '!=' => \&ne,
3207 '>=' => \&ge,
3208 '>' => \&gt,
3209 '<=' => \&le,
3210 '<' => \&lt,
3211 '++' => \&inc,
3212 '--' => \&dec,
3213 '""' => \&str,
3214 # '&' => \&and, # We use the zero flag as the bit returned by a Boolean operation so we cannot implement '&' or '|' which were previously in use because '&&' and '||' and "and" and "or" are all disallowed in Perl operator overloading.
3215 # '|' => \&or,
3216 '+=' => \&plusAssign,
3217 '-=' => \&minusAssign,
3218 '=' => \&equals,
3219 '<<' => \&shiftLeft,
3220 '>>' => \&shiftRight,
3221 '!' => \&not,
3222 1 }
3223  
3224 #sub Nasm::X86::Variable::call($) # Execute the call instruction for a target whose address is held in the specified variable.
3225 # {my ($target) = @_; # Variable containing the address of the code to call
3226 # $target->setReg(rdi); # Address of code to call
3227 # Call rdi; # Call referenced code
3228 # }
3229  
3230 sub Nasm::X86::Variable::addressExpr($;$) # Create a register expression to address an offset form a variable.
3231 0 ▶ {my ($left, $offset) = @_; # Left variable, optional offset
Subroutine addressExpr: not called CC=2 SCAR=17.9
3232 0 ▶ my $o = $offset ? "+$offset" : "";
Branch: 1 branch
BranchTrueFalseTotal
$offset ? : 0 0 0
3233 0 "[".$left-> label."$o]"
3234 }
3235  
3236 sub Nasm::X86::Variable::clone($$) # Clone a variable to make a new variable.
3237 0 ▶ {my ($variable, $name) = @_; # Variable to clone, new name for variable
Subroutine clone: not called CC=2 SCAR=17.9
3238 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3239 0 my $c = V($name => undef); # Use supplied name or fall back on existing name
3240 0 $c->copy($variable); # Copy into created variable
3241 0 $c # Return the clone of the variable
3242 }
3243  
3244 sub Nasm::X86::Variable::copy($$) # Copy one variable into another.
3245 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine copy: not called CC=8 SCAR=42.8
3246 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3247  
3248 0 ▶ if (ref $right) # Right hand side is a variable expression
Branch: 1 branch
BranchTrueFalseTotal
if (ref $right) { } 0 0 0
3249 0 {my $l = $left ->addressExpr;
3250 0 my $r = $right->addressExpr; # Variable address
3251  
3252 0 Mov rdi, $r; # Load right hand side
3253  
3254 0 ▶ if (ref($right) and $right->reference) # Dereference a reference
Branch: 1 branch
BranchTrueFalseTotal
if (ref $right and $right->reference) 0 0 0
Condition0%0/3
ref $right and $right->reference
!ll&&!rl&&r
000
MC/DC0%0/2
ref $right and $right->reference
ref $right $right->reference
Truth table0%0/3
A and B
A= ref $rightB= $right->reference
ABresult
0X0
100
111
3255 0 {Mov rdi, "[rdi]";
3256 }
3257  
3258 0 ▶ if ($left ->reference) # Copy a reference
Branch: 1 branch
BranchTrueFalseTotal
if ($left->reference) { } 0 0 0
3259 0 {Mov rsi, $l;
3260 0 Mov "[rsi]", rdi;
3261 }
3262 else # Copy a non reference
3263 0 {Mov $l, rdi;
3264 }
3265 }
3266 else # Right hand size is a register expression
3267 0 {my $l = $left->addressExpr;
3268 0 ▶ if ($left->reference) # Copy a constant to a reference
Branch: 1 branch
BranchTrueFalseTotal
if ($left->reference) { } 0 0 0
3269 0 ▶ {my $r = $right =~ m(rsi) ? rdi : rsi; # Choose a transfer register
Branch: 1 branch
BranchTrueFalseTotal
$right =~ /rsi/ ? : 0 0 0
3270 0 Mov $r, $l; # Load reference
3271 0 Mov "qword [$r]", $right; # Copy to referenced variable
3272 }
3273 else # Copy a constant to a non reference
3274 0 {Mov "qword $l", $right;
3275 }
3276 }
3277  
3278 0 $left # Return the variable on the left now that it has had the right hand side copied into it.
3279 }
3280  
3281 sub Nasm::X86::Variable::copyRef($$) # Copy a reference to a variable.
3282 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine copyRef: not called CC=4 SCAR=30.0
3283 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3284  
3285 0 ▶ $left->reference or confess "Left hand side must be a reference";
Branch: 1 branch
BranchTrueFalseTotal
$left->reference or confess("Left hand side must be a reference") 0 0 0
3286  
3287 0 my $l = $left ->addressExpr;
3288 0 my $r = $right->addressExpr;
3289  
3290 0 ▶ if ($right->reference) # Right is a reference so we copy its value to create a new reference to the original data
Branch: 1 branch
BranchTrueFalseTotal
if ($right->reference) { } 0 0 0
3291 0 {Mov rdi, $r;
3292 }
3293 else # Right is not a reference so we copy its address to make a reference to the data
3294 0 {Lea rdi, $r;
3295 }
3296 0 Mov $l, rdi; # Save value of address in left
3297  
3298 0 $left; # Chain
3299 }
3300  
3301 sub Nasm::X86::Variable::copyZF($) # Copy the current state of the zero flag into a variable.
3302 0 ▶ {my ($var) = @_; # Variable
Subroutine copyZF: not called CC=2 SCAR=17.9
3303 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
3304  
3305 0 my $a = $var->addressExpr; # Address of the variable
3306  
3307 0 PushR rax;
3308 0 Lahf; # Save flags to ah: (SF:ZF:0:AF:0:PF:1:CF)
3309 0 Shr ah, 6; # Put zero flag in bit zero
3310 0 And ah, 1; # Isolate zero flag
3311 0 Mov $a, ah; # Save zero flag
3312 0 PopR;
3313 }
3314  
3315 sub Nasm::X86::Variable::copyZFInverted($) # Copy the opposite of the current state of the zero flag into a variable.
3316 0 ▶ {my ($var) = @_; # Variable
Subroutine copyZFInverted: not called CC=3 SCAR=24.8
3317 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
3318  
3319 0 my $a = $var->addressExpr; # Address of the variable
3320  
3321 0 PushR rax, 15;
3322 0 Lahf; # Save flags to ah: (SF:ZF:0:AF:0:PF:1:CF)
3323 0 Shr ah, 6; # Put zero flag in bit zero
3324 0 Not ah; # Invert zero flag
3325 0 And ah, 1; # Isolate zero flag
3326 0 ▶ if ($var->reference) # Dereference and save
Branch: 1 branch
BranchTrueFalseTotal
if ($var->reference) { } 0 0 0
3327 0 {PushR rdx;
3328 0 Mov rdx, $a;
3329 0 Mov "[rdx]", ah; # Save zero flag
3330 0 PopR rdx;
3331 }
3332 else # Save without dereferencing
3333 0 {Mov $a, ah; # Save zero flag
3334 }
3335 0 PopR;
3336 }
3337  
3338 sub Nasm::X86::Variable::equals($$$) #P Equals operator.
3339 0 ▶ {my ($op, $left, $right) = @_; # Operator, left variable, right variable
Subroutine equals: not called CC=1 SCAR=6.9
3340 0 $op
3341 }
3342  
3343 sub Nasm::X86::Variable::assign($$$) #P Assign to the left hand side the value of the right hand side.
3344 0 ▶ {my ($left, $op, $right) = @_; # Left variable, operator, right variable
Subroutine assign: not called CC=6 SCAR=37.4
3345 0 ▶ $left->constant and confess "Cannot assign to a constant";
Branch: 1 branch
BranchTrueFalseTotal
$left->constant and confess("Cannot assign to a constant") 0 0 0
3346  
3347 0 Comment "Variable assign";
3348 0 Mov rdi, $left ->addressExpr;
3349 0 ▶ if ($left->reference) # Dereference left if necessary
Branch: 1 branch
BranchTrueFalseTotal
if ($left->reference) 0 0 0
3350 0 {Mov rdi, "[rdi]";
3351 }
3352 0 ▶ if (!ref($right)) # Load right constant
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $right) { } 0 0 0
3353 0 {Mov rsi, $right;
3354 }
3355 else # Load right variable
3356 0 {Mov rsi, $right->addressExpr;
3357 0 ▶ if ($right->reference) # Dereference right if necessary
Branch: 1 branch
BranchTrueFalseTotal
if ($right->reference) 0 0 0
3358 0 {Mov rsi, "[rsi]";
3359 }
3360 }
3361 0 &$op(rdi, rsi);
3362 0 ▶ if ($left->reference) # Store in reference on left if necessary
Branch: 1 branch
BranchTrueFalseTotal
if ($left->reference) { } 0 0 0
3363 0 {Mov r11, $left->addressExpr;
3364 0 Mov "[r11]", rdi;
3365 }
3366 else # Store in variable
3367 0 {Mov $left ->addressExpr, rdi;
3368 }
3369  
3370 0 $left;
3371 }
3372  
3373 sub Nasm::X86::Variable::plusAssign($$) #P Implement plus and assign.
3374 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine plusAssign: not called CC=1 SCAR=6.9
3375 0 $left->assign(\&Add, $right);
3376 }
3377  
3378 sub Nasm::X86::Variable::minusAssign($$) #P Implement minus and assign.
3379 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine minusAssign: not called CC=1 SCAR=6.9
3380 0 $left->assign(\&Sub, $right);
3381 }
3382  
3383 sub Nasm::X86::Variable::arithmetic($$$$) #P Return a variable containing the result of an arithmetic operation on the left hand and right hand side variables.
3384 0 ▶ {my ($op, $name, $left, $right) = @_; # Operator, operator name, Left variable, right variable
Subroutine arithmetic: not called CC=6 SCAR=37.4
3385  
3386 0 my $l = $left ->addressExpr;
3387 0 ▶ my $r = ref($right) ? $right->addressExpr : $right; # Right can be either a variable reference or a constant
Branch: 1 branch
BranchTrueFalseTotal
ref $right ? : 0 0 0
3388  
3389 0 Comment "Arithmetic Start";
3390 0 Mov rsi, $l;
3391 0 ▶ if ($left->reference) # Dereference left if necessary
Branch: 1 branch
BranchTrueFalseTotal
if ($left->reference) 0 0 0
3392 0 {Mov rsi, "[rsi]";
3393 }
3394 0 Mov rbx, $r;
3395 0 ▶ if (ref($right) and $right->reference) # Dereference right if necessary
Branch: 1 branch
BranchTrueFalseTotal
if (ref $right and $right->reference) 0 0 0
Condition0%0/3
ref $right and $right->reference
!ll&&!rl&&r
000
MC/DC0%0/2
ref $right and $right->reference
ref $right $right->reference
Truth table0%0/3
A and B
A= ref $rightB= $right->reference
ABresult
0X0
100
111
3396 0 {Mov rbx, "[rbx]";
3397 }
3398 0 &$op(rsi, rbx);
3399 0 ▶ my $v = V(join(' ', '('.$left->name, $name, (ref($right) ? $right->name : $right).')'), rsi);
Branch: 1 branch
BranchTrueFalseTotal
ref $right ? : 0 0 0
3400 0 Comment "Arithmetic End";
3401  
3402 0 return $v;
3403 }
3404  
3405 sub Nasm::X86::Variable::add($$) #P Add the right hand variable to the left hand variable and return the result as a new variable.
3406 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine add: not called CC=1 SCAR=6.9
3407 0 Nasm::X86::Variable::arithmetic(\&Add, q(add), $left, $right);
3408 }
3409  
3410 sub Nasm::X86::Variable::sub($$) #P Subtract the right hand variable from the left hand variable and return the result as a new variable.
3411 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine sub: not called CC=1 SCAR=6.9
3412 0 Nasm::X86::Variable::arithmetic(\&Sub, q(sub), $left, $right);
3413 }
3414  
3415 sub Nasm::X86::Variable::times($$) #P Multiply the left hand variable by the right hand variable and return the result as a new variable.
3416 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine times: not called CC=1 SCAR=6.9
3417 0 Nasm::X86::Variable::arithmetic(\&Imul, q(times), $left, $right);
3418 }
3419  
3420 sub Nasm::X86::Variable::division($$$) #P Return a variable containing the result or the remainder that occurs when the left hand side is divided by the right hand side.
3421 0 ▶ {my ($op, $left, $right) = @_; # Operator, Left variable, right variable
Subroutine division: not called CC=7 SCAR=40.3
3422  
3423 0 my $l = $left ->addressExpr;
3424 0 ▶ my $r = ref($right) ? $right->addressExpr : $right; # Right can be either a variable reference or a constant
Branch: 1 branch
BranchTrueFalseTotal
ref $right ? : 0 0 0
3425 0 PushR rax, rdx, 15;
3426 0 Mov rax, $l;
3427 0 ▶ Mov rax, "[rax]" if $left->reference;
Branch: 1 branch
BranchTrueFalseTotal
if $left->reference 0 0 0
3428 0 Mov r15, $r;
3429 0 ▶ Mov r15, "[r15]" if ref($right) and $right->reference;
Branch: 1 branch
BranchTrueFalseTotal
if ref $right and $right->reference 0 0 0
Condition0%0/3
ref $right and $right->reference
!ll&&!rl&&r
000
MC/DC0%0/2
ref $right and $right->reference
ref $right $right->reference
Truth table0%0/3
A and B
A= ref $rightB= $right->reference
ABresult
0X0
100
111
3430 0 ClearRegisters rdx; # Failure to do so means that rdx will have junk in it which can cause random divide exceptions that will be incorrectly reported as floating point exceptions.
3431 0 Idiv r15;
3432 0 ▶ my $v = V(join(' ', '('.$left->name, $op, (ref($right) ? $right->name : '').')'), $op eq "%" ? rdx : rax);
Branch: 2 branches
BranchTrueFalseTotal
ref $right ? : 0 0 0
$op eq '%' ? : 0 0 0
3433 0 PopR;
3434 0 $v;
3435 }
3436  
3437 sub Nasm::X86::Variable::divide($$) #P Divide the left hand variable by the right hand variable and return the result as a new variable.
3438 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine divide: not called CC=1 SCAR=6.9
3439 0 Nasm::X86::Variable::division("/", $left, $right);
3440 }
3441  
3442 sub Nasm::X86::Variable::mod($$) #P Divide the left hand variable by the right hand variable and return the remainder as a new variable.
3443 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine mod: not called CC=1 SCAR=6.9
3444 0 Nasm::X86::Variable::division("%", $left, $right);
3445 }
3446  
3447 sub Nasm::X86::Variable::shiftLeft($$) #P Shift the left hand variable left by the number of bits specified in the right hand variable and return the result as a new variable.
3448 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine shiftLeft: not called CC=2 SCAR=17.9
3449 0 $left ->setReg(rbx); # Value to shift
3450 0 ▶ confess "Variable required not $right" unless ref($right);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $right 0 0 0
3451 0 $right->setReg(rcx); # Amount to shift
3452 0 Shl rbx, cl; # Shift
3453 0 V "shift left" => rbx; # Save result in a new variable
3454 }
3455  
3456 sub Nasm::X86::Variable::shiftRight($$) #P Shift the left hand variable right by the number of bits specified in the right hand variable and return the result as a new variable.
3457 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine shiftRight: not called CC=2 SCAR=17.9
3458 0 $left ->setReg(rbx); # Value to shift
3459 0 ▶ confess "Variable required not $right" unless ref($right);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $right 0 0 0
3460 0 $right->setReg(rcx); # Amount to shift
3461 0 Shr rbx, cl; # Shift
3462 0 V "shift right" => rbx; # Save result in a new variable
3463 }
3464  
3465 sub Nasm::X86::Variable::not($) #P Form two complement of left hand side and return it as a variable.
3466 0 ▶ {my ($left) = @_; # Left variable
Subroutine not: not called CC=1 SCAR=6.9
3467 0 $left->setReg(rdi); # Value to negate
3468 0 Not rdi; # Two's complement
3469 0 V "neg" => rdi; # Save result in a new variable
3470 }
3471  
3472 sub Nasm::X86::Variable::booleanZF($$$$) #P Combine the left hand variable with the right hand variable via a boolean operator and indicate the result by setting the zero flag if the result is true.
3473 0 ▶ {my ($sub, $op, $left, $right) = @_; # Operator, operator name, Left variable, right variable
Subroutine booleanZF: not called CC=11 SCAR=48.8
3474  
3475 0 ▶ !ref($right) or ref($right) =~ m(Variable) or confess "Variable expected";
Branch: 1 branch
BranchTrueFalseTotal
not ref $right or ref($right) =~ /Variable/ or confess("Variable expected") 0 0 0
Condition0%0/3
not ref $right or ref($right) =~ /Variable/
l!l&&r!l&&!r
000
MC/DC0%0/2
not ref $right or ref($right) =~ /Variable/
not ref $right ref($right) =~ /Variable/
Truth table0%0/3
not(A) or B
A= not ref $rightB= ref($right) =~ /Variable/
ABresult
1X1
011
000
3476 0 ▶ my $r = ref($right) ? $right->addressExpr : $right; # Right can be either a variable reference or a constant
Branch: 1 branch
BranchTrueFalseTotal
ref $right ? : 0 0 0
3477  
3478 0 Comment "Boolean ZF Start";
3479  
3480 0 ▶ if ($op =~ m(\Ag)i)
Branch: 1 branch
BranchTrueFalseTotal
if ($op =~ /\Ag/i) 0 0 0
3481 0 {($left, $right) = ($right, $left);
3482 }
3483  
3484 0 ▶ if (ref($right) and $right->reference) # Dereference on right if necessary
Branch: 3 branches
BranchTrueFalseTotal
if (ref $right and $right->reference) { } 0 0 0
elsif (ref $right) { } 0 0 0
elsif ($left->reference) { } 0 0 0
Condition0%0/3
ref $right and $right->reference
!ll&&!rl&&r
000
MC/DC0%0/2
ref $right and $right->reference
ref $right $right->reference
Truth table0%0/3
A and B
A= ref $rightB= $right->reference
ABresult
0X0
100
111
3485 0 {Mov r11, $left ->addressExpr;
3486 0 ▶ Mov r11, "[r11]" if $left->reference;
Branch: 1 branch
BranchTrueFalseTotal
if $left->reference 0 0 0
3487 0 Mov rdi, $right ->addressExpr;
3488 0 Mov rdi, "[rdi]";
3489 0 Cmp r11, rdi;
3490 }
3491 elsif (ref($right)) # Variable but not a reference on the right
3492 0 {Mov r11, $left ->addressExpr;
3493 0 ▶ Mov r11, "[r11]" if $left->reference;
Branch: 1 branch
BranchTrueFalseTotal
if $left->reference 0 0 0
3494 0 Cmp r11, $right->addressExpr;
3495 }
3496 elsif ($left->reference) # Left is a reference, right is a constant
3497 0 {Mov r11, $left ->addressExpr;
3498 0 Mov r11, "[r11]";
3499 0 Cmp r11, $right;
3500 }
3501 else # Not a reference on the left and a constant on the right
3502 0 {Cmp "qword ".$left->addressExpr, $right;
3503 }
3504 0 Comment "Boolean ZF Arithmetic end $op";
3505  
3506 0 \$op
3507 }
3508  
3509 sub Nasm::X86::Variable::eq($$) #P Check whether the left hand variable is equal to the right hand variable.
3510 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine eq: not called CC=1 SCAR=6.9
3511 0 Nasm::X86::Variable::booleanZF(\&IfEq, q(Jne), $left, $right);
3512 }
3513  
3514 sub Nasm::X86::Variable::ne($$) #P Check whether the left hand variable is not equal to the right hand variable.
3515 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine ne: not called CC=1 SCAR=6.9
3516 0 Nasm::X86::Variable::booleanZF(\&IfNe, q(Je), $left, $right);
3517 }
3518  
3519 sub Nasm::X86::Variable::ge($$) #P Check whether the left hand variable is greater than or equal to the right hand variable.
3520 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine ge: not called CC=1 SCAR=6.9
3521 0 Nasm::X86::Variable::booleanZF(\&IfGe, q(Jl), $left, $right);
3522 }
3523  
3524 sub Nasm::X86::Variable::gt($$) #P Check whether the left hand variable is greater than the right hand variable.
3525 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine gt: not called CC=1 SCAR=6.9
3526 0 Nasm::X86::Variable::booleanZF(\&IfGt, q(Jle), $left, $right);
3527 }
3528  
3529 sub Nasm::X86::Variable::le($$) #P Check whether the left hand variable is less than or equal to the right hand variable.
3530 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine le: not called CC=1 SCAR=6.9
3531 0 Nasm::X86::Variable::booleanZF(\&IfLe, q(Jg), $left, $right);
3532 }
3533  
3534 sub Nasm::X86::Variable::lt($$) #P Check whether the left hand variable is less than the right hand variable.
3535 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine lt: not called CC=1 SCAR=6.9
3536 0 Nasm::X86::Variable::booleanZF(\&IfLt, q(Jge), $left, $right);
3537 }
3538  
3539 sub Nasm::X86::Variable::isRef($) # Check whether the specified variable is a reference to another variable.
3540 0 ▶ {my ($variable) = @_; # Variable
Subroutine isRef: not called CC=2 SCAR=17.9
3541 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
3542 0 my $n = $variable->name; # Variable name
3543 0 $variable->reference
3544 }
3545  
3546 sub Nasm::X86::Variable::setReg($$) # Set the named registers from the content of the variable.
3547 0 ▶ {my ($variable, $register) = @_; # Variable, register to load
Subroutine setReg: not called CC=5 SCAR=34.0
3548 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3549  
3550 0 my $r = registerNameFromNumber $register;
3551 0 ▶ if ($r =~ m(\Ak?[0-7]\Z)) # Mask register is being set
Branch: 1 branch
BranchTrueFalseTotal
if ($r =~ /\Ak?[0-7]\Z/) { } 0 0 0
3552 0 {Mov rdi, $variable->addressExpr;
3553 0 ▶ if ($variable->isRef)
Branch: 1 branch
BranchTrueFalseTotal
if ($variable->isRef) { } 0 0 0
3554 0 {Kmovq $r, "[rdi]";
3555 }
3556 else
3557 0 {Kmovq $r, rdi;
3558 }
3559 }
3560 else # Set normal register
3561 0 ▶ {if ($variable->isRef)
Branch: 1 branch
BranchTrueFalseTotal
if ($variable->isRef) { } 0 0 0
3562 0 {Mov $r, $variable->addressExpr;
3563 0 Mov $r, "[$r]";
3564 }
3565 else
3566 0 {Mov $r, $variable->addressExpr;
3567 }
3568 }
3569  
3570 0 $register # Name of register being set
3571 }
3572  
3573 #sub Nasm::X86::Variable::compare($$) # Compare the content of a variable with a numeric constant.
3574 # {my ($variable, $compare) = @_; # Variable, value to compare
3575 # @_ == 2 or confess "Two parameters";
3576 #
3577 # if ($variable->isRef)
3578 # {Mov rsi, $variable->addressExpr;
3579 # Cmp "qword [rsi]", $compare;
3580 # }
3581 # else
3582 # {Cmp "qword ".$variable->addressExpr, $compare;
3583 # }
3584 # }
3585  
3586 sub Nasm::X86::Variable::getReg($$) # Load the variable from a register expression.
3587 0 ▶ {my ($variable, $register) = @_; # Variable, register expression to load
Subroutine getReg: not called CC=4 SCAR=30.0
3588 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3589 0 my $r = registerNameFromNumber $register;
3590 0 ▶ if ($variable->isRef) # Move to the location referred to by this variable
Branch: 1 branch
BranchTrueFalseTotal
if ($variable->isRef) { } 0 0 0
3591 0 {Comment "Get variable value from register $r";
3592 0 ▶ my $p = $r eq rdi ? rsi : rdi;
Branch: 1 branch
BranchTrueFalseTotal
$r eq rdi() ? : 0 0 0
3593 0 PushR $p;
3594 0 Mov $p, $variable->addressExpr;
3595 0 Mov "[$p]", $r;
3596 0 PopR $p;
3597 }
3598 else # Move to this variable
3599 0 {Mov $variable->addressExpr, $r;
3600 }
3601 0 $variable # Chain
3602 }
3603  
3604 #sub Nasm::X86::Variable::getConst($$) # Load the variable from a constant in effect setting a variable to a specified value.
3605 # {my ($variable, $constant) = @_; # Variable, constant to load
3606 # @_ == 2 or confess "Two parameters";
3607 # Mov rdi, $constant;
3608 # $variable->getReg(rdi);
3609 # }
3610  
3611 sub Nasm::X86::Variable::incDec($$) #P Increment or decrement a variable.
3612 0 ▶ {my ($left, $op) = @_; # Left variable operator, address of operator to perform inc or dec
Subroutine incDec: not called CC=3 SCAR=24.8
3613 0 ▶ $left->constant and confess "Cannot increment or decrement a constant";
Branch: 1 branch
BranchTrueFalseTotal
$left->constant and confess("Cannot increment or decrement a constant") 0 0 0
3614 0 my $l = $left->addressExpr;
3615 0 ▶ if ($left->reference)
Branch: 1 branch
BranchTrueFalseTotal
if ($left->reference) { } 0 0 0
3616 0 {Mov rsi, $l;
3617 0 push @text, <<END;
3618 $op qword [rsi]
3619 END
3620 0 return $left;
3621 }
3622 else
3623 0 {push @text, <<END;
3624 $op qword $l
3625 END
3626 0 return $left;
3627 }
3628 }
3629  
3630 sub Nasm::X86::Variable::inc($) #P Increment a variable.
3631 0 ▶ {my ($left) = @_; # Variable
Subroutine inc: not called CC=1 SCAR=6.9
3632 0 $left->incDec("inc");
3633 }
3634  
3635 sub Nasm::X86::Variable::dec($) #P Decrement a variable.
3636 0 ▶ {my ($left) = @_; # Variable
Subroutine dec: not called CC=1 SCAR=6.9
3637 0 $left->incDec("dec");
3638 }
3639  
3640 sub Nasm::X86::Variable::str($) #P The name of the variable.
3641 0 ▶ {my ($left) = @_; # Variable
Subroutine str: not called CC=1 SCAR=6.9
3642 0 $left->name;
3643 }
3644  
3645 sub Nasm::X86::Variable::min($$) # Minimum of two variables.
3646 0 ▶ {my ($left, $right) = @_; # Left variable, right variable or constant
Subroutine min: not called CC=2 SCAR=17.9
3647 0 PushR 12, 14, 15;
3648 0 $left->setReg(14);
3649  
3650 0 ▶ if (ref($right)) # Right hand side is a variable
Branch: 1 branch
BranchTrueFalseTotal
if (ref $right) { } 0 0 0
3651 0 {$right->setReg(15);
3652 }
3653 else # Right hand side is a constant
3654 0 {Mov r15, $right;
3655 }
3656  
3657 0 Cmp r14, r15;
3658 0 Cmovg r12, r15;
3659 0 Cmovle r12, r14;
3660 0 my $r = V("min", r12);
3661 0 PopR;
3662 0 $r
3663 }
3664  
3665 sub Nasm::X86::Variable::max($$) # Maximum of two variables.
3666 0 ▶ {my ($left, $right) = @_; # Left variable, right variable or constant
Subroutine max: not called CC=2 SCAR=17.9
3667 0 PushR 12, 14, 15;
3668 0 $left->setReg(14);
3669  
3670 0 ▶ if (ref($right)) # Right hand side is a variable
Branch: 1 branch
BranchTrueFalseTotal
if (ref $right) { } 0 0 0
3671 0 {$right->setReg(15);
3672 }
3673 else # Right hand side is a constant
3674 0 {Mov r15, $right;
3675 }
3676  
3677 0 Cmp r14, r15;
3678 0 Cmovg r12, r14;
3679 0 Cmovle r12, r15;
3680  
3681 0 my $r = V("max", r12);
3682 0 PopR;
3683 0 $r
3684 }
3685  
3686 sub Nasm::X86::Variable::and($$) #P And two variables.
3687 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine and: not called CC=1 SCAR=6.9
3688 0 PushR 14, 15;
3689 0 Mov r14, 0;
3690 0 $left->setReg(15);
3691 0 Cmp r15, 0;
3692 &IfNe (
3693 sub
3694 0 ▶ {$right->setReg(15);
Subroutine __ANON__: not called CC=1 SCAR=6.9
3695 0 Cmp r15, 0;
3696 0 ▶ &IfNe(sub {Add r14, 1});
Subroutine __ANON__: not called CC=1 SCAR=6.9
3697 }
3698 0 );
3699 0 my $r = V("And(".$left->name.", ".$right->name.")", r14);
3700 0 PopR;
3701 0 $r
3702 }
3703  
3704 sub Nasm::X86::Variable::or($$) #P Or two variables.
3705 0 ▶ {my ($left, $right) = @_; # Left variable, right variable
Subroutine or: not called CC=1 SCAR=6.9
3706 0 PushR 14, 15;
3707 0 Mov r14, 1;
3708 0 $left->setReg(15);
3709 0 Cmp r15, 0;
3710 &IfEq (
3711 sub
3712 0 ▶ {$right->setReg(15);
Subroutine __ANON__: not called CC=1 SCAR=6.9
3713 0 Cmp r15, 0;
3714 0 ▶ &IfEq(sub {Mov r14, 0});
Subroutine __ANON__: not called CC=1 SCAR=6.9
3715 }
3716 0 );
3717 0 my $r = V("Or(".$left->name.", ".$right->name.")", r14);
3718 0 PopR;
3719 0 $r
3720 }
3721  
3722 sub Nasm::X86::Variable::setMask($$$) # Set the mask register to ones starting at the specified position for the specified length and zeroes elsewhere.
3723 0 ▶ {my ($start, $length, $mask) = @_; # Variable containing start of mask, variable containing length of mask, mask register
Subroutine setMask: not called CC=4 SCAR=30.0
3724 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3725  
3726 0 PushR 13, 14, 15;
3727 0 Mov r15, -1;
3728 0 ▶ if ($start) # Non zero start
Branch: 1 branch
BranchTrueFalseTotal
if ($start) { } 0 0 0
3729 0 {$start->setReg(14);
3730 0 Bzhi r15, r15, r14;
3731 0 Not r15;
3732 0 ▶ ref($length) or confess "Not a variable";
Branch: 1 branch
BranchTrueFalseTotal
ref $length or confess("Not a variable") 0 0 0
3733 0 $length->setReg(13);
3734 0 Add r14, r13;
3735 }
3736 else # Starting at zero
3737 0 {confess "Deprecated: use setMaskFirst instead";
3738 0 $length->setReg(13);
3739 0 Mov r14, $length;
3740 }
3741 0 Bzhi r15, r15, r14;
3742 0 Kmovq $mask, r15;
3743 0 PopR;
3744 }
3745  
3746 sub Nasm::X86::Variable::setMaskFirst($$) # Set the first bits in the specified mask register.
3747 0 ▶ {my ($length, $mask) = @_; # Variable containing length to set, mask register
Subroutine setMaskFirst: not called CC=4 SCAR=30.0
3748 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3749  
3750 0 PushR my ($l, $b) = ChooseRegisters(2, $mask); # Choose two registers not the mask register
3751 0 Mov $b, -1;
3752 0 $length->setReg($l);
3753 0 Bzhi $b, $b, $l;
3754 0 ▶ Kmovq $mask, $b if $mask =~ m(\Ak)i; # Set mask register if provided
Branch: 1 branch
BranchTrueFalseTotal
if $mask =~ /\Ak/i 0 0 0
3755 0 ▶ Mov $mask, $b if $mask =~ m(\Ar)i; # Set general purpose register if provided
Branch: 1 branch
BranchTrueFalseTotal
if $mask =~ /\Ar/i 0 0 0
3756 0 PopR;
3757 }
3758  
3759 sub Nasm::X86::Variable::setMaskBit($$) # Set a bit in the specified mask register retaining the other bits.
3760 0 ▶ {my ($index, $mask) = @_; # Variable containing bit position to set, mask register
Subroutine setMaskBit: not called CC=3 SCAR=24.8
3761 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3762 0 ▶ $mask =~ m(\Ak)i or confess "Mask register required";
Branch: 1 branch
BranchTrueFalseTotal
$mask =~ /\Ak/i or confess("Mask register required") 0 0 0
3763 0 PushR my ($l, $b) = (r14, r15);
3764 0 Kmovq $b, $mask;
3765 0 $index->setReg($l);
3766 0 Bts $b, $l;
3767 0 Kmovq $mask, $b; # Set mask register if provided
3768 0 PopR;
3769 }
3770  
3771 sub Nasm::X86::Variable::clearMaskBit($$) # Clear a bit in the specified mask register retaining the other bits.
3772 0 ▶ {my ($index, $mask) = @_; # Variable containing bit position to clear, mask register
Subroutine clearMaskBit: not called CC=3 SCAR=24.8
3773 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3774 0 ▶ $mask =~ m(\Ak)i or confess "Mask register required";
Branch: 1 branch
BranchTrueFalseTotal
$mask =~ /\Ak/i or confess("Mask register required") 0 0 0
3775  
3776 0 PushR my $l = r14, $b = r15;
3777 0 Kmovq $b, $mask;
3778 0 $index->setReg($l);
3779 0 Btc $b, $l;
3780 0 Kmovq $mask, $b; # Set mask register if provided
3781 0 PopR;
3782 }
3783  
3784 sub Nasm::X86::Variable::setBit($$) # Set a bit in the specified register retaining the other bits.
3785 0 ▶ {my ($index, $mask) = @_; # Variable containing bit position to set, mask register
Subroutine setBit: not called CC=2 SCAR=17.9
3786 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3787  
3788 0 PushR my ($l) = ChooseRegisters(1, $mask); # Choose a register
3789 0 $index->setReg($l);
3790 0 Bts $mask, $l;
3791 0 PopR;
3792 }
3793  
3794 sub Nasm::X86::Variable::clearBit($$) # Clear a bit in the specified mask register retaining the other bits.
3795 0 ▶ {my ($index, $mask) = @_; # Variable containing bit position to clear, mask register
Subroutine clearBit: not called CC=2 SCAR=17.9
3796 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3797  
3798 0 PushR my ($l) = ChooseRegisters(1, $mask); # Choose a register
3799 0 $index->setReg($l);
3800 0 Btc $mask, $l;
3801 0 PopR;
3802 }
3803  
3804 sub Nasm::X86::Variable::setZmm($$$$) # Load bytes from the memory addressed by specified source variable into the numbered zmm register at the offset in the specified offset moving the number of bytes in the specified variable.
3805 0 ▶ {my ($source, $zmm, $offset, $length) = @_; # Variable containing the address of the source, number of zmm to load, variable containing offset in zmm to move to, variable containing length of move
Subroutine setZmm: not called CC=4 SCAR=30.0
3806 0 ▶ @_ == 4 or confess;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess() 0 0 0
3807 0 ▶ ref($offset) && ref($length) or confess "Missing variable"; # Need variables of offset and length
Branch: 1 branch
BranchTrueFalseTotal
ref $offset and ref $length or confess("Missing variable") 0 0 0
Condition0%0/3
ref $offset and ref $length
!ll&&!rl&&r
000
MC/DC0%0/2
ref $offset and ref $length
ref $offset ref $length
Truth table0%0/3
A and B
A= ref $offsetB= ref $length
ABresult
0X0
100
111
3808 0 Comment "Set Zmm $zmm from Memory";
3809 0 PushR 7, 14, 15;
3810 0 $offset->setMask($length, k7); # Set mask for target
3811 0 $source->setReg(15);
3812 0 $offset->setReg(14); # Position memory for target
3813 0 Sub r15, r14; # Position memory for target
3814 0 Vmovdqu8 "zmm${zmm}{k7}", "[r15]"; # Read from memory
3815 0 PopR;
3816 }
3817  
3818 #D3 Load mm registers # Load zmm registers fom variables and retrieve data from zmm registers into variables.
3819  
3820 sub Nasm::X86::Variable::loadZmm($$) # Load bytes from the memory addressed by the specified source variable into the numbered zmm register.
3821 0 ▶ {my ($source, $zmm) = @_; # Variable containing the address of the source, number of zmm to get
Subroutine loadZmm: not called CC=2 SCAR=17.9
3822 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3823  
3824 0 $source->setReg(rdi);
3825 0 Vmovdqu8 zmm($zmm), "[rdi]";
3826 }
3827  
3828 sub Nasm::X86::Variable::bFromZ($$$) # Get the byte from the numbered zmm register and put it in a variable.
3829 0 ▶ {my ($variable, $zmm, $offset) = @_; # Variable, numbered zmm, offset in bytes
Subroutine bFromZ: not called CC=2 SCAR=17.9
3830 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3831 0 $variable->copy(getBwdqFromMm 'z', 'b', $zmm, $offset); # Get the numbered byte|word|double word|quad word from the numbered zmm register and put it in a variable
3832 }
3833  
3834 sub Nasm::X86::Variable::wFromZ($$$) # Get the word from the numbered zmm register and put it in a variable.
3835 0 ▶ {my ($variable, $zmm, $offset) = @_; # Variable, numbered zmm, offset in bytes
Subroutine wFromZ: not called CC=2 SCAR=17.9
3836 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3837 0 $variable->copy(getBwdqFromMm 'z', 'w', $zmm, $offset); # Get the numbered byte|word|double word|quad word from the numbered zmm register and put it in a variable
3838 }
3839  
3840 sub Nasm::X86::Variable::dFromZ($$$) # Get the double word from the numbered zmm register and put it in a variable.
3841 0 ▶ {my ($variable, $zmm, $offset) = @_; # Variable, numbered zmm, offset in bytes
Subroutine dFromZ: not called CC=2 SCAR=17.9
3842 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3843 0 $variable->copy(getBwdqFromMm 'z', 'd', $zmm, $offset); # Get the numbered byte|word|double word|quad word from the numbered zmm register and put it in a variable
3844 }
3845  
3846 sub Nasm::X86::Variable::qFromZ($$$) # Get the quad word from the numbered zmm register and put it in a variable.
3847 0 ▶ {my ($variable, $zmm, $offset) = @_; # Variable, numbered zmm, offset in bytes
Subroutine qFromZ: not called CC=2 SCAR=17.9
3848 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3849 0 $variable->copy(getBwdqFromMm 'z', 'q', $zmm, $offset); # Get the numbered byte|word|double word|quad word from the numbered zmm register and put it in a variable
3850 }
3851  
3852 sub Nasm::X86::Variable::putBwdqIntoMm($$$$) #P Place the value of the content variable at the byte|word|double word|quad word in the numbered zmm register.
3853 0 ▶ {my ($content, $size, $mm, $offset) = @_; # Variable with content, size of put, numbered zmm, offset in bytes
Subroutine putBwdqIntoMm: not called CC=10 SCAR=47.0
3854 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
3855  
3856 0 my $o; # The offset into the mm register
3857 0 ▶ if (ref $offset) # The offset is being passed in a variable
Branch: 1 branch
BranchTrueFalseTotal
if (ref $offset) { } 0 0 0
3858 0 {$offset->setReg($o = rdi);
3859 }
3860 else # The offset is being passed as a register expression
3861 0 {$o = $offset;
3862 0 Comment "Put $size at $offset in $mm";
3863 0 ▶ $offset >= 0 && $offset <= RegisterSize $mm or
Branch: 1 branch
BranchTrueFalseTotal
if $offset =~ /\A\d+\Z/ 0 0 0
Condition0%0/8
$offset =~ /\A\d+\Z/ && ($offset >= 0 && $offset <= &RegisterSize($mm) || confess('Out of range'))
!ll&&!rl&&r
000
$offset >= 0 and $offset <= &RegisterSize($mm) or confess("Out of range")
l!l
00
$offset >= 0 and $offset <= &RegisterSize($mm)
!ll&&!rl&&r
000
MC/DC0%0/3
$offset =~ /\A\d+\Z/ && ($offset >= 0 && $offset <= &RegisterSize($mm) || confess('Out of range'))
$offset =~ /\A\d+\Z/ $offset >= 0 $offset <= &RegisterSize($mm)
Truth table0%0/4
A && B and C
A= $offset =~ /\A\d+\Z/B= $offset >= 0C= $offset <= &RegisterSize($mm)
ABCresult
0XX0
10X0
1100
1111
3864 confess "Out of range" if $offset =~ m(\A\d+\Z); # Check the offset if it is a number
3865 }
3866  
3867 0 $content->setReg(rsi);
3868 0 my $w = RegisterSize $mm; # Size of mm register
3869 0 Vmovdqu32 "[rsp-$w]", $mm; # Write below the stack
3870 0 ▶ Mov "[rsp+$o-$w]", byteRegister(rsi) if $size =~ m(b); # Write byte register
Branch: 1 branch
BranchTrueFalseTotal
if $size =~ /b/ 0 0 0
3871 0 ▶ Mov "[rsp+$o-$w]", wordRegister(rsi) if $size =~ m(w); # Write word register
Branch: 1 branch
BranchTrueFalseTotal
if $size =~ /w/ 0 0 0
3872 0 ▶ Mov "[rsp+$o-$w]", dWordRegister(rsi) if $size =~ m(d); # Write double word register
Branch: 1 branch
BranchTrueFalseTotal
if $size =~ /d/ 0 0 0
3873 0 ▶ Mov "[rsp+$o-$w]", rsi if $size =~ m(q); # Write register
Branch: 1 branch
BranchTrueFalseTotal
if $size =~ /q/ 0 0 0
3874 0 Vmovdqu32 $mm, "[rsp-$w]"; # Read below the stack
3875 }
3876  
3877 sub Nasm::X86::Variable::bIntoX($$$) # Place the value of the content variable at the byte in the numbered xmm register.
3878 0 ▶ {my ($content, $xmm, $offset) = @_; # Variable with content, numbered xmm, offset in bytes
Subroutine bIntoX: not called CC=2 SCAR=17.9
3879 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3880 0 $content->putBwdqIntoMm('b', "xmm$xmm", $offset) # Place the value of the content variable at the word in the numbered xmm register
3881 }
3882  
3883 sub Nasm::X86::Variable::wIntoX($$$) # Place the value of the content variable at the word in the numbered xmm register.
3884 0 ▶ {my ($content, $xmm, $offset) = @_; # Variable with content, numbered xmm, offset in bytes
Subroutine wIntoX: not called CC=2 SCAR=17.9
3885 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3886 0 $content->putBwdqIntoMm('w', "xmm$xmm", $offset) # Place the value of the content variable at the byte|word|double word|quad word in the numbered xmm register
3887 }
3888  
3889 sub Nasm::X86::Variable::dIntoX($$$) # Place the value of the content variable at the double word in the numbered xmm register.
3890 0 ▶ {my ($content, $xmm, $offset) = @_; # Variable with content, numbered xmm, offset in bytes
Subroutine dIntoX: not called CC=2 SCAR=17.9
3891 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3892 0 $content->putBwdqIntoMm('d', "xmm$xmm", $offset) # Place the value of the content variable at the byte|word|double word|quad word in the numbered xmm register
3893 }
3894  
3895 sub Nasm::X86::Variable::qIntoX($$$) # Place the value of the content variable at the quad word in the numbered xmm register.
3896 0 ▶ {my ($content, $xmm, $offset) = @_; # Variable with content, numbered xmm, offset in bytes
Subroutine qIntoX: not called CC=2 SCAR=17.9
3897 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3898 0 $content->putBwdqIntoMm('q', "xmm$xmm", $offset) # Place the value of the content variable at the byte|word|double word|quad word in the numbered xmm register
3899 }
3900  
3901 sub Nasm::X86::Variable::bIntoZ($$$) # Place the value of the content variable at the byte in the numbered zmm register.
3902 0 ▶ {my ($content, $zmm, $offset) = @_; # Variable with content, numbered zmm, offset in bytes
Subroutine bIntoZ: not called CC=2 SCAR=17.9
3903 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3904 0 checkZmmRegister($zmm);
3905 0 $content->putBwdqIntoMm('b', zmm($zmm), $offset) # Place the value of the content variable at the word in the numbered zmm register
3906 }
3907  
3908 sub Nasm::X86::Variable::putWIntoZmm($$$) # Place the value of the content variable at the word in the numbered zmm register.
3909 0 ▶ {my ($content, $zmm, $offset) = @_; # Variable with content, numbered zmm, offset in bytes
Subroutine putWIntoZmm: not called CC=2 SCAR=17.9
3910 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3911 0 checkZmmRegister($zmm);
3912 0 $content->putBwdqIntoMm('w', zmm($zmm), $offset) # Place the value of the content variable at the byte|word|double word|quad word in the numbered zmm register
3913 }
3914  
3915 sub Nasm::X86::Variable::dIntoZ($$$) # Place the value of the content variable at the double word in the numbered zmm register.
3916 0 ▶ {my ($content, $zmm, $offset) = @_; # Variable with content, numbered zmm, offset in bytes
Subroutine dIntoZ: not called CC=2 SCAR=17.9
3917 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3918 0 my $z = extractRegisterNumberFromMM $zmm;
3919 0 $content->putBwdqIntoMm('d', "zmm$z", $offset) # Place the value of the content variable at the byte|word|double word|quad word in the numbered zmm register
3920 }
3921  
3922 sub Nasm::X86::Variable::qIntoZ($$$) # Place the value of the content variable at the quad word in the numbered zmm register.
3923 0 ▶ {my ($content, $zmm, $offset) = @_; # Variable with content, numbered zmm, offset in bytes
Subroutine qIntoZ: not called CC=2 SCAR=17.9
3924 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3925 0 checkZmmRegister $zmm;
3926 0 $content->putBwdqIntoMm('q', zmm($zmm), $offset) # Place the value of the content variable at the byte|word|double word|quad word in the numbered zmm register
3927 }
3928  
3929 #D3 At a point # Place data into mm registers and retrieve data from them at the indicated point.
3930  
3931 sub dFromPointInZ($$%) #P Get the double word from the numbered zmm register at a point specified by the variable or register and return it in a variable.
3932 0 ▶ {my ($point, $zmm, %options) = @_; # Point, numbered zmm, options
Subroutine dFromPointInZ: not called CC=5 SCAR=34.0
Pod documented
3933  
3934 0 ▶ my $s = $options{set} // rsi; # Register to set else a variable will be returned
Condition0%0/3
$options{"set"} // rsi()
l!l&&r!l&&!r
000
MC/DC0%0/2
$options{"set"} // rsi()
$options{"set"} rsi()
Truth table0%0/3
A // B
A= $options{"set"}B= rsi()
ABresult
1X1
011
000
3935 0 ▶ my $x = $zmm =~ m(\A(zmm)?0\Z) ? 1 : 0; # The zmm we will extract into
Branch: 1 branch
BranchTrueFalseTotal
$zmm =~ /\A(zmm)?0\Z/ ? : 0 0 0
3936 0 ▶ if (ref($point) =~ m(Variable)) {$point->setReg(k1)} # Point is in a variable
Branch: 1 branch
BranchTrueFalseTotal
if (ref($point) =~ /Variable/) { } 0 0 0
3937 0 else {Kmovq k1, $point} # Point is in a register
3938 0 my ($z) = zmm $zmm;
3939 0 Vpcompressd "zmm$x\{k1}", $z;
3940 0 Vpextrd dWordRegister($s), xmm($x), 0; # Extract dword from corresponding xmm
3941 0 ▶ V d => $s unless $options{set}; # Create a variable unless a register to set was provided
Branch: 1 branch
BranchTrueFalseTotal
unless $options{"set"} 0 0 0
3942 }
3943  
3944 sub Nasm::X86::Variable::dFromPointInZ($$%) # Get the double word from the numbered zmm register at a point specified by the variable and return it in a variable.
3945 0 ▶ {my ($point, $zmm, %options) = @_; # Point, numbered zmm, options
Subroutine dFromPointInZ: not called CC=2 SCAR=17.9
3946 0 ▶ @_ >= 2 or confess "Two or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("Two or more parameters") 0 0 0
3947 0 dFromPointInZ($point, $zmm, %options); # Register to set else a variable will be returned
3948 }
3949  
3950 sub Nasm::X86::Variable::dIntoPointInZ($$$) # Put the variable double word content into the numbered zmm register at a point specified by the variable.
3951 0 ▶ {my ($point, $zmm, $content) = @_; # Point, numbered zmm, content to be inserted as a variable
Subroutine dIntoPointInZ: not called CC=1 SCAR=6.9
3952 0 $content->setReg(rdi);
3953 0 $point->setReg(rsi);
3954 0 Kmovq k1, rsi;
3955 0 Vpbroadcastd zmmM($zmm, 1), edi; # Insert dword at desired location
3956 }
3957  
3958 #D2 Memory # Actions on memory described by variables
3959  
3960 sub Nasm::X86::Variable::clearMemory($$) # Clear the memory described in this variable.
3961 0 ▶ {my ($address, $size) = @_; # Address of memory to clear, size of the memory to clear
Subroutine clearMemory: not called CC=2 SCAR=17.9
3962 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3963 0 &ClearMemory($address, $size); # Free the memory
3964 }
3965  
3966 sub Nasm::X86::Variable::copyMemory($$$) # Copy from one block of memory to another.
3967 0 ▶ {my ($target, $source, $size) = @_; # Address of target, address of source, length to copy
Subroutine copyMemory: not called CC=2 SCAR=17.9
3968 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3969 0 &CopyMemory($source, $target, $size); # Copy the memory
3970 }
3971  
3972 sub Nasm::X86::Variable::printMemory($$$) #P Print the specified number of bytes from the memory addressed by the variable on the specified channel.
3973 0 ▶ {my ($address, $channel, $size) = @_; # Address of memory, channel to print on as a constant, number of bytes to print
Subroutine printMemory: not called CC=2 SCAR=17.9
3974 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
3975  
3976 0 PushR rax, rdi;
3977 0 $address->setReg(rax);
3978 0 $size->setReg(rdi);
3979 0 &PrintMemory($channel);
3980 0 PopR;
3981 }
3982  
3983 sub Nasm::X86::Variable::printErrMemory($$) #P Print the specified number of bytes of the memory addressed by the variable on stdout.
3984 0 ▶ {my ($address, $size) = @_; # Address of memory, number of bytes to print
Subroutine printErrMemory: not called CC=2 SCAR=17.9
3985 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3986 0 $address->printMemory($stderr, $size);
3987 }
3988  
3989 sub Nasm::X86::Variable::printErrMemoryNL($$) #P Print the specified number of bytes of the memory addressed by the variable on stdout followed by a new line.
3990 0 ▶ {my ($address, $size) = @_; # Address of memory, number of bytes to print
Subroutine printErrMemoryNL: not called CC=2 SCAR=17.9
3991 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3992 0 $address->printErrMemory($size);
3993 0 PrintErrNL;
3994 }
3995  
3996 sub Nasm::X86::Variable::printOutMemory($$) # Print the specified number of bytes of the memory addressed by the variable on stdout.
3997 0 ▶ {my ($address, $size) = @_; # Address of memory, number of bytes to print
Subroutine printOutMemory: not called CC=2 SCAR=17.9
3998 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
3999 0 $address->printMemory($stdout, $size);
4000 }
4001  
4002 sub Nasm::X86::Variable::printOutMemoryNL($$) # Print the specified number of bytes of the memory addressed by the variable on stdout followed by a new line.
4003 0 ▶ {my ($address, $size) = @_; # Address of memory, number of bytes to print
Subroutine printOutMemoryNL: not called CC=2 SCAR=17.9
4004 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
4005 0 $address->printOutMemory($size);
4006 0 PrintOutNL;
4007 }
4008  
4009 sub Nasm::X86::Variable::printMemoryInHexNL($$$) #P Write, in hexadecimal, the memory addressed by a variable to stdout or stderr.
4010 0 ▶ {my ($address, $channel, $size) = @_; # Address of memory, channel to print on, number of bytes to print
Subroutine printMemoryInHexNL: not called CC=2 SCAR=17.9
4011 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
4012 0 PushR rax, rdi;
4013 0 $address->setReg(rax);
4014 0 $size->setReg(rdi);
4015 0 &PrintMemoryInHex($channel);
4016 0 &PrintNL($channel);
4017 0 PopR;
4018 }
4019  
4020 sub Nasm::X86::Variable::printErrMemoryInHexNL($$) #P Write the memory addressed by a variable to stderr.
4021 0 ▶ {my ($address, $size) = @_; # Address of memory, number of bytes to print
Subroutine printErrMemoryInHexNL: not called CC=2 SCAR=17.9
4022 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
4023 0 $address->printMemoryInHexNL($stderr, $size);
4024 }
4025  
4026 sub Nasm::X86::Variable::printOutMemoryInHexNL($$) # Write the memory addressed by a variable to stdout.
4027 0 ▶ {my ($address, $size) = @_; # Address of memory, number of bytes to print
Subroutine printOutMemoryInHexNL: not called CC=2 SCAR=17.9
4028 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
4029 0 $address->printMemoryInHexNL($stdout, $size);
4030 }
4031  
4032 sub Nasm::X86::Variable::freeMemory($$) # Free the memory addressed by this variable for the specified length.
4033 0 ▶ {my ($address, $size) = @_; # Address of memory to free, size of the memory to free
Subroutine freeMemory: not called CC=2 SCAR=17.9
4034 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
4035 0 &FreeMemory($address, $size); # Free the memory
4036 }
4037  
4038 sub Nasm::X86::Variable::allocateMemory($) # Allocate a variable amount of memory via mmap and return its address.
4039 0 ▶ {my ($size) = @_; # Size as a variable
Subroutine allocateMemory: not called CC=2 SCAR=17.9
4040 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
4041 0 AllocateMemory($size);
4042 }
4043  
4044 #D2 Structured Programming with variables # Structured programming operations driven off variables.
4045  
4046 sub Nasm::X86::Variable::for($&) # Iterate a block a variable number of times.
4047 0 ▶ {my ($limit, $block) = @_; # Number of times, Block
Subroutine for: not called CC=2 SCAR=17.9
4048 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
4049 0 Comment "Variable::For $limit";
4050 0 my $index = V(q(index), 0); # The index that will be incremented
4051 0 my $start = Label;
4052 0 my $next = Label;
4053 0 my $end = Label;
4054 0 SetLabel $start; # Start of loop
4055  
4056 0 ▶ If $index >= $limit, sub {Jge $end}; # Condition
Subroutine __ANON__: not called CC=1 SCAR=6.9
4057  
4058 0 &$block($index, $start, $next, $end); # Execute block
4059  
4060 0 SetLabel $next; # Next iteration
4061 0 $index++; # Increment
4062 0 Jmp $start;
4063 0 SetLabel $end;
4064 }
4065  
4066 #D1 Operating system # Interacting with the operating system.
4067  
4068 #D2 Processes # Create and manage processes
4069  
4070 sub Fork() # Fork: create and execute a copy of the current process.
4071 0 ▶ {@_ == 0 or confess;
Subroutine Fork: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4072 0 Comment "Fork";
4073 0 Mov rax, 57;
4074 0 Syscall
4075 }
4076  
4077 sub GetPid() # Get process identifier.
4078 0 ▶ {@_ == 0 or confess;
Subroutine GetPid: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4079 0 Comment "Get Pid";
4080  
4081 0 Mov rax, 39;
4082 0 Syscall
4083 }
4084  
4085 sub GetPidInHex() # Get process identifier in hex as 8 zero terminated bytes in rax.
4086 0 ▶ {@_ == 0 or confess;
Subroutine GetPidInHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4087 0 Comment "Get Pid";
4088 0 my $hexTranslateTable = hexTranslateTable;
4089  
4090 my $s = Subroutine
4091 0 ▶ {SaveFirstFour;
Subroutine __ANON__: not called CC=2 SCAR=17.9
4092 0 Mov rax, 39; # Get pid
4093 0 Syscall;
4094 0 Mov rdx, rax; # Content to be printed
4095  
4096 0 ClearRegisters rax; # Save a trailing 00 on the stack
4097 0 Push ax;
4098 0 for my $i(reverse 5..7)
4099 0 {my $s = 8*$i;
4100 0 Mov rdi,rdx;
4101 0 Shl rdi,$s; # Push selected byte high
4102 0 Shr rdi,56; # Push select byte low
4103 0 Shl rdi,1; # Multiply by two because each entry in the translation table is two bytes long
4104 0 Mov ax, "[$hexTranslateTable+rdi]";
4105 0 Push ax;
4106 }
4107 0 Pop rax; # Get result from stack
4108 0 RestoreFirstFourExceptRax;
4109 0 } name => "GetPidInHex";
4110  
4111 0 $s->call;
4112 }
4113  
4114 sub GetPPid() # Get parent process identifier.
4115 0 ▶ {@_ == 0 or confess;
Subroutine GetPPid: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4116 0 Comment "Get Parent Pid";
4117  
4118 0 Mov rax, 110;
4119 0 Syscall
4120 }
4121  
4122 sub GetUid() # Get userid of current process.
4123 0 ▶ {@_ == 0 or confess;
Subroutine GetUid: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4124 0 Comment "Get User id";
4125  
4126 0 Mov rax, 102;
4127 0 Syscall
4128 }
4129  
4130 sub WaitPid() # Wait for the pid in rax to complete.
4131 0 ▶ {@_ == 0 or confess;
Subroutine WaitPid: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4132 0 Comment "WaitPid - wait for the pid in rax";
4133  
4134 my $s = Subroutine
4135 0 ▶ {SaveFirstSeven;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4136 0 Mov rdi,rax;
4137 0 Mov rax, 61;
4138 0 Mov rsi, 0;
4139 0 Mov rdx, 0;
4140 0 Mov r10, 0;
4141 0 Syscall;
4142 0 RestoreFirstSevenExceptRax;
4143 0 } name => "WaitPid";
4144  
4145 0 $s->call;
4146 }
4147  
4148 sub ReadTimeStampCounter() # Read the time stamp counter and return the time in nanoseconds in rax.
4149 0 ▶ {@_ == 0 or confess;
Subroutine ReadTimeStampCounter: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4150  
4151 my $s = Subroutine
4152 0 ▶ {Comment "Read Time-Stamp Counter";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4153 0 PushR rdx;
4154 0 ClearRegisters rax;
4155 0 Cpuid;
4156 0 Rdtsc;
4157 0 Shl rdx,32;
4158 0 Or rax,rdx;
4159 0 PopR;
4160 0 } name => "ReadTimeStampCounter";
4161  
4162 0 $s->call;
4163 }
4164  
4165 #D2 Memory # Allocate and print memory
4166  
4167 sub PrintMemoryInHex($) #P Dump memory from the address in rax for the length in rdi on the specified channel. As this method prints in blocks of 8 up to 7 bytes will be missing from the end unless the length is a multiple of 8 .
4168 0 ▶ {my ($channel) = @_; # Channel
Subroutine PrintMemoryInHex: not called CC=2 SCAR=17.9
Pod documented
4169 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
4170 0 Comment "Print out memory in hex on channel: $channel";
4171  
4172 my $s = Subroutine
4173 0 ▶ {my $size = RegisterSize rax;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4174 0 SaveFirstFour;
4175  
4176 0 Test rdi, 0x7; # Round the number of bytes to be printed
4177 IfNz
4178 Then # Round up
4179 0 ▶ {Add rdi, 8;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4180 0 };
4181 0 And rdi, 0x3f8; # Limit the number of bytes to be printed to 1024
4182  
4183 0 Mov rsi, rax; # Position in memory
4184 0 Lea rdi,"[rax+rdi-$size+1]"; # Upper limit of printing with an 8 byte register
4185 For # Print string in blocks
4186 0 ▶ {Mov rax, "[rsi]";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4187 0 Bswap rax;
4188 0 PrintRaxInHex($channel);
4189 0 Mov rdx, rsi;
4190 0 Add rdx, $size;
4191 0 Cmp rdx, rdi;
4192 IfLt
4193 Then
4194 0 ▶ {PrintString($channel, " ");
Subroutine __ANON__: not called CC=1 SCAR=6.9
4195 }
4196 0 } rsi, rdi, $size;
4197 0 RestoreFirstFour;
4198 0 } name=> "PrintOutMemoryInHexOnChannel$channel";
4199  
4200 0 $s->call;
4201 }
4202  
4203 sub PrintErrMemoryInHex #P Dump memory from the address in rax for the length in rdi on stderr.
4204 0 ▶ {@_ == 0 or confess "No parameters";
Subroutine PrintErrMemoryInHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("No parameters") 0 0 0
4205 0 PrintMemoryInHex($stderr);
4206 }
4207  
4208 sub PrintOutMemoryInHex # Dump memory from the address in rax for the length in rdi on stdout.
4209 0 ▶ {@_ == 0 or confess "No parameters";
Subroutine PrintOutMemoryInHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("No parameters") 0 0 0
4210 0 PrintMemoryInHex($stdout);
4211 }
4212  
4213 sub PrintErrMemoryInHexNL #P Dump memory from the address in rax for the length in rdi and then print a new line.
4214 0 ▶ {@_ == 0 or confess "No parameters";
Subroutine PrintErrMemoryInHexNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("No parameters") 0 0 0
4215 0 PrintMemoryInHex($stderr);
4216 0 PrintNL($stderr);
4217 }
4218  
4219 sub PrintOutMemoryInHexNL # Dump memory from the address in rax for the length in rdi and then print a new line.
4220 0 ▶ {@_ == 0 or confess "No parameters";
Subroutine PrintOutMemoryInHexNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("No parameters") 0 0 0
4221 0 PrintMemoryInHex($stdout);
4222 0 PrintNL($stdout);
4223 }
4224  
4225 sub PrintMemory_InHex($) #P Dump memory from the address in rax for the length in rdi on the specified channel. As this method prints in blocks of 8 up to 7 bytes will be missing from the end unless the length is a multiple of 8 .
4226 0 ▶ {my ($channel) = @_; # Channel
Subroutine PrintMemory_InHex: not called CC=2 SCAR=17.9
Pod documented
4227 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
4228 0 Comment "Print out memory in hex on channel: $channel";
4229  
4230 my $s = Subroutine
4231 0 ▶ {my $size = RegisterSize rax;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4232 0 SaveFirstFour;
4233  
4234 0 Test rdi, 0x7; # Round the number of bytes to be printed
4235 IfNz
4236 Then # Round up
4237 0 ▶ {Add rdi, 8;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4238 0 };
4239 0 And rdi, 0x3f8; # Limit the number of bytes to be printed to 1024
4240  
4241 0 Mov rsi, rax; # Position in memory
4242 0 Lea rdi,"[rax+rdi-$size+1]"; # Upper limit of printing with an 8 byte register
4243 For # Print string in blocks
4244 0 ▶ {Mov rax, "[rsi]";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4245 0 Bswap rax;
4246 0 PrintRax_InHex($channel);
4247 0 Mov rdx, rsi;
4248 0 Add rdx, $size;
4249 0 Cmp rdx, rdi;
4250 IfLt
4251 Then
4252 0 ▶ {PrintString($channel, " ");
Subroutine __ANON__: not called CC=1 SCAR=6.9
4253 }
4254 0 } rsi, rdi, $size;
4255 0 RestoreFirstFour;
4256 0 } name=> "PrintOutMemory_InHexOnChannel$channel";
4257  
4258 0 $s->call;
4259 }
4260  
4261 sub PrintErrMemory_InHex #P Dump memory from the address in rax for the length in rdi on stderr.
4262 0 ▶ {@_ == 0 or confess;
Subroutine PrintErrMemory_InHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4263 0 PrintMemory_InHex($stderr);
4264 }
4265  
4266 sub PrintOutMemory_InHex # Dump memory from the address in rax for the length in rdi on stdout.
4267 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutMemory_InHex: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4268 0 PrintMemory_InHex($stdout);
4269 }
4270  
4271 sub PrintErrMemory_InHexNL #P Dump memory from the address in rax for the length in rdi and then print a new line.
4272 0 ▶ {@_ == 0 or confess;
Subroutine PrintErrMemory_InHexNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4273 0 PrintMemory_InHex($stderr);
4274 0 PrintNL($stderr);
4275 }
4276  
4277 sub PrintOutMemory_InHexNL # Dump memory from the address in rax for the length in rdi and then print a new line.
4278 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutMemory_InHexNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4279 0 PrintMemory_InHex($stdout);
4280 0 PrintNL($stdout);
4281 }
4282  
4283 sub PrintMemory($) #P Print the memory addressed by rax for a length of rdi on the specified channel where channel can be a constant number or a register expression using a bound register.
4284 8 ▶ {my ($channel) = @_; # Channel
Subroutine PrintMemory: called CC=2 SCAR=6.9
Pod documented
4285 8 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 8 0 8
4286  
4287 8 SaveFirstFour;
4288 8 Mov rsi, rax;
4289 8 Mov rdx, rdi;
4290 8 Mov rax, 1; # Request
4291 8 Mov rdi, $channel; # Channel can be a constant or a register expression
4292 8 Syscall;
4293 8 RestoreFirstFour;
4294 }
4295  
4296 sub PrintMemoryNL #P Print the memory addressed by rax for a length of rdi on the specified channel followed by a new line.
4297 0 ▶ {my ($channel) = @_; # Channel
Subroutine PrintMemoryNL: not called CC=2 SCAR=17.9
Pod documented
4298 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
4299 0 PrintMemory($channel);
4300 0 PrintNL($channel);
4301 }
4302  
4303 sub PrintErrMemory #P Print the memory addressed by rax for a length of rdi on stderr.
4304 0 ▶ {@_ == 0 or confess;
Subroutine PrintErrMemory: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4305 0 PrintMemory($stdout);
4306 }
4307  
4308 sub PrintOutMemory # Print the memory addressed by rax for a length of rdi on stdout.
4309 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutMemory: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4310 0 PrintMemory($stdout);
4311 }
4312  
4313 sub PrintErrMemoryNL #P Print the memory addressed by rax for a length of rdi followed by a new line on stderr.
4314 0 ▶ {@_ == 0 or confess;
Subroutine PrintErrMemoryNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4315 0 PrintErrMemory;
4316 0 PrintErrNL;
4317 }
4318  
4319 sub PrintOutMemoryNL # Print the memory addressed by rax for a length of rdi followed by a new line on stdout.
4320 0 ▶ {@_ == 0 or confess;
Subroutine PrintOutMemoryNL: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4321 0 PrintOutMemory;
4322 0 PrintOutNL;
4323 }
4324  
4325 sub AllocateMemory($) # Allocate the variable specified amount of memory via mmap and return its address as a variable.
4326 0 ▶ {my ($size) = @_; # Size as a variable
Subroutine AllocateMemory: not called CC=2 SCAR=17.9
Pod documented
4327 0 ▶ @_ == 1 or confess "Size required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("Size required") 0 0 0
4328  
4329 my $s = Subroutine
4330 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=2 SCAR=17.9
4331 0 Comment "Allocate memory";
4332 0 SaveFirstSeven;
4333  
4334 0 my %d = getSystemConstantsFromIncludeFile "linux/mman.h", # Memory map constants
4335 qw(MAP_PRIVATE MAP_ANONYMOUS PROT_WRITE PROT_READ);
4336  
4337 0 my $pa = $d{MAP_PRIVATE} | $d{MAP_ANONYMOUS};
4338 0 my $wr = $d{PROT_WRITE} | $d{PROT_READ};
4339  
4340 0 Mov rax, 9; # Memory map
4341 0 $$p{size}->setReg(rsi); # Amount of memory
4342 0 Xor rdi, rdi; # Anywhere
4343 0 Mov rdx, $wr; # Read write protections
4344 0 Mov r10, $pa; # Private and anonymous map
4345 0 Mov r8, -1; # File descriptor for file backing memory if any
4346 0 Mov r9, 0; # Offset into file
4347 0 Syscall;
4348 0 ▶ if ($DebugMode)
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
4349 0 {Cmp rax, -1; # Check return code
4350 IfEq
4351 Then
4352 0 ▶ {PrintErrTraceBack "Cannot allocate memory, return code -1";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4353 0 };
4354 0 Cmp eax, 0xffffffea; # Check return code
4355 IfEq
4356 Then
4357 0 ▶ {PrintErrTraceBack "Cannot allocate memory, return code 0xffffffea";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4358 0 };
4359 0 Cmp rax, -12; # Check return code
4360 IfEq
4361 Then
4362 0 ▶ {PrintErrTraceBack "Cannot allocate memory, return code -12";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4363 0 };
4364 }
4365 0 $$p{address}->getReg(rax); # Amount of memory
4366 0 RestoreFirstSeven;
4367 0 } parameters=>[qw(address size)], name => 'AllocateMemory';
4368  
4369 0 $s->call(parameters=>{size=>$size, address => my $address = V address => 0});
4370  
4371 0 $address;
4372 }
4373  
4374 sub FreeMemory($$) # Free memory specified by variables.
4375 0 ▶ {my ($address, $size) = @_; # Variable address of memory, variable size of memory
Subroutine FreeMemory: not called CC=2 SCAR=17.9
Pod documented
4376 0 ▶ @_ == 2 or confess "Address, size to free";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Address, size to free") 0 0 0
4377  
4378 my $s = Subroutine
4379 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
4380 0 SaveFirstFour;
4381 0 Mov rax, 11; # Munmap
4382 0 $$p{address}->setReg(rdi); # Address
4383 0 $$p{size} ->setReg(rsi); # Length
4384 0 Syscall;
4385 0 RestoreFirstFour;
4386 0 } parameters=>[qw(size address)], name=> 'FreeMemory';
4387  
4388 0 $s->call(parameters => {address=>$address, size=>$size});
4389 }
4390  
4391 sub ClearMemory($$) # Clear memory with a variable address and variable length.
4392 0 ▶ {my ($address, $size) = @_; # Address of memory as a variable, size of memory as a variable
Subroutine ClearMemory: not called CC=2 SCAR=17.9
Pod documented
4393 0 ▶ @_ == 2 or confess "address, size required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("address, size required") 0 0 0
4394 0 Comment "Clear memory";
4395  
4396 my $s = Subroutine
4397 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
4398 0 PushR zmm0; PushR rax, rdi, rsi, rdx; # Reliance on push order which no longer matches the order of the arguments
4399 0 $$p{address}->setReg(rax);
4400 0 $$p{size} ->setReg(rdi);
4401 0 Lea rdx, "[rax+rdi]"; # Address of upper limit of buffer
4402  
4403 0 ClearRegisters zmm0; # Clear the register that will be written into memory
4404  
4405 0 Mov rsi, rdi; # Modulus the size of zmm
4406 0 And rsi, 0x3f; # Remainder modulo 64
4407 0 Cmp rsi, 0; # Test remainder
4408 IfNz sub # Need to align so that the rest of the clear can be done in full zmm blocks
4409 0 ▶ {PushR 7;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4410 0 V(align => rsi)->setMaskFirst(k7); # Set mask bits
4411 0 Vmovdqu8 "[rax]{k7}", zmm0; # Masked move to memory
4412 0 PopR;
4413 0 Add rax, rsi; # Update point to clear from
4414 0 Sub rdi, rsi; # Reduce clear length
4415 0 };
4416  
4417 For # Clear remaining memory in full zmm blocks
4418 0 ▶ {Vmovdqu64 "[rax]", zmm0;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4419 0 } rax, rdx, RegisterSize zmm0;
4420  
4421 0 PopR; PopR;
4422 0 } parameters=>[qw(size address)], name => 'ClearMemory';
4423  
4424 0 $s->call(parameters => {address => $address, size => $size});
4425 }
4426  
4427 sub CopyMemory($$$) # Copy memory.
4428 0 ▶ {my ($source, $target, $size) = @_; # Source address variable, target address variable, length variable
Subroutine CopyMemory: not called CC=2 SCAR=17.9
Pod documented
4429 0 ▶ @_ == 3 or confess "Source, target, size required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Source, target, size required") 0 0 0
4430  
4431 0 SaveFirstSeven;
4432 0 $source->setReg(rsi); # Source location
4433 0 $target->setReg(rax); # Target location
4434 0 $size ->setReg(rdi); # Size of area to copy
4435 0 ClearRegisters rdx;
4436 For # Clear memory
4437 0 ▶ {Mov "r8b", "[rsi+rdx]";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4438 0 Mov "[rax+rdx]", "r8b";
4439 0 } rdx, rdi, 1;
4440 0 RestoreFirstSeven;
4441 }
4442  
4443 sub CopyMemory64($$$) # Copy memory in 64 byte blocks.
4444 0 ▶ {my ($source, $target, $size) = @_; # Source address variable, target address variable, number of 64 byte blocks to move
Subroutine CopyMemory64: not called CC=2 SCAR=17.9
Pod documented
4445 0 ▶ @_ == 3 or confess "Source, target, size required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Source, target, size required") 0 0 0
4446  
4447 0 PushR my $s = r8, my $t = r9, my $z = r10, my $c = r11, 31;
4448  
4449 0 $source->setReg($s); # Source location
4450 0 $target->setReg($t); # Target location
4451 0 $size ->setReg($c); # Size of area to copy
4452 0 my $end = Label; # End of move loop
4453 0 Cmp $c, 0;
4454 0 Je $end; # Nothing to move
4455 0 my $start = SetLabel; # Move loop
4456 0 Vmovdqu64 zmm31, "[$s]";
4457 0 Vmovdqu64 "[$t]", zmm31;
4458 0 Add $s, 64;
4459 0 Add $t, 64;
4460 0 Sub $c, 1;
4461 0 Jnz $start;
4462 0 SetLabel $end;
4463 0 PopR;
4464 }
4465  
4466 sub CopyMemory4K($$$) #P Copy memory in 4K byte blocks.
4467 0 ▶ {my ($source, $target, $size) = @_; # Source address variable, target address variable, number of 4K byte blocks to move
Subroutine CopyMemory4K: not called CC=6 SCAR=37.4
Pod documented
4468 0 ▶ @_ == 3 or confess "Source, target, size required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Source, target, size required") 0 0 0
4469  
4470 0 PushR my $s = r8, my $t = r9, my $z = r10, my $c = r11, zmm(0..31);
4471 0 my $k2 = 2 ** 11; # Half of 4K == the bytes we can shift in one go using all zmm registers
4472 0 $size ->setReg($c); # Size of area to copy
4473 0 my $end = Label; # End of move loop
4474 0 Cmp $c, 0;
4475 0 Je $end; # Nothing to move
4476  
4477 0 $source->setReg($s); # Source location
4478 0 $target->setReg($t); # Target location
4479 0 ClearRegisters $z; # Offset into move
4480  
4481 0 my $start = SetLabel; # Move loop
4482 0 Vmovdqu64 "zmm$_", "[$s+$z+64*$_]" for 0..31; # Load 2K
4483 0 Vmovdqu64 "[$t+$z+64*$_]", "zmm$_" for 0..31; # Store 2k
4484 0 Vmovdqu64 "zmm$_", "[$s+$z+64*$_+$k2]" for 0..31; # Load next 2k
4485 0 Vmovdqu64 "[$t+$z+64*$_+$k2]", "zmm$_" for 0..31; # Store next 2k
4486 0 Add $z, $k2 * 2; # Next move offset
4487 0 Sub $c, 1; # Decrement loop counter
4488 0 Jnz $start; # Continue unless we are finished
4489 0 SetLabel $end;
4490 0 PopR;
4491 }
4492  
4493 #D2 Files # Interact with the operating system via files.
4494  
4495 sub OpenRead() # Open a file, whose name is addressed by rax, for read and return the file descriptor in rax.
4496 0 ▶ {@_ == 0 or confess "Zero parameters";
Subroutine OpenRead: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("Zero parameters") 0 0 0
4497  
4498 my $s = Subroutine
4499 0 ▶ {my %s = getSystemConstantsFromIncludeFile "fcntl.h", qw(O_RDONLY); # Constants for reading a file
Subroutine __ANON__: not called CC=1 SCAR=6.9
4500  
4501 0 SaveFirstFour;
4502 0 Mov rdi,rax;
4503 0 Mov rax,2;
4504 0 Mov rsi, $s{O_RDONLY};
4505 0 Xor rdx,rdx;
4506 0 Syscall;
4507 0 RestoreFirstFourExceptRax;
4508 0 } name=> "OpenRead";
4509  
4510 0 $s->call;
4511 }
4512  
4513 sub OpenWrite() # Create the file named by the terminated string addressed by rax for write. The file handle will be returned in rax.
4514 0 ▶ {@_ == 0 or confess "Zero parameters";
Subroutine OpenWrite: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("Zero parameters") 0 0 0
4515  
4516 my $s = Subroutine
4517 0 ▶ {my %s = getSystemConstantsFromIncludeFile "fcntl.h", qw(O_CREAT O_WRONLY); # Constants for creating a file
Subroutine __ANON__: not called CC=1 SCAR=6.9
4518 0 my $w = $s{O_WRONLY} | $s{O_CREAT};
4519  
4520 0 SaveFirstFour;
4521 0 Mov rdi, rax;
4522 0 Mov rax, 2;
4523 0 Mov rsi, $w;
4524 0 Mov rdx, 0x1c0; # Permissions: u=rwx 1o=x 4o=r 8g=x 10g=w 20g=r 40u=x 80u=r 100u=r 200=T 400g=S 800u=S #0,2,1000, nothing
4525 0 Syscall;
4526  
4527 0 RestoreFirstFourExceptRax;
4528 0 } name=> "OpenWrite";
4529  
4530 0 $s->call;
4531 }
4532  
4533 sub CloseFile() # Close the file whose descriptor is in rax.
4534 0 ▶ {@_ == 0 or confess "Zero parameters";
Subroutine CloseFile: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("Zero parameters") 0 0 0
4535  
4536 my $s = Subroutine
4537 0 ▶ {Comment "Close a file";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4538 0 SaveFirstFour;
4539 0 Mov rdi, rax;
4540 0 Mov rax, 3;
4541 0 Syscall;
4542 0 RestoreFirstFourExceptRax;
4543 0 } name=> "CloseFile";
4544  
4545 0 $s->call;
4546 }
4547  
4548 sub StatSize() # Stat a file whose name is addressed by rax to get its size in rax.
4549 0 ▶ {@_ == 0 or confess "Zero parameters";
Subroutine StatSize: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("Zero parameters") 0 0 0
4550  
4551 0 my ($F, $S) = (q(sys/stat.h), q(struct stat)); # Get location of struct stat.st_size field
4552 0 my $Size = getStructureSizeFromIncludeFile $F, $S;
4553 0 my $off = getFieldOffsetInStructureFromIncludeFile $F, $S, q(st_size);
4554  
4555 my $s = Subroutine
4556 0 ▶ {Comment "Stat a file for size";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4557 0 SaveFirstFour;
4558 0 Mov rdi, rax; # File name
4559 0 Mov rax,4;
4560 0 Lea rsi, "[rsp-$Size]";
4561 0 Syscall;
4562 0 Mov rax, "[$off+rsp-$Size]"; # Place size in rax
4563 0 RestoreFirstFourExceptRax;
4564 0 } name=> "StatSize";
4565  
4566 0 $s->call;
4567 }
4568  
4569 sub ReadChar() # Read a character from stdin and return it in rax else return -1 in rax if no character was read.
4570 0 ▶ {@_ == 0 or confess "Zero parameters";
Subroutine ReadChar: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("Zero parameters") 0 0 0
4571 my $s = Subroutine
4572 0 ▶ {my ($p) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4573 0 SaveFirstFour; # Generated code
4574  
4575 0 Mov rax, 0; # Read
4576 0 Mov rdi, 0; # Stdin
4577 0 Lea rsi, "[rsp-8]"; # Make space on stack
4578 0 Mov rdx, 1; # One character
4579 0 Syscall;
4580  
4581 0 Cmp rax, 1;
4582 IfEq
4583 Then
4584 0 ▶ {Mov al, "[rsp-8]";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4585 },
4586 Else
4587 0 ▶ {Mov rax, -1;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4588 0 };
4589  
4590 0 RestoreFirstFourExceptRax;
4591 0 } name => 'ReadChar';
4592  
4593 0 $s->call
4594 }
4595  
4596 sub ReadLine() # Reads up to 8 characters followed by a terminating return and place them into rax.
4597 0 ▶ {@_ == 0 or confess "Zero parameters";
Subroutine ReadLine: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("Zero parameters") 0 0 0
4598 my $s = Subroutine
4599 0 ▶ {my ($p) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4600 0 PushR rcx, 14, 15;
4601 0 ClearRegisters rax, rcx, r14, r15;
4602  
4603 (V max => RegisterSize(rax))->for(sub # Read each character
4604 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4605  
4606 0 ReadChar;
4607 0 Cmp rax, 0xf0; # Too high
4608 0 ▶ IfGe Then {Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
4609 0 Cmp rax, 0xa; # Too low
4610 0 ▶ IfLe Then {Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
4611 0 $index->setReg(rcx);
4612 0 Shl rcx, 3;
4613 0 Shl rax, cl; # Move into position
4614 0 Or r15, rax;
4615 0 Add rcx, $bitsInByte;
4616 0 });
4617  
4618 0 Mov rax, r15; # Return result in rax
4619 0 PopR;
4620 0 } name => 'ReadLine';
4621  
4622 0 $s->call
4623 }
4624  
4625 sub ReadInteger() # Reads an integer in decimal and returns it in rax.
4626 0 ▶ {@_ == 0 or confess "Zero parameters";
Subroutine ReadInteger: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("Zero parameters") 0 0 0
4627 my $s = Subroutine
4628 0 ▶ {my ($p) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4629 0 PushR 15;
4630 0 ClearRegisters rax, r15;
4631  
4632 (V max => RegisterSize(rax))->for(sub # Read each character
4633 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4634  
4635 0 ReadChar;
4636 0 Cmp rax, 0x3A; # Too high
4637 0 ▶ IfGe Then {Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
4638 0 Cmp rax, 0x29; # Too low
4639 0 ▶ IfLe Then {Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
4640 0 Imul r15, 10; # Move into position
4641 0 Sub rax, 0x30;
4642 0 Add r15, rax;
4643 0 });
4644  
4645 0 Mov rax, r15; # Return result in rax
4646 0 PopR;
4647 0 } name => 'ReadInteger';
4648  
4649 0 $s->call
4650 }
4651  
4652 sub ReadFile($) # Read a file into memory.
4653 0 ▶ {my ($File) = @_; # Variable addressing a zero terminated string naming the file to be read in by mapping it
Subroutine ReadFile: not called CC=3 SCAR=24.8
Pod documented
4654 0 ▶ @_ == 1 or confess "One parameter required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter required") 0 0 0
4655  
4656 my $s = Subroutine
4657 0 ▶ {my ($p) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4658 0 Comment "Read a file into memory";
4659 0 SaveFirstSeven; # Generated code
4660 0 my $size = V(size => undef);
4661 0 my $fdes = V(fdes => undef);
4662  
4663 0 $$p{file}->setReg(rax); # File name
4664  
4665 0 StatSize; # File size
4666 0 $size->getReg(rax); # Save file size
4667  
4668 0 $$p{file}->setReg(rax); # File name
4669 0 OpenRead; # Open file for read
4670 0 $fdes->getReg(rax); # Save file descriptor
4671  
4672 0 my %d = getSystemConstantsFromIncludeFile # Memory map constants
4673 "linux/mman.h", qw(MAP_PRIVATE PROT_READ PROT_EXEC);
4674 0 my $pa = $d{MAP_PRIVATE};
4675 0 my $ro = $d{PROT_READ};
4676 0 my $ex = $d{PROT_EXEC};
4677  
4678 0 Mov rax, 9; # Memory map
4679 0 $size->setReg(rsi); # Amount of memory
4680 0 Xor rdi, rdi; # Anywhere
4681 0 Mov rdx, $ro | $ex; # Read/execute contents
4682 0 Mov r10, $pa; # Private and anonymous map
4683 0 $fdes->setReg(r8); # File descriptor for file backing memory
4684 0 Mov r9, 0; # Offset into file
4685 0 Syscall;
4686 0 $size ->setReg(rdi);
4687 0 $$p{address}->getReg(rax);
4688 0 $$p{size} ->getReg(rdi);
4689 0 RestoreFirstSeven;
4690 0 } parameters=>[qw(file address size)], name => 'ReadFile';
4691  
4692 0 ▶ my $file = ref($File) ? $File : V file => Rs $File;
Branch: 1 branch
BranchTrueFalseTotal
ref $File ? : 0 0 0
4693 0 my $size = V(size => undef);
4694 0 my $address = V(address => undef);
4695 0 $s->call(parameters=>{file => $file, size=>$size, address=>$address});
4696  
4697 0 ($address, $size) # Return address and size of mapped file
4698 }
4699  
4700 sub executeFileViaBash($) # Execute the file named in a variable.
4701 0 ▶ {my ($file) = @_; # File variable
Subroutine executeFileViaBash: not called CC=2 SCAR=17.9
Pod documented
4702 0 ▶ @_ == 1 or confess "File required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("File required") 0 0 0
4703  
4704 my $s = Subroutine
4705 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
4706 0 SaveFirstFour;
4707 0 Fork; # Fork
4708  
4709 0 Test rax, rax;
4710  
4711 IfNz # Parent
4712 Then
4713 0 ▶ {WaitPid;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4714 },
4715 Else # Child
4716 0 ▶ {$$p{file}->setReg(rdi);
Subroutine __ANON__: not called CC=1 SCAR=6.9
4717 0 Mov rsi, 0;
4718 0 Mov rdx, 0;
4719 0 Mov rax, 59;
4720 0 Syscall;
4721 0 };
4722 0 RestoreFirstFour;
4723 0 } parameters=>[qw(file)], name => 'executeFileViaBash';
4724  
4725 0 $s->call(parameters=>{file => $file});
4726 }
4727  
4728 sub unlinkFile($) # Unlink the named file.
4729 0 ▶ {my ($file) = @_; # File variable
Subroutine unlinkFile: not called CC=2 SCAR=17.9
Pod documented
4730 0 ▶ @_ == 1 or confess "File required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("File required") 0 0 0
4731  
4732 my $s = Subroutine
4733 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
4734 0 SaveFirstFour;
4735 0 $$p{file}->setReg(rdi);
4736 0 Mov rax, 87;
4737 0 Syscall;
4738 0 RestoreFirstFour;
4739 0 } parameters=>[qw(file)], name => 'unlinkFile';
4740  
4741 0 $s->call(parameters=>{file => $file});
4742 }
4743  
4744 #D1 Hash functions # Hash functions
4745  
4746 sub Hash() # Hash a string addressed by rax with length held in rdi and return the hash code in r15.
4747 0 ▶ {@_ == 0 or confess;
Subroutine Hash: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess() 0 0 0
4748  
4749 my $s = Subroutine # Read file
4750 0 ▶ {Comment "Hash";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4751  
4752 0 PushR rax, rdi, k1, zmm0, zmm1; # Save registers
4753 0 PushR 15; # Return register
4754 0 Vpbroadcastq zmm0, rdi; # Broadcast length through ymm0
4755 0 Vcvtuqq2pd zmm0, zmm0; # Convert to lengths to float
4756 0 Vgetmantps zmm0, zmm0, 4; # Normalize to 1 to 2, see: https://hjlebbink.github.io/x86doc/html/VGETMANTPD.html
4757  
4758 0 Add rdi, rax; # Upper limit of string
4759  
4760 ForIn # Hash in ymm0 sized blocks
4761 0 ▶ {Vmovdqu ymm1, "[rax]"; # Load data to hash
Subroutine __ANON__: not called CC=1 SCAR=6.9
4762 0 Vcvtudq2pd zmm1, ymm1; # Convert to float
4763 0 Vgetmantps zmm0, zmm0, 4; # Normalize to 1 to 2, see: https://hjlebbink.github.io/x86doc/html/VGETMANTPD.html
4764  
4765 0 Vmulpd zmm0, zmm1, zmm0; # Multiply current hash by data
4766 }
4767 sub # Remainder in partial block
4768 0 ▶ {Mov r15, -1;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4769 0 Bzhi r15, r15, rdi; # Clear bits that we do not wish to load
4770 0 Kmovq k1, r15; # Take up mask
4771 0 Vmovdqu8 "ymm1{k1}", "[rax]"; # Load data to hash
4772  
4773 0 Vcvtudq2pd zmm1, ymm1; # Convert to float
4774 0 Vgetmantps zmm0, zmm0, 4; # Normalize to 1 to 2, see: https://hjlebbink.github.io/x86doc/html/VGETMANTPD.html
4775  
4776 0 Vmulpd zmm0, zmm1, zmm0; # Multiply current hash by data
4777 0 }, rax, rdi, RegisterSize ymm0;
4778  
4779 0 Vgetmantps zmm0, zmm0, 4; # Normalize to 1 to 2, see: https://hjlebbink.github.io/x86doc/html/VGETMANTPD.html
4780  
4781 0 Mov r15, 0b11110000; # Top 4 to bottom 4
4782 0 Kmovq k1, r15;
4783 0 Vpcompressq "zmm1{k1}", zmm0;
4784 0 Vaddpd ymm0, ymm0, ymm1; # Top 4 plus bottom 4
4785  
4786 0 Mov r15, 0b1100; # Top 2 to bottom 2
4787 0 Kmovq k1, r15;
4788 0 Vpcompressq "ymm1{k1}", ymm0;
4789 0 Vaddpd xmm0, xmm0, xmm1; # Top 2 plus bottom 2
4790  
4791 0 Pslldq xmm0, 2; # Move centers into double words
4792 0 Psrldq xmm0, 4;
4793 0 Mov r15, 0b0101; # Centers to lower quad
4794 0 Kmovq k1, r15;
4795 0 Vpcompressd "xmm0{k1}", xmm0; # Compress to lower quad
4796 0 PopR r15;
4797  
4798 0 Vmovq r15, xmm0; # Result in r15
4799  
4800 0 PopR;
4801 0 } name=> "Hash";
4802  
4803 0 $s->call;
4804 }
4805  
4806 #D1 Unicode # Convert between utf8 and utf32
4807  
4808 sub convert_rax_from_utf32_to_utf8 #P Convert a utf32 character held in rax to a utf8 character held in rax.
4809 0 ▶ {@_ and confess "Zero parameters";
Subroutine convert_rax_from_utf32_to_utf8: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ and confess("Zero parameters") 0 0 0
4810  
4811 my $s = Subroutine
4812 0 ▶ {PushR 14, 15;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4813 Block
4814 0 ▶ {my ($success) = @_; # As shown at: https://en.wikipedia.org/wiki/UTF-8
Subroutine __ANON__: not called CC=1 SCAR=6.9
4815 0 Cmp rax, 0x7f; # Ascii
4816 0 ▶ IfLe Then {Jmp $success};
Subroutine __ANON__: not called CC=1 SCAR=6.9
4817  
4818 0 Cmp rax, 0x7ff; # Char size is: 2 bytes
4819 IfLe
4820 Then
4821 0 ▶ {Mov r15, rax;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4822  
4823 0 Shr r15, 6; # High byte
4824 0 And r15, 0x1f;
4825 0 Or r15, 0xc0;
4826  
4827 0 Mov r14, rax; # Low byte
4828 0 And r14, 0x3f;
4829 0 Or r14, 0x80;
4830 0 Shl r14, 8;
4831 0 Or r15, r14;
4832 0 Mov rax, r15;
4833 0 Jmp $success;
4834 0 };
4835  
4836 0 Cmp rax, 0xffff; # Char size is: 3 bytes
4837 IfLe
4838 Then
4839 0 ▶ {Mov r15, rax;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4840  
4841 0 Shr r15, 12; # High byte
4842 0 And r15, 0x0f;
4843 0 Or r15, 0xe0;
4844  
4845 0 Mov r14, rax; # Middle byte
4846 0 Shr r14, 6;
4847 0 And r14, 0x3f;
4848 0 Or r14, 0x80;
4849 0 Shl r14, 8;
4850 0 Or r15, r14;
4851  
4852 0 Mov r14, rax; # Low byte
4853 0 And r14, 0x3f;
4854 0 Or r14, 0x80;
4855 0 Shl r14, 16;
4856 0 Or r15, r14;
4857  
4858 0 Mov rax, r15;
4859 0 Jmp $success;
4860 0 };
4861  
4862 0 Cmp rax, 0x10ffff; # Char size is: 4 bytes
4863 IfLe
4864 Then
4865 0 ▶ {Mov r15, rax;
Subroutine __ANON__: not called CC=1 SCAR=6.9
4866  
4867 0 Shr r15, 18; # High byte
4868 0 And r15, 0x03;
4869 0 Or r15, 0xf0;
4870  
4871 0 Mov r14, rax; # Middle byte
4872 0 Shr r14, 12;
4873 0 And r14, 0x3f;
4874 0 Or r14, 0x80;
4875 0 Shl r14, 8;
4876 0 Or r15, r14;
4877  
4878 0 Mov r14, rax; # Middle byte
4879 0 Shr r14, 6;
4880 0 And r14, 0x3f;
4881 0 Or r14, 0x80;
4882 0 Shl r14, 16;
4883 0 Or r15, r14;
4884  
4885 0 Mov r14, rax; # Low byte
4886 0 And r14, 0x3f;
4887 0 Or r14, 0x80;
4888 0 Shl r14, 24;
4889 0 Or r15, r14;
4890 0 Mov rax, r15;
4891 0 Jmp $success;
4892 0 };
4893 0 };
4894  
4895 0 PopR;
4896 0 } name => 'convert_rax_from_utf32_to_utf8';
4897  
4898 0 $s->call;
4899 } # convert_rax_from_utf32_to_utf8
4900  
4901 sub GetNextUtf8CharAsUtf32($) # Get the next UTF-8 encoded character from the addressed memory and return it as a UTF-32 character as a variable along with the size of the input character and a variable indicating the success - 1 - or failure - 0 - of the operation.
4902 0 ▶ {my ($in) = @_; # Address of utf8 character as a variable
Subroutine GetNextUtf8CharAsUtf32: not called CC=2 SCAR=17.9
Pod documented
4903 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
4904  
4905 my $s = Subroutine
4906 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
4907  
4908 0 $$p{fail}->copy(0); # Clear failure indicator
4909 0 $$p{in}->setReg(rbx); # Character to convert
4910 0 ClearRegisters rdx; # Move to byte register below does not clear the entire register
4911 0 Mov dl, "[rbx]";
4912 Block
4913 0 ▶ {my ($success) = @_; # As shown at: https://en.wikipedia.org/wiki/UTF-8
Subroutine __ANON__: not called CC=1 SCAR=6.9
4914  
4915 0 Cmp rdx, 0x7f; # Ascii
4916 IfLe
4917 Then
4918 0 ▶ {$$p{out}->getReg(rdx);
Subroutine __ANON__: not called CC=1 SCAR=6.9
4919 0 $$p{size}->copy(1);
4920 0 Jmp $success;
4921 0 };
4922  
4923 0 Cmp rdx, 0xdf; # Char size is: 2 bytes
4924 IfLe
4925 Then
4926 0 ▶ {Mov dil, "[rbx+1]";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4927 0 And rdi, 0x3f;
4928 0 And rdx, 0x1f;
4929 0 Shl rdx, 6;
4930 0 Or rdx, rdi;
4931 0 $$p{out}->getReg(rdx);
4932 0 $$p{size}->copy(2);
4933 0 Jmp $success;
4934 0 };
4935  
4936 0 Cmp rdx, 0xef; # Char size is: 3 bytes
4937 IfLe
4938 Then
4939 0 ▶ {Mov sil, "[rbx+2]";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4940 0 And rsi, 0x3f;
4941 0 Mov dil, "[rbx+1]";
4942 0 And rdi, 0x3f;
4943 0 And rdx, 0x0f;
4944 0 Shl rdi, 6;
4945 0 Shl rdx, 12;
4946 0 Or rdx, rdi;
4947 0 Or rdx, rsi;
4948 0 $$p{out}->getReg(rdx);
4949 0 $$p{size}->copy(3);
4950 0 Jmp $success;
4951 0 };
4952  
4953 0 Cmp rdx, 0xf7; # Char size is: 4 bytes
4954 IfLe
4955 Then
4956 0 ▶ {Mov r11b, "[rbx+3]";
Subroutine __ANON__: not called CC=1 SCAR=6.9
4957 0 And r11, 0x3f;
4958 0 Mov sil, "[rbx+2]";
4959 0 And rsi, 0x3f;
4960 0 Mov dil, "[rbx+1]";
4961 0 And rdi, 0x3f;
4962 0 And rdx, 0x07;
4963 0 Shl rsi, 6;
4964 0 Shl rdi, 12;
4965 0 Shl rdx, 18;
4966 0 Or rdx, rdi;
4967 0 Or rdx, rsi;
4968 0 Or rdx, r11;
4969 0 $$p{out}->getReg(rdx);
4970 0 $$p{size}->copy(4);
4971 0 Jmp $success;
4972 0 };
4973  
4974 0 $$p{fail}->copy(1); # Conversion failed
4975 0 };
4976  
4977 0 } parameters=>[qw(in out size fail)], name => 'GetNextUtf8CharAsUtf32';
4978  
4979 0 my $out = V(out => 0); # Utf32 equivalent
4980 0 my $size = V(size => 0); # Size of utf8 converted
4981 0 my $fail = V(fail => 0); # Failed if true else false
4982  
4983 0 $s->inline(parameters=>{in=>$in, out=>$out, size=>$size, fail=>$fail});
4984  
4985 0 ($out, $size, $fail) # Output character variable, output size of input, output error if any
4986 } # GetNextUtf8CharAsUtf32
4987  
4988 sub ConvertUtf8ToUtf32($$) # Convert an allocated string of utf8 to an allocated string of utf32 and return its address and length.
4989 0 ▶ {my ($a8, $s8) = @_; # Utf8 string address variable, utf8 length variable
Subroutine ConvertUtf8ToUtf32: not called CC=2 SCAR=17.9
Pod documented
4990 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
4991  
4992 my $s = Subroutine
4993 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
4994 0 PushR 10, 11, 12, 13, 14, 15;
4995  
4996 0 my $a8 = $$p{a8}; # Address of utf8
4997 0 my $s8 = $$p{s8}; # Length of utf8 in bytes
4998 0 my $size = $$p{s8} * RegisterSize(eax); # Maximum possible length of corresponding utf32
4999 0 my $address = AllocateMemory $size; # Allocate a buffer for utf32
5000 0 $$p{a32}->copy($address); # Address of allocation
5001 0 $$p{s32}->copy($size); # Size of allocation
5002  
5003 0 $a8 ->setReg(14); # Current position in input string
5004 0 ($a8+$s8)->setReg(15); # Upper limit of input string
5005 0 $address->setReg(13); # Current position in output string
5006 0 ClearRegisters 12; # Number of characters in output string
5007  
5008 $s8->for(sub # Loop through input string converting each utf8 sequence to utf32
5009 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
5010 0 my ($out, $size, $fail) = GetNextUtf8CharAsUtf32 V(in => r14); # Get next utf-8 character and convert it to utf32
5011 If $fail > 0,
5012 Then
5013 0 ▶ {$$p{fail}->copy($fail);
Subroutine __ANON__: not called CC=1 SCAR=6.9
5014 0 Jmp $end;
5015 0 };
5016  
5017 0 Inc r12; # Count characters converted
5018 0 $out->setReg(r11); # Output character
5019  
5020 0 Mov "[r13]", r11d;
5021 0 Add r13, RegisterSize eax; # Move up 32 bits output string
5022 0 $size->setReg(r10); # Decoded this many bytes
5023 0 Add r14, r10; # Move up in input string
5024 0 Cmp r14, r15;
5025 0 Jge $end; # Exhausted input string
5026 0 });
5027  
5028 0 $$p{count}->getReg(r12); # Number of unicode points converted from utf8 to utf32
5029 0 PopR;
5030 0 } parameters=>[qw(a8 s8 a32 s32 count fail)], name => 'ConvertUtf8ToUtf32';
5031  
5032 0 my $a32 = V(a32 => 0);
5033 0 my $s32 = V(s32 => 0);
5034 0 my $count = V(count => 0);
5035 0 my $fail = V(fail => 0); # Assume we will succeed
5036  
5037 0 $s->call(parameters=>
5038 {a8 => $a8, s8 => $s8,
5039 a32 => $a32, s32 => $s32, count=>$count, fail => $fail});
5040  
5041 0 ($a32, $s32, $count, $fail) # Utf32 string address as a variable, utf32 area length as a variable, number of characters converted, fail if one else zero
5042 } # ConvertUtf8ToUtf32
5043  
5044 #D1 C Strings # C strings are a series of bytes terminated by a zero byte.
5045  
5046 sub Cstrlen() #P Length of the C style string addressed by rax returning the length in r15.
5047 0 ▶ {@_ == 0 or confess "Deprecated in favor of StringLength";
Subroutine Cstrlen: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 0 or confess("Deprecated in favor of StringLength") 0 0 0
5048  
5049 my $s = Subroutine # Create area
5050 0 ▶ {PushR rax, rdi, rcx;
Subroutine __ANON__: not called CC=1 SCAR=6.9
5051 0 Mov rdi, rax;
5052 0 Mov rcx, -1;
5053 0 ClearRegisters rax;
5054 0 push @text, <<END;
5055 repne scasb
5056 END
5057 0 Mov r15, rcx;
5058 0 Not r15;
5059 0 Dec r15;
5060 0 PopR;
5061 0 } name => "Cstrlen";
5062  
5063 0 $s->call;
5064 }
5065  
5066 sub StringLength($) # Length of a zero terminated string.
5067 0 ▶ {my ($string) = @_; # String
Subroutine StringLength: not called CC=2 SCAR=17.9
Pod documented
5068 0 ▶ @_ == 1 or confess "One parameter: zero terminated string";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter: zero terminated string") 0 0 0
5069  
5070 my $s = Subroutine
5071 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
5072 0 PushR rax, rdi, rcx;
5073 0 $$p{string}->setReg(rax); # Address string
5074 0 Mov rdi, rax;
5075 0 Mov rcx, -1;
5076 0 ClearRegisters rax;
5077 0 push @text, <<END;
5078 repne scasb
5079 END
5080 0 Not rcx;
5081 0 Dec rcx;
5082 0 $$p{size}->getReg(rcx); # Save length
5083 0 PopR;
5084 0 } parameters => [qw(string size)], name => 'StringLength';
5085  
5086 0 $s->call(parameters=>{string=>$string, size => my $z = V size => 0}); # Variable that holds the length of the string
5087  
5088 0 $z
5089 }
5090  
5091 #D1 Areas # An area is single extensible block of memory which contains other data structures such as strings, arrays, trees within it.
5092  
5093 #D2 Constructors # Construct an area either in memory or by reading it from a file or by incorporating it into an assembly.
5094  
5095 sub DescribeArea(%) #P Describe a relocatable area. By describing an areas, we allocate space with which to describe it in the current stack frame but we do not allocate memory for the area itself in the heap.
5096 0 ▶ {my (%options) = @_; # Optional variable addressing the start of the area
Subroutine DescribeArea: not called CC=5 SCAR=34.0
Pod documented
5097 0 ▶ my $address = delete $options{address} // 0; # Address of area
Condition0%0/2
delete $options{"address"} // 0
l!l
00
MC/DC0%0/1
delete $options{"address"} // 0
delete $options{"address"}
Truth table0%0/2
A
A= delete $options{"address"}
Aresult
11
00
5098 0 ▶ my $stack = delete $options{stack} // 0; # Mark this area as being used as a stack
Condition0%0/2
delete $options{"stack"} // 0
l!l
00
MC/DC0%0/1
delete $options{"stack"} // 0
delete $options{"stack"}
Truth table0%0/2
A
A= delete $options{"stack"}
Aresult
11
00
5099 0 ▶ confess "Invalid options: ".join(", ", sort keys %options) if keys %options; # Complain about any invalid options
Branch: 1 branch
BranchTrueFalseTotal
if keys %options 0 0 0
5100  
5101 0 my $B = 12; # Log2 of size of initial allocation for the area
5102 0 my $N = 2 ** $B; # Initial size of area
5103 0 my $w = RegisterSize 31;
5104  
5105 0 my $quad = RegisterSize rax; # Field offsets of quad words used in the header to
5106 0 my $size = 0;
5107 0 my $used = $size + $quad; # Amount of memory in the area that has been used - includes the free chain.
5108 0 my $free = $used + $quad; # Free chain blocks = freed zmm blocks
5109 0 my $tree = $free + $quad; # Start of Yggdrasil,
5110 0 my $data = $w; # Data starts in the next zmm block
5111  
5112 0 ▶ genHash(__PACKAGE__."::Area", # Definition of area
Condition0%0/3
$address || &V('address', 0)
l!l&&r!l&&!r
000
MC/DC0%0/2
$address || &V('address', 0)
$address &V('address', 0)
Truth table0%0/3
A || B
A= $addressB= &V('address', 0)
ABresult
1X1
011
000
5113 B => $B, # Log2 of size of initial allocation
5114 N => $N, # Initial allocation
5115 stack => $stack, # MArk the area as being used as a stack
5116 sizeOffset => $size, # Size field offset
5117 usedOffset => $used, # Used field offset
5118 freeOffset => $free, # Free chain offset
5119 treeOffset => $tree, # Yggdrasil - a tree of global variables in this area
5120 dataOffset => $data, # The start of the data
5121 address => ($address || V address => 0), # Variable that addresses the memory containing the area
5122 zmmBlock => $w, # Size of a zmm block - 64 bytes
5123 nextOffset => $w - RegisterSize(eax), # Position of next offset on free chain
5124 );
5125 }
5126  
5127 sub CreateArea(%) # Create an relocatable area and returns its address in rax. We add a chain header so that 64 byte blocks of memory can be freed and reused within the area.
5128 0 ▶ {my (%options) = @_; # Free=>1 adds a free chain.
Subroutine CreateArea: not called CC=1 SCAR=6.9
Pod documented
5129 0 my $area = DescribeArea(%options); # Describe an area
5130 0 my $N = $area->N;
5131 0 my $used = $area->usedOffset;
5132 0 my $data = $area->dataOffset;
5133 0 my $size = $area->sizeOffset;
5134  
5135 my $s = Subroutine # Allocate area
5136 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
5137  
5138 0 my $area = AllocateMemory K size=> $N; # Allocate memory and save its location in a variable
5139  
5140 0 PushR rax;
5141 0 $$s{area}->address->copy($area); # Save address of area
5142 0 $area->setReg(rax);
5143 0 Mov "dword[rax+$used]", $data; # Initially used space
5144 0 Mov "dword[rax+$size]", $N; # Size
5145 0 PopR;
5146 0 } structures=>{area=>$area}, name => 'CreateArea';
5147  
5148 0 $s->call(structures=>{area=>$area}); # Variable that holds the reference to the area which is updated when the area is reallocated
5149  
5150 0 $area
5151 }
5152  
5153 sub ReadArea($) # Read an area stored in a file into memory and return an area descriptor for the area so created.
5154 0 ▶ {my ($file) = @_; # Name of file to read
Subroutine ReadArea: not called CC=1 SCAR=6.9
Pod documented
5155 0 my ($address, $size) = ReadFile $file; # Read the file into memory
5156 0 DescribeArea address => $address; # Describe it as an area
5157 }
5158  
5159 sub loadAreaIntoAssembly($) # Load an area into the current assembly and return a descriptor for it.
5160 0 ▶ {my ($file) = @_; # File containing an area
Subroutine loadAreaIntoAssembly: not called CC=2 SCAR=17.9
Pod documented
5161  
5162 0 ▶ if (my $l = $loadAreaIntoAssembly{$file}) # Check for a pre existing area
Branch: 1 branch
BranchTrueFalseTotal
if (my $l = $loadAreaIntoAssembly{$file}) 0 0 0
5163 0 {return DescribeArea address => V area=>$l; # Describe area
5164 }
5165  
5166 0 my $areaFinish = $loadAreaIntoAssembly{$file} = Label; # Label at start of area
5167 0 Jmp $areaFinish; # Jump over area
5168 0 push @text, <<END;
5169 align 16
5170 END
5171 0 my $areaStart = SetLabel;
5172 0 Incbin qq("$file"); # Include area as a binary file
5173 0 SetLabel $areaFinish;
5174  
5175 0 DescribeArea address => V area=>$areaStart; # Describe area
5176 }
5177  
5178 sub Nasm::X86::Area::free($) # Free an area.
5179 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine free: not called CC=2 SCAR=17.9
5180 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5181 0 FreeMemory($area->address, $area->size)
5182 }
5183  
5184 sub Nasm::X86::Area::copyDescriptor($$) #P Copy the description of one area into another
5185 0 ▶ {my ($target, $source) = @_; # Target area, source area
Subroutine copyDescriptor: not called CC=1 SCAR=6.9
5186  
5187 0 $target->address->copy($source->address); # target now addresses same area as source
5188 0 $target
5189 }
5190  
5191 #D2 Memory # Manage memory controlled by an area.
5192  
5193 sub Nasm::X86::Area::used($) # Return the currently used size of an area as a variable.
5194 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine used: not called CC=2 SCAR=17.9
5195 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5196  
5197 0 SaveFirstFour;
5198 0 $area->address->setReg(rax); # Address area
5199 0 Mov rdx, "[rax+$$area{usedOffset}]"; # Used
5200 0 Sub rdx, $area->dataOffset; # Subtract size of header so we get the actual amount in use
5201 0 my $size = V 'area used up' => rdx; # Save length in a variable
5202 0 RestoreFirstFour;
5203 0 $size # Return variable length
5204 }
5205  
5206 sub Nasm::X86::Area::size($) # Get the size of an area as a variable.
5207 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine size: not called CC=2 SCAR=17.9
5208 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5209  
5210 0 PushR rax;
5211 0 $area->address->setReg(rax); # Address area
5212 0 Mov rax, "[rax+$$area{sizeOffset}]"; # Get size
5213 0 my $size = V 'size of area' => rax; # Save size in a variable
5214 0 PopR;
5215 0 $size # Return size
5216 }
5217  
5218 sub Nasm::X86::Area::updateSpace($$) #P Make sure that a variable addressed area has enough space to accommodate content of a variable size.
5219 0 ▶ {my ($area, $size) = @_; # Area descriptor, variable size needed
Subroutine updateSpace: not called CC=2 SCAR=17.9
5220 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5221 0 my $base = rdi; # Base of area
5222 0 my $newSize = rsi; # New size needed
5223 0 my $areaSize = "[$base+$$area{sizeOffset}]"; # Size of area
5224 0 my $areaUsed = "[$base+$$area{usedOffset}]"; # Used space in area
5225  
5226 my $s = Subroutine
5227 0 ▶ {my ($p, $s) = @_; # Parameters, structures
Subroutine __ANON__: not called CC=1 SCAR=6.9
5228 0 PushR my $base = r15, my $newSize = r14, my $proposed = r13; # Base of area, New size needed, Proposed size
5229 0 my $areaSize = "[$base+$$area{sizeOffset}]"; # Size of area
5230 0 my $areaUsed = "[$base+$$area{usedOffset}]"; # Used space in area
5231  
5232 0 my $area = $$s{area}; # Area
5233 0 $area->address->setReg($base); # Address area
5234  
5235 0 $$p{size}->setReg($newSize); # Space requested
5236 0 Add $newSize, $areaUsed; # Space needed in area
5237  
5238 0 Mov $proposed, $areaSize; # Minimum proposed area size
5239  
5240 K(loop=>36)->for(sub # Maximum number of shifts
5241 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
5242 0 Shl $proposed, 1; # New proposed size
5243 0 Cmp $proposed, $newSize; # Big enough?
5244 0 Jge $end; # Big enough!
5245 0 });
5246  
5247 0 my $address = AllocateMemory V size => $proposed; # Create new area
5248 0 CopyMemory4K($area->address, $address, $area->size>>K(k4 => $area->B)); # Copy old area into new area 4K at a time
5249 0 FreeMemory $area->address, $area->size; # Free previous memory previously occupied area
5250 0 $area->address->copy($address); # Save new area address
5251 0 $address->setReg($base); # Address area
5252 0 Mov "[$base+$$area{sizeOffset}]", $proposed; # Save the new size in the area
5253  
5254 0 PopR;
5255 0 } parameters => [qw(size)],
5256 structures => {area => $area},
5257 name => 'Nasm::X86::Area::updateSpace';
5258  
5259 0 $area->address->setReg($base); # Address area
5260 0 $size->setReg($newSize); # Space requested
5261 0 Add $newSize, $areaUsed; # Space needed in area
5262 0 Cmp $newSize, $areaSize; # Compare size needed with current size
5263 IfGt # New size is bigger than current size
5264 Then # More space needed
5265 0 ▶ {$s->call(parameters=>{size => $size}, structures=>{area => $area}); # Allocate more space for area
Subroutine __ANON__: not called CC=1 SCAR=6.9
5266 0 };
5267 } # updateSpace
5268  
5269 sub Nasm::X86::Area::makeReadOnly($) # Make an area read only.
5270 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine makeReadOnly: not called CC=2 SCAR=17.9
5271 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5272  
5273 my $s = Subroutine
5274 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
5275 0 Comment "Make an area readable";
5276 0 SaveFirstFour;
5277 0 $$p{address}->setReg(rax);
5278 0 Mov rdi, rax; # Address of area
5279 0 Mov rsi, "[rax+$$area{sizeOffset}]"; # Size of area
5280  
5281 0 Mov rdx, 1; # Read only access
5282 0 Mov rax, 10;
5283 0 Syscall;
5284 0 RestoreFirstFour; # Return the possibly expanded area
5285 0 } parameters=>[qw(address)], name => 'Nasm::X86::Area::makeReadOnly';
5286  
5287 0 $s->call(parameters=>{address => $area->address});
5288 }
5289  
5290 sub Nasm::X86::Area::makeWriteable($) # Make an area writable.
5291 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine makeWriteable: not called CC=2 SCAR=17.9
5292 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5293  
5294 my $s = Subroutine
5295 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
5296 0 Comment "Make an area writable";
5297 0 SaveFirstFour;
5298 0 $$p{address}->setReg(rax);
5299 0 Mov rdi, rax; # Address of area
5300 0 Mov rsi, "[rax+$$area{sizeOffset}]"; # Size of area
5301 0 Mov rdx, 3; # Read only access
5302 0 Mov rax, 10;
5303 0 Syscall;
5304 0 RestoreFirstFour; # Return the possibly expanded area
5305 0 } parameters=>[qw(address)], name => 'Nasm::X86::Area::makeWriteable';
5306  
5307 0 $s->call(parameters=>{address => $area->address});
5308 }
5309  
5310 #D2 Alloc/Free # Allocate and free memory in an area, either once only but in variable size blocks or reusably in zmm sized blocks via the free block chain.
5311  
5312 sub Nasm::X86::Area::allocate($$) # Allocate the variable amount of space in the variable addressed area and return the offset of the allocation in the area as a variable.
5313 0 ▶ {my ($area, $Size) = @_; # Area descriptor, variable amount of allocation
Subroutine allocate: not called CC=3 SCAR=24.8
5314 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5315  
5316 0 ▶ my $size = ref($Size) ? $Size : K size => $Size; # Promote constant
Branch: 1 branch
BranchTrueFalseTotal
ref $Size ? : 0 0 0
5317  
5318 0 $area->updateSpace($size); # Update space if needed
5319 0 $area->address->setReg(rax);
5320 0 Mov rsi, "[rax+$$area{usedOffset}]"; # Currently used
5321 0 my $offset = V(offset => rsi); # Variable to hold offset of allocation
5322 0 $size ->setReg(rdi);
5323 0 Add rsi, rdi;
5324 0 Mov "[rax+$$area{usedOffset}]", rsi; # Update currently used
5325  
5326 0 $offset
5327 }
5328  
5329 sub Nasm::X86::Area::allocZmmBlock($) # Allocate a block to hold a zmm register in the specified area and return the offset of the block as a variable.
5330 0 ▶ {my ($area) = @_; # Area
Subroutine allocZmmBlock: not called CC=2 SCAR=17.9
5331 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5332 0 my $offset = V(offset => 0); # Variable to hold offset of allocation
5333  
5334 0 PushR rax;
5335  
5336 0 $area->address->setReg(rax); # Address of area
5337 0 my $firstBlock = "dword[rax+$$area{freeOffset}]"; # Offset of first block in free chain if such a block exists
5338  
5339 0 Cmp $firstBlock, 0;
5340 IfGt # Check free chain
5341 Then # Free block available on free chain
5342 0 ▶ {PushR my $first = r14, my $second = r15, my $block = 31;
Subroutine __ANON__: not called CC=1 SCAR=6.9
5343 0 my $firstD = $first.'d';
5344 0 my $secondD = $second.'d';
5345 0 Mov $firstD, $firstBlock; # Offset of first block
5346 0 $area->getZmmBlock(V(offset => $first), $block); # Load the first block on the free chain
5347 0 dFromZ($block, 0)->setReg($second); # The location of the second block if any
5348 0 Mov $firstBlock, $secondD; # Offset of first block in free chain if such a block exists
5349 0 ClearRegisters $block; # Clear the zmm block - possibly this only needs to be done if we are reusing a block
5350 0 $offset->getReg($first); # First block is the allocated block
5351 0 $area->putZmmBlock($offset, $block);
5352 0 PopR;
5353 },
5354 Else # Cannot reuse a free block so allocate
5355 0 ▶ {$offset->copy($area->allocate(K size => $area->zmmBlock)); # Copy offset of allocation
Subroutine __ANON__: not called CC=1 SCAR=6.9
5356 0 };
5357  
5358 0 PopR;
5359  
5360 0 $offset # Return offset of allocated block
5361 }
5362  
5363 sub Nasm::X86::Area::allocZmmBlock3($) #P Allocate three zmm blocks in one go and return their offsets.
5364 0 ▶ {my ($area) = @_; # Area
Subroutine allocZmmBlock3: not called CC=2 SCAR=17.9
5365 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5366 0 my $o1 = V(o1 => 0); # First block
5367 0 my $o2 = V(o2 => 0); # Second block
5368 0 my $o3 = V(o3 => 0); # Third block
5369  
5370 0 PushR rax;
5371  
5372 0 $area->address->setReg(rax); # Address of area
5373 0 my $firstBlock = "dword[rax+$$area{freeOffset}]"; # Offset of first block in free chain if such a block exists
5374  
5375 0 Cmp $firstBlock, 0;
5376 IfGt # Check free chain
5377 Then # Free block available on free chain
5378 0 ▶ {$o1->copy($area->allocZmmBlock);
Subroutine __ANON__: not called CC=1 SCAR=6.9
5379 0 $o2->copy($area->allocZmmBlock);
5380 0 $o3->copy($area->allocZmmBlock);
5381 },
5382 Else # Cannot reuse a free block so allocate
5383 0 ▶ {$o1->copy($area->allocate(K size => $area->zmmBlock * 3)); # Copy offset of allocation
Subroutine __ANON__: not called CC=1 SCAR=6.9
5384 0 $o2->copy($o1 + RegisterSize zmm0); # Cut out sub blocks
5385 0 $o3->copy($o2 + RegisterSize zmm0);
5386 0 };
5387  
5388 0 PopR;
5389  
5390 0 ($o1, $o2, $o3) # Return offsets of allocated blocks
5391 }
5392  
5393 sub Nasm::X86::Area::freeZmmBlock($$) # Free a block in an area by placing it on the free chain.
5394 0 ▶ {my ($area, $offset) = @_; # Area descriptor, offset of zmm block to be freed
Subroutine freeZmmBlock: not called CC=2 SCAR=17.9
5395 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5396  
5397 0 PushR rax, my $first = r14, my $second = r15, zmm7;
5398 0 my $firstD = $first.'d'; my $secondD = $second.'d';
5399 0 $area->address->setReg(rax); # Address of area
5400 0 Mov $secondD, "[rax+$$area{freeOffset}]"; # Offset of first block in free chain if such a block exists
5401 0 ClearRegisters zmm7;
5402 0 Movd xmm7, $secondD;
5403 0 $area->putZmmBlock($offset, 7);
5404 0 $offset->setReg($first); # Offset if what will soon be the first block on the free chain
5405 0 Mov "[rax+$$area{freeOffset}]", $firstD; # Offset of first block in free chain if such a block exists
5406 0 PopR;
5407 }
5408  
5409 sub Nasm::X86::Area::freeChainSpace($) # Count the number of blocks available on the free chain.
5410 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine freeChainSpace: not called CC=2 SCAR=17.9
5411 0 ▶ @_ == 1 or confess "One parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameters") 0 0 0
5412 0 my $count = V('free chain blocks' => 0);
5413  
5414 0 PushR rax, my $first = r15, 31;
5415 0 my $firstD = $first.'d';
5416  
5417 0 $area->address->setReg(rax); # Address of area
5418 0 Mov $firstD, "[rax+$$area{freeOffset}]"; # Offset of first block in free chain if such a block exists
5419 K( loop => 99)->for(sub # Loop through free block chain
5420 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
5421 0 Cmp $first, 0;
5422 0 ▶ IfEq Then{Jmp $end}; # No more free blocks
Subroutine __ANON__: not called CC=1 SCAR=6.9
5423 0 $area->getZmmBlock(V(offset => $first), 31); # Load the first block on the free chain
5424 0 dFromZ(31, 0)->setReg($first); # The location of the second block if any
5425 0 $count++ # Increment count of number of blocks on the free chain
5426 0 });
5427 0 PopR;
5428 0 $count * RegisterSize 31;
5429 }
5430  
5431 sub Nasm::X86::Area::getZmmBlock($$$) # Get the block with the specified offset in the specified string and return it in the numbered zmm.
5432 0 ▶ {my ($area, $block, $zmm) = @_; # Area descriptor, offset of the block as a variable or register, number of zmm register to contain block
Subroutine getZmmBlock: not called CC=5 SCAR=34.0
5433 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
5434  
5435 0 my $a = rdi; # Work registers
5436 0 ▶ my $o = ref($block) =~ m(Variable) ? rsi : $block; # Offset of block in area via register or variable
Branch: 1 branch
BranchTrueFalseTotal
ref($block) =~ /Variable/ ? : 0 0 0
5437  
5438 0 $area->address->setReg($a); # Area address
5439 0 ▶ $block ->setReg($o) if ref($block) =~ m(Variable); # Offset of block in area via variable
Branch: 1 branch
BranchTrueFalseTotal
if ref($block) =~ /Variable/ 0 0 0
5440  
5441 0 ▶ if ($DebugMode)
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
5442 0 {Cmp $o, $area->dataOffset;
5443 IfLt # We could have done this using variable arithmetic, but such arithmetic is expensive and so it is better to use register arithmetic if we can.
5444 Then
5445 0 ▶ {PrintErrTraceBack "Attempt to get block before start of area";
Subroutine __ANON__: not called CC=1 SCAR=6.9
5446 0 };
5447 }
5448  
5449 0 Vmovdqu64 zmm($zmm), "[$a+$o]"; # Read from memory
5450 }
5451  
5452 sub Nasm::X86::Area::putZmmBlock($$$) # Write the numbered zmm to the block at the specified offset in the specified area.
5453 0 ▶ {my ($area, $block, $zmm) = @_; # Area descriptor, offset of the block as a variable, number of zmm register to contain block
Subroutine putZmmBlock: not called CC=5 SCAR=34.0
5454 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
5455  
5456 0 my $a = rdi; # Work registers
5457 0 ▶ my $o = ref($block) =~ m(Variable) ? rsi : $block;
Branch: 1 branch
BranchTrueFalseTotal
ref($block) =~ /Variable/ ? : 0 0 0
5458  
5459 0 $area->address->setReg($a); # Area address
5460 0 ▶ $block->setReg($o) if ref($block) =~ m(Variable); # Offset of block in area
Branch: 1 branch
BranchTrueFalseTotal
if ref($block) =~ /Variable/ 0 0 0
5461  
5462 0 ▶ if ($DebugMode)
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
5463 0 {Cmp $o, $area->dataOffset;
5464 IfLt # We could have done this using variable arithmetic, but such arithmetic is expensive and so it is better to use register arithmetic if we can.
5465 Then
5466 0 ▶ {PrintErrTraceBack "Attempt to put block before start of area";
Subroutine __ANON__: not called CC=1 SCAR=6.9
5467 0 };
5468 }
5469 0 Vmovdqu64 "[$a+$o]", zmm($zmm); # Read from memory
5470 }
5471  
5472 sub Nasm::X86::Area::clearZmmBlock($$) # Clear the zmm block at the specified offset in the area.
5473 0 ▶ {my ($area, $offset) = @_; # Area descriptor, offset of the block as a variable
Subroutine clearZmmBlock: not called CC=2 SCAR=17.9
5474 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5475  
5476 0 ClearRegisters 1;
5477 0 $area->putZmmBlock($offset, 1);
5478 }
5479  
5480 #D2 Yggdrasil # The world tree from which we can address so many other things
5481  
5482 0 ▶sub Nasm::X86::Yggdrasil::UniqueStrings {K key => 0} #P A tree of strings that assigns unique numbers to strings.
Subroutine UniqueStrings: not called CC=1 SCAR=6.9
5483 0 ▶sub Nasm::X86::Yggdrasil::SubroutineOffsets {K key => 1} #P Translates a string number into the offset of a subroutine in an area.
Subroutine SubroutineOffsets: not called CC=1 SCAR=6.9
5484 0 ▶sub Nasm::X86::Yggdrasil::SubroutineDefinitions{K key => 2} #P Maps the unique string number for a subroutine name to the offset in the are that contains the length (as a dword) followed by the string content of the Perl data structure describing the subroutine in question.
Subroutine SubroutineDefinitions: not called CC=1 SCAR=6.9
5485 0 ▶sub Nasm::X86::Yggdrasil::Unisyn::Alphabets {K key => 3} #P Unisyn alphabets.
Subroutine Alphabets: not called CC=1 SCAR=6.9
5486 0 ▶sub Nasm::X86::Yggdrasil::Unisyn::Open {K key => 4} #P Open bracket to close bracket
Subroutine Open: not called CC=1 SCAR=6.9
5487 0 ▶sub Nasm::X86::Yggdrasil::Unisyn::Close {K key => 5} #P Close bracket to open bracket
Subroutine Close: not called CC=1 SCAR=6.9
5488 0 ▶sub Nasm::X86::Yggdrasil::Unisyn::Transitions {K key => 6} #P Permissible transitions from alphabet to alphabet
Subroutine Transitions: not called CC=1 SCAR=6.9
5489  
5490 sub Nasm::X86::Area::yggdrasil($) # Return a tree descriptor to the Yggdrasil world tree for an area creating the world tree Yggdrasil if it has not already been created.
5491 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine yggdrasil: not called CC=2 SCAR=17.9
5492 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5493  
5494 0 my $t = $area->DescribeTree; # Tree descriptor for Yggdrasil
5495 0 PushR rax, r15;
5496 0 $area->address->setReg(rax); # Address underlying area
5497 0 Mov r15, "[rax+$$area{treeOffset}]"; # Address Yggdrasil
5498  
5499 0 Cmp r15, 0; # Does Yggdrasil even exist?
5500 IfNe
5501 Then # Yggdrasil has already been created so we can address it
5502 0 ▶ {$t->first->getReg(r15);
Subroutine __ANON__: not called CC=1 SCAR=6.9
5503 },
5504 Else # Yggdrasil has not been created
5505 0 ▶ {my $T = $area->CreateTree;
Subroutine __ANON__: not called CC=1 SCAR=6.9
5506 0 $t->copyDescriptor($T);
5507 0 $T->first->setReg(r15);
5508 0 $area->address->setReg(rax); # Address underlying area - it might have moved
5509 0 Mov "[rax+$$area{treeOffset}]", r15; # Save offset of Yggdrasil
5510 0 };
5511 0 PopR;
5512 0 $t
5513 }
5514  
5515 sub Nasm::X86::Area::checkYggdrasilCreated($) #P Return a tree descriptor for the Yggdrasil world tree for an area. If Yggdrasil has not been created the found field of the returned descriptor will have zero in it else one.
5516 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine checkYggdrasilCreated: not called CC=2 SCAR=17.9
5517 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5518  
5519 0 my $t = $area->DescribeTree; # Tree descriptor for Yggdrasil
5520 0 PushR rax;
5521 0 $area->address->setReg(rax); #P Address underlying area
5522 0 Mov rax, "[rax+$$area{treeOffset}]"; # Address Yggdrasil
5523 0 my $v = V('Yggdrasil', rax); # Offset to Yggdrasil if it exists else zero
5524 0 Cmp rax, 0; # Does Yggdrasil even exist?
5525 IfNe
5526 Then # Yggdrasil has been created so we can address it
5527 0 ▶ {$t->first->copy(rax);
Subroutine __ANON__: not called CC=1 SCAR=6.9
5528 0 $t->found->copy(1);
5529 },
5530 Else # Yggdrasil has not been created
5531 0 ▶ {$t->found->copy(0);
Subroutine __ANON__: not called CC=1 SCAR=6.9
5532 0 };
5533 0 PopR rax;
5534 0 $t
5535 }
5536  
5537 #D2 Areas as Strings # Use the memory supplied by the area as a string - however, in general, this is too slow unless coupled with another slow operation such as executing a command, mapping a file or writing to a file.
5538  
5539 sub Nasm::X86::Area::appendMemory($$$) # Append the variable addressed content in memory of variable size to the specified area and return its offset in that area. Pre-pack data as much as possible before using this routine to optimize processing.
5540 0 ▶ {my ($area, $address, $size) = @_; # Area descriptor, variable address of content, variable length of content
Subroutine appendMemory: not called CC=2 SCAR=17.9
5541 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
5542  
5543 0 my $used = "[rax+$$area{usedOffset}]"; # Address the used field in the area
5544  
5545 my $s = Subroutine
5546 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
5547  
5548 0 my $area = $$s{area};
5549 0 $area->address->setReg(rax); # Address area
5550 0 my $oldUsed = V("used", $used); # Record currently used space
5551 0 $area->updateSpace($$p{size}); # Update space if needed
5552  
5553 0 my $target = $oldUsed + $area->address; # Where to write the copied memory to
5554 0 CopyMemory($$p{address}, $target, $$p{size}); # Copy data into the area
5555  
5556 0 my $newUsed = $oldUsed + $$p{size}; # Amount of space now being used
5557  
5558 0 $area->address->setReg(rax); # Update used field
5559 0 $newUsed->setReg(rdi);
5560 0 Mov $used, rdi;
5561  
5562 0 $$p{offset}->copy($oldUsed); # Return offset of content in area
5563  
5564 0 } structures => {area => $area},
5565 parameters => [qw(address size offset)],
5566 name => 'Nasm::X86::Area::m';
5567  
5568 0 my $offset = V offset => 0; # Offset within the area at which the content was appended
5569 0 $s->inline(structures => {area => $area},
5570 parameters => {address => $address, size => $size,
5571 offset => $offset});
5572 0 $offset
5573 }
5574  
5575 sub Nasm::X86::Area::appendZmm($$) # Append the contents of the specified zmm to the specified area and returns its offset in that area as a variable,
5576 0 ▶ {my ($area, $zmm) = @_; # Area descriptor, zmm number
Subroutine appendZmm: not called CC=2 SCAR=17.9
5577 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5578  
5579 0 my $k = $area->allocZmmBlock; # Allocate a block to hold the content of the zmm register
5580  
5581 0 $area->address->setReg(rax);
5582 0 $k->setReg(rbx);
5583 0 Vmovdqu64 "[rax+rbx]", zmm($zmm); # Copy in the data held in the supplied zmm register
5584  
5585 0 $k # Return offset in area
5586 }
5587  
5588 sub Nasm::X86::Area::appendVar($$) # Append the contents of a variable to the specified area
5589 0 ▶ {my ($area, $var) = @_; # Area descriptor, variable
Subroutine appendVar: not called CC=2 SCAR=17.9
5590 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5591  
5592 0 Lea rax, $var->addressExpr;
5593 0 $area->appendMemory(V(address => rax), V size => qSize) # Return offset in area
5594 }
5595  
5596 sub Nasm::X86::Area::q($$) # Append a constant string to the area.
5597 0 ▶ {my ($area, $string) = @_; # Area descriptor, string
Subroutine q: not called CC=2 SCAR=17.9
5598 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5599  
5600 0 my $s = Rs($string);
5601 0 $area->appendMemory(V('address', $s), V('size', length($string)));
5602 }
5603  
5604 sub Nasm::X86::Area::ql($$) # Append a constant quoted string containing new line characters to the specified area.
5605 0 ▶ {my ($area, $const) = @_; # Area, constant
Subroutine ql: not called CC=3 SCAR=24.8
5606 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5607 0 for my $l(split /\s*\n/, $const)
5608 0 {$area->q($l);
5609 0 $area->nl;
5610 }
5611 }
5612  
5613 sub Nasm::X86::Area::char($$) # Append a constant character expressed as a decimal number to the specified area.
5614 0 ▶ {my ($area, $char) = @_; # Area descriptor, number of character to be appended
Subroutine char: not called CC=2 SCAR=17.9
5615 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5616 0 my $s = Rb(ord($char));
5617 0 $area->appendMemory(V(address => $s), K size => 1); # Move data
5618 }
5619  
5620 sub Nasm::X86::Area::nl($) # Append a new line to the area addressed by rax.
5621 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine nl: not called CC=2 SCAR=17.9
5622 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5623 0 $area->char("\n");
5624 }
5625  
5626 sub Nasm::X86::Area::zero($) #P Append a trailing zero to the area addressed by rax.
5627 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine zero: not called CC=2 SCAR=17.9
5628 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5629 0 $area->char("\0");
5630 }
5631  
5632 sub Nasm::X86::Area::append($@) # Append one area to another.
5633 0 ▶ {my ($target, $source) = @_; # Target area descriptor, source area descriptor
Subroutine append: not called CC=2 SCAR=17.9
5634 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5635  
5636 0 SaveFirstFour;
5637 0 $source->address->setReg(rax);
5638 0 Mov rdi, "[rax+$$source{usedOffset}]";
5639 0 Sub rdi, $source->dataOffset;
5640 0 Lea rsi, "[rax+$$source{dataOffset}]";
5641 0 $target->appendMemory(V(address => rsi), V size => rdi);
5642 0 RestoreFirstFour;
5643 }
5644  
5645 sub Nasm::X86::Area::clear($) # Clear an area but keep it at the same size.
5646 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine clear: not called CC=2 SCAR=17.9
5647 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5648  
5649 my $s = Subroutine
5650 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
5651 0 PushR rax, rdi;
5652 0 $$p{address}->setReg(rax);
5653 0 Mov rdi, $area->dataOffset;
5654 0 Mov "[rax+$$area{usedOffset}]", rdi;
5655 0 ClearRegisters rdi;
5656 0 Mov "[rax+$$area{freeOffset}]", rdi;
5657 0 Mov "[rax+$$area{treeOffset}]", rdi;
5658 0 PopR;
5659 0 } parameters=>[qw(address)], name => 'Nasm::X86::Area::clear';
5660  
5661 0 $s->call(parameters=>{address => $area->address});
5662 }
5663  
5664 sub Nasm::X86::Area::read($$) # Read a file specified by a variable addressed zero terminated string and append its content to the specified area.
5665 0 ▶ {my ($area, $file) = @_; # Area descriptor, variable addressing file name
Subroutine read: not called CC=2 SCAR=17.9
5666 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5667  
5668 my $s = Subroutine
5669 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
5670 0 Comment "Read an area";
5671 0 my ($address, $size) = ReadFile $$p{file};
5672 0 my $area = $$s{area};
5673 0 $area->appendMemory($address, $size); # Move data into area
5674 0 FreeMemory($size, $address); # Free memory allocated by read
5675 0 } structures => {area=>$area},
5676 parameters => [qw(file)],
5677 name => 'Nasm::X86::Area::read';
5678  
5679 0 $s->call(structures => {area => $area}, parameters => {file => $file});
5680 }
5681  
5682 sub Nasm::X86::Area::write($$) # Write the content of the specified area to a file specified by a zero terminated string.
5683 0 ▶ {my ($area, $file) = @_; # Area descriptor, variable addressing zero terminated file name
Subroutine write: not called CC=3 SCAR=24.8
5684 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5685  
5686 my $s = Subroutine
5687 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
5688 0 SaveFirstFour;
5689 0 $$p{file}->setReg(rax);
5690 0 OpenWrite; # Open file
5691 0 my $file = V(fd => rax); # File descriptor
5692  
5693 0 $$p{address}->setReg(rsi); # Write from start of area
5694 0 Mov rdx, "[rsi+$$area{usedOffset}]"; # Length of the area to write
5695  
5696 0 Mov rax, 1; # Write content to file
5697 0 $file->setReg(rdi); # File number
5698 0 Syscall;
5699  
5700 0 $file->setReg(rax); # Close the file
5701 0 CloseFile;
5702 0 RestoreFirstFour;
5703 0 } parameters=>[qw(file address)], name => 'Nasm::X86::Area::write';
5704  
5705 0 ▶ my $f = ref($file) ? $file : V file => Rs $file; # Convert constant string to zero terminated string
Branch: 1 branch
BranchTrueFalseTotal
ref $file ? : 0 0 0
5706  
5707 0 $s->call(parameters=>{address => $area->address, file => $f});
5708 }
5709  
5710 sub Nasm::X86::Area::out($) # Print the specified area on sysout.
5711 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine out: not called CC=2 SCAR=17.9
5712 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5713  
5714 my $s = Subroutine
5715 0 ▶ {my ($p) = @_; # Parameters
Subroutine __ANON__: not called CC=1 SCAR=6.9
5716 0 SaveFirstFour;
5717 0 $$p{address}->setReg(rax);
5718  
5719 0 Mov rdi, "[rax+$$area{usedOffset}]"; # Length to print
5720 0 Sub rdi, $area->dataOffset; # Length to print
5721 0 Lea rax, "[rax+$$area{dataOffset}]"; # Address of data field
5722 0 PrintOutMemory;
5723 0 RestoreFirstFour;
5724 0 } parameters=>[qw(address)], name => 'Nasm::X86::Area::out';
5725  
5726 0 $s->call(parameters=>{address => $area->address});
5727 }
5728  
5729 sub Nasm::X86::Area::outNL($) # Print the specified area on sysout followed by a new line.
5730 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine outNL: not called CC=2 SCAR=17.9
5731 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5732  
5733 0 $area->out;
5734 0 PrintOutNL;
5735 }
5736  
5737 sub Nasm::X86::Area::printOut($$$) # Print part of the specified area on sysout.
5738 0 ▶ {my ($area, $Offset, $Length) = @_; # Area descriptor, offset, length
Subroutine printOut: not called CC=4 SCAR=30.0
5739 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
5740  
5741 0 ▶ my $offset = ref($Offset) ? $Offset : K offset => $Offset;
Branch: 1 branch
BranchTrueFalseTotal
ref $Offset ? : 0 0 0
5742 0 ▶ my $length = ref($Length) ? $Length : K length => $Length;
Branch: 1 branch
BranchTrueFalseTotal
ref $Length ? : 0 0 0
5743  
5744 0 PushR rax, rdi, rsi;
5745 0 ($area->address + $offset)->setReg(rax);
5746 0 $length ->setReg(rdi);
5747 0 PrintOutMemoryNL;
5748 0 PopR;
5749 }
5750  
5751 sub Nasm::X86::Area::dump($$;$) # Dump details of an area.
5752 0 ▶ {my ($area, $title, $depth) = @_; # Area descriptor, title string, optional variable number of 64 byte blocks to dump
Subroutine dump: not called CC=5 SCAR=34.0
5753 0 ▶ @_ == 2 or @_ == 3 or confess "Two or three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or @_ == 3 or confess("Two or three parameters") 0 0 0
Condition0%0/3
@_ == 2 or @_ == 3
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 2 or @_ == 3
@_ == 2 @_ == 3
Truth table0%0/3
A or B
A= @_ == 2B= @_ == 3
ABresult
1X1
011
000
5754 0 my $blockSize = 64; # Print in blocks of this size
5755  
5756 my $s = Subroutine
5757 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
5758  
5759 0 PushR rax, rdi;
5760 0 my $area = $$s{area};
5761 0 $area->address->setReg(rax); # Get address of area
5762 0 PrintOutString("Area ");
5763  
5764 0 PushR rax; # Print size
5765 0 Mov rax, "[rax+$$area{sizeOffset}]";
5766 0 PrintOutString " Size: ";
5767 0 PrintOutRightInDec rax, 8;
5768 0 PrintOutString " ";
5769 0 PopR rax;
5770  
5771 0 PushR rax; # Print size
5772 0 Mov rax, "[rax+$$area{usedOffset}]";
5773 0 PrintOutString(" Used: ");
5774 0 PrintOutRightInDec rax, 8;
5775 0 PrintOutNL;
5776 0 PopR rax;
5777  
5778 $$p{depth}->for(sub # Print the requested number of blocks
5779 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
5780 0 Mov rdi, $blockSize; # Length of each print
5781 0 ($index*RegisterSize(zmm31))->out('', ' | ');
5782 0 my $address = $area->address + $index * $blockSize; # Address of block to print
5783 0 $address->setReg(rax);
5784 0 PrintOutMemory_InHexNL;
5785 0 });
5786  
5787 0 PopR;
5788 0 } structures=>{area=>$area},
5789 parameters=>[qw(depth)],
5790 name => "Nasm::X86::Area::dump";
5791  
5792 0 PrintOutStringNL $title;
5793 0 ▶ $s->call(structures=>{area=>$area}, parameters=>{depth => defined($depth) ? (ref($depth) ? $depth : V(depth => $depth)) : V('depth', 4)});
Branch: 2 branches
BranchTrueFalseTotal
defined $depth ? : 0 0 0
ref $depth ? : 0 0 0
5794 }
5795  
5796 #D2 Areas as Stacks # Use an area as a stack. If the area is simultaneouls used for other operations confusion will ensue.
5797  
5798 sub Nasm::X86::Area::push($$) # Push the contents of a variable into an area
5799 0 ▶ {my ($area, $var) = @_; # Area descriptor, variable
Subroutine push: not called CC=3 SCAR=24.8
5800 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5801 0 ▶ confess "Not a stack" unless $area->stack; # Check that we are using the area as a stack
Branch: 1 branch
BranchTrueFalseTotal
unless $area->stack 0 0 0
5802  
5803 0 $area->updateSpace(K size => my $w = RegisterSize rax); # Update space if needed
5804  
5805 0 my $oldUsed = rsi, my $target = rdi, my $areaA = rax, my $dataToPush = rdx;
5806 0 my $used = "qword[$areaA+$$area{usedOffset}]"; # Address the used field in the area
5807  
5808 0 $area->address->setReg($areaA); # Address area
5809 0 Mov $oldUsed, $used; # Record currently used space
5810  
5811 0 Mov $dataToPush, $var->addressExpr; # Data to push
5812 0 Mov "[$oldUsed + $areaA]", $dataToPush; # Push data into the area
5813 0 Lea $target, "[$oldUsed + $w]"; # Amount of space now being used
5814  
5815 0 $area->address->setReg($areaA); # Update used field
5816 0 Mov $used, $target;
5817 }
5818  
5819 sub Nasm::X86::Area::stackSize($) # Size of the stack in an area being used as a stack
5820 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine stackSize: not called CC=3 SCAR=24.8
5821 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5822 0 ▶ confess "Not a stack" unless $area->stack; # Check that we are using the area as a stack
Branch: 1 branch
BranchTrueFalseTotal
unless $area->stack 0 0 0
5823  
5824 0 my $oldUsed = rsi, my $areaA = rax;
5825 0 my $used = "qword[$areaA+$$area{usedOffset}]"; # Address the used field in the area
5826  
5827 0 $area->address->setReg($areaA); # Address area
5828 0 Mov $oldUsed, $used; # Record currently used space
5829 0 Sub $oldUsed, $area->dataOffset; # Space minus header is actual space used by stack
5830 0 V stackSize => $oldUsed; # Return stack size as a variable
5831 }
5832  
5833 sub Nasm::X86::Area::peek($$) # Peek at a variable on the stack
5834 0 ▶ {my ($area, $back) = @_; # Area descriptor, how far back to look in the stack with the top most element being at one.
Subroutine peek: not called CC=4 SCAR=30.0
5835 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5836 0 ▶ confess "Not a stack" unless $area->stack; # Check that we are using the area as a stack
Branch: 1 branch
BranchTrueFalseTotal
unless $area->stack 0 0 0
5837 0 ▶ confess "Constant number required" unless $back =~ m(\A\d+\Z); # Number of variables to go back
Branch: 1 branch
BranchTrueFalseTotal
unless $back =~ /\A\d+\Z/ 0 0 0
5838  
5839 0 my $w = RegisterSize rax; # Size of a variable
5840 0 my $oldUsed = rsi, my $areaA = rax;
5841 0 my $used = "qword[$areaA+$$area{usedOffset}]"; # Address the used field in the area
5842  
5843 0 $area->address->setReg($areaA); # Address area
5844 0 Mov $oldUsed, $used; # Record currently used space
5845 0 Cmp $oldUsed, $area->dataOffset + $back * $w - 1; # Space minus header is actual space used by stack
5846 IfLe # Stack under flow
5847 Then
5848 0 ▶ {PrintErrTraceBack "Stack underflow";
Subroutine __ANON__: not called CC=1 SCAR=6.9
5849 0 };
5850  
5851 0 V pop => "[$oldUsed + $areaA - $back * $w]"; # Return popped data
5852 }
5853  
5854 sub Nasm::X86::Area::stackVariable($$) # Peek at the variable indexed variable on the stack
5855 0 ▶ {my ($area, $index) = @_; # Area descriptor, index of element sought
Subroutine stackVariable: not called CC=4 SCAR=30.0
5856 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5857 0 ▶ confess "Not a stack" unless $area->stack; # Check that we are using the area as a stack
Branch: 1 branch
BranchTrueFalseTotal
unless $area->stack 0 0 0
5858 0 ▶ confess "Variable required" unless ref $index; # Index of element must be a variable
Branch: 1 branch
BranchTrueFalseTotal
unless ref $index 0 0 0
5859  
5860 0 my $w = RegisterSize rax; # Size of a variable
5861 0 my $Index = rsi, my $Area = rax;
5862  
5863 0 $area ->address->setReg($Area); # Address area
5864 0 $index->setReg($Index); # Index of element
5865  
5866 0 V pop => "[$Area+$w*$Index+$$area{dataOffset}]"; # Return popped data
5867 }
5868  
5869 sub Nasm::X86::Area::stackVariableSize($) # Size of a stack of variables in an area.
5870 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine stackVariableSize: not called CC=3 SCAR=24.8
5871 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5872 0 ▶ confess "Not a stack" unless $area->stack; # Check that we are using the area as a stack
Branch: 1 branch
BranchTrueFalseTotal
unless $area->stack 0 0 0
5873  
5874 0 $area ->address->setReg(rax); # Address area
5875  
5876 0 Mov rax, "[rax+$$area{usedOffset}]"; # Used area in bytes
5877 0 Sub rax, $area->dataOffset; # Header space
5878 0 Shr rax, 3; # Used area in quads
5879 0 V size => rax; # Return size in quads
5880 }
5881  
5882 sub Nasm::X86::Area::pop($) # Pop a variable from the stack in an area being used as a stack
5883 0 ▶ {my ($area) = @_; # Area descriptor
Subroutine pop: not called CC=3 SCAR=24.8
5884 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
5885 0 ▶ confess "Not a stack" unless $area->stack; # Check that we are using the area as a stack
Branch: 1 branch
BranchTrueFalseTotal
unless $area->stack 0 0 0
5886  
5887 0 my $w = RegisterSize rax; # Size of a variable
5888 0 my $oldUsed = rsi, my $areaA = rax;
5889 0 my $used = "qword[$areaA+$$area{usedOffset}]"; # Address the used field in the area
5890  
5891 0 $area->address->setReg($areaA); # Address area
5892 0 Mov $oldUsed, $used; # Record currently used space
5893 0 Cmp $oldUsed, $area->dataOffset + $w; # Space minus header is actual space used by stack
5894 IfLt # Stack under flow
5895 Then
5896 0 ▶ {PrintErrTraceBack "Stack underflow";
Subroutine __ANON__: not called CC=1 SCAR=6.9
5897 0 };
5898  
5899 0 Sub $used, $w; # Reduce stack by one variable
5900 0 V pop => "[$oldUsed + $areaA - $w]"; # Return popped data
5901 }
5902  
5903 sub Nasm::X86::Area::pushZmm($$) # Push the contents of a zmm register into an area.
5904 0 ▶ {my ($area, $zmm) = @_; # Area descriptor, zmm number
Subroutine pushZmm: not called CC=3 SCAR=24.8
5905 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5906 0 ▶ confess "Not a stack" unless $area->stack; # Check that we are using the area as a stack
Branch: 1 branch
BranchTrueFalseTotal
unless $area->stack 0 0 0
5907  
5908 0 $area->updateSpace(K size => my $w = RegisterSize zmm1); # Update space if needed
5909  
5910 0 my $oldUsed = rsi, my $target = rdi, my $areaA = rax;
5911 0 my $used = "qword[$areaA+$$area{usedOffset}]"; # Address the used field in the area
5912  
5913 0 $area->address->setReg($areaA); # Address area
5914 0 Mov $oldUsed, $used; # Record currently used space
5915  
5916 0 Vmovdqu64 "[$oldUsed + $areaA]", zmm($zmm); # Push data into the area
5917 0 Lea $target, "[$oldUsed + $w]"; # Amount of space now being used
5918  
5919 0 $area->address->setReg($areaA); # Update used field
5920 0 Mov $used, $target;
5921  
5922 0 V zmmStackOffset => $oldUsed; # Offset of the zmm in the stack
5923 }
5924  
5925 sub Nasm::X86::Area::peekZmm($$$) # Peek at a zmm register from the stack in an area being used as a stack and return a variable containing its offset in the area so we can update the pushed zmm if desired.
5926 0 ▶ {my ($area, $zmm, $back) = @_; # Area descriptor, zmm number, how far back to look in the stack with the top most element being at one.
Subroutine peekZmm: not called CC=4 SCAR=30.0
5927 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
5928 0 ▶ confess "Not a stack" unless $area->stack; # Check that we are using the area as a stack
Branch: 1 branch
BranchTrueFalseTotal
unless $area->stack 0 0 0
5929 0 ▶ confess "Constant number required" unless $back =~ m(\A\d+\Z); # Number of variables to go back
Branch: 1 branch
BranchTrueFalseTotal
unless $back =~ /\A\d+\Z/ 0 0 0
5930 0 my $w = RegisterSize zmm1; # Size of a zmm register
5931  
5932 0 my $oldUsed = rsi, my $areaA = rax;
5933 0 my $used = "qword[$areaA+$$area{usedOffset}]"; # Address the used field in the area
5934  
5935 0 $area->address->setReg($areaA); # Address area
5936 0 Mov $oldUsed, $used; # Record currently used space
5937 0 Sub $oldUsed, $back * $w; # Back up
5938 0 Cmp $oldUsed, $area->dataOffset - 1; # Space minus header is actual space used by stack
5939 IfLe # Stack under flow
5940 Then
5941 0 ▶ {PrintErrTraceBack "Stack underflow when peeking for zmm";
Subroutine __ANON__: not called CC=1 SCAR=6.9
5942 0 };
5943  
5944 0 Vmovdqu64 zmm($zmm), "[$oldUsed + $areaA]"; # Set zmm to popped data
5945 0 V offset => $oldUsed; # Return offset of zmm block
5946 }
5947  
5948 sub Nasm::X86::Area::popZmm($$) # Pop a zmm register from the stack in an area being used as a stack
5949 0 ▶ {my ($area, $zmm) = @_; # Area descriptor, zmm number
Subroutine popZmm: not called CC=3 SCAR=24.8
5950 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
5951 0 ▶ confess "Not a stack" unless $area->stack; # Check that we are using the area as a stack
Branch: 1 branch
BranchTrueFalseTotal
unless $area->stack 0 0 0
5952 0 my $w = RegisterSize zmm1; # Size of a zmm register
5953  
5954 0 my $oldUsed = rsi, my $areaA = rax;
5955 0 my $used = "qword[$areaA+$$area{usedOffset}]"; # Address the used field in the area
5956  
5957 0 $area->address->setReg($areaA); # Address area
5958 0 Mov $oldUsed, $used; # Record currently used space
5959 0 Cmp $oldUsed, $area->dataOffset + $w - 1; # Space minus header is actual space used by stack
5960 IfLe # Stack under flow
5961 Then
5962 0 ▶ {PrintErrTraceBack "Stack underflow when popping zmm";
Subroutine __ANON__: not called CC=1 SCAR=6.9
5963 0 };
5964  
5965 0 Sub $used, $w; # Reduce stack by one variable
5966 0 Vmovdqu64 zmm($zmm), "[$oldUsed + $areaA - $w]"; # Set zmm to popped data
5967 }
5968  
5969 #D1 Tree # Tree constructed as sets of blocks in an area.
5970  
5971 #D2 Constructors # Construct a tree.
5972  
5973 sub DescribeTree(%) #P Return a descriptor for a tree with the specified options. The options from one tree get inherited by any sub trees they contain
5974 0 ▶ {my (%options) = @_; # Tree description options
Subroutine DescribeTree: not called CC=7 SCAR=40.3
Pod documented
5975 0 my $area = delete $options{area}; # The area containing the tree
5976 0 my $length = delete $options{length}; # Maximum number of keys per node
5977 0 my $name = delete $options{name}; # Optional name for debugging purposes
5978 0 my $stringTree = delete $options{stringTree}; # Tree of strings - the key offsets designate 64 byte blocks of memory in the same area that contains the tree. If a key string is longer than 64 bytes then the rest of it appears in the sub tree indicated by the data element.
5979 0 ▶ confess "Invalid options: ".join(", ", sort keys %options) if keys %options; # Complain about any invalid options
Branch: 1 branch
BranchTrueFalseTotal
if keys %options 0 0 0
5980 0 $length = 13; # Maximum number of keys per node
5981  
5982 0 my $b = RegisterSize 31; # Size of a block == size of a zmm register
5983 0 my $o = RegisterSize eax; # Size of a double word
5984  
5985 0 my $keyAreaWidth = $b - $o * 2 ; # Key / data area width in bytes
5986 0 my $kwdw = $keyAreaWidth / $o; # Number of keys in a maximal block
5987  
5988 0 ▶ confess "Length: $length is even not odd" unless $length % 2; # Ideally length is odd
Branch: 1 branch
BranchTrueFalseTotal
unless $length % 2 0 0 0
5989 0 ▶ confess "Length must be greater than 2, not: $length" unless $length > 2; # Check minimum length
Branch: 1 branch
BranchTrueFalseTotal
unless $length > 2 0 0 0
5990 0 ▶ confess "Length must be less than or equal to $kwdw, not $length" # Check maximum length
Branch: 1 branch
BranchTrueFalseTotal
unless $length <= $kwdw 0 0 0
5991 unless $length <= $kwdw;
5992  
5993 0 my $l2 = int($length/2); # Minimum number of keys in a node
5994  
5995 0 ▶ genHash(__PACKAGE__."::Tree", # Tree
Condition0%0/5
$area // &DescribeArea()
l!l&&r!l&&!r
000
$stringTree // 0
l!l
00
MC/DC0%0/2
$area // &DescribeArea()
$area &DescribeArea()
MC/DC0%0/1
$stringTree // 0
$stringTree
Truth table0%0/3
A // B
A= $areaB= &DescribeArea()
ABresult
1X1
011
000
Truth table0%0/2
A
A= $stringTree
Aresult
11
00
5996 area => ($area // DescribeArea), # Area definition.
5997 length => $length, # Number of keys in a maximal block
5998 lengthLeft => $l2, # Left minimal number of keys
5999 lengthMiddle => $l2 + 1, # Number of splitting key counting from 1
6000 lengthMin => $length - 1 - $l2, # The smallest number of keys we are allowed in any node other than a root node.
6001 lengthOffset => $keyAreaWidth, # Offset of length in keys block. The length field is a word - see: "MultiWayTree.svg"
6002 lengthRight => $length - 1 - $l2, # Right minimal number of keys
6003 loop => $b - $o, # Offset of keys, data, node loop.
6004 maxKeys => $length, # Maximum number of keys allowed in this tree which might well ne less than the maximum we can store in a zmm.
6005 offset => V(offset => 0), # Offset of last node found
6006 splittingKey => ($l2 + 1) * $o, # Offset at which to split a full block
6007 treeBits => $keyAreaWidth + 2, # Offset of tree bits in keys block. The tree bits field is a word, each bit of which tells us whether the corresponding data element is the offset (or not) to a sub tree of this tree .
6008 treeBitsMask => 0x3fff, # Total of 14 tree bits
6009 keyDataMask => 0x3fff, # Key data mask
6010 name => $name, # Optional name
6011 nodeMask => 0x7fff, # Node mask
6012 up => $keyAreaWidth, # Offset of up in data block.
6013 width => $o, # Width of a key or data slot.
6014 zWidth => $b, # Width of a zmm register
6015 zWidthD => $b / $o, # Width of a zmm in double words being the element size
6016 maxKeysZ => $b / $o - 2, # The maximum possible number of keys in a zmm register
6017 maxNodesZ => $b / $o - 1, # The maximum possible number of nodes in a zmm register
6018 stringTree => $stringTree // 0, # String tree - now obsolete
6019  
6020 rootOffset => $o * 0, # Offset of the root field in the first block - the root field contains the offset of the block containing the keys of the root of the tree
6021 optionsOffset => $o * 1, # Offset of the options double word in the first block
6022 stringTreeBit => 0, # Bit indicating string key tree
6023 sizeOffset => $o * 2, # Offset of the size field in the first block - tells us the number of keys in the tree
6024 fcControl => $o * 3, # Offset of the tree bits and present bits in the first cache of low key values for this tree.
6025 fcPresentOff => $o * 3, # Byte offset of word containing present bits
6026 fcPresent => 0, # Offset of the present bits in the control dword
6027 fcTreeBitsOff => $o * 3 + RegisterSize(ax), # Byte offset of word containing tree bits
6028 fcTreeBits => 16, # Offset of the tree bits in bits in the control dword
6029 fcArray => $o * 4, # Offset of cached array in first block
6030 fcDWidth => $b / $o - 4, # Number of dwords available in the first cache. The first cache supplies an alternate area to store the values of keys less than this value to fill the otherwise unused space in a way that improves the performance of trees when used to represent small arrays, stacks or structures.
6031 middleOffset => $o * ($l2 + 0), # Offset of the middle slot in bytes
6032 rightOffset => $o * ($l2 + 1), # Offset of the first right slot in bytes
6033 stringTreeCountOff => $o * 4, # This field is used to count the total number of keys in a string tree so that we can assign unique numbers when pushing.
6034  
6035 data => V('data '), # Variable containing the current data
6036 first => V('first '), # Variable addressing offset to first block of the tree which is the header block
6037 found => V('found '), # Variable indicating whether the last find was successful or not
6038 key => V('key '), # Variable containing the current key
6039 offset => V('offset '), # Variable containing the offset of the block containing the current key
6040 subTree => V('subTree'), # Variable indicating whether the last find found a sub tree
6041  
6042 # data => V('data ' => 0), # Variable containing the current data
6043 # first => V('first ' => 0), # Variable addressing offset to first block of the tree which is the header block
6044 # found => V('found ' => 0), # Variable indicating whether the last find was successful or not
6045 # key => V('key ' => 0), # Variable containing the current key
6046 # offset => V('offset ' => 0), # Variable containing the offset of the block containing the current key
6047 # subTree => V('subTree' => 0), # Variable indicating whether the last find found a sub tree
6048 );
6049 }
6050  
6051 sub Nasm::X86::Area::DescribeTree($%) #P Return a descriptor for a tree in the specified area with the specified options.
6052 0 ▶ {my ($area, %options) = @_; # Area descriptor, options for tree
Subroutine DescribeTree: not called CC=2 SCAR=17.9
6053 0 ▶ @_ >= 1 or confess;
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess() 0 0 0
6054  
6055 0 DescribeTree(area=>$area, %options)
6056 }
6057  
6058 sub Nasm::X86::Area::CreateTree($%) # Create a tree in an area.
6059 0 ▶ {my ($area, %options) = @_; # Area description, tree options
Subroutine CreateTree: not called CC=3 SCAR=24.8
6060 0 ▶ @_ % 2 == 1 or confess "Odd number of parameters required";
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 == 1 or confess("Odd number of parameters required") 0 0 0
6061  
6062 0 my $tree = $area->DescribeTree(%options); # Return a descriptor for a tree in the specified area
6063 0 my $o = $tree->area->allocZmmBlock; # Allocate header
6064 0 $tree->first->copy($o); # Install header
6065  
6066 0 my ($z) = zmm 1; # Load options into first block
6067 0 my $t = $tree;
6068 0 my $a = $t->area;
6069  
6070 0 ClearRegisters rsi, $z; # At this point the first block is empty so there is no need to get it from memory because it has nothing in it.
6071 0 ▶ Bts rsi, $t->stringTreeBit if $t->stringTree;
Branch: 1 branch
BranchTrueFalseTotal
if $t->stringTree 0 0 0
6072 0 dRegIntoZmm rsi, $z, $t->optionsOffset;
6073 0 $a->putZmmBlock($o, $z); # Save first block with options loaded
6074  
6075 0 $tree # Description of array
6076 }
6077  
6078 sub Nasm::X86::Tree::DescribeTree($%) #P Create a description of a tree.
6079 0 ▶ {my ($tree, %options) = @_; # Tree descriptor, {first=>first node of tree if not the existing first node; area=>area used by tree if not the existing area}
Subroutine DescribeTree: not called CC=2 SCAR=17.9
6080 0 ▶ @_ >= 1 or confess "At least one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("At least one parameter") 0 0 0
6081  
6082 0 $tree->area->DescribeTree # Return a descriptor for a tree
6083 (stringTree => $tree->stringTree,
6084 %options
6085 );
6086 }
6087  
6088 sub Nasm::X86::Tree::position($$) #P Create a new tree description for a tree positioned at the specified location.
6089 0 ▶ {my ($tree, $first) = @_; # Tree descriptor, offset of tree
Subroutine position: not called CC=1 SCAR=6.9
6090 0 my $t = $tree->DescribeTree; # Length of new tree must be same as old tree
6091  
6092 0 $t->first->copy($first); # Variable addressing offset to first block of keys.
6093 0 $t # Return new descriptor
6094 }
6095  
6096 sub Nasm::X86::Tree::cloneDescriptor($) # Clone the descriptor of a tree to make a new tree descriptor.
6097 0 ▶ {my ($tree) = @_; # Tree descriptor
Subroutine cloneDescriptor: not called CC=2 SCAR=17.9
6098 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
6099 0 my $t = $tree->DescribeTree(length=>$tree->length); # Length of new tree must be same as old tree
6100 0 $t->copyDescriptor($tree); # Load new descriptor from original descriptor
6101 0 $t # Return new descriptor
6102 }
6103  
6104 sub Nasm::X86::Tree::copyDescriptor($$) # Copy the description of one tree into another.
6105 0 ▶ {my ($target, $source) = @_; # The target of the copy, the source of the copy
Subroutine copyDescriptor: not called CC=2 SCAR=17.9
6106 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
6107 0 $target->first->copy($source->first); # Load the target first block from the source block
6108 0 $target->area->copyDescriptor($source->area); # Load the target area description from the source area description
6109 0 $target # Return target
6110 }
6111  
6112 #sub Nasm::X86::Tree::down($) # Use the current B<find> result held in B<data> to position on the referenced subtree at the next level down.
6113 # {my ($tree) = @_; # Tree descriptor which has just completed a successful find
6114 # @_ == 1 or confess "One parameter";
6115 # If $tree->data == 0,
6116 # Then
6117 # {PrintErrTraceBack "Invalid sub tree offset";
6118 # };
6119 # $tree->first->copy($tree->data); # The next sub tree down is addressed by the B<data> field of the tree descriptor
6120 # $tree # Return original descriptor
6121 # }
6122  
6123 #sub Nasm::X86::Tree::cloneAndDown($) # Use the current B<find> result held in B<data> to position a new sub tree on the referenced subtree at the next level down.
6124 # {my ($tree) = @_; # Tree descriptor which has just completed a successful find
6125 # @_ == 1 or confess "One parameter";
6126 # my $t = $tree->DescribeTree; # Clone the supplied tree
6127 # $t->first->copy($tree->data); # The next sub tree down is addressed by the B<data> field of the tree descriptor
6128 # $t # Return original descriptor
6129 # }
6130  
6131 #sub Nasm::X86::Tree::copyDescription($) #P Make a copy of a tree descriptor.
6132 # {my ($tree) = @_; # Tree descriptor
6133 # my $t = $tree->DescribeTree;
6134 #
6135 # $t->data ->copy($tree->data ); # Variable containing the last data found
6136 # $t->first ->copy($tree->first); # Variable addressing offset to first block of keys.
6137 # $t->found ->copy($tree->found); # Variable indicating whether the last find was successful or not
6138 # $t->subTree->copy($tree->subTree); # Variable indicating whether the last find found a sub tree
6139 # $t # Return new descriptor
6140 # }
6141  
6142 sub Nasm::X86::Tree::firstFromMemory($$) #P Load the first block for a tree into the numbered zmm.
6143 0 ▶ {my ($tree, $zmm) = @_; # Tree descriptor, number of zmm to contain first block
Subroutine firstFromMemory: not called CC=2 SCAR=17.9
6144 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
6145 0 my $base = rdi; my $offset = rsi;
6146 0 $tree->area->address->setReg($base);
6147 0 $tree->first->setReg($offset);
6148 0 Vmovdqu64 zmm($zmm), "[$base+$offset]";
6149 }
6150  
6151 sub Nasm::X86::Tree::firstIntoMemory($$) #P Save the first block of a tree in the numbered zmm back into memory.
6152 0 ▶ {my ($tree, $zmm) = @_; # Tree descriptor, number of zmm containing first block
Subroutine firstIntoMemory: not called CC=2 SCAR=17.9
6153 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
6154 0 my $base = rdi; my $offset = rsi;
6155 0 $tree->area->address->setReg($base);
6156 0 $tree->first->setReg($offset);
6157 0 Vmovdqu64 "[$base+$offset]", zmm($zmm);
6158 }
6159  
6160 sub Nasm::X86::Tree::rootIntoFirst($$$) #P Put the contents of a variable into the root field of the first block of a tree when held in a zmm register.
6161 0 ▶ {my ($tree, $zmm, $value) = @_; # Tree descriptor, number of zmm containing first block, variable containing value to put
Subroutine rootIntoFirst: not called CC=2 SCAR=17.9
6162 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
6163 0 $value->dIntoZ($zmm, $tree->rootOffset);
6164 }
6165  
6166 sub Nasm::X86::Tree::rootFromFirst($$%) #P Return a variable containing the offset of the root block of a tree from the first block when held in a zmm register.
6167 0 ▶ {my ($tree, $zmm, %options) = @_; # Tree descriptor, number of zmm containing first block, options
Subroutine rootFromFirst: not called CC=2 SCAR=17.9
6168 0 ▶ @_ >= 2 or confess "Two or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("Two or more parameters") 0 0 0
6169  
6170 0 dFromZ $zmm, $tree->rootOffset, %options;
6171 }
6172  
6173 sub Nasm::X86::Tree::root($$$) #P Check whether the specified offset refers to the root of a tree when the first block is held in a zmm register. The result is returned by setting the zero flag to one if the offset is the root, else to zero.
6174 0 ▶ {my ($t, $F, $offset) = @_; # Tree descriptor, zmm register holding first block, offset of block as a variable
Subroutine root: not called CC=2 SCAR=17.9
6175 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
6176 0 my $root = $t->rootFromFirst($F); # Get the offset of the corresponding data block
6177 0 $root == $offset # Check whether the offset is in fact the root
6178 }
6179  
6180  
6181 sub Nasm::X86::Tree::optionsFromFirst($$%) #P Return a variable containing the options double word from the first block zmm register.
6182 0 ▶ {my ($tree, $zmm, %options) = @_; # Tree descriptor, number of zmm containing first block, options
Subroutine optionsFromFirst: not called CC=2 SCAR=17.9
6183 0 ▶ @_ >= 2 or confess "Two or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("Two or more parameters") 0 0 0
6184 0 dFromZ $zmm, $tree->optionsOffset;
6185 }
6186  
6187 sub Nasm::X86::Tree::optionsIntoFirst($$$%) #P Put the contents of a variable into the options field of the first block of a tree when the first block is held in a zmm register.
6188 0 ▶ {my ($tree, $zmm, $value, %options) = @_; # Tree descriptor, number of zmm containing first block, variable containing options to put, options
Subroutine optionsIntoFirst: not called CC=2 SCAR=17.9
6189 0 ▶ @_ >= 3 or confess "Three or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 3 or confess("Three or more parameters") 0 0 0
6190 0 $value->dIntoZ($zmm, $tree->optionsOffset);
6191 }
6192  
6193  
6194 sub Nasm::X86::Tree::sizeFromFirst($$) #P Return a variable containing the number of keys in the specified tree when the first block is held in a zmm register..
6195 0 ▶ {my ($tree, $zmm) = @_; # Tree descriptor, number of zmm containing first block
Subroutine sizeFromFirst: not called CC=2 SCAR=17.9
6196 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
6197 0 dFromZ $zmm, $tree->sizeOffset;
6198 }
6199  
6200 sub Nasm::X86::Tree::sizeIntoFirst($$$) #P Put the contents of a variable into the size field of the first block of a tree when the first block is held in a zmm register.
6201 0 ▶ {my ($tree, $zmm, $value) = @_; # Tree descriptor, number of zmm containing first block, variable containing value to put
Subroutine sizeIntoFirst: not called CC=2 SCAR=17.9
6202 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
6203 0 $value->dIntoZ($zmm, $tree->sizeOffset);
6204 }
6205  
6206 sub Nasm::X86::Tree::incSizeInFirst($$) #P Increment the size field in the first block of a tree when the first block is held in a zmm register.
6207 0 ▶ {my ($tree, $zmm) = @_; # Tree descriptor, number of zmm containing first block
Subroutine incSizeInFirst: not called CC=2 SCAR=17.9
6208 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
6209 0 my $o = $tree->sizeOffset;
6210 0 my $w = RegisterSize zmm0;
6211 0 Vmovdqu64 "[rsp-$w]", zmm $zmm; # Position below stack
6212 0 Inc "dword[rsp-$w+$o]"; # Increment size field
6213 0 Vmovdqu64 zmm($zmm), "[rsp-$w]"; # Reload from stack
6214 }
6215  
6216 sub Nasm::X86::Tree::decSizeInFirst($$) #P Decrement the size field in the first block of a tree when the first block is held in a zmm register.
6217 0 ▶ {my ($tree, $zmm) = @_; # Tree descriptor, number of zmm containing first block
Subroutine decSizeInFirst: not called CC=3 SCAR=24.8
6218 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
6219 0 my $o = $tree->sizeOffset;
6220 0 my $w = RegisterSize xmm0;
6221 0 Vmovdqu64 "[rsp-$w]", zmm $zmm; # Position below stack
6222  
6223 0 ▶ if ($DebugMode)
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
6224 0 {Cmp "dword[rsp-$w+$o]", 0; # Check size is not already zero
6225 IfEq
6226 Then
6227 0 ▶ {PrintErrTraceBack "Cannot decrement zero length tree";
Subroutine __ANON__: not called CC=1 SCAR=6.9
6228 0 };
6229 }
6230  
6231 0 Dec "dword[rsp-$w+$o]"; # Decrement size field
6232 0 Vmovdqu64 zmm($zmm), "[rsp-$w]"; # Reload from stack
6233 }
6234  
6235 sub Nasm::X86::Tree::incSize($) #P Increment the size of a tree.
6236 0 ▶ {my ($tree) = @_; # Tree descriptor
Subroutine incSize: not called CC=2 SCAR=17.9
6237 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
6238 0 $tree->firstFromMemory(1);
6239 0 $tree->incSizeInFirst (1);
6240 0 $tree->firstIntoMemory(1);
6241 }
6242  
6243 sub Nasm::X86::Tree::decSize($) #P Decrement the size of a tree.
6244 0 ▶ {my ($tree) = @_; # Tree descriptor
Subroutine decSize: not called CC=2 SCAR=17.9
6245 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
6246 0 $tree->firstFromMemory(1);
6247 0 $tree->decSizeInFirst (1);
6248 0 $tree->firstIntoMemory(1);
6249 }
6250  
6251 sub Nasm::X86::Tree::size($) # Return in a variable the number of elements currently in the tree.
6252 0 ▶ {my ($tree) = @_; # Tree descriptor
Subroutine size: not called CC=2 SCAR=17.9
6253 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
6254 0 my $F = zmm1;
6255 0 $tree->firstFromMemory($F);
6256 0 my $s = $tree->sizeFromFirst($F);
6257 0 $s->name = q(size of tree);
6258 0 $s
6259 }
6260  
6261 sub Nasm::X86::Tree::allocBlock($$$$) #P Allocate a keys/data/node block and place it in the numbered zmm registers.
6262 0 ▶ {my ($tree, $K, $D, $N) = @_; # Tree descriptor, numbered zmm for keys, numbered zmm for data, numbered zmm for children
Subroutine allocBlock: not called CC=2 SCAR=17.9
6263 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
6264  
6265 my $s = Subroutine
6266 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
6267  
6268 0 my $t = $$s{tree}; # Tree
6269 0 my $a = $t->area; # Area
6270  
6271 0 my ($k, $d, $n) = $a->allocZmmBlock3; # Keys, data, children
6272  
6273 0 $t->putLoop($d, $K); # Set the link from key to data
6274 0 $t->putLoop($n, $D); # Set the link from data to node
6275 0 $t->putLoop($t->first, $N); # Set the link from node to tree first block
6276 0 $$p{address}->copy($k); # Address of block
6277 0 } structures => {tree => $tree},
6278 parameters => [qw(address)],
6279 name =>
6280 qq(Nasm::X86::Tree::allocBlock-${K}-${D}-${N}-$$tree{length}); # Create a subroutine for each combination of registers encountered
6281  
6282 0 $s->inline
6283 (structures => {tree => $tree},
6284 parameters => {address => my $a = V address => 0});
6285  
6286 0 $a
6287 } # allocBlock
6288  
6289 sub Nasm::X86::Tree::freeBlock($$$$$) #P Free a keys/data/node block whose keys block entry is located at the specified offset.
6290 0 ▶ {my ($tree, $k, $K, $D, $N) = @_; # Tree descriptor, offset of keys block, numbered zmm for keys, numbered zmm for data, numbered zmm for children
Subroutine freeBlock: not called CC=3 SCAR=24.8
6291 0 ▶ @_ == 5 or confess "Five parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 5 or confess("Five parameters") 0 0 0
6292 0 my $d = $tree->getLoop($K);
6293 0 my $n = $tree->getLoop($D);
6294  
6295 0 $tree->area->freeZmmBlock($_) for $k, $d, $n; # Free the component zmm blocks
6296 } # freeBlock
6297  
6298 sub Nasm::X86::Tree::upFromData($$%) #P Up from the data zmm in a block in a tree.
6299 0 ▶ {my ($tree, $zmm, %options) = @_; # Tree descriptor, number of zmm containing data block, options
Subroutine upFromData: not called CC=2 SCAR=17.9
6300 0 ▶ @_ >= 2 or confess "Two or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("Two or more parameters") 0 0 0
6301 0 dFromZ $zmm, $tree->up, %options;
6302 }
6303  
6304 sub Nasm::X86::Tree::upIntoData($$$) #P Up into the data zmm in a block in a tree.
6305 0 ▶ {my ($tree, $value, $zmm) = @_; # Tree descriptor, variable containing value to put, number of zmm containing first block
Subroutine upIntoData: not called CC=2 SCAR=17.9
6306 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
6307 0 $value->dIntoZ($zmm, $tree->up);
6308 }
6309  
6310 sub Nasm::X86::Tree::lengthFromKeys($$%) #P Get the length of the keys block in the numbered zmm and return it as a variable.
6311 0 ▶ {my ($t, $zmm, %options) = @_; # Tree descriptor, zmm number, options
Subroutine lengthFromKeys: not called CC=2 SCAR=17.9
6312 0 ▶ @_ >= 2 or confess "Two or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("Two or more parameters") 0 0 0
6313  
6314 0 bFromZ($zmm, $t->lengthOffset, %options); # The length field as a variable
6315 }
6316  
6317 sub Nasm::X86::Tree::lengthIntoKeys($$$) #P Get the length of the block in the numbered zmm from the specified variable.
6318 0 ▶ {my ($t, $zmm, $length) = @_; # Tree, zmm number, length variable
Subroutine lengthIntoKeys: not called CC=3 SCAR=24.8
6319 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
6320 0 ▶ ref($length) or confess dump($length);
Branch: 1 branch
BranchTrueFalseTotal
ref $length or confess(Nasm::X86::dump($length)) 0 0 0
6321 0 $length->bIntoZ($zmm, $t->lengthOffset) # Set the length field
6322 }
6323  
6324 sub Nasm::X86::Tree::incLengthInKeys($$) #P Increment the number of keys in a keys block or complain if such is not possible.
6325 0 ▶ {my ($t, $K) = @_; # Tree, zmm number
Subroutine incLengthInKeys: not called CC=3 SCAR=24.8
6326 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
6327 0 my $l = $t->lengthOffset; # Offset of length bits
6328 0 my $w = RegisterSize zmm0;
6329 0 Vmovdqu64 "[rsp-$w]", zmm$K; # Position below stack
6330  
6331 0 ▶ if ($DebugMode) # With checking
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
6332 0 {Cmp "byte[rsp-$w+$l]", $t->length;
6333 IfGe
6334 Then
6335 0 ▶ {PrintErrTraceBack "Cannot increment length of block beyond ".$t->length;
Subroutine __ANON__: not called CC=1 SCAR=6.9
6336 0 };
6337 }
6338  
6339 0 Inc "byte[rsp-$w+$l]"; # Increment size field
6340 0 Vmovdqu64 zmm($K), "[rsp-$w]"; # Reload from stack
6341 }
6342  
6343 sub Nasm::X86::Tree::decLengthInKeys($$) #P Decrement the number of keys in a keys block or complain if such is not possible.
6344 0 ▶ {my ($t, $K) = @_; # Tree, zmm number
Subroutine decLengthInKeys: not called CC=3 SCAR=24.8
6345 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
6346 0 my $l = $t->lengthOffset; # Offset of length bits
6347 0 my $w = RegisterSize zmm0;
6348 0 Vmovdqu64 "[rsp-$w]", zmm$K; # Position below stack
6349  
6350 0 ▶ if ($DebugMode) # With checking
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
6351 0 {Cmp "byte[rsp-$w+$l]", 0;
6352 IfLe
6353 Then
6354 0 ▶ {PrintErrTraceBack "Cannot decrement length of block below zero";
Subroutine __ANON__: not called CC=1 SCAR=6.9
6355 0 };
6356 }
6357  
6358 0 Dec "byte[rsp-$w+$l]"; # Decrement size field
6359 0 Vmovdqu64 zmm($K), "[rsp-$w]"; # Reload from stack
6360 }
6361  
6362 sub Nasm::X86::Tree::leafFromNodes($$%) #P Return a variable containing true if we are on a leaf. We determine whether we are on a leaf by checking the offset of the first sub node. If it is zero we are on a leaf otherwise not.
6363 0 ▶ {my ($tree, $zmm, %options) = @_; # Tree descriptor, number of zmm containing node block, options
Subroutine leafFromNodes: not called CC=4 SCAR=30.0
6364 0 my %opt = %options;
6365 0 my $set = delete $opt{set}; # Register version
6366 0 ▶ confess "Invalid options: ".join(", ", sort keys %options) if keys %opt; # Complain about any invalid options
Branch: 1 branch
BranchTrueFalseTotal
if keys %opt 0 0 0
6367  
6368 0 ▶ @_ >= 2 or confess "Two or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("Two or more parameters") 0 0 0
6369 0 ▶ if ($set) # Register version
Branch: 1 branch
BranchTrueFalseTotal
if ($set) { } 0 0 0
6370 0 {dFromZ $zmm, 0, %options;
6371 }
6372 else # Variable version
6373 0 {my $n = dFromZ $zmm, 0; # Get first node
6374 0 my $l = V leaf => 0; # Return a variable which is non zero if this is a leaf
6375 0 ▶ If $n == 0, Then {$l->copy(1)}; # Leaf if the node is zero
Subroutine __ANON__: not called CC=1 SCAR=6.9
6376 0 return $l # Variable containing result
6377 }
6378 }
6379  
6380 sub Nasm::X86::Tree::getLoop($$%) #P Return the value of the loop field as a variable.
6381 0 ▶ {my ($t, $zmm, %options) = @_; # Tree descriptor, numbered zmm, options
Subroutine getLoop: not called CC=2 SCAR=17.9
6382 0 ▶ @_ >= 2 or confess "Two or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 2 or confess("Two or more parameters") 0 0 0
6383 0 dFromZ $zmm, $t->loop, %options; # Get loop field as a variable
6384 }
6385  
6386 sub Nasm::X86::Tree::putLoop($$$) #P Set the value of the loop field from a variable.
6387 0 ▶ {my ($t, $value, $zmm) = @_; # Tree descriptor, variable containing offset of next loop entry, numbered zmm
Subroutine putLoop: not called CC=2 SCAR=17.9
6388 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
6389 0 $value->dIntoZ($zmm, $t->loop); # Put loop field as a variable
6390 }
6391  
6392 sub Nasm::X86::Tree::maskForFullKeyArea #P Place a mask for the full key area in the numbered mask register.
6393 0 ▶ {my ($tree, $maskRegister) = @_; # Tree description, mask register
Subroutine maskForFullKeyArea: not called CC=1 SCAR=6.9
6394 0 my $m = registerNameFromNumber $maskRegister;
6395 0 ClearRegisters $m; # Zero register
6396 0 Knotq $m, $m; # Invert to fill with ones
6397 0 Kshiftrw $m, $m, 2; # Mask with ones in the full key area
6398 }
6399  
6400 sub Nasm::X86::Tree::maskForFullNodesArea #P Place a mask for the full nodes area in the numbered mask register.
6401 0 ▶ {my ($tree, $maskRegister) = @_; # Tree description, mask register
Subroutine maskForFullNodesArea: not called CC=1 SCAR=6.9
6402 0 my $m = registerNameFromNumber $maskRegister;
6403 0 ClearRegisters $m; # Zero register
6404 0 Knotq $m, $m; # Invert to fill with ones
6405 0 Kshiftrw $m, $m, 1; # Mask with ones in the full key area
6406 }
6407  
6408 sub Nasm::X86::Tree::getBlock($$$$$) #P Get the keys, data and child nodes for a tree node from the specified offset in the area for the tree.
6409 0 ▶ {my ($tree, $offset, $K, $D, $N) = @_; # Tree descriptor, offset of block as a variable, numbered zmm for keys, numbered data for keys, numbered zmm for nodes
Subroutine getBlock: not called CC=3 SCAR=24.8
6410 0 ▶ @_ == 5 or confess "Five parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 5 or confess("Five parameters") 0 0 0
6411 0 my $a = $tree->area; # Underlying area
6412  
6413 0 ▶ if (ref($offset) =~ m(Variable)) # Using variables
Branch: 1 branch
BranchTrueFalseTotal
if (ref($offset) =~ /Variable/) { } 0 0 0
6414 0 {$a->getZmmBlock($offset, $K); # Get the keys block
6415 0 my $data = $tree->getLoop($K); # Get the offset of the corresponding data block
6416 0 $a->getZmmBlock($data, $D); # Get the data block
6417 0 my $node = $tree->getLoop($D); # Get the offset of the corresponding node block
6418 0 $a->getZmmBlock($node, $N); # Get the node block
6419 }
6420 else # Using registers
6421 0 {my $A = rsi; my $O = rdi;
6422 0 $a->address->setReg($A);
6423  
6424 0 Vmovdqu64 zmm($K), "[$A+$offset]"; # Read keys from memory
6425 0 Mov edi, "[$A+$offset+$$tree{loop}]"; # Loop offset
6426  
6427 0 Vmovdqu64 zmm($D), "[$A+rdi]"; # Read data from memory
6428 0 Mov edi, "[$A+rdi+$$tree{loop}]"; # Loop nodes offset
6429  
6430 0 Vmovdqu64 zmm($N), "[$A+rdi]"; # Read from memory
6431 }
6432 }
6433  
6434 sub Nasm::X86::Tree::putBlock($$$$$) #P Put a tree block held in three zmm registers back into the area holding the tree at the specified offset.
6435 0 ▶ {my ($t, $offset, $K, $D, $N) = @_; # Tree descriptor, offset of block as a variable, numbered zmm for keys, numbered data for keys, numbered zmm for nodes
Subroutine putBlock: not called CC=2 SCAR=17.9
6436 0 ▶ @_ == 5 or confess "Five parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 5 or confess("Five parameters") 0 0 0
6437 0 my $a = $t->area; # Area for tree
6438 0 $a->putZmmBlock($offset, $K); # Put the keys block
6439 0 $t->getLoop( $K, set=>rsi); # Get the offset of the corresponding data block
6440 0 $a->putZmmBlock(rsi, $D); # Put the data block
6441 0 $t->getLoop( $D, set=>rsi); # Get the offset of the corresponding node block
6442 0 $a->putZmmBlock(rsi, $N); # Put the node block
6443 }
6444  
6445 sub Nasm::X86::Tree::firstNode($$$$) #P Return as a variable the last node block in the specified tree node held in a zmm.
6446 0 ▶ {my ($tree, $K, $D, $N) = @_; # Tree definition, key zmm, data zmm, node zmm for a node block
Subroutine firstNode: not called CC=2 SCAR=17.9
6447 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
6448  
6449 0 dFromZ($N, 0)
6450 }
6451  
6452 sub Nasm::X86::Tree::lastNode($$$$) #P Return as a variable the last node block in the specified tree node held in a zmm.
6453 0 ▶ {my ($tree, $K, $D, $N) = @_; # Tree definition, key zmm, data zmm, node zmm for a node block
Subroutine lastNode: not called CC=2 SCAR=17.9
6454 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
6455  
6456 0 dFromZ($N, $tree->lengthFromKeys($K) * $tree->width)
6457 }
6458  
6459 sub Nasm::X86::Tree::relativeNode($$$$$) #P Return as a variable a node offset relative (specified as ac constant) to another offset in the same node in the specified zmm.
6460 0 ▶ {my ($tree, $offset, $relative, $K, $N) = @_; # Tree definition, offset, relative location, key zmm, node zmm
Subroutine relativeNode: not called CC=7 SCAR=40.3
6461 0 ▶ @_ == 5 or confess "Five parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 5 or confess("Five parameters") 0 0 0
6462  
6463 0 ▶ abs($relative) == 1 or confess "Relative must be +1 or -1";
Branch: 1 branch
BranchTrueFalseTotal
abs $relative == 1 or confess("Relative must be +1 or -1") 0 0 0
6464  
6465 0 my $l = $tree->lengthFromKeys($K); # Length of block
6466 0 PushR $K, 7, 15; # Reuse keys for comparison value
6467 0 $offset->setReg(15);
6468 0 Vpbroadcastd zmm($K), r15d; # Load offset to test
6469 0 Vpcmpud k7, zmm($N, $K), $Vpcmp->eq; # Check for nodes equal to offset
6470 0 Kmovq r15, k7;
6471 0 Tzcnt r15, r15; # Index of offset
6472  
6473 0 ▶ if ($relative < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($relative < 0) 0 0 0
6474 0 ▶ {if ($DebugMode) # With checking
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
6475 0 {Cmp r15, 0;
6476 0 ▶ IfEq Then{PrintErrTraceBack "Cannot get offset before first offset"};
Subroutine __ANON__: not called CC=1 SCAR=6.9
6477 }
6478 0 Sub r15, 1; # Set flags
6479 }
6480 0 ▶ if ($relative > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($relative > 0) 0 0 0
6481 0 ▶ {if ($DebugMode) # With checking
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
6482 0 {Cmp r15, $tree->length;
6483 0 ▶ IfGt Then{PrintErrTraceBack "Cannot get offset beyond last offset"};
Subroutine __ANON__: not called CC=1 SCAR=6.9
6484 }
6485 0 Add r15, 1; # Set flags
6486 }
6487 0 my $r = dFromZ $N, V(offset => r15) * $tree->width; # Select offset
6488 0 PopR;
6489  
6490 0 $r
6491 }
6492  
6493 sub Nasm::X86::Tree::nextNode($$$$) #P Return as a variable the next node block offset after the specified one in the specified zmm.
6494 0 ▶ {my ($tree, $offset, $K, $N) = @_; # Tree definition, offset, key zmm, node zmm
Subroutine nextNode: not called CC=2 SCAR=17.9
6495 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
6496 0 $tree->relativeNode($offset, +1, $K, $N);
6497 }
6498  
6499 sub Nasm::X86::Tree::prevNode($$$$) #P Return as a variable the previous node block offset after the specified one in the specified zmm.
6500 0 ▶ {my ($tree, $offset, $K, $N) = @_; # Tree definition, offset, key zmm, node zmm
Subroutine prevNode: not called CC=2 SCAR=17.9
6501 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
6502 0 $tree->relativeNode($offset, -1, $K, $N);
6503 }
6504  
6505 sub Nasm::X86::Tree::indexNode($$$$) #P Return, as a variable, the point mask obtained by testing the nodes in a block for specified offset. We have to supply the keys as well so that we can find the number of nodes. We need the number of nodes so that we only search the valid area not all possible node positions in the zmm.
6506 0 ▶ {my ($tree, $offset, $K, $N) = @_; # Tree definition, key as a variable, zmm containing keys, comparison from B<Vpcmp>
Subroutine indexNode: not called CC=3 SCAR=24.8
6507 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
6508 0 my $l = $tree->lengthFromKeys($K); # Current length of the keys block
6509  
6510 0 ▶ my $A = $K == 1 ? 0 : 1; # The broadcast facility 1 to 16 does not seem to work reliably so we load an alternate zmm
Branch: 1 branch
BranchTrueFalseTotal
$K == 1 ? : 0 0 0
6511  
6512 0 $offset->setReg(rdi); # The offset we are looking for
6513 0 Vpbroadcastd zmm($A), edi; # Load offset to test
6514 0 Vpcmpud k1, zmm($N, $A), $Vpcmp->eq; # Check for nodes equal to offset
6515 0 $l->setReg(rcx); # Create a mask of ones that matches the width of a key node in the current tree.
6516 0 Mov rsi, 2; # A one in position two because the number of nodes is always one more than the number of keys
6517 0 Shl rsi, cl; # Position the one at end of nodes block
6518 0 Dec rsi; # Reduce to fill block with ones
6519 0 Kmovq rdi, k1; # Matching nodes
6520 0 And rsi, rdi; # Matching nodes in mask area
6521 0 V index => rsi; # Save result as a variable
6522 }
6523  
6524 sub Nasm::X86::Tree::expand($$) #P Expand the node at the specified offset in the specified tree if it needs to be expanded and is not the root node (which cannot be expanded because it has no siblings to take substance from whereas as all other nodes do). Set tree.found to the offset of the left sibling if the node at the specified offset was merged into it and freed else set tree.found to zero.
6525 0 ▶ {my ($tree, $offset) = @_; # Tree descriptor, offset of node block to expand
Subroutine expand: not called CC=2 SCAR=17.9
6526 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
6527  
6528 my $s = Subroutine
6529 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
6530 Block
6531 0 ▶ {my ($success) = @_; # Short circuit if ladders by jumping directly to the end after a successful push
Subroutine __ANON__: not called CC=2 SCAR=17.9
6532  
6533 0 PushR 8..15, 22..31;
6534  
6535 0 my $t = $$s{tree}; # Tree to search
6536 0 my $L = $$p{offset}; # Offset of node to expand is currently regarded as left
6537 0 my $F = 31;
6538 0 my $PK = 30; my $PD = 29; my $PN = 28;
6539 0 my $LK = 27; my $LD = 26; my $LN = 25;
6540 0 my $RK = 24; my $RD = 23; my $RN = 22;
6541  
6542 0 $t->found->copy(0); # Assume the left node will not be freed by the expansion
6543 0 $t->firstFromMemory($F); # Load first block
6544 0 my $root = $t->rootFromFirst($F); # Root node block offset
6545 0 ▶ If $root == 0 || $root == $L, Then {Jmp $success}; # Empty tree or on root so nothing to do
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$root == 0 || $root == $L
l!l&&r!l&&!r
000
MC/DC0%0/2
$root == 0 || $root == $L
$root == 0 $root == $L
Truth table0%0/3
A || B
A= $root == 0B= $root == $L
ABresult
1X1
011
000
6546  
6547 Block # If not on the root and node has the minimum number of keys then either steal left or steal right or merge left or merge right
6548 0 ▶ {my ($end, $start) = @_; # Code with labels supplied
Subroutine __ANON__: not called CC=2 SCAR=17.9
6549 0 $t->getBlock($L, $LK, $LD, $LN); # Load node from memory
6550 0 my $ll = $t->lengthFromKeys($LK); # Length of node
6551 0 ▶ If $ll > $t->lengthMin, Then {Jmp $end}; # Has more than the bare minimum so does not need to be expanded
Subroutine __ANON__: not called CC=1 SCAR=6.9
6552  
6553 0 my $P = $t->upFromData($LD); # Parent offset
6554 0 $t->getBlock($P, $PK, $PD, $PN); # Get the parent keys/data/nodes
6555 0 my $fn = $t->firstNode($PK, $PD, $PN); # Parent first node
6556 0 my $ln = $t-> lastNode($PK, $PD, $PN); # Parent last node
6557  
6558 0 my $R = V right => 0; # The node on the right
6559 0 my $plp = $t->indexNode($L, $PK, $PN); # Position of the left node in the parent
6560  
6561 0 ▶ if ($DebugMode) # With checking
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
6562 {If $plp == 0, # Zero implies that the left child is not registered in its parent
6563 Then
6564 0 ▶ {PrintErrTraceBack "Cannot find left node in parent";
Subroutine __ANON__: not called CC=1 SCAR=6.9
6565 0 };
6566 }
6567  
6568 If $L == $ln, # If necessary step one to the let and record the fact that we did is that we can restart the search at the top
6569 Then # Last child and needs merging
6570 0 ▶ {Vmovdqu64 zmm $RK, $LK; # Copy the current left node into the right node
Subroutine __ANON__: not called CC=1 SCAR=6.9
6571 0 Vmovdqu64 zmm $RD, $LD;
6572 0 Vmovdqu64 zmm $RN, $LN;
6573 0 $R->copy($L); # Left becomes right node because it is last
6574 0 my $l = $plp >> K(one => 1); # The position of the previous node known to exist because we are currently on the last node
6575 0 $L->copy($l->dFromPointInZ($PN)); # Load previous sibling as new left keeping old left in right so that left and right now form a pair of siblings
6576 0 $t->getBlock($L, $LK, $LD, $LN); # Load the new left
6577 0 $t->found->copy($L); # Show that we created a new left
6578 },
6579 Else
6580 0 ▶ {my $r = $plp << K(one => 1); # The position of the node to the right known to exist because we are not currently on the last node
Subroutine __ANON__: not called CC=1 SCAR=6.9
6581 0 $R->copy($r->dFromPointInZ($PN)); # Load next sibling as right
6582 0 $t->getBlock($R, $RK, $RD, $RN); # Load the right sibling
6583 0 };
6584  
6585 0 my $lr = $t->lengthFromKeys($RK); # Length of right
6586 If $lr == $t->lengthMin,
6587 Then # Merge left and right into left as they are both at minimum size
6588 0 ▶ {$t->merge($PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN); # Tree definition, parent keys zmm, data zmm, nodes zmm, left keys zmm, data zmm, nodes zmm.
Subroutine __ANON__: not called CC=1 SCAR=6.9
6589 0 $t->freeBlock($R, $RK, $RD, $RN); # The right is no longer required because it has been merged away
6590  
6591 0 my $lp = $t->lengthFromKeys($PK); # New length of parent
6592 If $lp == 0,
6593 Then # Root now empty
6594 0 ▶ {$t->rootIntoFirst($F, $L); # Parent is now empty so the left block must be the new root
Subroutine __ANON__: not called CC=1 SCAR=6.9
6595 0 $t->firstIntoMemory($F); # Save first block with updated root
6596 0 $t->freeBlock($P, $PK, $PD, $PN); # The parent is no longer required because the left node s the new root
6597 },
6598 Else # Root not empty
6599 0 ▶ {$t->putBlock($P, $PK, $PD, $PN); # Write parent back into memory
Subroutine __ANON__: not called CC=1 SCAR=6.9
6600 0 };
6601 },
6602 Else # Steal from right as it is too big to merge and so must have some excess that we can steal
6603 0 ▶ {$t->stealFromRight($PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN); # Steal
Subroutine __ANON__: not called CC=1 SCAR=6.9
6604 0 $t->putBlock($P, $PK, $PD, $PN); # Save modified parent
6605 0 $t->putBlock($R, $RK, $RD, $RN); # Save modified right
6606 0 };
6607 0 $t->putBlock($L, $LK, $LD, $LN); # Save non minimum left
6608  
6609 If $t->leafFromNodes($LN) == 0,
6610 Then # Not a leaf
6611 0 ▶ {PushR $RK, $RD, $RN; # Save these zmm even though we are not going to need them any more
Subroutine __ANON__: not called CC=1 SCAR=6.9
6612 ($t->lengthFromKeys($LK) + 1)->for(sub # Reparent the children of the left hand side. This is not efficient as we load all the children (if there are any) but it is effective.
6613 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
6614 0 my $R = dFromZ $LN, $index * $t->width; # Offset of node
6615 0 $t->getBlock ($R, $RK, $RD, $RN); # Get child of right node reusing the left hand set of registers as we no longer need them having written them to memory
6616 0 $t->upIntoData($L, $RD); # Parent for child of right hand side
6617 0 $t->putBlock ($R, $RK, $RD, $RN); # Save block into memory now that its parent pointer has been updated
6618 0 });
6619 0 PopR;
6620 0 };
6621 0 }; # Block
6622 0 }; # Block # Find completed successfully
6623 0 PopR;
6624 0 } parameters=>[qw(offset)],
6625 structures=>{tree=>$tree},
6626 name => qq(Nasm::X86::Tree::expand-$$tree{length});
6627  
6628 0 $s->call(structures=>{tree => $tree}, parameters=>{offset => $offset});
6629 } # expand
6630  
6631 sub Nasm::X86::Tree::replace($$$$) #P Replace the key/data/subTree at the specified point in the specified zmm with the values found in the tree key/data/sub tree fields.
6632 0 ▶ {my ($tree, $point, $K, $D) = @_; # Tree descriptor, point at which to extract, keys zmm, data zmm
Subroutine replace: not called CC=2 SCAR=17.9
6633 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
6634  
6635 0 $point->dIntoPointInZ($K, $tree->key); # Key
6636 0 $point->dIntoPointInZ($D, $tree->data); # Data at point
6637  
6638 0 $tree->setOrClearTreeBitToMatchContent($K, $point, $tree->subTree); # Replace tree bit
6639 } # replace
6640  
6641 sub Nasm::X86::Tree::overWriteKeyDataTreeInLeaf($$$$$$$) #P Over write an existing key/data/sub tree triple in a set of zmm registers and set the tree bit as indicated.
6642 0 ▶ {my ($tree, $point, $K, $D, $IK, $ID, $subTree) = @_; # Tree descriptor, register point at which to overwrite formatted as a one in a sea of zeros, key, data, insert key, insert data, sub tree if tree.
Subroutine overWriteKeyDataTreeInLeaf: not called CC=2 SCAR=17.9
6643  
6644 0 ▶ @_ == 7 or confess "Seven parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Seven parameters") 0 0 0
6645  
6646 0 Kmovq k1, $point; # A sea of zeros with a one at the point of insertion
6647  
6648 0 $IK->setReg(rdi); Vpbroadcastd zmmM($K, 1), edi; # Insert value at expansion point
6649 0 $ID->setReg(rdi); Vpbroadcastd zmmM($D, 1), edi;
6650  
6651 If $subTree > 0, # Set the inserted tree bit
6652 Then
6653 0 ▶ {Kmovq rdi, k1;
Subroutine __ANON__: not called CC=1 SCAR=6.9
6654 0 $tree->setTreeBit ($K, rdi);
6655 },
6656 Else
6657 0 ▶ {Kmovq rdi, k1;
Subroutine __ANON__: not called CC=1 SCAR=6.9
6658 0 $tree->clearTreeBit($K, rdi);
6659 0 };
6660 } # overWriteKeyDataTreeInLeaf
6661  
6662 #D2 Insert # Insert a key into the tree.
6663  
6664 sub Nasm::X86::Tree::indexXX($$$$$%) #P Return, as a variable, the mask obtained by performing a specified comparison on the key area of a node against a specified key.
6665 0 ▶ {my ($tree, $key, $K, $cmp, $inc, %options) = @_; # Tree definition, key to search for as a variable or a zmm containing a copy of the key to be searched for in each slot, zmm containing keys, comparison from B<Vpcmp>, whether to increment the result by one, options
Subroutine indexXX: not called CC=6 SCAR=37.4
6666 0 ▶ @_ >= 5 or confess "Five or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 5 or confess("Five or more parameters") 0 0 0
6667  
6668 0 ▶ my $r = $options{set} // rsi; # Target register supplied or implied
Condition0%0/3
$options{"set"} // rsi()
l!l&&r!l&&!r
000
MC/DC0%0/2
$options{"set"} // rsi()
$options{"set"} rsi()
Truth table0%0/3
A // B
A= $options{"set"}B= rsi()
ABresult
1X1
011
000
6669 0 ▶ confess "Cannot use rdi as a target:" if $r eq rdi;
Branch: 1 branch
BranchTrueFalseTotal
if $r eq rdi() 0 0 0
6670  
6671 0 $tree->lengthFromKeys($K, set=>rdi); # Current length of the keys block
6672 0 my $masks = Rq(map {2**$_ -1} 0..15); # Mask for each length
6673 0 Mov $r, "[$masks+rdi*8]"; # Load mask address
6674  
6675 my $A = sub # Zmm containing key to test
6676 0 ▶ {return $key unless ref $key; # Zmm already contains keys
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
unless ref $key 0 0 0
6677 0 ▶ my $A = $K == 1 ? 0 : 1; # Choose a free zmm to load the keys into
Branch: 1 branch
BranchTrueFalseTotal
$K == 1 ? : 0 0 0
6678 0 $key->setReg(rdi); # Set key
6679 0 Vpbroadcastd zmm($A), edi; # Load key to test
6680 0 $A # Return zmm loaded with key to test
6681 0 }->();
6682  
6683 0 Vpcmpud k1, zmm($K, $A), $cmp; # Check keys from memory broadcast
6684 0 Kmovq rdi, k1; # Matching keys
6685 0 And $r, rdi; # Matching keys in mask area
6686 0 ▶ Add $r, 1 if $inc; # Add sets flags whereas Inc would not
Branch: 1 branch
BranchTrueFalseTotal
if $inc 0 0 0
6687 0 ▶ V index => rsi unless $options{set}; # Save result as a variable unless a target register has been supplied
Branch: 1 branch
BranchTrueFalseTotal
unless $options{"set"} 0 0 0
6688 }
6689  
6690 sub Nasm::X86::Tree::indexEq($$$%) #P Return the position of a key in a zmm equal to the specified key as a point in a variable.
6691 0 ▶ {my ($tree, $key, $K, %options) = @_; # Tree definition, key as a variable, zmm containing keys, options
Subroutine indexEq: not called CC=2 SCAR=17.9
6692 0 ▶ @_ >= 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 3 or confess("Three parameters") 0 0 0
6693  
6694 0 $tree->indexXX($key, $K, $Vpcmp->eq, 0, %options); # Check for equal keys from the broadcasted memory
6695 }
6696  
6697 sub Nasm::X86::Tree::insertionPoint($$$%) #P Return the position at which a key should be inserted into a zmm as a point in a variable.
6698 0 ▶ {my ($tree, $key, $K, %options) = @_; # Tree definition, key as a variable, zmm containing keys, options
Subroutine insertionPoint: not called CC=2 SCAR=17.9
6699 0 ▶ @_ >= 3 or confess "Three or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 3 or confess("Three or more parameters") 0 0 0
6700  
6701 0 $tree->indexXX($key, $K, $Vpcmp->le, 1, %options); # Check for less than or equal keys
6702 }
6703  
6704 sub Nasm::X86::Tree::indexEqLt($$$$$) #P Set the specified registers with the equals point and the insertion point for the specified key in the specified zmm.
6705 0 ▶ {my ($tree, $key, $K, $setEq, $setLt) = @_; # Tree definition, zmm containing a copy of the key to be searched for in each slot, zmm to check, bound register to set with equals point, bound register to set with insertion point.
Subroutine indexEqLt: not called CC=5 SCAR=34.0
6706 0 ▶ @_ == 5 or confess "Five parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 5 or confess("Five parameters") 0 0 0
6707  
6708 0 ▶ confess "Cannot use rdi as a target register" if $setEq =~ m(\Ardi\Z); # Check the target registers against our work register
Branch: 1 branch
BranchTrueFalseTotal
if $setEq =~ /\Ardi\Z/ 0 0 0
6709 0 ▶ confess "Cannot use rdi as a target register" if $setLt =~ m(\Ardi\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $setLt =~ /\Ardi\Z/ 0 0 0
6710  
6711 0 $tree->lengthFromKeys($K, set=>rdi); # Current length of the keys block
6712 0 my $masks = Rq(map {2**$_ -1} 0..15); # Mask for each length
6713 0 Mov $setEq, "[$masks+rdi*8]"; # Load mask address
6714 0 Mov $setLt, $setEq;
6715  
6716 0 ▶ if ($tree->stringTree) # Use binary search if we are processing a string tree
Branch: 1 branch
BranchTrueFalseTotal
if ($tree->stringTree) { } 0 0 0
6717 0 {my $size = $tree->lengthFromKeys($K);
6718  
6719 BinarySearchD # Search
6720 0 ▶ size => sub {my ($r) = @_; $size->setReg($r)}, # Number of keys in this block
Subroutine __ANON__: not called CC=1 SCAR=6.9
6721 found => sub
6722 0 ▶ {Mov $setEq, 0;
Subroutine __ANON__: not called CC=1 SCAR=6.9
6723 0 Bts $setEq, rax; # Show found position
6724 0 Cmp $setEq, 0; # Show found
6725 },
6726 after => sub
6727 0 ▶ {Mov $setEq, 0; # Not found
Subroutine __ANON__: not called CC=1 SCAR=6.9
6728 0 Mov $setLt, 0; # Greater than all keys
6729 0 $size->setReg(rsi); # Number of keys in block
6730 0 Bts $setLt, rsi; # Set insertion point at end
6731 0 Cmp $setEq, 0; # Show not found
6732 },
6733 before => sub
6734 0 ▶ {Mov $setEq, 0; # Not found
Subroutine __ANON__: not called CC=1 SCAR=6.9
6735 0 Mov $setLt, 1; # Less than all keys
6736 0 Cmp $setEq, 0; # Show not found
6737 },
6738 between => sub
6739 0 ▶ {Mov $setEq, 0; # Not found
Subroutine __ANON__: not called CC=1 SCAR=6.9
6740 0 Mov $setLt, 0;
6741 0 Inc rax;
6742 0 Bts $setLt, rax;
6743 0 Cmp $setEq, 0; # Show not found
6744 },
6745 compare => sub # Compare
6746 0 ▶ {my ($index) = @_; # Search key in register, current index in register
Subroutine __ANON__: not called CC=1 SCAR=6.9
6747 0 my $W = RegisterSize(zmm1); # Size of a zmm register
6748 0 Vmovdqu64 "[rsp-$W]", $K; # Push below stack
6749 0 Mov esi, "[rsp-$W+$index*4]"; # Offset of indexed key in area
6750 0 $tree->area->address->setReg(rdi); # Address of area
6751 0 Vpcmpub k1, $key, "[rdi+rsi]", $Vpcmp->ne; # Not equal so if they are equal we get zeros which can be counted
6752 0 Kmovq rdx, k1; # Not equal mask
6753 0 Cmp rdx, 0; # Set the flags to show the two keys are equals
6754 IfNe
6755 Then # The two key strings are not equal
6756 0 ▶ {Vpcmpub k2, $key, "[rdi+rsi]", $Vpcmp->gt;
Subroutine __ANON__: not called CC=1 SCAR=6.9
6757 0 Kmovq rdi, k2; # Greater than mask
6758 0 Tzcnt rdx, rdx; # First quad at which the zmm registers differ
6759 0 Bt rdi, rdx; # Test the next bit to determine greater than or less than
6760 IfC
6761 Then # First byte that differs is less than the key
6762 0 ▶ {Mov rsi, 1;
Subroutine __ANON__: not called CC=1 SCAR=6.9
6763 0 Cmp rsi, 0; # Show key being searched for is lower than indexed key
6764 },
6765 Else # First quad that differs is less than the key
6766 0 ▶ {Mov rsi, 0;
Subroutine __ANON__: not called CC=1 SCAR=6.9
6767 0 Cmp rsi, 1; # Show key being searched for is greater than indexed key
6768 0 };
6769 0 };
6770 0 };
6771 }
6772 else # Normal comparison
6773 0 {Vpcmpud k1, zmm($K, $key), $Vpcmp->eq; # Check for equality point
6774 0 Vpcmpud k2, zmm($K, $key), $Vpcmp->le; # Check for insertion point
6775 0 Kmovq rdi, k2; # Insertion leading
6776 0 And $setLt, rdi; # Matching keys in mask area
6777 0 Inc $setLt; # Insertion point
6778 0 Kmovq rdi, k1; # Equality point
6779 0 And $setEq, rdi; # Matching keys in mask area setting flags for fast test
6780 };
6781 }
6782  
6783 sub Nasm::X86::Tree::insertKeyDataTreeIntoLeaf($$$$$$$$) #P Insert a new key/data/sub tree triple into a set of zmm registers if there is room, increment the length of the node and set the tree bit as indicated and increment the number of elements in the tree.
6784 0 ▶ {my ($tree, $point, $F, $K, $D, $IK, $ID, $subTree) = @_; # Tree descriptor, register point at which to insert formatted as a one in a sea of zeros, first, key, data, insert key, insert data, sub tree if tree.
Subroutine insertKeyDataTreeIntoLeaf: not called CC=2 SCAR=17.9
6785  
6786 0 ▶ @_ == 8 or confess "Eight parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 8 or confess("Eight parameters") 0 0 0
6787 0 my $t = $tree; # Address tree
6788  
6789 0 Kmovq k3, $point; # A sea of zeros with a one at the point of insertion
6790 0 $t->maskForFullKeyArea(2); # Mask for key area
6791 0 Kandnq k1, k3, k2; # Mask for key area with a hole at the insertion point
6792  
6793 0 Vpexpandd zmmM($K, 1), zmm($K); # Expand to make room for the value to be inserted
6794 0 Vpexpandd zmmM($D, 1), zmm($D);
6795  
6796 0 $IK->setReg(rdi); Vpbroadcastd zmmM($K, 3), edi; # Insert value at expansion point
6797 0 $ID->setReg(rdi); Vpbroadcastd zmmM($D, 3), edi;
6798  
6799 0 $t->incLengthInKeys($K); # Increment the length of this node to include the inserted value
6800  
6801 0 $t->insertIntoTreeBits($K, 3, $subTree); # Set the matching tree bit depending on whether we were supplied with a tree or a variable
6802  
6803 0 $t->incSizeInFirst($F); # Update number of elements in entire tree.
6804 } # insertKeyDataTreeIntoLeaf
6805  
6806 sub Nasm::X86::Tree::splitNode($$) #P Split a node if it it is full returning a variable that indicates whether a split occurred or not.
6807 0 ▶ {my ($tree, $offset) = @_; # Tree descriptor, offset of block in area of tree as a variable
Subroutine splitNode: not called CC=2 SCAR=17.9
6808 0 ▶ @_ == 2 or confess 'Two parameters';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
6809  
6810 0 my $PK = 11; my $PD = 2; my $PN = 3; # Key, data, node blocks. L<insertionPoint> uses zmm registers 0 and 1 so we cannot use those registers
6811 0 my $LK = 4; my $LD = 5; my $LN = 6;
6812 0 my $RK = 7; my $RD = 8; my $RN = 9;
6813 0 my $F = 10;
6814 # First block of this tree
6815 my $s = Subroutine
6816 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
6817 Block
6818 0 ▶ {my ($success) = @_; # Short circuit if ladders by jumping directly to the end after a successful push
Subroutine __ANON__: not called CC=1 SCAR=6.9
6819  
6820 0 my $t = $$s{tree}; # Tree
6821 0 my $area = $t->area; # Area
6822  
6823 0 ClearRegisters $PD; # Otherwise we get left over junk
6824  
6825 0 my $offset = $$p{offset}; # Offset of block in area
6826 0 my $split = $$p{split}; # Indicate whether we split or not
6827 0 $t->getBlock($offset, $LK, $LD, $LN); # Load node as left
6828  
6829 0 $t->lengthFromKeys($LK, set => rsi);
6830 0 Cmp rsi, $t->maxKeys;
6831 IfLt
6832 Then # Only split full blocks
6833 0 ▶ {$split->copy(K split => 0); # Split not required
Subroutine __ANON__: not called CC=1 SCAR=6.9
6834 0 Jmp $success;
6835 0 };
6836  
6837 0 my $parent = $t->upFromData($LD); # Parent of this block
6838  
6839 0 my $r = $t->allocBlock ($RK, $RD, $RN); # Create a new right block
6840 If $parent > 0,
6841 Then # Not the root node because it has a parent
6842 0 ▶ {$t->upIntoData ($parent, $RD); # Address existing parent from new right
Subroutine __ANON__: not called CC=1 SCAR=6.9
6843 0 $t->getBlock ($parent, $PK, $PD, $PN); # Load extent parent
6844 0 $t->splitNotRoot ($r, $PK, $PD, $PN, $LK,$LD,$LN, $RK,$RD,$RN);
6845 0 $t->putBlock ($parent, $PK, $PD, $PN);
6846 0 $t->putBlock ($offset, $LK, $LD, $LN);
6847 },
6848 Else # Split the root node
6849 0 ▶ {my $p = $t->allocBlock ($PK, $PD, $PN); # Create a new parent block
Subroutine __ANON__: not called CC=1 SCAR=6.9
6850 0 $t->splitRoot ($offset, $r, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN);
6851 0 $t->upIntoData ($p, $LD); # Left points up to new parent
6852 0 $t->upIntoData ($p, $RD); # Right points up to new parent
6853 0 $t->putBlock ($p, $PK, $PD, $PN);
6854  
6855 0 $t->putBlock ($offset, $LK, $LD, $LN);
6856 0 $t->putBlock ($r, $RK, $RD, $RN);
6857  
6858 0 $t->firstFromMemory ($F); # Update new root of tree
6859 0 $t->rootIntoFirst ($F, $p);
6860 0 $t->firstIntoMemory ($F);
6861 0 };
6862  
6863 0 $t->leafFromNodes($RN); # Whether the right block is a leaf
6864 0 $t->leafFromNodes($RN, set=>rsi); # NB: in this mode returns 0 if a leaf which is the opposite of what happens if we do not use a transfer register
6865 0 Cmp rsi, 0;
6866  
6867 IfGt # Not a leaf
6868 Then
6869 0 ▶ {$t->area->address->setReg(rdi); # Area address
Subroutine __ANON__: not called CC=1 SCAR=6.9
6870 0 $r->setReg(rdx); # Parent offset
6871 0 Mov rcx, 0; # Start the loop at zero
6872 0 my $W = RegisterSize zmm1;
6873  
6874 0 Vmovdqu64 "[rsp-$W]", zmm $RN; # Stack list of nodes to be re-parented
6875 For # Reparent the children of the right hand side now known not to be a leaf
6876 0 ▶ {Mov esi, "[rsp+rcx*4-$W]"; # Offset of node
Subroutine __ANON__: not called CC=1 SCAR=6.9
6877 0 Mov esi, "[rdi+rsi+$$t{loop}]"; # Offset of data node
6878 0 Mov "[rdi+rsi+$$t{up}]", edx; # Update parent offset
6879 0 } rcx, $t->lengthRight + 1;
6880 0 };
6881  
6882 0 $t->putBlock ($r, $RK, $RD, $RN); # Save right block
6883 0 }; # Insert completed successfully
6884 0 } structures => {tree => $tree},
6885 parameters => [qw(offset split)],
6886 name => qq(Nasm::X86::Tree::splitNode-$$tree{length});
6887  
6888 0 $s->inline
6889 (structures => {tree => $tree},
6890 parameters => {offset => $offset, split => my $p = V split => 1});
6891  
6892 0 $p # Return a variable containing one if the node was split else zero.
6893 } # splitNode
6894  
6895 sub Nasm::X86::Tree::splitNotRoot($$$$$$$$$$$) #P Split a non root left node pushing its excess right and up.
6896 0 ▶ {my ($tree, $newRight, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN) = @_; # Tree definition, variable offset in area of right node block, parent keys zmm, data zmm, nodes zmm, left keys zmm, data zmm, nodes zmm, right keys, data, node zmm
Subroutine splitNotRoot: not called CC=2 SCAR=17.9
6897 0 ▶ @_ == 11 or confess "Eleven parameters required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 11 or confess("Eleven parameters required") 0 0 0
6898  
6899 0 my $w = $tree->width; # Size of keys, data, nodes
6900 0 my $zw = $tree->zWidthD; # Number of dwords in a zmm
6901 0 my $zwn = $tree->maxNodesZ; # Maximum number of dwords that could be used for nodes in a zmm register.
6902 0 my $zwk = $tree->maxKeysZ; # Maximum number of dwords used for keys/data in a zmm
6903 0 my $lw = $tree->maxKeys; # Maximum number of keys in a node
6904 0 my $ll = $tree->lengthLeft; # Minimum node width on left
6905 0 my $lm = $tree->lengthMiddle; # Position of splitting key
6906 0 my $lr = $tree->lengthRight; # Minimum node on right
6907 0 my $lb = $tree->lengthOffset; # Position of length byte
6908 0 my $tb = $tree->treeBits; # Position of tree bits
6909 0 my $up = $tree->up; # Position of up word in data
6910 0 my $transfer = r8; # Transfer register
6911 0 my $transferD = r8d; # Transfer register as a dword
6912 0 my $transferW = r8w; # Transfer register as a word
6913 0 my $work = r9; # Work register as a dword
6914  
6915 my $s = Subroutine
6916 0 ▶ {my ($p, $s, $sub) = @_; # Variable parameters, structure variables, structure copies, subroutine description
Subroutine __ANON__: not called CC=1 SCAR=6.9
6917 0 PushR $transfer, $work, 1..7;
6918  
6919 0 my $SK = dFromZ $LK, $ll * $w; # Splitting key
6920 0 my $SD = dFromZ $LD, $ll * $w; # Data corresponding to splitting key
6921  
6922 my $mask = sub # Set k7 to a specified bit mask
6923 0 ▶ {my ($prefix, @onesAndZeroes) = @_; # Prefix bits, alternating zeroes and ones
Subroutine __ANON__: not called CC=1 SCAR=6.9
6924 0 LoadBitsIntoMaskRegister(7, $prefix, @onesAndZeroes); # Load k7 with mask
6925 0 };
6926  
6927 0 &$mask("00", $zwk); # Copy Left node to right node
6928  
6929 0 Vmovdqu32 zmmM($RK, 7), zmm($LK); # Copy keys from left to right
6930 0 Vmovdqu32 zmmM($RD, 7), zmm($LD); # Copy data from left to right
6931  
6932 0 &$mask("0", $zwn);
6933 0 Vmovdqu32 zmmM($RN, 7), zmm($LN); # Copy nodes from left to right
6934  
6935 0 &$mask("00", $lw-$zwk, $lr, -$ll-1); # Compress right data/keys
6936 0 Vpcompressd zmmM($RK, 7), zmm($RK); # Compress copied right keys
6937 0 Vpcompressd zmmM($RD, 7), zmm($RD); # Compress right copied data
6938  
6939 0 &$mask("0", $lw-$zwk, $lr+1, -$lr-1); # Compress right nodes
6940 0 Vpcompressd zmmM($RN, 7), zmm($RN);
6941  
6942 0 &$mask("11", $ll-$zwk, $ll); # Clear left keys and data
6943 0 Vmovdqu32 zmmMZ($LK, 7), zmm($LK);
6944 0 Vmovdqu32 zmmMZ($LD, 7), zmm($LD);
6945  
6946 0 &$mask("1", $ll-$zwk, $ll+1); # Clear left nodes
6947 0 Vmovdqu32 zmmMZ($LN, 7), zmm($LN);
6948  
6949 0 &$mask("11", 2+$lr-$zw, $lr); # Clear right keys and data
6950 0 Vmovdqu32 zmmMZ($RK, 7), zmm($RK);
6951 0 Vmovdqu32 zmmMZ($RD, 7), zmm($RD);
6952  
6953 0 &$mask("1", $lr-$zwk, $lr+1); # Clear right nodes
6954 0 Vmovdqu32 zmmMZ($RN, 7), zmm($RN);
6955  
6956 0 my $t = $$s{tree}; # Address tree
6957  
6958 0 &$mask("00", $zwk); # Area to clear in keys and data preserving last qword
6959 0 my $in = $t->insertionPoint($SK, $PK); # The position at which the key would be inserted if this were a leaf
6960 0 $in->setReg($transfer);
6961 0 Kmovq k6, $transfer; # Mask shows insertion point
6962 0 Kandnq k5, k6, k7; # Mask shows expansion needed to make the insertion possible
6963  
6964 0 Vpexpandd zmmM($PK, 5), zmm($PK); # Make room in parent keys and place the splitting key
6965 0 Vpexpandd zmmM($PD, 5), zmm($PD); # Make room in parent data and place the data associated with the splitting key
6966  
6967 0 $SK->setReg($transfer); # Key to be inserted
6968 0 Vpbroadcastd zmmM($PK, 6), $transferD; # Insert key
6969  
6970 0 $SD->setReg($transfer); # Data to be inserted
6971 0 Vpbroadcastd zmmM($PD, 6), $transferD; # Insert data
6972  
6973  
6974 0 $in->setReg($transfer); # Next node up as we always expand to the right
6975 0 Shl $transfer, 1;
6976 0 Kmovq k4, $transfer; # Mask shows insertion point
6977 0 &$mask("0", $zwn); # Area to clear in keys and data preserving last qword
6978 0 Kandnq k3, k4, k7; # Mask shows expansion needed to make the insertion possible
6979 0 Vpexpandd zmmM($PN, 3), zmm($PN); # Expand nodes
6980  
6981 0 $$p{newRight}->setReg($transfer); # New right node to be inserted
6982 0 Vpbroadcastd zmmM($PN, 4), $transferD; # Insert node
6983  
6984 # Lengths
6985 0 wRegFromZmm $work, $PK, $lb; # Increment length of parent field
6986 0 Inc $work;
6987 0 wRegIntoZmm $work, $PK, $lb;
6988  
6989 0 Mov $work, $ll; # Lengths
6990 0 wRegIntoZmm $work, $LK, $lb; # Left after split
6991 0 Mov $work, $lr; # Lengths
6992 0 wRegIntoZmm $work, $RK, $lb; # Right after split
6993  
6994 0 &$mask("01", -$zwk); # Copy parent offset from left to right so that the new right node still has the same parent
6995 0 Vmovdqu32 zmmM($RD, 7), zmm($LD);
6996  
6997 0 wRegFromZmm $transfer, $LK, $tb;
6998 0 Mov $work, $transfer;
6999 0 And $work, (1 << $ll) - 1;
7000 0 wRegIntoZmm $work, $LK, $tb; # Left after split
7001  
7002 0 Mov $work, $transfer;
7003 0 Shr $work, $lm;
7004 0 And $work, (1 << $lr) - 1;
7005 0 wRegIntoZmm $work, $RK, $tb; # Right after split
7006  
7007 0 Mov $work, $transfer; # Insert splitting key tree bit into parent at the location indicated by k5
7008 0 Shr $work, $ll;
7009 0 And $work, 1; # Tree bit to be inserted parent at the position indicated by a single 1 in k5 in parent
7010 0 wRegFromZmm $transfer, $PK, $tb; # Tree bits from parent
7011  
7012 0 Cmp $work, 0; # Are we inserting a zero into the tree bits?
7013 IfEq
7014 Then # Inserting zero
7015 0 ▶ {InsertZeroIntoRegisterAtPoint k6, $transfer; # Insert a zero into transfer at the point indicated by k5
Subroutine __ANON__: not called CC=1 SCAR=6.9
7016 },
7017 Else # Inserting one
7018 0 ▶ {InsertOneIntoRegisterAtPoint k6, $transfer; # Insert a zero into transfer at the point indicated by k5
Subroutine __ANON__: not called CC=1 SCAR=6.9
7019 0 };
7020 0 wRegIntoZmm $transfer, $PK, $tb; # Save parent tree bits after split
7021  
7022 0 PopR;
7023 }
7024 structures => {tree => $tree},
7025 parameters => [qw(newRight)],
7026 name => join('-', qq(Nasm::X86::Tree::splitNotRoot), $$tree{length},
7027 0 $lw, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN);
7028  
7029 0 $s->inline(
7030 structures => {tree => $tree},
7031 parameters => {newRight => $newRight});
7032 } # splitNotRoot
7033  
7034 sub Nasm::X86::Tree::splitRoot($$$$$$$$$$$$) #P Split a non root node into left and right nodes with the left half left in the left node and splitting key/data pushed into the parent node with the remainder pushed into the new right node.
7035 0 ▶ {my ($tree, $nLeft, $nRight, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN) = @_;# Tree definition, variable offset in area of new left node block, variable offset in area of new right node block, parent keys zmm, data zmm, nodes zmm, left keys zmm, data zmm, nodes zmm, right keys, data , nodes zmm
Subroutine splitRoot: not called CC=2 SCAR=17.9
7036 0 ▶ @_ == 12 or confess "Twelve parameters required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 12 or confess("Twelve parameters required") 0 0 0
7037  
7038 0 my $w = $tree->width; # Size of keys, data, nodes
7039 0 my $zw = $tree->zWidthD; # Number of dwords in a zmm
7040 0 my $zwn = $tree->maxNodesZ; # Maximum number of dwords that could be used for nodes in a zmm register.
7041 0 my $zwk = $tree->maxKeysZ; # Maximum number of dwords used for keys/data in a zmm
7042 0 my $lw = $tree->maxKeys; # Maximum number of keys in a node
7043 0 my $ll = $tree->lengthLeft; # Minimum node width on left
7044 0 my $lm = $tree->lengthMiddle; # Position of splitting key
7045 0 my $lr = $tree->lengthRight; # Minimum node on right
7046 0 my $lb = $tree->lengthOffset; # Position of length byte
7047 0 my $tb = $tree->treeBits; # Position of tree bits
7048 0 my $transfer = r8; # Transfer register
7049 0 my $transferD = r8d; # Transfer register as a dword
7050 0 my $transferW = r8w; # Transfer register as a word
7051  
7052 my $s = Subroutine
7053 0 ▶ {my ($p, $s, $sub) = @_; # Variable parameters, structure variables, structure copies, subroutine description
Subroutine __ANON__: not called CC=1 SCAR=6.9
7054  
7055 my $mask = sub # Set k7 to a specified bit mask
7056 0 ▶ {my ($prefix, @onesAndZeroes) = @_; # Prefix bits, alternating zeroes and ones
Subroutine __ANON__: not called CC=1 SCAR=6.9
7057 0 LoadBitsIntoMaskRegister(7, $prefix, @onesAndZeroes); # Load k7 with mask
7058 0 };
7059  
7060 0 my $t = $$s{tree}; # Address tree
7061  
7062 0 PushR $transfer, 6, 7;
7063  
7064 0 $t->maskForFullKeyArea(7); # Mask for keys area
7065 0 $t->maskForFullNodesArea(6); # Mask for nodes area
7066  
7067 0 Mov $transfer, -1;
7068 0 Vpbroadcastd zmmM($PK, 7), $transferD; # Force keys to be high so that insertion occurs before all of them
7069  
7070 0 Mov $transfer, 0;
7071 0 Vpbroadcastd zmmM($PD, 7), $transferD; # Zero other keys and data
7072 0 Vpbroadcastd zmmM($RK, 7), $transferD;
7073 0 Vpbroadcastd zmmM($RD, 7), $transferD;
7074  
7075 0 Mov $transfer, 0;
7076 0 Vpbroadcastd zmmM($PN, 6), $transferD;
7077 0 Vpbroadcastd zmmM($RN, 6), $transferD;
7078  
7079 0 my $newRight = $$p{newRight};
7080 0 $t->splitNotRoot($newRight, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN); # Split the root node as if it were a non root node
7081  
7082 0 $$p{newLeft} ->dIntoZ($PN, 0); # Place first - left sub node into new root
7083 0 $$p{newRight}->dIntoZ($PN, 4); # Place second - right sub node into new root
7084  
7085 0 Kshiftrw k7, k7, 1; # Reset parent keys/data outside of single key/data
7086 0 Kshiftlw k7, k7, 1;
7087 0 Mov $transfer, 0;
7088 0 Vpbroadcastd zmmM($PK, 7), $transferD;
7089  
7090 0 Mov $transfer, 1; # Lengths
7091 0 wRegIntoZmm $transfer, $PK, $lb; # Left after split
7092  
7093 0 wRegFromZmm $transfer, $PK, $tb; # Parent tree bits
7094 0 And $transfer, 1;
7095 0 wRegIntoZmm $transfer, $PK, $tb;
7096  
7097 0 PopR;
7098 }
7099 structures => {tree => $tree},
7100 parameters => [qw(newLeft newRight)],
7101 name => join '-', "Nasm::X86::Tree::splitRoot", $$tree{length},
7102 0 $lw, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN;
7103  
7104 0 $s->inline
7105 (structures => {tree => $tree},
7106 parameters => {newLeft => $nLeft, newRight => $nRight});
7107 } # splitRoot
7108  
7109 sub Nasm::X86::Tree::put($$$) # Put a variable key and data into a tree. The data could be a tree descriptor to place a sub tree into a tree at the indicated key.
7110 0 ▶ {my ($tree, $key, $data) = @_; # Tree definition, variable key containing a number for a normal key or the offset in the area of a zmm block containing the key, data as a variable or a tree descriptor
Subroutine put: not called CC=6 SCAR=37.4
7111 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
7112  
7113 0 my $dt = ref($data) =~ m(Tree); # We are inserting a sub tree if true
7114  
7115 my $s = Subroutine
7116 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
7117  
7118 Block
7119 0 ▶ {my ($success) = @_; # End label
Subroutine __ANON__: not called CC=2 SCAR=17.9
7120 0 PushR my $Q = r13, my $setEq = r14, my $setLt = r15, # Offset of current node, insertion point, equality point
7121 my ($F, $K, $D, $N, $key) = zmm reverse 27..31; # First, keys, data, nodes, search key
7122 0 my $t = $$s{tree};
7123 0 my $k = $$p{key};
7124 0 my $d = $$p{data};
7125 0 my $S = $$p{subTree};
7126 0 my $a = $t->area;
7127  
7128 0 $k->setReg(rdi); # Load key once
7129 0 ▶ if ($t->stringTree) # Key is the offset to a key in the same area as the tree
Branch: 1 branch
BranchTrueFalseTotal
if ($t->stringTree) { } 0 0 0
7130 0 {$a->address->setReg(rsi);
7131 0 Vmovdqu64 zmm($key), "[rsi+rdi]";
7132 }
7133 else # Key is any double word
7134 0 {$k->setReg(rdi);
7135 0 Vpbroadcastd zmm($key), edi;
7136 }
7137  
7138 0 my $start = SetLabel; # Start the descent through the tree
7139  
7140 0 $t->firstFromMemory($F);
7141 0 $t->rootFromFirst($F, set=>$Q); # Start the descent at the root node
7142  
7143 0 Cmp $Q, 0;
7144 IfEq
7145 Then # First entry as there is no root node
7146 0 ▶ {my $block = $t->allocBlock($K, $D, $N);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7147 0 $k->dIntoZ ($K, 0);
7148 0 $d->dIntoZ ($D, 0);
7149 0 $t->incLengthInKeys ($K);
7150 0 $t->setOrClearTreeBitToMatchContent($K, K(key => 1), $S);
7151 0 $t->putBlock($block, $K, $D, $N);
7152 0 $t->rootIntoFirst ($F, $block);
7153 0 $t->incSizeInFirst ($F);
7154 0 $t->firstIntoMemory ($F); # First back into memory
7155 0 Jmp $success;
7156 0 };
7157  
7158 0 my $descend = SetLabel; # Descend to the next level
7159  
7160 0 $t->getBlock($Q, $K, $D, $N); # Get the current block from memory
7161  
7162 0 $t->indexEqLt($key, $K, $setEq, $setLt); # Check for an equal key
7163 IfNz # Equal key found
7164 Then # Overwrite the existing key/data
7165 0 ▶ {$t->overWriteKeyDataTreeInLeaf($setEq, $K, $D, $k, $d, $S);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7166 0 $t->putBlock ($Q, $K, $D, $N);
7167 0 Jmp $success;
7168 0 };
7169  
7170 0 $t->lengthFromKeys($K, set=>rsi);
7171 0 Cmp rsi, $t->maxKeys;
7172 IfGe
7173 Then # Split full blocks
7174 0 ▶ {$t->splitNode(V offset => $Q); # Split node is a large function that is hopefully called infrequently so crating a register parameter is, perhaps, not worth the effort
Subroutine __ANON__: not called CC=1 SCAR=6.9
7175 0 Jmp $start; # Restart the descent now that this block has been split
7176 0 };
7177  
7178 0 $t->leafFromNodes($N, set=>rsi); # NB: in this mode returns 0 if a leaf which is the opposite of what happens if we do not use a transfer register
7179 0 Cmp rsi, 0;
7180 IfEq
7181 Then # On a leaf
7182 0 ▶ {$t->insertKeyDataTreeIntoLeaf($setLt, $F, $K, $D, $k, $d, $S);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7183 0 $t->putBlock ($Q, $K, $D, $N);
7184 0 $t->firstIntoMemory ($F); # First back into memory
7185 0 Jmp $success;
7186 0 };
7187  
7188 0 dFromPointInZ($setLt, $N, set=>$Q); # The node to the left of the insertion point - this works because the insertion point can be up to one more than the maximum number of keys
7189 0 Jmp $descend; # Descend to the next level
7190 0 };
7191 0 PopR;
7192 0 } name => qq(Nasm::X86::Tree::put-$$tree{length}-$$tree{stringTree}),
7193 structures => {tree=>$tree},
7194 parameters => [qw(key data subTree)];
7195  
7196  
7197 0 ▶ if ($dt) # Put a sub tree
Branch: 1 branch
BranchTrueFalseTotal
if ($dt) { } 0 0 0
7198 0 ▶ {$s->call(structures => {tree => $tree},
Branch: 1 branch
BranchTrueFalseTotal
ref $key ? : 0 0 0
7199 parameters => {key => (ref($key) ? $key : K key => $key),
7200 data => $data->first,
7201 subTree => K(subTree => 1)});
7202 }
7203 else # Not a sub tree
7204 0 ▶ {$s->call(structures => {tree => $tree},
Branch: 2 branches
BranchTrueFalseTotal
ref $key ? : 0 0 0
ref $data ? : 0 0 0
7205 parameters => {key => (ref($key) ? $key : K key => $key),
7206 data => (ref($data) ? $data : K data => $data),
7207 subTree => K(subTree => 0)});
7208 }
7209 } # put
7210  
7211 #D2 Find # Find a key in the tree. Trees have dword integer keys and so can act as arrays as well.
7212  
7213 sub Nasm::X86::Tree::zero($) #P Zero the return fields of a tree descriptor.
7214 0 ▶ {my ($tree) = @_; # Tree descriptor
Subroutine zero: not called CC=2 SCAR=17.9
7215 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
7216 0 $tree->found ->copy(0); # Key not found
7217 0 $tree->data ->copy(0); # Data not yet found
7218 0 $tree->subTree->copy(0); # Not yet a sub tree
7219 0 $tree->offset ->copy(0); # Offset not known
7220 0 $tree # Chaining
7221 }
7222  
7223 sub Nasm::X86::Tree::find($$) # Find a key in a tree and tests whether the found data is a sub tree. The results are held in the variables "found", "data", "subTree" addressed by the tree descriptor. The key just searched for is held in the key field of the tree descriptor. The point at which it was found is held in B<found> which will be zero if the key was not found.
7224 0 ▶ {my ($tree, $key) = @_; # Tree descriptor, key field to search for which can either be a variable containing a double word for a normal tree or a zmm register containing the key to be sought for a string tree.
Subroutine find: not called CC=7 SCAR=40.3
7225 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
7226  
7227 0 ▶ if ($tree->stringTree) # Key in variable
Branch: 1 branch
BranchTrueFalseTotal
if ($tree->stringTree) 0 0 0
7228 0 ▶ {confess "Zmm required" if ref($key);
Branch: 1 branch
BranchTrueFalseTotal
if ref $key 0 0 0
7229 0 ▶ confess "Bound zmm required not $key" if $key =~ m(\A(zmm)?(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $key =~ /\A(zmm)?(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)\Z/ 0 0 0
7230 }
7231  
7232 my $s = Subroutine
7233 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
7234 0 my $F = zmm1, my $K = zmm2, my $D = zmm3, my $N = zmm4, my $zKey = zmm5; # We are boldly assuming that these registers are not being used independently
7235 0 PushR my $Q = r15, my $loop = r14, my $equals = r13, my $insert = r12;
7236  
7237 Block
7238 0 ▶ {my ($success) = @_; # Short circuit if ladders by jumping directly to the end after a successful push
Subroutine __ANON__: not called CC=3 SCAR=24.8
7239  
7240 0 my $t = $$s{tree}; # Tree to search
7241 0 $t->zero; # Clear search fields
7242  
7243 0 ▶ if (ref($$p{key})) # Does not apply to string trees which uses zmm registers to pass in the keys.
Branch: 1 branch
BranchTrueFalseTotal
if (ref $p->{"key"}) 0 0 0
7244 0 {$t->key->copy(my $k = $$p{key}); # Copy in key so we know what was searched for
7245 }
7246  
7247 0 $t->firstFromMemory ($F); # Load first block
7248  
7249 0 $t->rootFromFirst($F, set => $Q); # Start the search from the root
7250  
7251 0 Cmp $Q, 0;
7252 0 Je $success; # Empty tree so we have not found the key
7253  
7254 0 ▶ if ($tree->stringTree) # Load key just once
Branch: 1 branch
BranchTrueFalseTotal
if ($tree->stringTree) { } 0 0 0
7255 0 {$zKey = $key;
7256 }
7257 else
7258 0 {$$p{key}->setReg(rdi);
7259 0 Vpbroadcastd zmm($zKey), edi;
7260 }
7261  
7262 uptoNTimes # Step down through tree
7263 0 ▶ {my (undef, $start) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
7264 0 $t->getBlock($Q, $K, $D, $N); # Get the keys/data/nodes
7265  
7266 0 $t->indexEqLt($zKey, $K, $equals, $insert); # The position of a key in a zmm equal to the specified key as a point in a variable.
7267 IfNz # Result mask is non zero so we must have found the key
7268 Then
7269 0 ▶ {dFromPointInZ $equals, $D, set=>rsi; # Get the corresponding data
Subroutine __ANON__: not called CC=1 SCAR=6.9
7270 0 $t->data ->copy(rsi); # Data associated with the key
7271 0 $t->found ->copy($equals); # Show found
7272 0 $t->offset->copy($Q); # Offset of the containing block
7273 0 $t->getTreeBit($K, $equals, set => rdx); # Get corresponding tree bit
7274 0 $t->subTree->copy(rdx); # Save corresponding tree bit
7275 0 Jmp $success; # Return
7276 0 };
7277  
7278 0 $t->leafFromNodes($N, set=>rsi), # Check whether this is a leaf by looking at the first sub node - if it is zero this must be a leaf as no node van have a zero offset in an area
7279 Cmp rsi, 0; # Leaf if zero
7280 0 Jz $success; # Return
7281  
7282 0 dFromPointInZ ($insert, $N, set => $Q); # Get the corresponding offset to the next sub tree
7283 0 Sub $loop, 1;
7284 0 Jnz $start; # Keep going but not for ever
7285 0 } $loop, 99; # Loop a limited number of times
7286 0 PrintErrTraceBack "Stuck in find"; # We seem to be looping endlessly
7287 0 }; # Find completed successfully
7288  
7289 0 PopR;
7290 0 } parameters => [qw(key)],
7291 structures => {tree=>$tree},
7292 name => qq(Nasm::X86::Tree::find-$$tree{length}-$$tree{stringTree});
7293  
7294 0 ▶ $s->inline(structures => {tree => $tree},
Branch: 1 branch
BranchTrueFalseTotal
ref $key || $key =~ /\Azmm/ ? : 0 0 0
Condition0%0/3
ref $key or $key =~ /\Azmm/
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $key or $key =~ /\Azmm/
ref $key $key =~ /\Azmm/
Truth table0%0/3
A or B
A= ref $keyB= $key =~ /\Azmm/
ABresult
1X1
011
000
7295 parameters => {key => ref($key) || $key =~ m(\Azmm) ? $key : K key => $key});
7296 } # find
7297  
7298 sub Nasm::X86::Tree::findFirst($) # Find the first element in a tree and set B<found>|B<key>|B<data>|B<subTree> to show the result.
7299 0 ▶ {my ($tree) = @_; # Tree descriptor
Subroutine findFirst: not called CC=2 SCAR=17.9
7300 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
7301  
7302 my $s = Subroutine
7303 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
7304 Block
7305 0 ▶ {my ($success) = @_; # Successfully completed
Subroutine __ANON__: not called CC=1 SCAR=6.9
7306  
7307 0 my $t = $$s{tree}; # Tree to search
7308 0 $t->zero; # Key not found
7309  
7310 0 PushR my $F = 31, my $K = 30, my $D = 29, my $N = 28;
7311  
7312 0 $t->firstFromMemory($F); # Update the size of the tree
7313 0 my $size = $t->sizeFromFirst($F); # Size of tree
7314  
7315 If $size == 0, # Empty tree
7316 Then
7317 0 ▶ {$t->found->copy(0); # Could not find anything
Subroutine __ANON__: not called CC=1 SCAR=6.9
7318 0 Jmp $success
7319 0 };
7320  
7321 0 my $root = $t->rootFromFirst($F); # Root of tree
7322 0 $t->getBlock($root, $K, $D, $N); # Load root
7323  
7324 K(loop => 99)->for(sub # Step down through the tree a reasonable number of times
7325 0 ▶ {my ($i, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
7326  
7327 If $t->leafFromNodes($N) > 0, # Leaf node means we have arrived
7328 Then
7329 0 ▶ {my $k = dFromZ($K, 0);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7330 0 my $d = dFromZ($D, 0);
7331 0 my $b = $t->getTreeBit($K, K key => 1);
7332 0 $t->found ->copy(1);
7333 0 $t->key ->copy($k);
7334 0 $t->data ->copy($d);
7335 0 $t->subTree->copy($b);
7336 0 Jmp $success
7337 0 };
7338  
7339 0 my $n = dFromZ($N, 0);
7340 0 $t->getBlock($n, $K, $D, $N);
7341 0 });
7342 0 PrintErrTraceBack "Stuck looking for first";
7343 0 }; # Find completed successfully
7344 0 PopR;
7345 0 } structures=>{tree=>$tree},
7346 name => qq(Nasm::X86::Tree::findFirst-$$tree{length}-$$tree{stringTree});
7347  
7348 0 $s->call(structures=>{tree => $tree});
7349 } # findFirst
7350  
7351 sub Nasm::X86::Tree::findLast($) # Find the last key in a tree - crucial for stack like operations.
7352 0 ▶ {my ($tree) = @_; # Tree descriptor
Subroutine findLast: not called CC=2 SCAR=17.9
7353 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
7354  
7355 my $s = Subroutine
7356 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
7357 Block
7358 0 ▶ {my ($success) = @_; # Successfully completed
Subroutine __ANON__: not called CC=1 SCAR=6.9
7359  
7360 0 my $t = $$s{tree}->zero; # Tree to search
7361  
7362 0 PushR my $F = 31, my $K = 30, my $D = 29, my $N = 28;
7363  
7364 0 $t->firstFromMemory($F); # Update the size of the tree
7365 0 my $size = $t->sizeFromFirst($F); # Number of entries in tree
7366  
7367 If $size > 0, # Non empty tree
7368 Then
7369 0 ▶ {my $root = $t->rootFromFirst($F); # Root of tree
Subroutine __ANON__: not called CC=1 SCAR=6.9
7370  
7371 0 $t->getBlock($root, $K, $D, $N); # Load root
7372  
7373 K(loop => 99)->for(sub # Step down through the tree a reasonable number of times
7374 0 ▶ {my ($i, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
7375 0 my $l = $t->lengthFromKeys($K);
7376  
7377 If $t->leafFromNodes($N) > 0, # Leaf node means we have arrived
7378 Then
7379 0 ▶ {my $o = ($l - 1) * $t->width;
Subroutine __ANON__: not called CC=1 SCAR=6.9
7380 0 my $k = dFromZ($K, $o);
7381 0 my $d = dFromZ($D, $o);
7382 0 my $b = $t->getTreeBit($K, $l);
7383  
7384 0 $t->found ->copy(1);
7385 0 $t->key ->copy($k);
7386 0 $t->data ->copy($d);
7387 0 $t->subTree->copy($b);
7388 0 Jmp $success
7389 0 };
7390  
7391 0 my $O = $l * $t->width;
7392 0 my $n = dFromZ($N, $O); # Step down to the next level
7393 0 $t->getBlock($n, $K, $D, $N);
7394 0 });
7395 0 PrintErrTraceBack "Stuck looking for last";
7396 },
7397 Else
7398 0 ▶ {$t->found->copy(0);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7399 0 };
7400 0 }; # Find completed successfully
7401 0 PopR;
7402 0 } structures=>{tree=>$tree},
7403 name => qq(Nasm::X86::Tree::findLast-$$tree{length}-$$tree{stringTree});
7404  
7405 0 $s->call(structures=>{tree => $tree}); # Inline causes very long assembly times so we call instead.
7406 } # findLast
7407  
7408 sub Nasm::X86::Tree::findNext($$) # Find the next key greater than the one specified.
7409 0 ▶ {my ($tree, $key) = @_; # Tree descriptor, key
Subroutine findNext: not called CC=3 SCAR=24.8
7410 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
7411 0 ▶ ref($key) =~ m(Variable) or confess "Variable required";
Branch: 1 branch
BranchTrueFalseTotal
ref($key) =~ /Variable/ or confess("Variable required") 0 0 0
7412  
7413 my $s = Subroutine
7414 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
7415 Block
7416 0 ▶ {my ($success) = @_; # Short circuit if ladders by jumping directly to the end after a successful push
Subroutine __ANON__: not called CC=1 SCAR=6.9
7417  
7418 0 PushR my $F = 31, my $K = 30, my $D = 29, my $N = 28;
7419 0 my $t = $$s{tree}->zero; # Tree to search
7420 0 my $k = $$p{key}; # Key to find
7421 0 $t->key->copy($k); # Copy in key so we know what was searched for
7422  
7423 0 $t->firstFromMemory ($F); # Load first block
7424 0 my $Q = $t->rootFromFirst($F); # Start the search from the root
7425 If $Q == 0,
7426 Then # Empty tree so we have successfully not found the key
7427 0 ▶ {Jmp $success; # Return
Subroutine __ANON__: not called CC=1 SCAR=6.9
7428 0 };
7429  
7430 0 my $li = V(key => 0); # Offset of last not right tells us where to continue the search -
7431 0 my $lQ = V(key => 0); # Insertion point of last non right
7432  
7433 K(loop=>99)->for(sub # Step down through tree
7434 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
7435  
7436 0 $t->getBlock($Q, $K, $D, $N); # Get the keys/data/nodes
7437 0 my $lp = K(key => 1) << $t->lengthFromKeys($K); # Point to last node in nodes area
7438 0 my $i = $t->insertionPoint($k, $K); # The insertion point
7439 If $t->leafFromNodes($N) > 0,
7440 Then # On a leaf
7441 0 ▶ {If $i == $lp,
Subroutine __ANON__: not called CC=1 SCAR=6.9
7442 Then # Last in leaf so reposition on last not right
7443 0 ▶ {If $li == 0, Then {Jmp $success}; # Greater than all keys
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
7444 0 $t->getBlock($li, $K, $D, $N);
7445 0 $i->copy($lQ);
7446 0 };
7447 0 $t->found ->copy($i); # Key found at this point
7448 0 $t->key ->copy($i->dFromPointInZ($K)); # Save key
7449 0 $t->data ->copy($i->dFromPointInZ($D)); # Save data
7450 0 $t->subTree->copy($t->getTreeBit ($K, $i)); # Save sub tree
7451 0 $t->offset ->copy($Q); # Save offset
7452 0 Jmp $success; # Return
7453 0 };
7454  
7455 0 my $n = $i->dFromPointInZ($N); # Get the corresponding data
7456 If $i != $lp,
7457 Then # Not descending through the last right
7458 0 ▶ {$li->copy($Q);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7459 0 $lQ->copy($i);
7460 0 };
7461 0 $Q->copy($n); # Corresponding node
7462 0 });
7463 0 PrintErrTraceBack "Stuck in find next"; # We seem to be looping endlessly
7464 0 }; # Find completed successfully
7465 0 PopR;
7466 0 } parameters => [qw(key)],
7467 structures => {tree=>$tree},
7468 name => qq(Nasm::X86::Tree::findNext-$$tree{length}-$$tree{stringTree});
7469  
7470 0 $s->call(structures=>{tree => $tree}, parameters=>{key => $key});
7471 } # findNext
7472  
7473 sub Nasm::X86::Tree::findPrev($$) # Find the previous key less than the one specified.
7474 0 ▶ {my ($tree, $key) = @_; # Tree descriptor, key
Subroutine findPrev: not called CC=3 SCAR=24.8
7475 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
7476 0 ▶ ref($key) =~ m(Variable) or confess "Variable required";
Branch: 1 branch
BranchTrueFalseTotal
ref($key) =~ /Variable/ or confess("Variable required") 0 0 0
7477  
7478 my $s = Subroutine
7479 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
7480 Block
7481 0 ▶ {my ($success) = @_; # Short circuit if ladders by jumping directly to the end after a successful push
Subroutine __ANON__: not called CC=1 SCAR=6.9
7482  
7483 0 PushR my $F = 31, my $K = 30, my $D = 29, my $N = 28;
7484 0 my $t = $$s{tree}->zero; # Tree to search
7485 0 my $k = $$p{key}; # Key to find
7486 0 $t->key->copy($k); # Copy in key so we know what was searched for
7487  
7488 0 $t->firstFromMemory ($F); # Load first block
7489 0 my $Q = $t->rootFromFirst($F); # Start the search from the root
7490 0 ▶ If $Q == 0, Then {Jmp $success}; # Empty tree so we have successfully not found the key
Subroutine __ANON__: not called CC=1 SCAR=6.9
7491  
7492 0 my $li = V key => 0; # Offset of last not right tells us where to continue the search -
7493 0 my $lQ = V key => 0; # Insertion point of last non right
7494  
7495 K(loop => 99)->for(sub # Step down through tree
7496 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
7497 0 $t->getBlock($Q, $K, $D, $N); # Get the keys/data/nodes
7498 0 my $i = $t->insertionPoint($k, $K); # The insertion point
7499 If $i > 1,
7500 Then
7501 0 ▶ {my $j = $i >> K key => 1;
Subroutine __ANON__: not called CC=1 SCAR=6.9
7502 If $j->dFromPointInZ($K) == $k,
7503 Then
7504 0 ▶ {$i->copy($j);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7505 0 };
7506 0 };
7507  
7508 If $t->leafFromNodes($N) > 0,
7509 Then # On a leaf
7510 0 ▶ {If $i == 1,
Subroutine __ANON__: not called CC=1 SCAR=6.9
7511 Then # First in leaf so reposition on last not left
7512 0 ▶ {If $li == 0, Then {Jmp $success}; # Greater than all keys
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
7513 0 $t->getBlock($li, $K, $D, $N);
7514 0 $i->copy($lQ);
7515 0 };
7516 0 $i->copy($i >> K(one => 1));
7517 0 $t->found ->copy($i); # Key found at this point
7518 0 $t->key ->copy($i->dFromPointInZ($K)); # Save key
7519 0 $t->data ->copy($i->dFromPointInZ($D)); # Save data
7520 0 $t->subTree->copy($t->getTreeBit ($K, $i)); # Save sub tree
7521 0 $t->offset ->copy($Q); # Save offset
7522 0 Jmp $success; # Return
7523 0 };
7524  
7525 0 my $n = $i->dFromPointInZ($N); # Get the corresponding data
7526 If $i != 1,
7527 Then # Not descending through the first left
7528 0 ▶ {$li->copy($Q);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7529 0 $lQ->copy($i);
7530 0 };
7531 0 $Q->copy($n); # Corresponding node
7532 0 });
7533 0 PrintErrTraceBack "Stuck in find prev"; # We seem to be looping endlessly
7534 0 }; # Find completed successfully
7535 0 PopR;
7536 0 } parameters => [qw(key)],
7537 structures => {tree=>$tree},
7538 name => qq(Nasm::X86::Tree::findPrev-$$tree{length}-$$tree{stringTree});
7539  
7540 0 $s->call(structures=>{tree => $tree}, parameters=>{key => $key});
7541 } # findPrev
7542  
7543 sub Nasm::X86::Tree::findAndReload($$) #P Find a key in the specified tree and clone it is it is a sub tree.
7544 0 ▶ {my ($t, $key) = @_; # Tree descriptor, key as a dword
Subroutine findAndReload: not called CC=2 SCAR=17.9
7545 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
7546  
7547 0 $t->find($key); # Find the key
7548 If $t->found > 0, # Make the found data the new tree
7549 Then
7550 0 ▶ {$t->first->copy($t->data); # Copy the data variable to the first variable without checking whether it is valid
Subroutine __ANON__: not called CC=1 SCAR=6.9
7551 0 };
7552 }
7553  
7554 sub Nasm::X86::Tree::findSubTree($$) # Find a key in the specified tree and create a sub tree from the data field if possible.
7555 0 ▶ {my ($tree, $key) = @_; # Tree descriptor, key as a dword
Subroutine findSubTree: not called CC=3 SCAR=24.8
7556 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
7557  
7558 0 my $t = $tree->DescribeTree; # The sub tree we are attempting to load
7559 0 $t->copyDescriptor($tree); # Position on the tree
7560  
7561 my $s = Subroutine
7562 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
7563 0 my $t = $$s{tree};
7564 0 $t->find($$p{key}); # Find the key
7565  
7566 0 ▶ ifAnd [sub{$t->found > 0}, sub{$t->subTree > 0}], # Make the found data the new tree
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
7567 Then
7568 0 ▶ {$t->first->copy($t->data); # Copy the data variable to the first variable without checking whether it is valid
Subroutine __ANON__: not called CC=1 SCAR=6.9
7569 0 $t->found->copy(1);
7570 },
7571 Else
7572 0 ▶ {$t->first->copy(-1); # Remove any hint of a tree
Subroutine __ANON__: not called CC=1 SCAR=6.9
7573 0 $t->found->copy(0); # We did not find the sub tree
7574 0 };
7575 0 } parameters => [qw(key)],
7576 structures => {tree=>$t},
7577 name => qq(Nasm::X86::Tree::findSubTree);
7578  
7579 0 ▶ $s->call(structures => {tree => $t},
Branch: 1 branch
BranchTrueFalseTotal
ref $key ? : 0 0 0
7580 parameters => {key => ref($key) ? $key : K key => $key});
7581  
7582 0 $t
7583 }
7584  
7585 sub Nasm::X86::Tree::leftOrRightMost($$$$) #P Return the offset of the left most or right most node.
7586 0 ▶ {my ($tree, $dir, $node, $offset) = @_; # Tree descriptor, direction: left = 0 or right = 1, start node, offset of located node
Subroutine leftOrRightMost: not called CC=3 SCAR=24.8
7587 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
7588  
7589 my $s = Subroutine
7590 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
7591 Block
7592 0 ▶ {my ($success) = @_; # Short circuit if ladders by jumping directly to the end after a successful push
Subroutine __ANON__: not called CC=1 SCAR=6.9
7593  
7594 0 my $t = $$s{tree}; # Tree
7595 0 $t->first->copy(my $F = $$p{node}); # First block
7596 0 my $area = $t->area; # Area
7597 0 PushR rax, 8, 9, 29..31;
7598  
7599 K(loopLimit=>9)->for(sub # Loop a reasonable number of times
7600 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
7601 0 $t->getBlock($F, 31, 30, 29); # Get the first keys block
7602 0 my $n = dFromZ 29, 0; # Get the node block offset from the data block loop
7603 If $n == 0,
7604 Then # Reached the end so return the containing block
7605 0 ▶ {$$p{offset}->copy($F);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7606 0 Jmp $success;
7607 0 };
7608 0 ▶ if ($dir == 0) # Left most
Branch: 1 branch
BranchTrueFalseTotal
if ($dir == 0) { } 0 0 0
7609 0 {my $l = dFromZ 29, 0; # Get the left most node
7610 0 $F->copy($l); # Continue with the next level
7611 }
7612 else # Right most
7613 0 {my $l = $t->lengthFromKeys(31); # Length of the node
7614 0 my $r = dFromZ 31, $l; # Get the right most child
7615 0 $F->copy($r); # Continue with the next level
7616 }
7617 0 });
7618 0 PrintErrStringNL "Stuck in LeftOrRightMost";
7619 0 Exit(1);
7620 0 }; # Insert completed successfully
7621 0 PopR;
7622 0 ▶ } structures => {tree => $tree},
Branch: 1 branch
BranchTrueFalseTotal
$dir == 0 ? : 0 0 0
7623 parameters => [qw(node offset)],
7624 name => $dir==0 ? qq(Nasm::X86::Tree::leftMost-$$tree{length}-$$tree{smallTree}-$$tree{lowTree}-$$tree{stringTree}) :
7625 qq(Nasm::X86::Tree::rightMost-$$tree{length}-$$tree{smallTree}-$$tree{lowTree}-$$tree{stringTree});
7626  
7627 0 $s->call
7628 (structures => {tree=>$tree},
7629 parameters => {node => $node, offset=>$offset});
7630 }
7631  
7632 sub Nasm::X86::Tree::leftMost($$$) #P Return the offset of the left most node from the specified node.
7633 0 ▶ {my ($t, $node, $offset) = @_; # Tree descriptor, start node, returned offset
Subroutine leftMost: not called CC=2 SCAR=17.9
7634 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
7635 0 $t->leftOrRightMost(0, $node, $offset) # Return the left most node
7636 }
7637  
7638 sub Nasm::X86::Tree::rightMost($$$) #P Return the offset of the left most node from the specified node.
7639 0 ▶ {my ($t, $node, $offset) = @_; # Tree descriptor, start node, returned offset
Subroutine rightMost: not called CC=2 SCAR=17.9
7640 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
7641 0 $t->leftOrRightMost(1, $node, $offset) # Return the right most node
7642 }
7643  
7644 sub Nasm::X86::Tree::depth($$) #P Return the depth of a node within a tree.
7645 0 ▶ {my ($tree, $node) = @_; # Tree descriptor, node
Subroutine depth: not called CC=2 SCAR=17.9
7646 0 ▶ @_ == 2 or confess "Two parameters required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters required") 0 0 0
7647 0 PrintErrTraceBack "Rewrite me";
7648  
7649 my $s = Subroutine
7650 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
7651 Block
7652 0 ▶ {my ($success) = @_; # Short circuit if ladders by jumping directly to the end after a successful push
Subroutine __ANON__: not called CC=1 SCAR=6.9
7653  
7654 0 my $t = $$s{tree}; # Tree
7655 0 my $area = $tree->area; # Area
7656 0 my $N = $$p{node}; # Starting node
7657  
7658 0 PushR 8, 9, 14, 15, 30, 31;
7659 0 my $tree = $N->clone('tree'); # Start at the specified node
7660  
7661 K(loop => 9)->for(sub # Step up through tree
7662 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
7663 0 $t->getKeysData($tree, 31, 30, r8, r9); # Get the first node of the tree
7664 0 my $P = $t->getUpFromData(30); # Parent
7665 If $P == 0,
7666 Then # Empty tree so we have not found the key
7667 0 ▶ {$$p{depth}->copy($index+1); # Key not found
Subroutine __ANON__: not called CC=1 SCAR=6.9
7668 0 Jmp $success; # Return
7669 0 };
7670 0 $tree->copy($P); # Up to next level
7671 0 });
7672 0 PrintErrStringNL "Stuck in depth"; # We seem to be looping endlessly
7673 0 Exit(1);
7674 0 }; # Insert completed successfully
7675 0 PopR;
7676 0 } structures => {tree => $tree},
7677 parameters => [qw(node depth)],
7678 name => qq(Nasm::X86::Tree::depth-$$tree{length}-$$tree{smallTree}-$$tree{lowTree}-$$tree{stringTree});
7679  
7680 0 $s->call(structures => {tree => $tree->copyDescriptor},
7681 parameters => {node => $node, depth => my $d = V depth => 0});
7682  
7683 0 $d
7684 } # depth
7685  
7686 #D2 Sub trees # Construct trees of trees - all private.
7687  
7688 sub Nasm::X86::Tree::isTree($$$) #P Set the Zero Flag to oppose the tree bit in the numbered zmm register holding the keys of a node to indicate whether the data element indicated by the specified register is an offset to a sub tree in the containing area or not.
7689 0 ▶{my ($t, $zmm, $point) = @_; # Tree descriptor, numbered zmm register holding the keys for a node in the tree, register showing point to test
Subroutine isTree: not called CC=2 SCAR=17.9
7690 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
7691  
7692 0 my $z = registerNameFromNumber $zmm; # Full name of zmm register
7693 0 my $o = $t->treeBits; # Bytes from tree bits to end of zmm
7694 0 my $w = $t->zWidth; # Size of zmm register
7695 0 Vmovdqu64 "[rsp-$w]", $z; # Write beyond stack
7696 0 Test $point, "[rsp-$w+$o]"; # Test the tree bit under point
7697 } # isTree
7698  
7699 sub Nasm::X86::Tree::getTreeBit($$$%) #P Get the tree bit from the numbered zmm at the specified point and return it in a variable as a one or a zero.
7700 0 ▶ {my ($t, $zmm, $point, %options) = @_; # Tree descriptor, register showing point to test, numbered zmm register holding the keys for a node in the tree, options
Subroutine getTreeBit: not called CC=5 SCAR=34.0
7701 0 ▶ @_ >= 3 or confess "Three or more parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 3 or confess("Three or more parameters") 0 0 0
7702  
7703 0 ▶ if (ref($point)) # Point is a variable so we will do everything in variables
Branch: 1 branch
BranchTrueFalseTotal
if (ref $point) { } 0 0 0
7704 0 {$t->getTreeBits($zmm, rdi); # Tree bits
7705 0 $point->setReg(rsi);
7706 0 And rdi, rsi; # Write beyond stack
7707 0 my $r = V treeBit => 0;
7708 0 Cmp di, 0;
7709 0 ▶ IfNe Then {$r->copy(1)};
Subroutine __ANON__: not called CC=1 SCAR=6.9
7710 0 return $r
7711 }
7712 else # Point is a register so we will do everything in registers
7713 0 ▶ {my $s = $options{set} // rdi; # The register we are going to be set to something other than zero if the tree bit is set
Condition0%0/3
$options{"set"} // rdi()
l!l&&r!l&&!r
000
MC/DC0%0/2
$options{"set"} // rdi()
$options{"set"} rdi()
Truth table0%0/3
A // B
A= $options{"set"}B= rdi()
ABresult
1X1
011
000
7714 0 ▶ confess "Target cannot be rsi" if $s eq rsi;
Branch: 1 branch
BranchTrueFalseTotal
if $s eq rsi() 0 0 0
7715 0 $t->getTreeBits($zmm, $s); # Tree bits
7716 0 And $s, $point; # Jnz jumps if the tree bit has been set
7717 }
7718 }
7719  
7720 sub Nasm::X86::Tree::setOrClearTreeBit($$$$) #P Set or clear the tree bit selected by the specified point in the numbered zmm register holding the keys of a node to indicate that the data element indicated by the specified register is an offset to a sub tree in the containing area.
7721 0 ▶ {my ($t, $set, $point, $zmm) = @_; # Tree descriptor, set if true else clear, register holding point to set, numbered zmm register holding the keys for a node in the tree
Subroutine setOrClearTreeBit: not called CC=3 SCAR=24.8
7722 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
7723 #CheckGeneralPurposeRegister($point);
7724 0 my $z = registerNameFromNumber $zmm; # Full name of zmm register
7725 0 my $o = $t->treeBits; # Tree bits to end of zmm
7726 0 my $r = registerNameFromNumber $point;
7727 0 PushR $z; # Push onto stack so we can modify it
7728 0 ▶ if ($set) # Set the indexed bit
Branch: 1 branch
BranchTrueFalseTotal
if ($set) { } 0 0 0
7729 0 {And $point, $t->treeBitsMask; # Mask tree bits to prevent operations outside the permitted area
7730 0 Or "[rsp+$o]", $point; # Set tree bit in zmm
7731 }
7732 else # Clear the indexed bit
7733 0 {And $point, $t->treeBitsMask; # Mask tree bits to prevent operations outside the permitted area
7734 0 Not $point;
7735 0 And "[rsp+$o]", $point;
7736 }
7737 0 PopR; # Retrieve zmm
7738 } # setOrClearTree
7739  
7740 sub Nasm::X86::Tree::setTreeBit($$$) #P Set the tree bit in the numbered zmm register holding the keys of a node to indicate that the data element indexed by the specified register is an offset to a sub tree in the containing area.
7741 0 ▶ {my ($t, $zmm, $point) = @_; # Tree descriptor, numbered zmm register holding the keys for a node in the tree, register holding the point to clear
Subroutine setTreeBit: not called CC=2 SCAR=17.9
7742 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
7743 0 $t->setOrClearTreeBit(1, $point, $zmm);
7744 } # setTree
7745  
7746 sub Nasm::X86::Tree::clearTreeBit($$$) #P Clear the tree bit in the numbered zmm register holding the keys of a node to indicate that the data element indexed by the specified register is an offset to a sub tree in the containing area.
7747 0 ▶{my ($t, $zmm, $point) = @_; # Tree descriptor, numbered zmm register holding the keys for a node in the tree, register holding register holding the point to set
Subroutine clearTreeBit: not called CC=2 SCAR=17.9
7748 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
7749 0 $t->setOrClearTreeBit(0, $point, $zmm);
7750 } # clearTree
7751  
7752  
7753 sub Nasm::X86::Tree::setOrClearTreeBitToMatchContent($$$$) #P Set or clear the tree bit pointed to by the specified register depending on the content of the specified variable.
7754 0 ▶ {my ($t, $zmm, $point, $content) = @_; # Tree descriptor, numbered keys zmm, register indicating point, content indicating zero or one
Subroutine setOrClearTreeBitToMatchContent: not called CC=3 SCAR=24.8
7755 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
7756  
7757 0 ▶ if (ref($point)) # Point is a variable so we must put it in a register
Branch: 1 branch
BranchTrueFalseTotal
if (ref $point) 0 0 0
7758 0 {PushR 15;
7759 0 $point->setReg(15);
7760 If $content > 0, # Content represents a tree
7761 Then
7762 0 ▶ {$t->setTreeBit($zmm, r15);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7763 },
7764 Else # Content represents a variable
7765 0 ▶ {$t->clearTreeBit($zmm, r15);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7766 0 };
7767 0 PopR;
7768 }
7769 Else
7770 0 ▶ {If $content > 0, # Content represents a tree
Subroutine __ANON__: not called CC=1 SCAR=6.9
7771 Then
7772 0 ▶ {$t->setTreeBit($zmm, $point);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7773 },
7774 Else # Content represents a variable
7775 0 ▶ {$t->clearTreeBit($zmm, $point);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7776 0 };
7777 }
7778 0 }
7779  
7780 sub Nasm::X86::Tree::getTreeBits($$$) #P Load the tree bits from the numbered zmm into the specified register.
7781 0 ▶ {my ($t, $zmm, $register) = @_; # Tree descriptor, numbered zmm, target register
Subroutine getTreeBits: not called CC=2 SCAR=17.9
7782 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
7783  
7784 0 wRegFromZmm $register, $zmm, $t->treeBits;
7785 0 And $register, $t->treeBitsMask;
7786 }
7787  
7788 sub Nasm::X86::Tree::setTreeBits($$$) #P Put the tree bits in the specified register into the numbered zmm.
7789 0 ▶ {my ($t, $zmm, $register) = @_; # Tree descriptor, numbered zmm, target register
Subroutine setTreeBits: not called CC=2 SCAR=17.9
7790 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
7791 0 And $register, $t->treeBitsMask;
7792 0 wRegIntoZmm $register, $zmm, $t->treeBits;
7793 }
7794  
7795 sub Nasm::X86::Tree::insertTreeBit($$$$) #P Insert a zero or one into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
7796 0 ▶ {my ($t, $onz, $zmm, $point) = @_; # Tree descriptor, 0 - zero or 1 - one, numbered zmm, register indicating point
Subroutine insertTreeBit: not called CC=3 SCAR=24.8
7797 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
7798 0 my $z = registerNameFromNumber $zmm;
7799 0 my $p = registerNameFromNumber $point;
7800 0 PushR my @save = my ($bits) = ChooseRegisters(1, $point); # Tree bits register
7801 0 $t->getTreeBits($zmm, $bits); # Get tree bits
7802 0 ▶ if ($onz)
Branch: 1 branch
BranchTrueFalseTotal
if ($onz) { } 0 0 0
7803 0 {InsertOneIntoRegisterAtPoint ($p, $bits); # Insert a one into the tree bits at the indicated location
7804 }
7805 else
7806 0 {InsertZeroIntoRegisterAtPoint($p, $bits); # Insert a zero into the tree bits at the indicated location
7807 }
7808 0 $t->setTreeBits($zmm, $bits); # Put tree bits
7809 0 PopR;
7810 }
7811  
7812 sub Nasm::X86::Tree::insertZeroIntoTreeBits($$$) #P Insert a zero into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
7813 0 ▶ {my ($t, $zmm, $point) = @_; # Tree descriptor, numbered zmm, register indicating point
Subroutine insertZeroIntoTreeBits: not called CC=2 SCAR=17.9
7814 0 ▶ @_ == 3 or confess "3 parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("3 parameters") 0 0 0
7815 0 $t->insertTreeBit(0, $zmm, $point); # Insert a zero into the tree bits field in the numbered zmm at the specified point
7816 }
7817  
7818 sub Nasm::X86::Tree::insertOneIntoTreeBits($$$) #P Insert a one into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
7819 0 ▶ {my ($t, $zmm, $point) = @_; # Tree descriptor, numbered zmm, register indicating point
Subroutine insertOneIntoTreeBits: not called CC=2 SCAR=17.9
7820 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
7821 0 $t->insertTreeBit(1, $zmm, $point); # Insert a one into the tree bits field in the numbered zmm at the specified point
7822 }
7823  
7824 sub Nasm::X86::Tree::insertIntoTreeBits($$$$) #P Insert a one into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
7825 0 ▶ {my ($t, $zmm, $point, $content) = @_; # Tree descriptor, numbered zmm, register indicating point, bit to insert
Subroutine insertIntoTreeBits: not called CC=3 SCAR=24.8
7826 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
7827  
7828 0 ▶ if (ref($point)) # Point is a variable so we must put into a register
Branch: 1 branch
BranchTrueFalseTotal
if (ref $point) { } 0 0 0
7829 0 {PushR 15;
7830 0 $point->setReg(15);
7831 If $content > 0, # Content represents a one
7832 Then
7833 0 ▶ {$t->insertOneIntoTreeBits ($zmm, r15);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7834 },
7835 Else # Content represents a zero
7836 0 ▶ {$t->insertZeroIntoTreeBits($zmm, r15);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7837 0 };
7838 0 PopR;
7839 }
7840 else
7841 {If $content > 0, # Content represents a one
7842 Then
7843 0 ▶ {$t->insertOneIntoTreeBits ($zmm, $point);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7844 },
7845 Else # Content represents a zero
7846 0 ▶ {$t->insertZeroIntoTreeBits($zmm, $point);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7847 0 };
7848 }
7849 }
7850  
7851 #D2 Delete # Delete a key from the tree
7852  
7853 sub Nasm::X86::Tree::extract($$$$$) #P Extract the key/data/node and tree bit at the specified point from the block held in the specified zmm registers.
7854 0 ▶ {my ($tree, $point, $K, $D, $N) = @_; # Tree descriptor, point at which to extract, keys zmm, data zmm, node zmm
Subroutine extract: not called CC=2 SCAR=17.9
7855 0 ▶ @_ == 5 or confess "Five parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 5 or confess("Five parameters") 0 0 0
7856  
7857 my $s = Subroutine
7858 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=2 SCAR=17.9
7859  
7860 0 my $t = $$s{tree}; # Tree to search
7861 0 ▶ if ($DebugMode) # With checking
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
7862 {If $t->leafFromNodes($N) == 0, # If the zero Flag is zero then this is not a leaf
7863 Then # We can only perform this operation on a leaf
7864 0 ▶ {PrintErrTraceBack "Cannot extract from a non leaf node";
Subroutine __ANON__: not called CC=1 SCAR=6.9
7865 0 };
7866 }
7867  
7868 0 PushR 7, 15;
7869  
7870 0 my $q = $$p{point}; # Point at which to extract
7871 0 $t->data->copy($q->dFromPointInZ($D)); # Data at point
7872 0 $t->subTree->copy($t->getTreeBit($K, $q)); # Sub tree or not a sub tree
7873  
7874 0 $q->setReg(15); # Create a compression mask to squeeze out the key/data
7875 0 Not r15; # Invert point
7876 0 Mov rsi, r15; # Inverted point
7877 0 And rsi, $t->keyDataMask; # Mask for keys area
7878 0 Kmovq k7, rsi;
7879 0 Vpcompressd zmmM($K, 7), zmm($K); # Compress out the key
7880 0 Vpcompressd zmmM($D, 7), zmm($D); # Compress out the data
7881  
7882 0 PushR 6, 31;
7883 0 $t->getTreeBits($K, rsi); # Tree bits
7884 0 Kmovq k6, rsi;
7885 0 Vpmovm2d zmm(31), k6; # Broadcast the tree bits into a zmm
7886 0 Vpcompressd zmmM(31, 7), zmm(31); # Compress out the tree bit in question
7887 0 Vpmovd2m k6, zmm(31); # Reform the tree bits minus the squeezed out bit
7888 0 Kmovq rsi, k6; # New tree bits
7889 0 $t->setTreeBits($K, rsi); # Reload tree bits
7890 0 PopR;
7891  
7892 0 Mov rsi, r15; # Inverted point
7893 0 And rsi, $t->nodeMask; # Mask for node area
7894 0 Kmovq k7, rsi;
7895 0 Vpcompressd zmmM($N, 7), zmm($N); # Compress out the node
7896  
7897 0 $t->decLengthInKeys($K); # Reduce length by one
7898  
7899 0 PopR;
7900 0 } parameters => [qw(point)],
7901 structures => {tree=>$tree},
7902 name => qq(Nasm::X86::Tree::extract-$K-$D-$N-$$tree{length}-$$tree{stringTree});
7903  
7904 0 $s->inline(structures=>{tree => $tree}, parameters=>{point => $point});
7905 } # extract
7906  
7907 sub Nasm::X86::Tree::extractFirst($$$$) #P Extract the first key/data and tree bit at the specified point from the block held in the specified zmm registers and place the extracted data/bit in tree data/subTree.
7908 0 ▶ {my ($tree, $K, $D, $N) = @_; # Tree descriptor, keys zmm, data zmm, node zmm
Subroutine extractFirst: not called CC=2 SCAR=17.9
7909 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
7910  
7911 my $s = Subroutine
7912 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=2 SCAR=17.9
7913  
7914 0 my $t = $$s{tree}; # Tree to search
7915 0 $t->leafFromNodes($N); # Check for a leaf
7916 0 ▶ if ($DebugMode) # Checking
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
7917 {IfNe # If the zero Flag is zero then this is not a leaf
7918 Then # We can only perform this operation on a leaf
7919 0 ▶ {PrintErrTraceBack "Cannot extract first from a non leaf node";
Subroutine __ANON__: not called CC=1 SCAR=6.9
7920 0 };
7921 }
7922 0 $t->key ->copy(dFromZ($K, 0)); # Save corresponding key into tree data field
7923 0 $t->data->copy(dFromZ($D, 0)); # Save corresponding data into tree data field
7924  
7925 0 PushR 7;
7926 0 Mov rsi, $t->keyDataMask; # Mask for keys area
7927 0 Sub rsi, 1; # Mask for keys area with a zero in the first position
7928 0 Kmovq k7, rsi;
7929 0 Vpcompressd zmmM($K, 7), zmm($K); # Compress out the key
7930 0 Vpcompressd zmmM($D, 7), zmm($D); # Compress out the data
7931  
7932 0 $t->getTreeBits($K, rdi); # Tree bits
7933 0 Mov rsi, rdi;
7934 0 And rsi, 1; # First tree bit
7935 0 $t->subTree->getReg(rsi); # Save tree bit
7936 0 Shr rdi, 1; # Remove first tree bit
7937 0 $t->setTreeBits($K, rdi); # Reload tree bits
7938  
7939 0 $t->decLengthInKeys($K); # Reduce length by one
7940  
7941 0 PopR;
7942 0 } structures=>{tree=>$tree},
7943 name => qq(Nasm::X86::Tree::extractFirst-$K-$D-$N-$$tree{length}-$$tree{stringTree});
7944  
7945 0 $s->call(structures=>{tree => $tree});
7946 } # extractFirst
7947  
7948 sub Nasm::X86::Tree::mergeOrSteal($$) #P Merge the block at the specified offset with its right sibling or steal from it. If there is no right sibling then do the same thing but with the left sibling. The supplied block must not be the root. The key we are looking for must be in the tree key field.
7949 0 ▶ {my ($tree, $offset) = @_; # Tree descriptor, offset of non root block that might need to merge or steal
Subroutine mergeOrSteal: not called CC=2 SCAR=17.9
7950 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
7951  
7952 my $s = Subroutine
7953 0 ▶ {my ($parameters, $structures, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=3 SCAR=24.8
7954  
7955 0 my $t = $$structures{tree}; # Tree to search
7956 0 my $F = 31;
7957 0 my $PK = 30; my $PD = 29; my $PN = 28;
7958 0 my $LK = 27; my $LD = 26; my $LN = 25;
7959 0 my $RK = 24; my $RD = 23; my $RN = 22;
7960  
7961 0 PushR 22..31;
7962  
7963 0 my $l = $$parameters{offset}->clone("left"); # Offset of left node that might need merging
7964  
7965 0 ▶ if ($DebugMode) # Checking
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
7966 {If $l == 0,
7967 Then
7968 0 ▶ {PrintErrTraceBack "Zero offset in mergeOrSteal";
Subroutine __ANON__: not called CC=1 SCAR=6.9
7969 0 };
7970 }
7971 0 $t->getBlock($l, $LK, $LD, $LN); # Get the keys/data/nodes
7972 0 my $p = $t->upFromData($LD); # Parent offset
7973  
7974 0 ▶ if ($DebugMode) # Checking
Branch: 1 branch
BranchTrueFalseTotal
if ($Nasm::X86::DebugMode) 0 0 0
7975 {If $p == 0,
7976 Then
7977 0 ▶ {PrintErrTraceBack "Cannot mergeOrSteal the root";
Subroutine __ANON__: not called CC=1 SCAR=6.9
7978 0 };
7979 }
7980  
7981 0 my $ll = $t->lengthFromKeys($LK); # Length of left
7982 If $ll == $t->lengthMin, # Need to merge or steal
7983 Then
7984 0 ▶ {$t->getBlock($p, $PK, $PD, $PN); # Get the parent
Subroutine __ANON__: not called CC=1 SCAR=6.9
7985 If $l != $t->lastNode($PK, $PD, $PN),
7986 Then # Not the last node so we ca either steal or merge right
7987 0 ▶ {my $ll = $t->lengthFromKeys($LK); # Length of left
Subroutine __ANON__: not called CC=1 SCAR=6.9
7988 0 my $r = $t->nextNode($l, $PK, $PN); # Right hand will be next sibling
7989 0 $t->getBlock($r, $RK, $RD, $RN); # Get next sibling
7990  
7991 0 my $rl = $t->lengthFromKeys($RK);
7992 If $rl == $t->lengthMin,
7993 Then # Merge left and right siblings because we now know they are both minimal
7994 0 ▶ {$t->merge($PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN); # Tree definition, parent keys zmm, data zmm, nodes zmm, left keys zmm, data zmm, nodes zmm.
Subroutine __ANON__: not called CC=1 SCAR=6.9
7995 If $t->lengthFromKeys($PK) == 0,
7996 Then # We just merged in the root so make the left sibling the root
7997 0 ▶ {$t->firstFromMemory($F);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7998 0 $t->rootIntoFirst($F, $l);
7999 0 $t->firstIntoMemory($F);
8000 0 $t->upIntoData(K(zero => 0), $LD); # Zero the up pointer for the root
8001 0 $t->freeBlock($p, $PK, $PD, $PN); # Free parent as it is no longer needed
8002 }, # Else not required
8003 Else # Steal from right sibling
8004 0 ▶ {$t->putBlock($p, $PK, $PD, $PN); # Save modified parent
Subroutine __ANON__: not called CC=1 SCAR=6.9
8005 0 };
8006 0 $t->freeBlock($r, $RK, $RD, $RN); # Free right as it is no longer needed
8007 },
8008 Else # Steal from right sibling
8009 0 ▶ {$t->stealFromRight($PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN); # Steal
Subroutine __ANON__: not called CC=1 SCAR=6.9
8010 0 $t->putBlock($p, $PK, $PD, $PN); # Save modified parent
8011 0 $t->putBlock($r, $RK, $RD, $RN); # Save modified right
8012 0 };
8013 0 $t->putBlock($l, $LK, $LD, $LN); # Save non minimum left
8014 0 $$parameters{changed}->copy(1); # Show that we changed the tree layout
8015 },
8016  
8017 Else # Left sibling is last so we either merge the two nodes to eliminate the right node or steal from the left is that is not possible
8018 0 ▶ {my $r = $l; # The left sibling is last so we make it the right block
Subroutine __ANON__: not called CC=1 SCAR=6.9
8019 0 $t->getBlock($r, $RK, $RD, $RN); # Get the right keys/data/nodes
8020 0 my $l = $t->prevNode($r, $PK, $PN); # Left block will be previous sibling
8021 0 $t->getBlock($l, $LK, $LD, $LN); # Get the right keys/data/nodes
8022 0 my $ll = $t->lengthFromKeys($LK); # Length of left
8023 If $ll == $t->lengthMin, # Has the the bare minimum so must merge or steal
8024 Then
8025 0 ▶ {$t->merge($PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN); # Tree definition, parent keys zmm, data zmm, nodes zmm, left keys zmm, data zmm, nodes zmm.
Subroutine __ANON__: not called CC=1 SCAR=6.9
8026 If $t->lengthFromKeys($PK) == 0,
8027 Then # We just merged in the root so make the left sibling the root
8028 0 ▶ {$t->firstFromMemory($F);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8029 0 $t->rootIntoFirst($F, $l);
8030 0 $t->firstIntoMemory($F);
8031 0 $t->upIntoData(K(zero => 0), $LD); # Zero the up pointer for the root
8032 0 $t->freeBlock($p, $PK, $PD, $PN); # Free parent as it is no longer needed
8033 }, # Else not required
8034 Else # Steal from right sibling
8035 0 ▶ {$t->putBlock($p, $PK, $PD, $PN); # Save modified parent
Subroutine __ANON__: not called CC=1 SCAR=6.9
8036 0 };
8037 0 $t->freeBlock($r, $RK, $RD, $RN); # Save modified right
8038 },
8039 Else # Steal from right sibling
8040 0 ▶ {$t->stealFromLeft($PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN); # Steal
Subroutine __ANON__: not called CC=1 SCAR=6.9
8041 0 $t->putBlock($p, $PK, $PD, $PN); # Save modified parent
8042 0 $t->putBlock($r, $RK, $RD, $RN); # Save modified right
8043 0 };
8044 0 $t->putBlock($l, $LK, $LD, $LN); # Save non minimum left
8045 0 $$parameters{changed}->copy(1); # Show that we changed the tree layout
8046 0 };
8047 0 };
8048 0 PopR;
8049 0 } parameters => [qw(offset changed)],
8050 structures => {tree=>$tree},
8051 name => qq(Nasm::X86::Tree::mergeOrSteal-$$tree{length}-$$tree{stringTree});
8052  
8053 0 $s->call
8054 (structures => {tree => $tree},
8055 parameters => {offset => $offset, changed => my $changed = V changed => 0});
8056  
8057 0 $changed # Whether we did a merge or steal
8058 } # mergeOrSteal
8059  
8060 sub Nasm::X86::Tree::stealFromRight($$$$$$$$$$) #P Steal one key from the node on the right where the current left node,parent node and right node are held in zmm registers and return one if the steal was performed, else zero.
8061 0 ▶ {my ($tree, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN) = @_; # Tree definition, parent keys zmm, data zmm, nodes zmm, left keys zmm, data zmm, nodes zmm, right keys, data, nodes zmm.
Subroutine stealFromRight: not called CC=2 SCAR=17.9
8062 0 ▶ @_ == 10 or confess "Ten parameters required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 10 or confess("Ten parameters required") 0 0 0
8063  
8064 my $s = Subroutine
8065 0 ▶ {my ($p, $s, $sub) = @_; # Variable parameters, structure variables, structure copies, subroutine description
Subroutine __ANON__: not called CC=1 SCAR=6.9
8066 0 my $t = $$s{tree};
8067 0 my $ll = $t->lengthFromKeys($LK);
8068 0 my $lr = $t->lengthFromKeys($RK);
8069  
8070 0 PushR 7;
8071  
8072 0 $t->found->copy(0); # Assume we cannot steal
8073  
8074 Block # Check that it is possible to steal key a from the node on the right
8075 0 ▶ {my ($end, $start) = @_; # Code with labels supplied
Subroutine __ANON__: not called CC=1 SCAR=6.9
8076 If $ll != $t->lengthLeft,
8077 Then # Left not minimal
8078 0 ▶ {PrintErrStringNL "Left not minimal";
Subroutine __ANON__: not called CC=1 SCAR=6.9
8079 0 Jmp $end
8080 0 };
8081 If $lr == $t->lengthRight, # Right minimal
8082 Then
8083 0 ▶ {PrintErrStringNL "Should merge not steal";
Subroutine __ANON__: not called CC=1 SCAR=6.9
8084 0 Jmp $end
8085 0 };
8086  
8087 0 $t->found->copy(1); # Proceed with the steal
8088  
8089 0 my $pir = (K one => 1); # Point of right key to steal
8090 0 my $pil = $pir << ($ll - 1); # Point of left key to receive key
8091  
8092 0 my $rk = $pir->dFromPointInZ($RK); # Right key to rotate left
8093 0 my $rd = $pir->dFromPointInZ($RD); # Right data to rotate left
8094 0 my $rn = $pir->dFromPointInZ($RN); # Right node to rotate left
8095  
8096 If $t->leafFromNodes($LN) == 0,
8097 Then # Left is not a leaf so the right is not a leaf so we must upgrade first right child up pointer
8098 0 ▶ {PushR $LK, $LD, $LN, $RK, $RD, $RN;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8099 0 my $ln = dFromZ($LN, 0); # First child of left
8100 0 $t->getBlock($ln, $LK, $LD, $LN); # Left grand child
8101 0 $t->getBlock($rn, $RK, $RD, $RN); # Right grand child
8102 0 my $lcu = $t->upFromData($LD); # Offset of left block
8103 0 $t->upIntoData($lcu, $RD); # Set up of right grand child to left block
8104 0 $t->putBlock($rn, $RK, $RD, $RN);
8105 0 PopR;
8106 0 };
8107  
8108 0 my $pip = $t->insertionPoint($rk, $PK); # Point of parent key to insert
8109 0 my $pip1= $pip >> K(one=>1); # Point of parent key to merge in
8110 0 my $pk = $pip1->dFromPointInZ($PK); # Parent key to rotate left
8111 0 my $pd = $pip1->dFromPointInZ($PD); # Parent data to rotate left
8112  
8113 0 my $pb = $t->getTreeBit($PK, $pip); # Parent tree bit
8114 0 my $rb = $t->getTreeBit($RK, K one => 1); # First right tree bit
8115 0 $pip1->dIntoPointInZ($PK, $rk); # Right key into parent
8116 0 $pip1->dIntoPointInZ($PD, $rd); # Right data into parent
8117 0 $t->setOrClearTreeBitToMatchContent($PK, $pip, $rb); # Right tree bit into parent
8118 0 $pk->dIntoZ($LK, $t->middleOffset); # Parent key into left
8119 0 $pd->dIntoZ($LD, $t->middleOffset); # Parent data into left
8120 0 $rn->dIntoZ($LN, $t->rightOffset); # Right node into left
8121  
8122 0 $t->insertIntoTreeBits($LK, K(position => 1 << $t->lengthLeft), $pb); # Parent tree bit into left
8123  
8124 0 LoadConstantIntoMaskRegister # Nodes area
8125 (7, createBitNumberFromAlternatingPattern '00', $t->maxKeysZ-1, -1);
8126 0 Vpcompressd zmmM($RK, 7), zmm($RK); # Compress right keys one slot left
8127 0 Vpcompressd zmmM($RD, 7), zmm($RD); # Compress right data one slot left
8128  
8129 0 LoadConstantIntoMaskRegister # Nodes area
8130 (7, createBitNumberFromAlternatingPattern '0', $t->maxNodesZ-1, -1);
8131 0 Vpcompressd zmmM($RN, 7), zmm($RN); # Compress right nodes one slot left
8132  
8133 0 $t->incLengthInKeys($LK); # Increment left hand length
8134 0 $t->decLengthInKeys($RK); # Decrement right hand
8135 0 };
8136 0 PopR;
8137 }
8138 0 name => join('::',
8139 "Nasm::X86::Tree::stealFromRight",
8140 $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN, $tree->length),
8141 structures => {tree => $tree};
8142  
8143 0 $s->call(structures => {tree => $tree});
8144  
8145 0 $tree # Chain
8146 }
8147  
8148 sub Nasm::X86::Tree::stealFromLeft($$$$$$$$$$) #P Steal one key from the node on the left where the current left node,parent node and right node are held in zmm registers and return one if the steal was performed, else zero.
8149 0 ▶ {my ($tree, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN) = @_; # Tree definition, parent keys zmm, data zmm, nodes zmm, left keys zmm, data zmm, nodes zmm, right keys, data, nodes zmm.
Subroutine stealFromLeft: not called CC=2 SCAR=17.9
8150 0 ▶ @_ == 10 or confess "Ten parameters required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 10 or confess("Ten parameters required") 0 0 0
8151  
8152 my $s = Subroutine
8153 0 ▶ {my ($p, $s, $sub) = @_; # Variable parameters, structure variables, structure copies, subroutine description
Subroutine __ANON__: not called CC=1 SCAR=6.9
8154 0 my $t = $$s{tree};
8155 0 my $ll = $t->lengthFromKeys($LK);
8156 0 my $lr = $t->lengthFromKeys($RK);
8157  
8158 0 PushR 7;
8159  
8160 0 $t->found->copy(0); # Assume we cannot steal
8161  
8162 Block # Check that it is possible to steal a key from the node on the left
8163 0 ▶ {my ($end, $start) = @_; # Code with labels supplied
Subroutine __ANON__: not called CC=1 SCAR=6.9
8164 0 ▶ If $lr != $t->lengthRight, Then {Jmp $end}; # Right not minimal
Subroutine __ANON__: not called CC=1 SCAR=6.9
8165 0 ▶ If $ll == $t->lengthLeft, Then {Jmp $end}; # Left minimal
Subroutine __ANON__: not called CC=1 SCAR=6.9
8166  
8167 0 $t->found->copy(1); # Proceed with the steal
8168  
8169 0 my $pir = K(one => 1); # Point of right key
8170 0 my $pil = $pir << ($ll - 1); # Point of left key
8171  
8172 0 my $lk = $pil->dFromPointInZ($LK); # Left key to rotate right
8173 0 my $ld = $pil->dFromPointInZ($LD); # Left data to rotate right
8174 0 my $ln = ($pil << K(key => 1))->dFromPointInZ($LN); # Left node to rotate right
8175  
8176 0 my $lb = $t->getTreeBit($LK, $pil); # Left tree bit to rotate right
8177  
8178 0 my $pip = $t->insertionPoint($lk, $PK); # Point of parent key to merge in
8179  
8180 0 my $pk = $pip->dFromPointInZ($PK); # Parent key to rotate right
8181 0 my $pd = $pip->dFromPointInZ($PD); # Parent data to rotate right
8182 0 my $pb = $t->getTreeBit($PK, $pip); # Parent tree bit
8183  
8184 0 LoadConstantIntoMaskRegister # Nodes area
8185 (7, createBitNumberFromAlternatingPattern '00', $t->maxKeysZ-1, -1);
8186 0 Vpexpandd zmmM($RK, 7), zmm($RK); # Expand right keys one slot right
8187 0 Vpexpandd zmmM($RD, 7), zmm($RD); # Expand right data one slot right
8188  
8189 0 LoadConstantIntoMaskRegister # Nodes area
8190 (7, createBitNumberFromAlternatingPattern '0', $t->maxNodesZ-1, -1);
8191 0 Vpexpandd zmmM($RN, 7), zmm($RN); # Expand right nodes one slot right
8192  
8193 0 $pip->dIntoPointInZ($PK, $lk); # Left key into parent
8194 0 $pip->dIntoPointInZ($PD, $ld); # Left data into parent
8195 0 $t->setOrClearTreeBitToMatchContent($PK, $pip, $lb); # Left tree bit into parent
8196  
8197 0 $pir->dIntoPointInZ($RK, $pk); # Parent key into right
8198 0 $pir->dIntoPointInZ($RD, $pd); # Parent data into right
8199 0 $pir->dIntoPointInZ($RN, $ln); # Left node into right
8200 0 $t->insertIntoTreeBits($RK, $pir, $pb); # Parent tree bit into right
8201  
8202 0 $t->decLengthInKeys($LK); # Decrement left hand
8203 0 $t->incLengthInKeys($RK); # Increment right hand
8204  
8205 If $t->leafFromNodes($RN) == 0,
8206 Then # Right is not a leaf so we must upgrade the up pointer of the first child of right to match that of the second child of right
8207 0 ▶ {PushR $LK, $LD, $LN, $RK, $RD, $RN;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8208 0 my $r1 = dFromZ($RN, 0); # First child of right
8209 0 my $r2 = dFromZ($RN, 0); # Second child of right
8210 0 $t->getBlock($r1, $LK, $LD, $LN); # Load first child of right
8211 0 $t->getBlock($r2, $RK, $RD, $RN); # Load second child of right
8212 0 my $r2u = $t->upFromData($RD); # Up from second child of right
8213 0 $t->upIntoData($r2u, $LD); # Set first child up to second child up
8214 0 $t->putBlock($r1, $LK, $LD, $LN);
8215 0 PopR;
8216 0 };
8217  
8218 0 };
8219 0 PopR;
8220 }
8221 0 name => join('::',
8222 "Nasm::X86::Tree::stealFromLeft",
8223 $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN, $tree->length),
8224  
8225 structures => {tree => $tree};
8226  
8227 0 $s->call(structures => {tree => $tree});
8228  
8229 0 $tree # Chain
8230 } # stealFromLeft
8231  
8232 sub Nasm::X86::Tree::merge($$$$$$$$$$) #P Merge a left and right node if they are at minimum size.
8233 0 ▶ {my ($tree, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN) = @_; # Tree definition, parent keys zmm, data zmm, nodes zmm, left keys zmm, data zmm, nodes zmm, right keys, data, nodes zmm.
Subroutine merge: not called CC=2 SCAR=17.9
8234 0 ▶ @_ == 10 or confess "Ten parameters required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 10 or confess("Ten parameters required") 0 0 0
8235  
8236 my $s = Subroutine
8237 0 ▶ {my ($p, $s, $sub) = @_; # Variable parameters, structure variables, structure copies, subroutine description
Subroutine __ANON__: not called CC=1 SCAR=6.9
8238 0 my $t = $$s{tree};
8239 0 my $ll = $t->lengthFromKeys($LK);
8240 0 my $lr = $t->lengthFromKeys($RK);
8241  
8242 0 PushR 7, 14, 15;
8243  
8244 Block # Check that it is possible to steal a key from the node on the left
8245 0 ▶ {my ($end, $start) = @_; # Code with labels supplied
Subroutine __ANON__: not called CC=2 SCAR=17.9
8246 0 ▶ If $ll != $t->lengthLeft, Then {Jmp $end}; # Left not minimal
Subroutine __ANON__: not called CC=1 SCAR=6.9
8247 0 ▶ If $lr != $t->lengthRight, Then {Jmp $end}; # Right not minimal
Subroutine __ANON__: not called CC=1 SCAR=6.9
8248  
8249 0 my $pil = K(one => 1); # Point of first left key
8250 0 my $lk = $pil->dFromPointInZ($LK); # First left key
8251 0 my $pip = $t->insertionPoint($lk, $PK); # Point of parent key to merge in
8252 0 my $pk = $pip->dFromPointInZ($PK); # Parent key to merge
8253 0 my $pd = $pip->dFromPointInZ($PD); # Parent data to merge
8254 0 my $pn = $pip->dFromPointInZ($PN); # Parent node to merge
8255 0 my $pb = $t->getTreeBit($PK, $pip); # Parent tree bit
8256  
8257 0 my $m = K(one => 1) << K( shift => $t->lengthLeft); # Position of parent key in left
8258 0 $m->dIntoPointInZ($LK, $pk); # Position parent key in left
8259 0 $m->dIntoPointInZ($LD, $pd); # Position parent data in left
8260 0 $t->insertIntoTreeBits($LK, $m, $pb); # Tree bit for parent data
8261 0 LoadConstantIntoMaskRegister # Keys/Data area
8262 (7, createBitNumberFromAlternatingPattern '00', $t->lengthRight, -$t->lengthMiddle);
8263 0 Vpexpandd zmmM($LK, 7), zmm($RK); # Expand right keys into left
8264 0 Vpexpandd zmmM($LD, 7), zmm($RD); # Expand right data into left
8265 0 LoadConstantIntoMaskRegister # Nodes area
8266 (7, createBitNumberFromAlternatingPattern '0', $t->lengthRight+1, -$t->lengthMiddle);
8267 0 Vpexpandd zmmM($LN, 7), zmm($RN); # Expand right data into left
8268  
8269 0 $pip->setReg(15); # Collapse mask for keys/data in parent
8270 0 Not r15;
8271 0 And r15, $t->treeBitsMask;
8272 0 Kmovq k7, r15;
8273 0 Vpcompressd zmmM($PK, 7), zmm($PK); # Collapse parent keys
8274 0 Vpcompressd zmmM($PD, 7), zmm($PD); # Collapse data keys
8275  
8276 0 my $one = K(one => 1); # Collapse mask for keys/data in parent
8277 # my $np = (!$pip << $one) >> $one;
8278 0 my $np = !$pip << $one; # Move the compression point up one to remove the matching node
8279 0 $np->setReg(14);
8280 0 Add r14, 1; # Fill hole left at position 0
8281 0 Kmovq k7, r14; # Node squeeze mask
8282 0 Vpcompressd zmmM($PN, 7), zmm($PN); # Collapse nodes
8283  
8284 0 ▶ my $z = $PK == 31 ? 30: 31; # Collapse parent tree bits
Branch: 1 branch
BranchTrueFalseTotal
$PK == 31 ? : 0 0 0
8285 0 PushR zmm $z; # Collapse parent tree bits
8286 0 $t->getTreeBits($PK, r15); # Get tree bits
8287 0 Kmovq k7, r15; # Tree bits
8288 0 Vpmovm2d zmm($z), k7; # Broadcast the bits into a zmm
8289 0 $pip->setReg(15); # Parent insertion point
8290 0 Kmovq k7, r15;
8291 0 Knotq k7, k7; # Invert parent insertion point
8292 0 Vpcompressd zmmM($z, 7), zmm($z); # Compress
8293 0 Vpmovd2m k7, zmm $z; # Recover bits
8294 0 Kmovq r15, k7;
8295 0 And r15, $t->treeBitsMask; # Clear trailing bits beyond valid tree bits
8296 0 $t->setTreeBits($PK, r15);
8297 0 PopR;
8298  
8299 0 $t->getTreeBits($LK, r15); # Append right tree bits to the Left tree bits
8300 0 $t->getTreeBits($RK, r14); # Right tree bits
8301 0 my $sl = RegisterSize(r15) * $bitsInByte / 4 - $tree->lengthMiddle; # Clear bits right of the lower left bits
8302 0 Shl r15w, $sl;
8303 0 Shr r15w, $sl;
8304  
8305 0 Shl r14, $tree->lengthMiddle; # Move right tree bits into position
8306 0 Or r15, r14; # And in left tree bits
8307 0 And r15, $t->treeBitsMask; # Clear trailing bits beyond valid tree bits
8308 0 $t->setTreeBits($LK, r15); # Set tree bits
8309  
8310 If $t->leafFromNodes($RN) == 0,
8311 Then # Right is not a leaf so we must upgrade the up offset of its children to the up pointer of the first left child
8312 0 ▶ {PushR $LK, $LD, $LN;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8313 0 my $l1 = dFromZ($LN, 0); # First child of left
8314 0 $t->getBlock($l1, $LK, $LD, $LN); # Load first child of left
8315 0 my $l2u = $t->upFromData($LD); # Offset of left block
8316 0 my $lr = 1 + $t->lengthFromKeys($RK); # Number of right children
8317 $lr->for(sub # Each child of right
8318 0 ▶ {my ($i) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8319 0 my $r = dFromZ($RN, $i * $tree->width); # Offset of child
8320 0 $t->getBlock($r, $LK, $LD, $LN); # Load child of right
8321 0 $t->upIntoData ($l2u, $LD); # Set parent
8322 0 $t->putBlock($r, $LK, $LD, $LN); # Write back into memory
8323 0 });
8324 0 PopR;
8325 0 };
8326  
8327 0 $t->decLengthInKeys($PK); # Parent now has one less
8328 0 $t->lengthIntoKeys($LK, K length => $t->length); # Left is now full
8329  
8330 0 };
8331 0 PopR;
8332 }
8333 0 name => join('::',
8334 "Nasm::X86::Tree::merge",
8335 $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN, $tree->length),
8336 structures => {tree => $tree};
8337  
8338 0 $s->call(structures => {tree=> $tree});
8339  
8340 0 $tree # Chain
8341 } # merge
8342  
8343 sub Nasm::X86::Tree::deleteFirstKeyAndData($$$) #P Delete the first element of a leaf mode returning its characteristics in the calling tree descriptor.
8344 0 ▶ {my ($tree, $K, $D) = @_; # Tree definition, keys zmm, data zmm
Subroutine deleteFirstKeyAndData: not called CC=2 SCAR=17.9
8345 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
8346  
8347 my $s = Subroutine
8348 0 ▶ {my ($p, $s, $sub) = @_; # Variable parameters, structure variables, structure copies, subroutine description
Subroutine __ANON__: not called CC=1 SCAR=6.9
8349 0 my $t = $$s{tree};
8350 0 my $l = $t->lengthFromKeys($K);
8351  
8352 0 PushR 7, 14, 15;
8353  
8354 0 $t->found->copy(0); # Assume not found
8355  
8356 Block # Check that it is possible to steal a key from the node on the left
8357 0 ▶ {my ($end, $start) = @_; # Code with labels supplied
Subroutine __ANON__: not called CC=1 SCAR=6.9
8358 0 ▶ If $l == 0, Then {Jmp $end}; # No elements left
Subroutine __ANON__: not called CC=1 SCAR=6.9
8359  
8360 0 $t->found->copy(1); # Show first key and data have been found
8361  
8362 0 $t->key ->copy(dFromZ $K, 0); # First key
8363 0 $t->data->copy(dFromZ $D, 0); # First data
8364 0 $t->getTreeBits($K, r15); # First tree bit
8365  
8366 0 Mov r14, r15;
8367 0 Shr r14, 1; # Shift tree bits over by 1
8368 0 $t->setTreeBits($K, r14); # Save new tree bits
8369 0 And r15, 1; # Isolate first tree bit
8370 0 $t->subTree->copy(r15); # Save first tree bit
8371  
8372 0 my $m = (K(one => 1) << K(shift => $t->length)) - 2; # Compression mask to remove key/data
8373 0 $m->setReg(7);
8374 0 Vpcompressd zmmM($K, 7), zmm($K); # Compress out first key
8375 0 Vpcompressd zmmM($D, 7), zmm($D); # Compress out first data
8376  
8377 0 $t->decLengthInKeys($K); # Reduce length
8378 0 };
8379 0 PopR;
8380 }
8381 0 name => qq(Nasm::X86::Tree::deleteFirstKeyAndData-$K-$D-$$tree{length}-$$tree{stringTree}),
8382 structures => {tree => $tree};
8383  
8384 0 $s->call(structures => {tree => $tree});
8385  
8386 0 $tree # Chain tree - actual data is in key, data, subTree, found variables
8387 }
8388  
8389 sub Nasm::X86::Tree::delete($$) # Find a key in a tree and delete it returning he value of the l=key deleted if found.
8390 0 ▶ {my ($tree, $key) = @_; # Tree descriptor, key field to delete
Subroutine delete: not called CC=4 SCAR=30.0
8391 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
8392  
8393 0 ▶ confess "No yet implemented for stringTrees" if $tree->stringTree;
Branch: 1 branch
BranchTrueFalseTotal
if $tree->stringTree 0 0 0
8394  
8395 my $s = Subroutine
8396 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
8397  
8398 Block
8399 0 ▶ {my ($success) = @_; # Short circuit if ladders by jumping directly to the end after a successful push
Subroutine __ANON__: not called CC=2 SCAR=17.9
8400  
8401 0 my $t = $$s{tree}->zero; # Tree to search
8402 0 my $k = $$p{key}; # Key to find
8403 0 $t->key->copy($k); # Copy in key so we know what was searched for
8404  
8405 0 $t->find($k); # See if we can find the key
8406 0 ▶ If $t->found == 0, Then {Jmp $success}; # Key not present so we cannot delete
Subroutine __ANON__: not called CC=1 SCAR=6.9
8407  
8408 0 PushR my $F = 31, my $K = 30, my $D = 29, my $N = 28;
8409  
8410 0 $t->firstFromMemory($F); # Update the size of the tree
8411 0 my $size = $t->sizeFromFirst($F); # Size of tree
8412 0 $t->decSizeInFirst($F);
8413 0 $t->firstIntoMemory($F);
8414  
8415 K(loop => 99)->for(sub
8416 0 ▶ {my ($i, $startDescent, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8417  
8418 0 $t->firstFromMemory ($F); # Load first block
8419 0 my $root = $t->rootFromFirst($F); # Start the search from the root to locate the key to be deleted
8420 0 ▶ If $root == 0, Then{Jmp $success}; # Empty tree so we have not found the key and nothing needs to be done
Subroutine __ANON__: not called CC=1 SCAR=6.9
8421  
8422 If $size == 1, # Delete the last element which must be the matching element
8423 Then
8424 0 ▶ {$t->rootIntoFirst($F, K z=>0); # Empty the tree
Subroutine __ANON__: not called CC=1 SCAR=6.9
8425 0 $t->firstIntoMemory($F); # The position of the key in the root node
8426 0 Jmp $success
8427 0 };
8428  
8429 0 $t->getBlock($root, $K, $D, $N); # Load root block
8430 If $t->leafFromNodes($N) > 0, # Element must be in the root as the root is a leaf and we know the key can be found
8431 Then
8432 0 ▶ {my $eq = $t->indexEq($k, $K); # Key must be in this leaf as we know it can be found and this is the last opportunity to find it
Subroutine __ANON__: not called CC=1 SCAR=6.9
8433 0 $t->extract($eq, $K, $D, $N); # Extract from root
8434 0 $t->putBlock($root, $K, $D, $N);
8435 0 Jmp $success
8436 0 };
8437  
8438 0 my $P = $root->clone('position'); # Position in tree
8439 K(loop => 99)->for(sub # Step down through tree looking for the key
8440 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8441 0 my $eq = $t->indexEq($k, $K); # The key might still be in the parent now known not be a leaf
8442 If $eq > 0,
8443 Then # We have found the key so now we need to find the next leaf unless this node is in fact a leaf
8444 0 ▶ {my $pu = $t->upFromData($D); # Parent offset
Subroutine __ANON__: not called CC=1 SCAR=6.9
8445 If $pu > 0,
8446 Then # Cannot merge or steal on root
8447 0 ▶ {If $t->mergeOrSteal($P) > 0, # Merge or steal if necessary
Subroutine __ANON__: not called CC=1 SCAR=6.9
8448 Then # Restart entire process because we might have changed the position of the key being deleted by merging in its vicinity
8449 0 ▶ {Jmp $startDescent;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8450 0 };
8451 0 };
8452  
8453 If $t->leafFromNodes($N) > 0, # We found the item in a leaf so it can be deleted immediately if there is enough
8454 Then
8455 0 ▶ {my $eq = $t->indexEq($k, $K); # Key must be in this leaf as we know it can be found and this is the last opportunity to find it
Subroutine __ANON__: not called CC=1 SCAR=6.9
8456 0 $t->extract($eq, $K, $D, $N); # Remove from block
8457 0 $t->putBlock($P, $K, $D, $N); # Save block
8458 0 Jmp $success; # Leaf removed
8459 0 };
8460  
8461 0 my $eq = $t->indexEq($k, $K); # Location of key
8462 0 my $Q = ($eq << K(one=>1))->dFromPointInZ($N); # Go right to the next level down
8463  
8464 K(loop => 99)->for(sub # Find the left most leaf
8465 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8466  
8467 If $t->mergeOrSteal($Q) > 0, # Merge or steal if necessary
8468 Then # Restart entire process because we might have changed the position of the key being deleted by merging in its vicinity
8469 0 ▶ {Jmp $startDescent;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8470 0 };
8471 0 $t->getBlock($Q, $K, $D, $N); # Next block down
8472 If $t->leafFromNodes($N) > 0, # We must hit a leaf eventually
8473 Then
8474 0 ▶ {$t->extractFirst($K, $D, $N); # Remove from block
Subroutine __ANON__: not called CC=1 SCAR=6.9
8475 0 $t->putBlock($Q, $K, $D, $N); # Save block
8476  
8477 0 my $key = $t->key->clone("key"); # Record details of leaf
8478 0 my $data = $t->data->clone("data");
8479 0 my $subTree = $t->subTree->clone("data");
8480 0 $t->find($k); # Find key we actually want to delete
8481  
8482 0 $t->key ->copy($key); # Reload
8483 0 $t->data ->copy($data);
8484 0 $t->subTree->copy($subTree);
8485  
8486 0 my $l = $t->offset; # Offset of block containing key
8487  
8488 0 $t->getBlock($l, $K, $D, $N); # Block containing key
8489 0 $t->replace ($t->found, $K, $D); # Replace key to delete with leaf
8490 0 $t->putBlock($l, $K, $D, $N); # Save block
8491 0 Jmp $success;
8492 0 };
8493  
8494 0 my $i = $t->insertionPoint($k, $K); # The insertion point if we were inserting is the next node to visit
8495 0 $Q->copy($i->dFromPointInZ($N)); # Get the corresponding offset of the the next block down
8496 0 });
8497 0 Jmp $success;
8498 0 };
8499  
8500 0 my $i = $t->insertionPoint($k, $K); # The insertion point if we were inserting is the next node to visit
8501 0 $P->copy($i->dFromPointInZ($N)); # Get the corresponding node
8502  
8503 0 $t->getBlock($P, $K, $D, $N); # Get the next block
8504  
8505 0 my $l = $t->lengthFromKeys($K); # Length of block
8506  
8507 If $l == $t->lengthMin, # Has the the bare minimum so must be merged.
8508 Then
8509 0 ▶ {If $t->mergeOrSteal($P) > 0, # Merge or steal if necessary
Subroutine __ANON__: not called CC=1 SCAR=6.9
8510 Then # Restart entire process because we might have changed the position of the key being deleted by merging in its vicinity
8511 0 ▶ {Jmp $startDescent;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8512 0 };
8513 0 };
8514 0 });
8515 0 });
8516 0 ▶ PrintErrTraceBack "Stuck looking for leaf" if $DebugMode;
Branch: 1 branch
BranchTrueFalseTotal
if $Nasm::X86::DebugMode 0 0 0
8517 0 }; # Find completed successfully
8518 0 PopR;
8519 0 } parameters =>[qw(key)],
8520 structures =>{tree=>$tree},
8521 name => qq(Nasm::X86::Tree::delete-$$tree{length}-$$tree{stringTree});
8522  
8523 0 ▶ $s->call(structures => {tree => $tree},
Branch: 1 branch
BranchTrueFalseTotal
ref $key ? : 0 0 0
8524 parameters => {key => ref($key) ? $key : K key => $key});
8525 } # delete
8526  
8527 sub Nasm::X86::Tree::clear($) # Delete everything in the tree except the first block recording any memory liberated on the free chain.
8528 0 ▶ {my ($tree) = @_; # Tree
Subroutine clear: not called CC=2 SCAR=17.9
8529 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
8530  
8531 my $s = Subroutine # Delete all the sub blocks of a block and then free the block as well
8532 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
8533  
8534 0 my $t = $$s{tree}; # Tree
8535 0 my $area = $t->area; # Area
8536  
8537 0 PushR my $K = 31, my $D = 30, my $N = 29;
8538  
8539 Block # Free sub blocks then free block
8540 0 ▶ {my ($end, $start) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8541  
8542 0 $t->getBlock($$p{offset}, $K, $D, $N); # Load block
8543  
8544 If $t->leafFromNodes($N) == 0,
8545 Then # Not a leaf so free the sub blocks
8546 0 ▶ {my $l = $t->lengthFromKeys($K); # Number of nodes
Subroutine __ANON__: not called CC=1 SCAR=6.9
8547 ($l+1)->for(sub # Free sub blocks
8548 0 ▶ {my ($i) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8549 0 $sub->call(parameters => {offset => dFromZ $N, $i * $t->width}, # Recurse
8550 structures => {tree => $t});
8551 0 });
8552 0 };
8553  
8554 0 $t->freeBlock($$p{offset}, $K, $D, $N); # Free this block
8555 0 };
8556  
8557 0 PopR;
8558 0 } parameters => [qw(offset)],
8559 structures => {tree => $tree},
8560 name => qq(Nasm::X86::Tree::clear-$$tree{length}-$$tree{stringTree});
8561  
8562 0 PushR my $F = 31;
8563 0 $tree->firstFromMemory($F);
8564 0 my $root = $tree->rootFromFirst($F); # Root block if any
8565  
8566 If $root > 0, # Non empty tree
8567 Then
8568 0 ▶ {$s->call(structures => {tree => $tree}, parameters => {offset => $root}); # Free from root node
Subroutine __ANON__: not called CC=1 SCAR=6.9
8569 0 $tree->rootIntoFirst($F, K root => 0);
8570 0 $tree->sizeIntoFirst($F, K size => 0);
8571 0 $tree->firstIntoMemory($F);
8572 0 };
8573  
8574 0 PopR;
8575 }
8576  
8577 sub Nasm::X86::Tree::free($) # Free all the memory used by a tree.
8578 0 ▶ {my ($tree) = @_; # Tree
Subroutine free: not called CC=2 SCAR=17.9
8579 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
8580 0 $tree->clear; # Clear the tree
8581 }
8582  
8583 #D2 Iteration # Iterate through a tree non recursively
8584  
8585 sub Nasm::X86::Tree::by($&) # Call the specified block with each element of the specified tree in ascending order.
8586 0 ▶ {my ($tree, $block) = @_; # Tree descriptor, block to execute
Subroutine by: not called CC=2 SCAR=17.9
8587 0 ▶ @_ == 2 or confess "Two parameters required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters required") 0 0 0
8588  
8589 0 $tree->findFirst; # First element
8590 0 my $end = Label; # End of processing
8591 0 my $next = Label; # Next iteration
8592 0 my $start = SetLabel; # Start of this iteration
8593 0 ▶ If $tree->found == 0, Then {Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
8594 0 &$block($tree, $start, $next, $end); # Perform the specified block
8595 0 SetLabel $next;
8596 0 $tree->findNext($tree->key);
8597 0 Jmp $start;
8598 0 SetLabel $end;
8599 }
8600  
8601 sub Nasm::X86::Tree::yb($&) # Call the specified block with each element of the specified tree in descending order.
8602 0 ▶ {my ($tree, $block) = @_; # Tree descriptor, block to execute
Subroutine yb: not called CC=2 SCAR=17.9
8603 0 ▶ @_ == 2 or confess "Two parameters required";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters required") 0 0 0
8604  
8605 0 $tree->findLast; # Last element
8606 0 my $end = Label; # End of processing
8607 0 my $prev = Label; # Next iteration
8608 0 my $start = SetLabel; # Start of this iteration
8609 0 ▶ If $tree->found == 0, Then {Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
8610 0 &$block($tree, $start, $prev, $end); # Perform the specified block
8611 0 SetLabel $prev;
8612 0 $tree->findPrev($tree->key);
8613 0 Jmp $start;
8614 0 SetLabel $end;
8615 }
8616  
8617 #D2 Push and Pop # Use a tree as a stack: Push elements on to a tree with the next available key; Pop the last element in a tree.
8618  
8619 sub Nasm::X86::Tree::push($$) #P Push a data value onto a tree. If the data is a reference to a tree then the offset of the first block of the tree is pushed.
8620 0 ▶ {my ($tree, $data) = @_; # Tree descriptor, variable data
Subroutine push: not called CC=2 SCAR=17.9
8621 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
8622  
8623 0 $tree->findLast; # Last element
8624 If $tree->found == 0,
8625 Then # Empty tree
8626 0 ▶ {$tree->put(K(key => 0), $data); # First element in tree
Subroutine __ANON__: not called CC=1 SCAR=6.9
8627 },
8628 Else # Non empty tree
8629 0 ▶ {$tree->put($tree->key + 1, $data); # Last element in tree
Subroutine __ANON__: not called CC=1 SCAR=6.9
8630 0 };
8631 }
8632  
8633 sub Nasm::X86::Tree::peek($$) # Peek at the element the specified distance back from the top of the stack and return its B<value> in data and found status in B<found> in the tree descriptor.
8634 0 ▶ {my ($tree, $Back) = @_; # Tree descriptor, how far back to go with 1 being the top
Subroutine peek: not called CC=3 SCAR=24.8
8635 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
8636  
8637 0 $tree->found->copy(0); # Assume we will not be able to find the desired element
8638  
8639 0 my $size = $tree->size; # Size of the stack
8640 0 ▶ my $back = ref($Back) ? $Back : K back => $Back;
Branch: 1 branch
BranchTrueFalseTotal
ref $Back ? : 0 0 0
8641 If $back <= $size,
8642 Then # Requested element is available on the stack
8643 0 ▶ {$tree->find($size - $back);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8644 0 };
8645 0 $tree
8646 }
8647  
8648 sub Nasm::X86::Tree::peekSubTree($$) # Pop the last value out of a tree and return a tree descriptor positioned on it with the first/found fields set.
8649 0 ▶ {my ($tree, $Back) = @_; # Tree descriptor, how far back to go with 1 being the top
Subroutine peekSubTree: not called CC=3 SCAR=24.8
8650 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
8651 0 ▶ my $back = ref($Back) ? $Back : K back => $Back;
Branch: 1 branch
BranchTrueFalseTotal
ref $Back ? : 0 0 0
8652  
8653 0 my $t = $tree->DescribeTree; # Create a tree descriptor
8654 0 $t->found->copy(0); # Mark tree as not set
8655 0 $tree->peek($back); # Requested element
8656 If $tree->found > 0,
8657 Then # Found an element
8658 0 ▶ {If $tree->subTree > 0,
Subroutine __ANON__: not called CC=1 SCAR=6.9
8659 Then # Found a sub tree
8660 0 ▶ {$t->first->copy($tree->data); # Reposition on sub tree
Subroutine __ANON__: not called CC=1 SCAR=6.9
8661 0 $t->found->copy(1);
8662 0 };
8663 0 };
8664 0 $t
8665 }
8666  
8667 sub Nasm::X86::Tree::pop($) # Pop the last value out of a tree and return the key/data/subTree in the tree descriptor.
8668 0 ▶ {my ($tree) = @_; # Tree descriptor
Subroutine pop: not called CC=2 SCAR=17.9
8669 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
8670  
8671 0 $tree->findLast; # Last element
8672 If $tree->found > 0,
8673 Then # Empty tree
8674 0 ▶ {my $k = $tree->key ->clone('key');
Subroutine __ANON__: not called CC=1 SCAR=6.9
8675 0 my $d = $tree->data ->clone('data');
8676 0 my $s = $tree->subTree->clone('subTree');
8677 0 $tree->delete($k); # Delete last key
8678 0 $tree->key ->copy($k); # Retrieved key
8679 0 $tree->data ->copy($d); # Retrieved data
8680 0 $tree->subTree->copy($s); # Retrieved sub tree indicator
8681 0 $tree->found ->copy(1); # Indicate success
8682 },
8683 Else
8684 0 ▶ {PrintErrTraceBack "Empty stack";
Subroutine __ANON__: not called CC=1 SCAR=6.9
8685 0 };
8686 }
8687  
8688 sub Nasm::X86::Tree::popSubTree($%) # Pop the last value out of a tree and return a tree descriptor positioned on it with the first/found fields set.
8689 0 ▶ {my ($tree, %options) = @_; # Tree descriptor, options describing the sub tree
Subroutine popSubTree: not called CC=2 SCAR=17.9
8690 0 ▶ @_ >= 1 or confess "One or more parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 or confess("One or more parameter") 0 0 0
8691  
8692 0 $tree->pop;
8693  
8694 0 my $t = $tree->DescribeTree(%options); # Create a tree descriptor to indicate the result
8695 0 $t->zero;
8696 If $tree->found > 0,
8697 Then
8698 0 ▶ {If $tree->subTree > 0,
Subroutine __ANON__: not called CC=1 SCAR=6.9
8699 Then
8700 0 ▶ {$t->found->copy($tree->found);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8701 0 $t->first->copy($tree->data); # We are popping a tree so the data is the offset of the first block
8702 0 $t->subTree->copy(1);
8703 },
8704 Else
8705 0 ▶ {PrintErrTraceBack "Not a sub tree";
Subroutine __ANON__: not called CC=1 SCAR=6.9
8706 0 };
8707 0 };
8708  
8709 0 $t # Sub tree
8710 }
8711  
8712 sub Nasm::X86::Tree::get($$) # Retrieves the element at the specified zero based index in the stack.
8713 0 ▶ {my ($tree, $Key) = @_; # Tree descriptor, zero based index
Subroutine get: not called CC=3 SCAR=24.8
8714 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
8715 0 ▶ my $key = ref($Key) ? $Key : K(key => $Key); # Promote constant
Branch: 1 branch
BranchTrueFalseTotal
ref $Key ? : 0 0 0
8716  
8717 0 $tree->find($key);
8718 0 $tree->key->copy($key);
8719 }
8720  
8721 #D2 Trees as Strings # Use trees as strings of dwords. The size of the tree is the length of the string. Each dword is consider as an indivisible unit. This arrangement allows the normal string operations of concatenation and substring to be performed easily.
8722  
8723 sub Nasm::X86::Tree::appendAscii($$$) # Append ascii bytes in memory to a tree acting as a string. The address and size of the source memory are specified via variables. Each byte should represent a valid ascii byte so that it can be considered, when left extended with 24 zero bits, as utf32.
8724 0 ▶ {my ($string, $address, $size) = @_; # Tree descriptor of string to append to, variable address of memory to append from, variable size of memory
Subroutine appendAscii: not called CC=2 SCAR=17.9
8725 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
8726  
8727 my $s = Subroutine
8728 0 ▶ {my ($parameters, $structures, $sub) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8729 0 PushR rax, 13, 14, 15;
8730 0 my $s = $$structures{string};
8731 0 $$parameters{address}->setReg(r13);
8732 0 $$parameters{size} ->setReg(r14);
8733 0 ClearRegisters r15;
8734 For # Clear memory
8735 0 ▶ {Mov al, "[r13+r15]";
Subroutine __ANON__: not called CC=1 SCAR=6.9
8736 0 $s->push(V byte => rax);
8737 0 } r15, r14, 1;
8738 0 PopR;
8739 0 } structures => {string=>$string},
8740 parameters => [qw(address size)],
8741 name => qq(Nasm::X86::Tree::m::$$string{length});
8742  
8743 0 $s->call(parameters=>{address => $address, size=>$size},
8744 structures=>{string=>$string});
8745 }
8746  
8747 sub Nasm::X86::Tree::append($$) # Append the second source string to the first target string renumbering the keys of the source string to follow on from those of the target string. A string can safely be appended to itself.
8748 0 ▶ {my ($string, $append) = @_; # Tree descriptor of string to append to, tree descriptor of string to append from
Subroutine append: not called CC=2 SCAR=17.9
8749 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
8750  
8751 0 my $lt = $string->size; # Target string size
8752 0 my $ls = $append->size; # Source string size
8753 $ls->for(sub # Look up each character
8754 0 ▶ {my ($i, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8755 0 $append->get($i);
8756 0 $string->put($lt+$i, $append->data);
8757 0 });
8758 0 $string # Chain from the target string
8759 }
8760  
8761 sub Nasm::X86::Tree::clone($) # Clone a string.
8762 0 ▶ {my ($string) = @_; # Tree descriptor
Subroutine clone: not called CC=2 SCAR=17.9
8763 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
8764  
8765 0 my $t = $string->area->CreateTree; # Cloned copy
8766 $string->by(sub
8767 0 ▶ {$t->put($string->key, $string->data);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8768 0 });
8769 0 $t # Chain from the target string
8770 }
8771  
8772 sub Nasm::X86::Tree::substring($$$) # Create the substring of the specified string between the specified start and end keys.
8773 0 ▶ {my ($string, $Start, $Finish) = @_; # Tree descriptor of string to extract from, start key, end key
Subroutine substring: not called CC=4 SCAR=30.0
8774 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
8775  
8776 0 ▶ my $start = ref($Start) ? $Start : K(start => $Start); # Promote constant
Branch: 1 branch
BranchTrueFalseTotal
ref $Start ? : 0 0 0
8777 0 ▶ my $finish = ref($Finish) ? $Finish : K(finish => $Finish); # Promote constant
Branch: 1 branch
BranchTrueFalseTotal
ref $Finish ? : 0 0 0
8778  
8779 0 my $t = $string->area->CreateTree; # Cloned copy
8780 If $start == $finish,
8781 Then # Start and end are the same
8782 0 ▶ {$string->find($start);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8783 If $string->found > 0,
8784 Then
8785 0 ▶ {$t->put($string->key, $string->data);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8786 0 };
8787 },
8788 0 ▶ Ef {$start < $finish}
Subroutine __ANON__: not called CC=1 SCAR=6.9
8789 Then # Range of several keys
8790 0 ▶ {$string->find($finish-1);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8791 If $string->found > 0,
8792 Then # Finish exists
8793 0 ▶ {$string->find($start);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8794 If $string->found > 0,
8795 Then # Start exists
8796 0 ▶ {$string->size->for(sub # Each key in range
Subroutine __ANON__: not called CC=1 SCAR=6.9
8797 0 ▶ {my ($i, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8798 0 $t->put($i, $string->data);
8799 0 $string->findNext($string->key);
8800 0 ▶ If $string->found == 0, Then {Jmp $end}; # End of input string
Subroutine __ANON__: not called CC=1 SCAR=6.9
8801 0 ▶ If $string->key >= $finish, Then {Jmp $end}; # End of range
Subroutine __ANON__: not called CC=1 SCAR=6.9
8802 0 });
8803 0 };
8804 0 };
8805 0 };
8806 0 $t # Chain from the target string
8807 }
8808  
8809 sub Nasm::X86::Tree::reverse($) # Create a clone of the string in reverse order.
8810 0 ▶ {my ($string) = @_; # Tree descriptor of string
Subroutine reverse: not called CC=2 SCAR=17.9
8811 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
8812  
8813 0 my $t = $string->area->CreateTree; # Cloned reversed copy
8814 0 my $l = $string->size; # Size of string
8815 $string->by(sub
8816 0 ▶ {$t->put($l - $string->key - 1, $string->data);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8817 0 });
8818 0 $t # Chain from the target string
8819 }
8820  
8821 #sub Nasm::X86::Area::treeFromString($$$) # Create a tree from a string of bytes held at a variable address with a variable length and return the resulting tree. The first element of the tree is the specified length, in bytes, of the string.
8822 # {my ($area, $address, $size) = @_; # Area description, address of string, length of string in bytes
8823 # @_ == 3 or confess "Three parameters";
8824 #
8825 # my $t = $area->CreateTree; # Create a tree to be used to store the string
8826 #
8827 # PushR my $c = r13, my $a = r14, my $i = r15;
8828 #
8829 # ClearRegisters $i;
8830 # $address->setReg($a);
8831 #
8832 # $size->for(sub # Push each byte of the input string into the tree
8833 # {Mov $c."b", "[r14+r15]"; # Load byte
8834 # $t->push(V chunk => $c); # Push byte into string
8835 # Inc $i;
8836 # });
8837 # PopR;
8838 #
8839 # $t # Description of tree loaded from string
8840 # }
8841  
8842 #D2 Trees as sets # Trees of trees as sets
8843  
8844 sub Nasm::X86::Tree::union($) # Given a tree of trees consider each sub tree as a set and form the union of all these sets as a new tree.
8845 0 ▶ {my ($tree) = @_; # Tree descriptor for a tree of trees
Subroutine union: not called CC=2 SCAR=17.9
8846 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
8847  
8848 0 my $u = $tree->area->CreateTree;
8849 $tree->by(sub # Each sub tree
8850 0 ▶ {my ($T) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8851 0 my $t = $tree->position($T->data);
8852 $t->by(sub # Insert each element of each sub tree
8853 0 ▶ {my ($s) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8854 0 $u->put($s->key, $s->data);
8855 0 });
8856 0 });
8857 0 $u # Union
8858 }
8859  
8860 sub Nasm::X86::Tree::intersection($) # Given a tree of trees consider each sub tree as a set and form the intersection of all these sets as a new tree.
8861 0 ▶ {my ($tree) = @_; # Tree descriptor for a tree of trees
Subroutine intersection: not called CC=2 SCAR=17.9
8862 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
8863  
8864 0 my $i = $tree->area->CreateTree; # Resulting intersection
8865 0 my $F = V smallest => -1;
8866 0 my $S = V size => -1;
8867  
8868 $tree->by(sub # Find smallest sub tree
8869 0 ▶ {my ($T, $start, $next) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8870 0 my $f = $T->data;
8871 0 my $t = $tree->position($f);
8872 0 my $s = $t->size;
8873 OrBlock # Update size if no size seen yet or if the size is smaller
8874 0 ▶ {my ($pass) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8875 0 ▶ If $S == -1, Then {Jmp $pass}; # No size set yet
Subroutine __ANON__: not called CC=1 SCAR=6.9
8876 0 ▶ If $S > $s, Then {Jmp $pass}; # Smaller size
Subroutine __ANON__: not called CC=1 SCAR=6.9
8877 } # Do not attempt to put a comma here!
8878 Then # Smallest so far
8879 0 ▶ {$S->copy($s);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8880 0 $F->copy($f);
8881 0 };
8882 0 });
8883  
8884 If $S > 0, # The smallest set is not empty set so the intersection might not be empty either
8885 Then
8886 0 ▶ {$tree->findFirst;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8887 0 my $f = $tree->position($F); # First tree (but the smallest sub tree would be better)
8888  
8889 $f->by(sub # Insert each element of each sub tree
8890 0 ▶ {my ($t, undef, $nextElement) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8891 0 my $k = $t->key;
8892  
8893 $tree->by(sub # Each sub tree
8894 0 ▶ {my ($T, undef, $nextTree) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8895 0 ▶ If $F == $T->data, Then {Jmp $nextTree}; # Skip the first tree
Subroutine __ANON__: not called CC=1 SCAR=6.9
8896  
8897 0 my $t = $tree->position($T->data);
8898 0 $t->find($k);
8899 0 ▶ If $t->found == 0, Then {Jmp $nextElement}; # Not found in this sub tree so it cannot be part of the intersection
Subroutine __ANON__: not called CC=1 SCAR=6.9
8900 0 });
8901 0 $i->put($k, $k);
8902 0 });
8903 0 };
8904  
8905 0 $i # Intersection
8906 }
8907  
8908 #D2 Key String Trees # A key string tree has strings for keys.
8909  
8910 sub Nasm::X86::Tree::getKeyString($$$) # Find a string in a string tree and return the associated data and find status in the data and found fields of the tree.
8911 0 ▶ {my ($tree, $address, $size) = @_; # Tree descriptor, address of key, length of key
Subroutine getKeyString: not called CC=2 SCAR=17.9
8912 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
8913  
8914 my $s = Subroutine
8915 0 ▶ {my ($p, $s, $sub) = @_; # should be optimized for case where string is less than one zmm
Subroutine __ANON__: not called CC=1 SCAR=6.9
8916  
8917 0 my $t = $$s{tree};
8918 0 my $a = $t->area;
8919 0 my $d = $$p{data};
8920  
8921 0 PushR my $address = r15, my $remainder = r14, my $offset = r13, my $key = 31;
8922 0 $$p{address}->setReg($address); # Address parameters
8923 0 $$p{size} ->setReg($remainder);
8924  
8925 0 my $T = $t->cloneDescriptor; # Copy the descriptor for the tree so we can reposition it if needed
8926  
8927 Block
8928 0 ▶ {my ($end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8929 0 Mov $offset, 0;
8930 ForIn # Find initial full blocks
8931 0 ▶ {Vmovdqu64 zmm($key), "[$address+$offset]";
Subroutine __ANON__: not called CC=1 SCAR=6.9
8932 0 $T->find(zmm $key);
8933 If $T->found > 0,
8934 Then
8935 0 ▶ {$T->first->copy($T->data); # The next sub tree down is addressed by the B<data> field of the tree descriptor
Subroutine __ANON__: not called CC=1 SCAR=6.9
8936 },
8937 Else # Not found at this level
8938 0 ▶ {$t->found->copy(0); # Show not found
Subroutine __ANON__: not called CC=1 SCAR=6.9
8939 0 Jmp $end; # Finished
8940 0 };
8941 }
8942 Then # Last block (which might be empty
8943 0 ▶ {Mov rsi, 0;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8944 0 Bts rsi, $remainder; # Set bit
8945 0 Dec rsi; # All the zeroes left of the bit are now ones
8946 0 Kmovq k1, rsi;
8947 0 Vmovdqu8 zmmMZ($key, 1), "[$address+$offset]";
8948 0 $T->find(zmm $key); # Find the zmm
8949 0 }, $offset, $remainder, RegisterSize(zmm0);
8950  
8951 0 $t->found->copy($T->found); # Copy results into original tree
8952 0 $t->data ->copy($T->data);
8953 0 };
8954  
8955 0 PopR;
8956 0 } structures => {tree => $tree},
8957 parameters => [qw(address size)],
8958 name => qq(Nasm::X86::Tree::getKeyString);
8959  
8960 0 $s->call(parameters => {address => $address, size=>$size},
8961 structures => {tree => $tree});
8962 }
8963  
8964 sub Nasm::X86::Tree::putKeyString($$$$) # Associate a string of any length with a double word.
8965 0 ▶ {my ($tree, $address, $size, $data) = @_; # Tree descriptor, address of key, length of key, data associated with key
Subroutine putKeyString: not called CC=3 SCAR=24.8
8966 0 ▶ @_ == 4 or confess "Four parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Four parameters") 0 0 0
8967  
8968 0 ▶ $tree->stringTree or confess "Not a string tree"; # Check that we are creating a string tree
Branch: 1 branch
BranchTrueFalseTotal
$tree->stringTree or confess("Not a string tree") 0 0 0
8969  
8970 my $s = Subroutine # should be optimized for case where string is less than one zmm
8971 0 ▶ {my ($p, $s, $sub) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8972  
8973 0 my $t = $$s{tree}->cloneDescriptor; # Clone the input tree descriptor so we can reposition it to handle strings longer than one zmm block
8974 0 my $a = $t->area;
8975 0 my $d = $$p{data};
8976  
8977 0 PushR my $area = r15, my $remainder = r14, my $offset = r13, my $zKey = 31;
8978 0 $$p{address}->setReg($area); # Address parameters
8979 0 $$p{size} ->setReg($remainder);
8980  
8981 0 Mov $offset, 0;
8982 ForIn # Load initial full blocks into area
8983 0 ▶ {Vmovdqu64 zmm($zKey), "[$area+$offset]";
Subroutine __ANON__: not called CC=1 SCAR=6.9
8984 0 $t->find(zmm $zKey);
8985 If $t->found > 0,
8986 Then
8987 0 ▶ {$t->first->copy($t->data);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8988 },
8989 Else
8990 0 ▶ {my $k = $a->appendZmm(zmm $zKey);
Subroutine __ANON__: not called CC=1 SCAR=6.9
8991 0 my $T = $a->CreateTree(stringTree => 1);
8992 0 $t->put($k, $T);
8993 0 $t->copyDescriptor($T);
8994 0 };
8995 }
8996 Then # Append remainder of string as a full zmm block padded with zeroes
8997 0 ▶ {Mov rsi, 0;
Subroutine __ANON__: not called CC=1 SCAR=6.9
8998 0 Bts rsi, $remainder; # Set bit
8999 0 Dec rsi; # All the zeroes left of the bit are now ones
9000 0 Kmovq k1, rsi;
9001 0 Vmovdqu8 "zmm1{k1}{z}", "[$area+$offset]";
9002 0 my $k = $a->appendZmm(1); # Place the zmm data into the area
9003 0 $t->put($k, $d);
9004 0 }, $offset, $remainder, RegisterSize(zmm0);
9005  
9006 0 PopR;
9007 0 } structures => {tree => $tree},
9008 parameters => [qw(address size data)],
9009 name => qq(Nasm::X86::Tree::putKeyString);
9010  
9011 0 $tree->getKeyString($address, $size); # See if we can find the string in the tree as an existing tree
9012  
9013 If $tree->found == 0, # Not found so insert
9014 Then
9015 0 ▶ {$s->call(parameters => {address => $address, size=>$size, data=>$data},
Subroutine __ANON__: not called CC=1 SCAR=6.9
9016 structures => {tree => $tree});
9017 0 $tree->found->copy(0); # We had to insert
9018 0 };
9019 }
9020  
9021 sub Nasm::X86::Tree::uniqueKeyString($$$) # Add a key string to a string tree if the key is not already present and return a unique number identifying the string (although currently there is no way to fast way to recover the string from the number). If the key string is already present in the string tree return the number associated with the original key string rather than creating a new entry.
9022 0 ▶ {my ($tree, $address, $size) = @_; # Tree descriptor, address of key, length of key
Subroutine uniqueKeyString: not called CC=2 SCAR=17.9
9023 0 ▶ @_ == 3 or confess "Three parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or confess("Three parameters") 0 0 0
9024  
9025 0 PushR my $area = r15, my $first = r14, my $count = r13;
9026 0 $tree->area->address->setReg($area);
9027 0 $tree->first->setReg($first);
9028 0 my $o = $tree->stringTreeCountOff; # Offset of count field - long keys are stored in multiple sub trees so the conventional size field is not enough
9029 0 Mov dWordRegister($count),"[$area+$first+$o]"; # Number of strings so far
9030  
9031 0 my $c = V count => $count;
9032 0 $tree->putKeyString($address, $size, $c); # Try to add the string
9033 If $tree->found == 0,
9034 Then # A new key string was inserted
9035 0 ▶ {$c->getReg($count);
Subroutine __ANON__: not called CC=1 SCAR=6.9
9036 0 Inc $count;
9037 0 $tree->area->address->setReg($area); # The area might have moved due to the new allocation
9038 0 Mov "[$area+$first+$o]", dWordRegister($count); # Update string count after successful insert
9039 },
9040 Else
9041 0 ▶ {$c->copy($tree->data);
Subroutine __ANON__: not called CC=1 SCAR=6.9
9042 0 };
9043 0 PopR;
9044  
9045 0 $c # Unique string number as a variable
9046 }
9047  
9048 #D2 Print # Print a tree
9049  
9050 sub Nasm::X86::Tree::dumpWithWidth($$$$$$$) #P Dump a tree and all its sub trees.
9051 0 ▶ {my ($tree, $title, $width, $margin, $first, $keyX, $dataX) = @_; # Tree, title, width of offset field, the maximum width of the indented area, whether to print the offset of the tree, whether to print the key field in hex or decimal, whether to print the data field in hex or decimal
Subroutine dumpWithWidth: not called CC=2 SCAR=17.9
9052 0 ▶ @_ == 7 or confess "Seven parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Seven parameters") 0 0 0
9053  
9054 0 PushR my $F = 31;
9055  
9056 my $s = Subroutine # Print a tree
9057 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
9058 0 my $t = $$s{tree}; # Tree
9059 0 my $I = $$p{indentation}; # Indentation to apply to the start of each new line
9060  
9061 0 PushR my $transfer = r8, my $treeBitsR = r9, my $treeBitsIndexR = r10,
9062 my $K = 30, my $D = 29, my $N = 28;
9063  
9064 Block # Print each node in the tree
9065 0 ▶ {my ($end, $start) = @_; # Labels
Subroutine __ANON__: not called CC=1 SCAR=6.9
9066 0 my $offset = $$p{offset}; # Offset of node to print
9067 0 $t->getBlock($offset, $K, $D, $N); # Load node
9068 0 $t->getTreeBits($K, $treeBitsR); # Tree bits for this node
9069 0 my $l = $t->lengthFromKeys($K); # Number of nodes
9070  
9071 0 my $root = $t->rootFromFirst($F); # Root or not
9072  
9073 0 $I->outSpaces;
9074 0 PrintOutString "At: "; # Print position and length
9075 0 $offset->outRightInHex(K width => $width);
9076 0 (K(col => $margin) - $I)->outSpaces;
9077 0 PrintOutString "length: ";
9078 0 $l->outRightInDec($width);
9079  
9080 0 PrintOutString ", data: "; # Position of data block
9081 0 $t->getLoop($K)->outRightInHex(K width => $width);
9082  
9083 0 PrintOutString ", nodes: "; # Position of nodes block
9084 0 $t->getLoop($D)->outRightInHex(K width => $width);
9085  
9086 0 PrintOutString ", first: "; # First block of tree
9087 0 $t->getLoop($N)->outRightInHex(K width => $width);
9088  
9089 0 my $U = $t->upFromData($D); # Up field determines root / parent / leaf
9090  
9091 If $root == $offset,
9092 Then
9093 0 ▶ {PrintOutString ", root"; # Root
Subroutine __ANON__: not called CC=1 SCAR=6.9
9094 },
9095 Else
9096 0 ▶ {PrintOutString ", up: "; # Up
Subroutine __ANON__: not called CC=1 SCAR=6.9
9097 0 $U->outRightInHex(K width => $width);
9098 0 };
9099  
9100 If dFromZ($N, 0) == 0, # Leaf or parent
9101 Then
9102 0 ▶ {PrintOutString ", leaf";
Subroutine __ANON__: not called CC=1 SCAR=6.9
9103 },
9104 Else
9105 0 ▶ {PrintOutString ", parent";
Subroutine __ANON__: not called CC=1 SCAR=6.9
9106 0 };
9107  
9108 0 $t->getTreeBits($K, $transfer);
9109 0 Cmp $transfer, 0;
9110 IfGt
9111 Then # Identify the data elements which are sub trees
9112 0 ▶ {PrintOutString ", trees: ";
Subroutine __ANON__: not called CC=1 SCAR=6.9
9113 0 V(bits => $transfer)->outRightInBin(K width => $t->maxKeys);
9114 0 };
9115 0 PrintOutNL;
9116  
9117 0 $I->copy($I + 2); # Indent sub tree
9118  
9119 0 $I->outSpaces; PrintOutString "Index:"; # Indices
9120 $l->for(sub
9121 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
9122 0 PrintOutString ' ';
9123 0 $index->outRightInDec($width);
9124 0 });
9125 0 PrintOutNL;
9126  
9127 my $printKD = sub # Print keys or data or nodes
9128 0 ▶ {my ($name, $zmm, $nodes, $tb) = @_; # Key or data or node, zmm containing key or data or node, print nodes if true, print tree bits if true
Subroutine __ANON__: not called CC=3 SCAR=24.8
9129 0 $I->outSpaces; PrintOutString $name; # Keys
9130 0 ▶ Mov $treeBitsIndexR, 1 if $tb; # Check each tree bit position
Branch: 1 branch
BranchTrueFalseTotal
if $tb 0 0 0
9131  
9132 ($nodes ? $l + 1 : $l)->for(sub # There is one more node than keys or data
9133 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
9134 0 my $i = $index * $t->width; # Key or Data offset
9135 0 my $k = dFromZ $zmm, $i; # Key or Data
9136  
9137 0 ▶ if (!$tb) # No tree bits
Branch: 1 branch
BranchTrueFalseTotal
if (not $tb) { } 0 0 0
9138 0 {PrintOutString ' ';
9139 0 $k->outRightInHex(K width => $width);
9140 }
9141 else
9142 0 {Test $treeBitsR, $treeBitsIndexR; # Check for a tree bit
9143 IfNz
9144 Then # This key indexes a sub tree
9145 0 ▶ {if ($first) # Print out the offset of the first block as used by the sub tree
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if ($first) { } 0 0 0
9146 0 {($k >> K(four => 4))->outRightInHex(K width => $width); # This field indicates the offset of the first block
9147 }
9148 else # This key indexes a sub tree and for a reason which I have no desire to call to mind, I once thought it necessary to print the offset of the first node rather than the first block.
9149 0 {PushR 31;
9150 0 $t->area->getZmmBlock($k, 31);
9151 0 my $r = $t->rootFromFirst($F) >> K(four => 4);
9152 0 PopR;
9153 0 $r->outRightInHex(K width => $width);
9154 }
9155 0 PrintOutString '*';
9156 },
9157 Else
9158 0 ▶ {PrintOutString ' ';
Subroutine __ANON__: not called CC=6 SCAR=37.4
9159 0 ▶ if ($name =~ m(key))
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /key/) { } 0 0 0
9160 0 ▶ {$k->outRightInHex($width) if $keyX;
Branch: 1 branch
BranchTrueFalseTotal
if $keyX 0 0 0
9161 0 ▶ $k->outRightInDec($width) unless $keyX;
Branch: 1 branch
BranchTrueFalseTotal
unless $keyX 0 0 0
9162 }
9163 else
9164 0 ▶ {$k->outRightInHex($width) if $dataX;
Branch: 1 branch
BranchTrueFalseTotal
if $dataX 0 0 0
9165 0 ▶ $k->outRightInDec($width) unless $dataX;
Branch: 1 branch
BranchTrueFalseTotal
unless $dataX 0 0 0
9166 }
9167 0 };
9168 }
9169 0 ▶ Shl $treeBitsIndexR, 1 if $tb; # Next tree bit position
Branch: 1 branch
BranchTrueFalseTotal
if $tb 0 0 0
9170 0 ▶ });
Branch: 1 branch
BranchTrueFalseTotal
$nodes ? : 0 0 0
9171 0 PrintOutNL;
9172 0 };
9173  
9174 0 $printKD->('Keys :', $K, 0, 0); # Print key
9175 0 $printKD->('Data :', $D, 0, 1); # Print data
9176 If dFromZ($N, 0) > 0, # If the first node is not zero we are not on a leaf
9177 Then
9178 0 ▶ {$printKD->('Nodes:', $N, 1, 0);
Subroutine __ANON__: not called CC=1 SCAR=6.9
9179 0 };
9180  
9181 0 Cmp $treeBitsR, 0; # Any tree bits set?
9182 IfNe
9183 Then # Tree bits present
9184 0 ▶ {Mov $treeBitsIndexR, 1; # Check each tree bit position
Subroutine __ANON__: not called CC=1 SCAR=6.9
9185 0 PushR my $F = 31; # Load first block of sub tree
9186 K(loop => $t->maxKeys)->for(sub
9187 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
9188 0 Test $treeBitsR, $treeBitsIndexR; # Check for a tree bit
9189 IfNz
9190 Then # This key indexes a sub tree
9191 0 ▶ {my $i = $index * $t->width; # Key/data offset
Subroutine __ANON__: not called CC=2 SCAR=17.9
9192 0 my $d = dFromZ($D, $i); # Data
9193 0 my $I = V(indentation => 0)->copy($I + 2 + 1); # Indent by one extra space to show separate sub tree rather than continuation of the existing tree and to make the at address line up with the address in data.
9194  
9195 0 my $T = $t->position($d);
9196 0 $T->firstFromMemory($F); # First block for tree
9197 0 my $r = $T->rootFromFirst($F);
9198  
9199 0 ▶ if ($first) # The offset of the tree if requested
Branch: 1 branch
BranchTrueFalseTotal
if ($first) 0 0 0
9200 0 {($I-2)->outSpaces; # The word 'tree' is two letters longer than the word 'at'
9201 0 PrintOutString "Tree: ";
9202 0 $T->first->outRightInHexNL(K width => $width);
9203 }
9204  
9205 If $r == 0, # Empty tree
9206 Then
9207 0 ▶ {PrintOutStringNL "- empty";
Subroutine __ANON__: not called CC=1 SCAR=6.9
9208 },
9209 Else
9210 0 ▶ {$sub->call(parameters => {indentation => $I, offset => $r},
Subroutine __ANON__: not called CC=1 SCAR=6.9
9211 structures => {tree => $T}); # Print sub tree referenced by data field
9212 0 };
9213 0 };
9214 0 Shl $treeBitsIndexR, 1; # Next tree bit position
9215 0 });
9216 0 PopR;
9217 0 };
9218  
9219 If $l > 0,
9220 Then # If the block only has one node it must be a leaf
9221 0 ▶ {($l+1)->for(sub # Print sub nodes
Subroutine __ANON__: not called CC=1 SCAR=6.9
9222 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
9223 0 my $i = $index * $t->width; # Key/Data offset
9224 0 my $d = dFromZ($N, $i); # Sub nodes
9225 If $d > 0, # Print any sub nodes
9226 Then
9227 0 ▶ {my $I = V(indentation => 0)->copy($I + 2);
Subroutine __ANON__: not called CC=1 SCAR=6.9
9228 0 $sub->call(parameters => {indentation => $I, offset=>$d},
9229 structures => {tree => $t}); # Print sub tree referenced by data field
9230 0 };
9231 0 });
9232 0 };
9233  
9234 0 ($I - 2)->outSpaces; PrintOutStringNL "end"; # Separate sub tree dumps
9235  
9236 0 };
9237  
9238 0 PopR;
9239 0 } parameters => [qw(indentation offset)],
9240 structures => {tree => $tree},
9241 name => "Nasm::X86::Tree::dump-$$tree{length}-$width-$margin-$first";
9242  
9243 0 PrintOutStringNL $title; # Title of the piece so we do not lose it
9244  
9245 0 $tree->firstFromMemory($F); # First block for tree
9246 0 my $Q = $tree->rootFromFirst($F);
9247  
9248 If $Q == 0, # Empty tree
9249 Then
9250 0 ▶ {PrintOutStringNL "- empty";
Subroutine __ANON__: not called CC=1 SCAR=6.9
9251 },
9252 Else
9253 0 ▶ {$tree->first->outNL("Tree: ") if $first;
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if $first 0 0 0
9254 0 $s->call(structures => {tree => $tree}, # Print root node
9255 parameters => {indentation => V(indentation => 0),
9256 offset => $Q});
9257 0 };
9258  
9259 0 PopR;
9260 }
9261  
9262 sub Nasm::X86::Tree::dump($$) #P Dump a tree and all its sub trees.
9263 0 ▶ {my ($tree, $title) = @_; # Tree, title
Subroutine dump: not called CC=2 SCAR=17.9
9264 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
9265 0 $tree->dumpWithWidth($title, 4, 20, 0, 1, 0)
9266 }
9267  
9268 sub Nasm::X86::Tree::dump8($$) #P Dump a tree and all its sub trees using 8 character fields for numbers.
9269 0 ▶ {my ($tree, $title) = @_; # Tree, title
Subroutine dump8: not called CC=2 SCAR=17.9
9270 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
9271 0 $tree->dumpWithWidth($title, 8, 80, 1, 1, 0)
9272 }
9273  
9274 sub Nasm::X86::Tree::dump8xx($$) #P Dump a tree and all its sub trees using 8 character fields for numbers printing the keys and data in hexadecimal.
9275 0 ▶ {my ($tree, $title) = @_; # Tree, title
Subroutine dump8xx: not called CC=2 SCAR=17.9
9276 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
9277 0 $tree->dumpWithWidth($title, 8, 80, 1, 1, 1)
9278 }
9279  
9280 sub Nasm::X86::Tree::printInOrder($$) # Print a tree in order.
9281 0 ▶ {my ($tree, $title) = @_; # Tree, title
Subroutine printInOrder: not called CC=2 SCAR=17.9
9282 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
9283  
9284 0 PushR my $F = 31;
9285  
9286 my $s = Subroutine # Print a tree
9287 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
9288  
9289 0 my $t = $$s{tree}; # Tree
9290 0 my $area = $t->area; # Area
9291  
9292 0 PushR my $treeBitsR = r8, my $treeBitsIndexR = r9,
9293 my $K = 30, my $D = 29, my $N = 28;
9294  
9295 Block # Print each node in the tree
9296 0 ▶ {my ($end, $start) = @_; # Labels
Subroutine __ANON__: not called CC=1 SCAR=6.9
9297 0 my $offset = $$p{offset}; # Offset of node to print
9298 0 $t->getBlock($offset, $K, $D, $N); # Load node
9299 0 my $l = $t->lengthFromKeys($K); # Number of nodes
9300 $l->for(sub # Print sub nodes
9301 0 ▶ {my ($index, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
9302 0 my $i = $index * $t->width; # Key/Data?node offset
9303 0 my $k = dFromZ $K, $i; # Key
9304 0 my $d = dFromZ $D, $i; # Data
9305 0 my $n = dFromZ $N, $i; # Sub nodes
9306 If $n > 0, # Not a leaf
9307 Then
9308 0 ▶ {$sub->call(parameters => {offset => $n}, # Recurse
Subroutine __ANON__: not called CC=1 SCAR=6.9
9309 structures => {tree => $t});
9310 0 };
9311 0 $k->outRightInHex(K width => 4); # Print key
9312 0 });
9313  
9314 If $l > 0, # Print final sub tree
9315 Then
9316 0 ▶ {my $o = $l * $t->width; # Final sub tree offset
Subroutine __ANON__: not called CC=1 SCAR=6.9
9317 0 my $n = dFromZ $N, $l * $t->width; # Final sub tree
9318 If $n > 0, # Not a leaf
9319 Then
9320 0 ▶ {$sub->call(parameters => {offset => $n},
Subroutine __ANON__: not called CC=1 SCAR=6.9
9321 structures => {tree => $t});
9322  
9323 0 };
9324 0 };
9325 0 };
9326 0 PopR;
9327 0 } parameters => [qw(offset)],
9328 structures => {tree => $tree},
9329 name => qq(Nasm::X86::Tree::printInOrder-$$tree{length}-$$tree{stringTree});
9330  
9331 0 PrintOutString $title; # Title of the piece so we do not lose it
9332  
9333 0 $tree->firstFromMemory($F);
9334 0 my $R = $tree->rootFromFirst($F);
9335 0 my $C = $tree->sizeFromFirst($F);
9336  
9337 If $R == 0, # Empty tree
9338 Then
9339 0 ▶ {PrintOutStringNL "- empty";
Subroutine __ANON__: not called CC=1 SCAR=6.9
9340 },
9341 Else
9342 0 ▶ {$C->outRightInDec(4);
Subroutine __ANON__: not called CC=1 SCAR=6.9
9343 0 PrintOutString ": ";
9344  
9345 0 $s->call(structures => {tree => $tree}, # Print root node
9346 parameters => {offset => $R});
9347 0 PrintOutNL;
9348 0 };
9349  
9350 0 PopR;
9351 }
9352  
9353 sub Nasm::X86::Tree::outAsUtf8($) # Print the data values of the specified string on stdout assuming each data value is a utf32 character and that the output device supports utf8.
9354 0 ▶ {my ($string) = @_; # Tree descriptor of string
Subroutine outAsUtf8: not called CC=2 SCAR=17.9
9355 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
9356  
9357 $string->by(sub # Each character
9358 0 ▶ {my ($i, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
9359 0 PushR rax;
9360 0 $string->data->setReg(rax);
9361 0 convert_rax_from_utf32_to_utf8;
9362 0 PrintOutRaxAsText;
9363 0 PopR;
9364 0 });
9365 0 $string # Chain from the target string
9366 }
9367  
9368 sub Nasm::X86::Tree::outAsUtf8NL($) # Print the data values of the specified string on stdout assuming each data value is a utf32 character and that the output device supports utf8. Follow the print with a new line character.
9369 0 ▶ {my ($string) = @_; # Tree descriptor of string
Subroutine outAsUtf8NL: not called CC=2 SCAR=17.9
9370 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
9371 0 $string->outAsUtf8;
9372 0 PrintOutNL;
9373 0 $string # Chain from the target string
9374 }
9375  
9376 #if (1) # Define operator overloading for trees
9377 # {package Nasm::X86::Tree;
9378 # use overload
9379 ## '+' => \&add,
9380 ## '-' => \&sub,
9381 ## '*' => \&times,
9382 ## '/' => \&divide,
9383 ## '%' => \&mod,
9384 ## '==' => \&eq,
9385 ## '!=' => \&ne,
9386 ## '>=' => \&ge,
9387 ## '>' => \&gt,
9388 ## '<=' => \&le,
9389 ## '<' => \&lt,
9390 ## '++' => \&inc,
9391 # '--' => \&dec,
9392 ## '""' => \&str,
9393 ## '&' => \&and, # We use the zero flag as the bit returned by a Boolean operation so we cannot implement '&' or '|' which were previously in use because '&&' and '||' and "and" and "or" are all disallowed in Perl operator overloading.
9394 ## '|' => \&or,
9395 # '+=' => \&plusAssign,
9396 ## '-=' => \&minusAssign,
9397 ## '=' => \&equals,
9398 ## '<<' => \&shiftLeft,
9399 ## '>>' => \&shiftRight,
9400 ## '!' => \&not,
9401 # "fallback" => 1,
9402 # }
9403 #
9404 #sub Nasm::X86::Tree::plusAssign($$) # Use plus to push an element to a tree being used as a stack.
9405 # {my ($tree, $data) = @_; # Tree being used as a stack, data to push
9406 #
9407 # ref($data) =~ m(Variable|Tree) or # Check right operand on right
9408 # confess "Need a tree or variable on the right";
9409 #
9410 # $tree->push($data); # Perform the push
9411 # $tree # The resulting tree
9412 # }
9413 #
9414 #sub Nasm::X86::Tree::dec($) # Pop from the tree if it is being used as a stack.
9415 # {my ($tree) = @_; # Tree being used as a stack
9416 #
9417 # $tree->pop # Perform the pop
9418 # }
9419  
9420 #D1 Unisyn # Parse Unisyn language statements.
9421  
9422 sub compactRangeIntoHex(@) #P Compact a range of numbers into hexadecimal.
9423 0 ▶ {my (@P) = @_; # Numbers to compact
Subroutine compactRangeIntoHex: not called CC=5 SCAR=34.0
Pod documented
9424 0 my @p = sort @P;
9425  
9426 0 ▶ confess "Unsorted range" unless dump(@p) eq dump(@P);
Branch: 1 branch
BranchTrueFalseTotal
unless Nasm::X86::dump(@p) eq Nasm::X86::dump(@P) 0 0 0
9427 0 my @r;
9428  
9429 my sub format(@) # Format a range
9430 0 ▶ {my (@f) = @_;
Subroutine format: not called CC=3 SCAR=24.8
9431 0 ▶ return push @r, sprintf "0x%x..0x%x", $f[0], $f[-1] if @f > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @f > 1 0 0 0
9432 0 ▶ return push @r, sprintf "0x%x", $f[0] if @f == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @f == 1 0 0 0
9433 0 confess "Empty range";
9434 }
9435  
9436 0 my @f = shift @p;
9437 0 ▶ for(;@p;) # Break into ranges
Branch: 1 branch
BranchTrueFalseTotal
if (@p) 0 0 0
9438 0 ▶ {if ($f[-1] + 1 == $p[0])
Branch: 1 branch
BranchTrueFalseTotal
if ($f[-1] + 1 == $p[0]) { } 0 0 0
9439 0 {push @f, shift @p;
9440 }
9441 else
9442 0 {format @f;
9443 0 @f = shift @p;
9444 }
9445 }
9446 0 ▶ format @f if @f; # Last range if any
Branch: 1 branch
BranchTrueFalseTotal
if @f 0 0 0
9447  
9448 0 join ', ', @r; # Range as a string
9449 }
9450  
9451 #D2 Lex # Lexical Analysis
9452  
9453 0 ▶sub Nasm::X86::Unisyn::Lex::Number::S {0} #P Start symbol.
Subroutine S: not called CC=1 SCAR=6.9
9454 0 ▶sub Nasm::X86::Unisyn::Lex::Number::F {1} #P End symbol.
Subroutine F: not called CC=1 SCAR=6.9
9455  
9456 0 ▶sub Nasm::X86::Unisyn::Lex::Number::A {2} #P ASCII characters extended with circled characters to act as escape sequences.
Subroutine A: not called CC=1 SCAR=6.9
9457 0 ▶sub Nasm::X86::Unisyn::Lex::Letter::A {(0x0..0x7f, 0x24b6..0x24e9)} #P
Subroutine A: not called CC=1 SCAR=6.9
9458  
9459 0 ▶sub Nasm::X86::Unisyn::Lex::Number::p {3} #P Prefix operator - applies only to the following variable or bracketed term.
Subroutine p: not called CC=1 SCAR=6.9
9460 0 ▶sub Nasm::X86::Unisyn::Lex::Letter::p {(0x1d468...0x1d49b, 0x1d71c..0x1d755, map {ord} qw(₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₀))} #P
Subroutine p: not called CC=1 SCAR=6.9
9461  
9462 0 ▶sub Nasm::X86::Unisyn::Lex::Number::v {4} #P Variable names.
Subroutine v: not called CC=1 SCAR=6.9
9463 0 ▶sub Nasm::X86::Unisyn::Lex::Letter::v {(0x1d5d4...0x1d607, 0x1d756..0x1d78f)} #P
Subroutine v: not called CC=1 SCAR=6.9
9464  
9465 0 ▶sub Nasm::X86::Unisyn::Lex::Number::q {5} #P Suffix operator - applies only to the preceding variable or bracketed term.
Subroutine q: not called CC=1 SCAR=6.9
9466 0 ▶sub Nasm::X86::Unisyn::Lex::Letter::q {(0x1d63c...0x1d66f,0x1d790..0x1d7c9, map {ord} qw(¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁰ ᵃ ᵇ ᶜ ᵈ ᵉ ᶠ ᵍ ʰ ⁱ ʲ ᵏ ˡ ᵐ ⁿ ᵒ ᵖ ʳ ˢ ᵗ ᵘ ᵛ ʷ ˣ ʸ ᶻ))}
Subroutine q: not called CC=1 SCAR=6.9
9467  
9468 0 ▶sub Nasm::X86::Unisyn::Lex::Number::s {6} #P Infix operator with left to right binding at priority 1.
Subroutine s: not called CC=1 SCAR=6.9
9469 0 ▶sub Nasm::X86::Unisyn::Lex::Letter::s {(0x27e2)}
Subroutine s: not called CC=1 SCAR=6.9
9470  
9471 0 ▶sub Nasm::X86::Unisyn::Lex::Number::b {7} #P Open.
Subroutine b: not called CC=1 SCAR=6.9
9472 sub Nasm::X86::Unisyn::Lex::Letter::b #P
9473 0 ▶ {(0x2308,0x230a,0x2329,0x2768,0x276a,0x276c,0x276e,0x2770,0x2772,0x2774,0x27e6,0x27e8,0x27ea,0x27ec,0x27ee,0x2983,0x2985,0x2987,0x2989,0x298b,0x298d,0x298f,0x2991,0x2993,0x2995,0x2997,0x29fc,0x2e28,0x3008,0x300a,0x3010,0x3014,0x3016,0x3018,0x301a,0xfd3e,0xff08,0xff5f)
Subroutine b: not called CC=1 SCAR=6.9
9474 }
9475  
9476 0 ▶sub Nasm::X86::Unisyn::Lex::Number::B {8} #P Close.
Subroutine B: not called CC=1 SCAR=6.9
9477 sub Nasm::X86::Unisyn::Lex::Letter::B #P
9478 0 ▶ {(0x2309,0x230b,0x232a,0x2769,0x276b,0x276d,0x276f,0x2771,0x2773,0x2775,0x27e7,0x27e9,0x27eb,0x27ed,0x27ef,0x2984,0x2986,0x2988,0x298a,0x298c,0x298e,0x2990,0x2992,0x2994,0x2996,0x2998,0x29fd,0x2e29,0x3009,0x300b,0x3011,0x3015,0x3017,0x3019,0x301b,0xfd3f,0xff09,0xff60)
Subroutine B: not called CC=1 SCAR=6.9
9479 }
9480  
9481 0 ▶sub Nasm::X86::Unisyn::Lex::Number::d{9} #P
Subroutine d: not called CC=1 SCAR=6.9
9482 sub Nasm::X86::Unisyn::Lex::Letter::d #P Dyad 2 - Double struck
9483 0 ▶ {(0x1d538..0x1d538+51, 0x2103, 0x210d, 0x2115, 0x2119, 0x211a, 0x211d,
Subroutine d: not called CC=1 SCAR=6.9
9484 0x2124)
9485 }
9486  
9487 0 ▶sub Nasm::X86::Unisyn::Lex::Number::e{10} #P
Subroutine e: not called CC=1 SCAR=6.9
9488 sub Nasm::X86::Unisyn::Lex::Letter::e #P Dyad 3 - Mono
9489 0 ▶ {(0x1d670..0x1d670+51)
Subroutine e: not called CC=1 SCAR=6.9
9490 }
9491  
9492 0 ▶sub Nasm::X86::Unisyn::Lex::Number::a {11} #P Assign infix operator with right to left binding at priority 4.
Subroutine a: not called CC=1 SCAR=6.9
9493 sub Nasm::X86::Unisyn::Lex::Letter::a #P
9494 0 ▶ {(0x210e, 0x2190..0x21fe, 0xff1d, 0x1d434..0x1d454,
Subroutine a: not called CC=1 SCAR=6.9
9495 0x1d456..0x1d467, 0x1d6e2..0x1d71b)
9496 }
9497  
9498 0 ▶sub Nasm::X86::Unisyn::Lex::Number::f {12} #P
Subroutine f: not called CC=1 SCAR=6.9
9499 sub Nasm::X86::Unisyn::Lex::Letter::f #P Dyad 5 - Sans-serif Normal
9500 0 ▶ {(0x1d5a0..0x1d5a0+51)
Subroutine f: not called CC=1 SCAR=6.9
9501 }
9502  
9503 0 ▶sub Nasm::X86::Unisyn::Lex::Number::g {13} #P
Subroutine g: not called CC=1 SCAR=6.9
9504 sub Nasm::X86::Unisyn::Lex::Letter::g #P Dyad 6 - Sans-serif Bold
9505 0 ▶ {(0x1d608..0x1d608+51)
Subroutine g: not called CC=1 SCAR=6.9
9506 }
9507  
9508 0 ▶sub Nasm::X86::Unisyn::Lex::Number::h {14} #P
Subroutine h: not called CC=1 SCAR=6.9
9509 sub Nasm::X86::Unisyn::Lex::Letter::h #P Dyad 7 - Calligraphy - normal
9510 0 ▶ {(0x1d49c..0x1d49c+51)
Subroutine h: not called CC=1 SCAR=6.9
9511 }
9512  
9513 0 ▶sub Nasm::X86::Unisyn::Lex::Number::i {15} #P
Subroutine i: not called CC=1 SCAR=6.9
9514 sub Nasm::X86::Unisyn::Lex::Letter::i #P Dyad 8 - Calligraphy - bold
9515 0 ▶ {(0x1d4d0..0x1d4d0+51)
Subroutine i: not called CC=1 SCAR=6.9
9516 }
9517  
9518 0 ▶sub Nasm::X86::Unisyn::Lex::Number::j {16} #P
Subroutine j: not called CC=1 SCAR=6.9
9519 sub Nasm::X86::Unisyn::Lex::Letter::j #P Dyad 9 - Fraktur - Normal
9520 0 ▶ {(0x1d504..0x1d504+51)
Subroutine j: not called CC=1 SCAR=6.9
9521 }
9522  
9523 0 ▶sub Nasm::X86::Unisyn::Lex::Number::k{17} #P
Subroutine k: not called CC=1 SCAR=6.9
9524 sub Nasm::X86::Unisyn::Lex::Letter::k #P Dyad 10 - Fraktur - bold
9525 0 ▶ {(0x1d56c..0x1d56c+51)
Subroutine k: not called CC=1 SCAR=6.9
9526 }
9527 #P
9528 0 ▶sub Nasm::X86::Unisyn::Lex::Number::l {18} #P Dyad 11
Subroutine l: not called CC=1 SCAR=6.9
9529 0 ▶sub Nasm::X86::Unisyn::Lex::Letter::l {(0x1d400..0x1d433,0x1d6a8..0x1d6e1)}
Subroutine l: not called CC=1 SCAR=6.9
9530  
9531 0 ▶sub Nasm::X86::Unisyn::Lex::Number::m {19} #P Dyad 12
Subroutine m: not called CC=1 SCAR=6.9
9532 sub Nasm::X86::Unisyn::Lex::Letter::m #P
9533 0 ▶ {(0xac, 0xb1, 0xd7, 0xf7, 0x3f6, 0x606..0x608,
Subroutine m: not called CC=1 SCAR=6.9
9534 0x200b..0x202E, 0x2030..0x2044,
9535 0x2047..0x205E, 0x2060..0x2061,
9536 0x2065..0x2069, 0x207a..0x207c, 0x208a..0x208c, 0x2118, 0x2140..0x2144,
9537 0x214b, 0x2200..0x2307, 0x230c..0x2328, 0x232c..0x23ff, 0x25a0..0x26ff,
9538 0x2715, 0x27c0..0x27e1, 0x27e3..0x27e5, 0x27f0..0x2982, 0x2999..0x29fb,
9539 0x29fe..0x2b58, 0x2e00..0x2e1f, 0x2e2a..0x2e30, 0xfb29, 0xfe62,
9540 0xfe64..0xfe66, 0xff0b, 0xff1c, 0xff1e, 0xff5c, 0xff5e, 0xffe2,
9541 0x1eef0..0x1eef1)
9542 }
9543  
9544 0 ▶sub Nasm::X86::Unisyn::Lex::Number::w {20} #P White space
Subroutine w: not called CC=1 SCAR=6.9
9545 sub Nasm::X86::Unisyn::Lex::Letter::w #P
9546 0 ▶ {(0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007,
Subroutine w: not called CC=1 SCAR=6.9
9547 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000)
9548 }
9549  
9550 # Add: 1d5a0 , 0x1d608, 0x1d49c, 0x1d4d0, 0x1d504, 0x1d56c, 0x1d670, 0x1d538
9551  
9552 sub Nasm::X86::Unisyn::Lex::composeUnisyn($) # Compose phrases of Unisyn and return them as a string
9553 0 ▶ {my ($words) = @_; # String of words
Subroutine composeUnisyn: not called CC=23 SCAR=63.1
9554 0 my $s = '';
9555  
9556 my sub w($$) # Variable name
9557 0 ▶ {my ($chars, $alpha) = @_; # Characters
Subroutine w: not called CC=39 SCAR=73.5
9558 0 my @c = eval "Nasm::X86::Unisyn::Lex::Letter::$alpha"; # Alphabet in array context
9559  
9560 0 for my $c(split //, $chars)
9561 0 ▶ {if ($alpha eq 'd')
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha eq "d") 0 0 0
9562 0 ▶ {$s .= '𝕒', next if $c eq 'a';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "a" 0 0 0
9563 0 ▶ $s .= '𝕓', next if $c eq 'b';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "b" 0 0 0
9564 0 ▶ $s .= '𝕔', next if $c eq 'c';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "c" 0 0 0
9565 0 ▶ $s .= '𝕕', next if $c eq 'd';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "d" 0 0 0
9566 0 ▶ $s .= '𝕖', next if $c eq 'e';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "e" 0 0 0
9567 0 ▶ $s .= '𝕗', next if $c eq 'f';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "f" 0 0 0
9568 0 ▶ $s .= '𝕘', next if $c eq 'g';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "g" 0 0 0
9569 0 ▶ $s .= '𝕙', next if $c eq 'h';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "h" 0 0 0
9570 0 ▶ $s .= '𝕚' , next if $c eq 'i';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "i" 0 0 0
9571 0 ▶ $s .= '𝕛' , next if $c eq 'j';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "j" 0 0 0
9572 0 ▶ $s .= '𝕜', next if $c eq 'k';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "k" 0 0 0
9573 0 ▶ $s .= '𝕝', next if $c eq 'l';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "l" 0 0 0
9574 0 ▶ $s .= '𝕞', next if $c eq 'm';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "m" 0 0 0
9575 0 ▶ $s .= '𝕟', next if $c eq 'n';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "n" 0 0 0
9576 0 ▶ $s .= '𝕠', next if $c eq 'o';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "o" 0 0 0
9577 0 ▶ $s .= '𝕡', next if $c eq 'p';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "p" 0 0 0
9578 0 ▶ $s .= '𝕢', next if $c eq 'q';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "q" 0 0 0
9579 0 ▶ $s .= '𝕣', next if $c eq 'r';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "r" 0 0 0
9580 0 ▶ $s .= '𝕤', next if $c eq 's';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "s" 0 0 0
9581 0 ▶ $s .= '𝕥', next if $c eq 't';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "t" 0 0 0
9582 0 ▶ $s .= '𝕦', next if $c eq 'u';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "u" 0 0 0
9583 0 ▶ $s .= '𝕧', next if $c eq 'v';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "v" 0 0 0
9584 0 ▶ $s .= '𝕨', next if $c eq 'w';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "w" 0 0 0
9585 0 ▶ $s .= '𝕩', next if $c eq 'x';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "x" 0 0 0
9586 0 ▶ $s .= '𝕪', next if $c eq 'y';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "y" 0 0 0
9587 0 ▶ $s .= '𝕫', next if $c eq 'z';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "z" 0 0 0
9588 0 ▶ $s .= 'ℂ', next if $c eq 'C';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "C" 0 0 0
9589 0 ▶ $s .= 'ℍ', next if $c eq 'H';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "H" 0 0 0
9590 0 ▶ $s .= 'ℕ', next if $c eq 'N';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "N" 0 0 0
9591 0 ▶ $s .= 'ℙ', next if $c eq 'P';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "P" 0 0 0
9592 0 ▶ $s .= 'ℚ', next if $c eq 'Q';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "Q" 0 0 0
9593 0 ▶ $s .= 'ℤ', next if $c eq 'Z';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "Z" 0 0 0
9594 }
9595 0 ▶ if ($alpha eq 'd')
Branch: 1 branch
BranchTrueFalseTotal
if ($alpha eq 'd') { } 0 0 0
9596 0 ▶ {$s .= chr $c[ord($c) - ord('A')] if $c =~ m(\A[A-Z]\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $c =~ /\A[A-Z]\Z/ 0 0 0
9597 }
9598 else
9599 0 ▶ {$s .= chr $c[ord($c) - ord('A')] if $c =~ m(\A[A-Z]\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $c =~ /\A[A-Z]\Z/ 0 0 0
9600 0 ▶ $s .= chr $c[ord($c) - ord('a') + 26] if $c =~ m(\A[a-z]\Z);
Branch: 1 branch
BranchTrueFalseTotal
if $c =~ /\A[a-z]\Z/ 0 0 0
9601 }
9602 }
9603 }
9604  
9605 my sub c($$) # Character from table
9606 0 ▶ {my ($pos, $alpha) = @_; # Position, character table name
Subroutine c: not called CC=1 SCAR=6.9
9607 0 my @c = eval "Nasm::X86::Unisyn::Lex::Letter::$alpha"; # Alphabet in array context
9608 0 chr $c[$pos] # Character requested
9609 }
9610  
9611 0 for my $w(split /\s+/, $words)
9612 0 ▶ {if ($w =~ m(\A[aAbBdefghijklmpqsSvw]))
Branch: 1 branch
BranchTrueFalseTotal
if ($w =~ /\A[aAbBdefghijklmpqsSvw]/) { } 0 0 0
9613 0 ▶ {if ($w =~ m(\AA(.*))) {$s .= $1} # Ascii - normal letters where possible
Branch: 18 branches
BranchTrueFalseTotal
if ($w =~ /\AA(.*)/) { } 0 0 0
elsif ($w =~ /\Aa=/) { } 0 0 0
elsif ($w =~ /\Ab\(/) { } 0 0 0
elsif ($w =~ /\Ab\[/) { } 0 0 0
elsif ($w =~ /\Ab\</) { } 0 0 0
elsif ($w =~ /\Ab(\d+)/) { } 0 0 0
elsif ($w =~ /\AB\)/) { } 0 0 0
elsif ($w =~ /\AB\]/) { } 0 0 0
elsif ($w =~ /\AB\>/) { } 0 0 0
elsif ($w =~ /\AB(\d+)/) { } 0 0 0
elsif ($w =~ /\Am\*/) { } 0 0 0
elsif ($w =~ /\Am\+/) { } 0 0 0
elsif ($w =~ /\Ap(\d+)/) { } 0 0 0
elsif ($w =~ /\Aq(\d+)/) { } 0 0 0
elsif ($w =~ /\A[s;]\Z/) { } 0 0 0
elsif ($w =~ /\AS\Z/) { } 0 0 0
elsif ($w =~ /\Aw\Z/) { } 0 0 0
elsif ($w =~ /\Aw(\d+)/) { } 0 0 0
9614 0 elsif ($w =~ m(\Aa=)) {$s .= "="} # Assign chosen by number
9615 0 elsif ($w =~ m/\Ab\(/) {$s .= '【'} # Open bracket
9616 0 elsif ($w =~ m/\Ab\[/) {$s .= '⟦'} # Open bracket
9617 0 elsif ($w =~ m/\Ab\</) {$s .= '⟨'} # Open bracket
9618 0 elsif ($w =~ m(\Ab(\d+))) {$s .= c $1, "b"} # Open bracket
9619 0 elsif ($w =~ m/\AB\)/) {$s .= '】'} # Open bracket
9620 0 elsif ($w =~ m/\AB\]/) {$s .= '⟧'} # Open bracket
9621 0 elsif ($w =~ m/\AB\>/) {$s .= '⟩'} # Open bracket
9622 0 elsif ($w =~ m(\AB(\d+))) {$s .= c $1, "B"} # Close bracket
9623 0 elsif ($w =~ m(\Am\*)) {$s .= "✕"} # Multiply
9624 0 elsif ($w =~ m(\Am\+)) {$s .= "+"} # Plus
9625 0 elsif ($w =~ m(\Ap(\d+))) {$s .= c $1, "p"} # Prefix chosen by number
9626 0 elsif ($w =~ m(\Aq(\d+))) {$s .= c $1, "q"} # Suffix chosen by number
9627 0 elsif ($w =~ m(\A[s;]\Z)) {$s .= c 0, "s"} # Semicolon
9628 0 elsif ($w =~ m(\AS\Z)) {$s .= ' '} # Space
9629 0 elsif ($w =~ m(\Aw\Z)) {$s .= ' '} # Single space
9630 0 elsif ($w =~ m(\Aw(\d+))) {$s .= ' ' x $1} # Spaces
9631 else
9632 0 {my $a = substr($w, 0, 1);
9633 0 ▶ if ($w =~ m(\A$a(\d+))) {c $1, $a} # Dyad chosen by number
Branch: 2 branches
BranchTrueFalseTotal
if ($w =~ /\A$a(\d+)/) { } 0 0 0
elsif ($w =~ /\A$a(\w+)/) { } 0 0 0
9634 0 elsif ($w =~ m(\A$a(\w+))) {w $1, $a} # Dyad chosen by letter
9635 }
9636 }
9637 else
9638 0 {confess "Invalid first character: $w";
9639 }
9640 }
9641  
9642 $s # Composed string
9643 0 }
9644  
9645 0 ▶sub Nasm::X86::Unisyn::Lex::PermissibleTransitionsArrayBits {5} #P The number of bits needed to express a transition
Subroutine PermissibleTransitionsArrayBits: not called CC=1 SCAR=6.9
9646  
9647 sub Nasm::X86::Unisyn::Lex::PermissibleTransitionsArray() # Create and load the table of lexical transitions.
9648 0 ▶ {my $a = Nasm::X86::Unisyn::Lex::Number::a; # Assign-2 - right to left
Subroutine PermissibleTransitionsArray: not called CC=9 SCAR=45.0
9649 0 my $A = Nasm::X86::Unisyn::Lex::Number::A; # Ascii
9650 0 my $b = Nasm::X86::Unisyn::Lex::Number::b; # Open
9651 0 my $B = Nasm::X86::Unisyn::Lex::Number::B; # Close
9652 0 my $d = Nasm::X86::Unisyn::Lex::Number::d; # Dyad
9653 0 my $F = Nasm::X86::Unisyn::Lex::Number::F; # Finish
9654 0 my $p = Nasm::X86::Unisyn::Lex::Number::p; # Prefix
9655 0 my $q = Nasm::X86::Unisyn::Lex::Number::q; # Suffix
9656 0 my $s = Nasm::X86::Unisyn::Lex::Number::s; # Semicolon-1
9657 0 my $S = Nasm::X86::Unisyn::Lex::Number::S; # Start
9658 0 my $v = Nasm::X86::Unisyn::Lex::Number::v; # Variable
9659  
9660 0 my @d = (Nasm::X86::Unisyn::Lex::Number::a,
9661 Nasm::X86::Unisyn::Lex::Number::e,
9662 Nasm::X86::Unisyn::Lex::Number::f,
9663 Nasm::X86::Unisyn::Lex::Number::g,
9664 Nasm::X86::Unisyn::Lex::Number::h,
9665 Nasm::X86::Unisyn::Lex::Number::i,
9666 Nasm::X86::Unisyn::Lex::Number::j,
9667 Nasm::X86::Unisyn::Lex::Number::k,
9668 Nasm::X86::Unisyn::Lex::Number::l,
9669 Nasm::X86::Unisyn::Lex::Number::m);
9670  
9671 my %x = ( # The transitions table: this tells us which combinations of lexical items are valid. The table is augmented with start and end symbols so that we know where to start and end.
9672 0 $A => {map {$_=>1} $a, $B, $d, $F, $q, $s, },
9673 0 $b => {map {$_=>1} $A, $b, $B, $p, $s, $v},
9674 0 $B => {map {$_=>1} $a, $B, $d, $F, $q, $s },
9675 0 $d => {map {$_=>1} $A, $b, $p, $v},
9676 0 $p => {map {$_=>1} $A, $b, $v},
9677 0 $q => {map {$_=>1} $a, $A, $B, $d, $F, $s },
9678 0 $s => {map {$_=>1} $A, $b, $B, $F, $p, $s, $v},
9679 0 $S => {map {$_=>1} $A, $b, $F, $p, $s, $v},
9680 0 $v => {map {$_=>1} $a, $B, $d, $F, $q, $s },
9681 );
9682  
9683 0 $x{$_} = $x{$d} for @d; # The infix operators all have the same sequencing
9684  
9685 0 for my $x(keys %x)
9686 0 ▶ {if ($x{$x}{$d}) # If something can be followed by a dyad then it can be followed by any dyad
Branch: 1 branch
BranchTrueFalseTotal
if ($x{$x}{$d}) 0 0 0
9687 0 {$x{$x}{$_} = 1 for @d;
9688 }
9689 }
9690  
9691 0 my @t; # The transitions table will be held as an array of bytes
9692  
9693 0 for my $x(keys %x) # Each source lexical item
9694 0 {my %y = $x{$x}->%*; # The lexical items that can follow the current lexical item. If there are duplicates they are squashed out by assigning them to the same index in the target array
9695 0 for my $y(keys %y) # Each permissible transition
9696 0 {$t[($x << Nasm::X86::Unisyn::Lex::PermissibleTransitionsArrayBits) + # Two dimensional index
9697 $y] = 1;
9698 }
9699 }
9700  
9701 0 ▶ $t[$_] //= -1 for 0..$#t; # Mark disallowed transitions
Condition0%0/2
$t[$_] //= -1
l!l
00
MC/DC0%0/1
$t[$_] //= -1
$t[$_]
Truth table0%0/2
A
A= $t[$_]
Aresult
11
00
9702  
9703 0 (Rq(scalar @t), Rb(@t)) # Return size of transitions array and array content
9704 }
9705  
9706 sub Nasm::X86::Unisyn::Lex::AlphabetsArray # Create an array of utf32 to alphabet number.
9707 0 ▶ {my %a =
Subroutine AlphabetsArray: not called CC=5 SCAR=34.0
9708 (Nasm::X86::Unisyn::Lex::Number::A => [Nasm::X86::Unisyn::Lex::Letter::A],
9709 Nasm::X86::Unisyn::Lex::Number::p => [Nasm::X86::Unisyn::Lex::Letter::p],
9710 Nasm::X86::Unisyn::Lex::Number::v => [Nasm::X86::Unisyn::Lex::Letter::v],
9711 Nasm::X86::Unisyn::Lex::Number::q => [Nasm::X86::Unisyn::Lex::Letter::q],
9712 Nasm::X86::Unisyn::Lex::Number::s => [Nasm::X86::Unisyn::Lex::Letter::s],
9713  
9714 Nasm::X86::Unisyn::Lex::Number::b => [Nasm::X86::Unisyn::Lex::Letter::b],
9715 Nasm::X86::Unisyn::Lex::Number::B => [Nasm::X86::Unisyn::Lex::Letter::B],
9716  
9717 Nasm::X86::Unisyn::Lex::Number::d => [Nasm::X86::Unisyn::Lex::Letter::d],
9718 Nasm::X86::Unisyn::Lex::Number::e => [Nasm::X86::Unisyn::Lex::Letter::e],
9719 Nasm::X86::Unisyn::Lex::Number::a => [Nasm::X86::Unisyn::Lex::Letter::a],
9720 Nasm::X86::Unisyn::Lex::Number::f => [Nasm::X86::Unisyn::Lex::Letter::f],
9721 Nasm::X86::Unisyn::Lex::Number::g => [Nasm::X86::Unisyn::Lex::Letter::g],
9722 Nasm::X86::Unisyn::Lex::Number::h => [Nasm::X86::Unisyn::Lex::Letter::h],
9723 Nasm::X86::Unisyn::Lex::Number::i => [Nasm::X86::Unisyn::Lex::Letter::i],
9724 Nasm::X86::Unisyn::Lex::Number::j => [Nasm::X86::Unisyn::Lex::Letter::j],
9725 Nasm::X86::Unisyn::Lex::Number::k => [Nasm::X86::Unisyn::Lex::Letter::k],
9726 Nasm::X86::Unisyn::Lex::Number::l => [Nasm::X86::Unisyn::Lex::Letter::l],
9727 Nasm::X86::Unisyn::Lex::Number::m => [Nasm::X86::Unisyn::Lex::Letter::m],
9728 Nasm::X86::Unisyn::Lex::Number::w => [Nasm::X86::Unisyn::Lex::Letter::w],
9729 );
9730  
9731 0 my @a;
9732 0 for my $n(sort keys %a)
9733 0 {my @c = $a{$n}->@*;
9734 0 for my $c(@c)
9735 0 {$a[$c] = $n;
9736 }
9737 }
9738  
9739 0 ▶ $a[$_] //= -1 for 0..$#a; # Mark disallowed characters
Condition0%0/2
$a[$_] //= -1
l!l
00
MC/DC0%0/1
$a[$_] //= -1
$a[$_]
Truth table0%0/2
A
A= $a[$_]
Aresult
11
00
9740  
9741 0 (Rq(scalar @a), Rb(@a)) # Allowed utf32 characters array
9742 }
9743  
9744 sub Nasm::X86::Unisyn::Lex::letterToNumber # Map each letter in the union of the alphabets to a sequential number
9745 0 ▶ {my %a; # Letters mapped to unique numbers
Subroutine letterToNumber: not called CC=6 SCAR=37.4
9746 0 for my $a(qw(A p v q s b B d e a f g h i j k l m w))
9747 0 {$a{$_} = keys %a for eval "Nasm::X86::Unisyn::Lex::Letter::$a";
9748 }
9749  
9750 0 my @a; $a[$_] = $a{$_} for sort keys %a; # Mapping from letter to number
9751  
9752 0 ▶ $a[$_] //= -1 for 0..$#a; # Mark disallowed characters
Condition0%0/2
$a[$_] //= -1
l!l
00
MC/DC0%0/1
$a[$_] //= -1
$a[$_]
Truth table0%0/2
A
A= $a[$_]
Aresult
11
00
9753  
9754 0 (K(size => scalar @a), K array => Rd @a) # Size of array, array
9755 }
9756  
9757 sub Nasm::X86::Unisyn::Lex::numberToLetter # Recover a letter from its unique number
9758 0 ▶ {my %a; # Letters mapped to unique numbers
Subroutine numberToLetter: not called CC=5 SCAR=34.0
9759 0 my $i = 0;
9760 0 for my $a(qw(A p v q s b B d e a f g h i j k l m w))
9761 0 {for my $a(eval "Nasm::X86::Unisyn::Lex::Letter::$a") # Each letter
9762 0 {$a{$a} = $i++;
9763 0 ▶ confess "Key mismatch on: ", sprintf("%x", $a), " at $i"
Branch: 1 branch
BranchTrueFalseTotal
unless keys %a == $i 0 0 0
9764 unless keys(%a) == $i; # Check for duplicates
9765 }
9766 }
9767  
9768 0 my @a; $a[$a{$_}] = $_ for sort keys %a; # Mapping from number to letter
9769  
9770 0 (K(size => scalar @a), K array => Rd @a) # Size of array, array
9771 }
9772  
9773 #D2 Parse # Parse Unisyn language statements.
9774  
9775 0 ▶sub Nasm::X86::Unisyn::Lex::Reason::Success {0}; #P Successful parse.
Subroutine Success: not called CC=1 SCAR=6.9
9776 0 ▶sub Nasm::X86::Unisyn::Lex::Reason::BadUtf8 {1}; #P Bad utf8 character encountered.
Subroutine BadUtf8: not called CC=1 SCAR=6.9
9777 0 ▶sub Nasm::X86::Unisyn::Lex::Reason::InvalidChar {2}; #P Character not part of Earl Zero.
Subroutine InvalidChar: not called CC=1 SCAR=6.9
9778 0 ▶sub Nasm::X86::Unisyn::Lex::Reason::InvalidTransition {3}; #P Transition from one lexical item to another not allowed.
Subroutine InvalidTransition: not called CC=1 SCAR=6.9
9779 0 ▶sub Nasm::X86::Unisyn::Lex::Reason::TrailingClose {4}; #P Trailing closing bracket discovered.
Subroutine TrailingClose: not called CC=1 SCAR=6.9
9780 0 ▶sub Nasm::X86::Unisyn::Lex::Reason::Mismatch {5}; #P Mismatched bracket.
Subroutine Mismatch: not called CC=1 SCAR=6.9
9781 0 ▶sub Nasm::X86::Unisyn::Lex::Reason::NotFinal {6}; #P Expected something after final character.
Subroutine NotFinal: not called CC=1 SCAR=6.9
9782 0 ▶sub Nasm::X86::Unisyn::Lex::Reason::BracketsNotClosed {7}; #P Open brackets not closed at end of.
Subroutine BracketsNotClosed: not called CC=1 SCAR=6.9
9783  
9784 0 ▶sub Nasm::X86::Unisyn::Lex::position {0}; #P Position of the parsed item in the input text.
Subroutine position: not called CC=1 SCAR=6.9
9785 0 ▶sub Nasm::X86::Unisyn::Lex::length {1}; #P Length of the lexical item in bytes.
Subroutine length: not called CC=1 SCAR=6.9
9786 0 ▶sub Nasm::X86::Unisyn::Lex::type {2}; #P Type of the lexical item.
Subroutine type: not called CC=1 SCAR=6.9
9787 0 ▶sub Nasm::X86::Unisyn::Lex::left {3}; #P Left operand.
Subroutine left: not called CC=1 SCAR=6.9
9788 0 ▶sub Nasm::X86::Unisyn::Lex::right {4}; #P Right operand.
Subroutine right: not called CC=1 SCAR=6.9
9789 0 ▶sub Nasm::X86::Unisyn::Lex::symbol {5}; #P Symbol.
Subroutine symbol: not called CC=1 SCAR=6.9
9790  
9791 sub Nasm::X86::Unisyn::DescribeParse() #P Describe a parse - create a description on the stack to receive the results of a parse
9792 0 ▶ {genHash("Nasm::X86::Unisyn::Parse", # Parse results
Subroutine DescribeParse: not called CC=1 SCAR=6.9
9793 area => DescribeArea, # The area in which the parse tree was built
9794 tree => V('tree '), # The offset of the start of the parse tree in the parse area
9795 char => V('parseChar '), # Last character processed
9796 fail => V('parseFail '), # If not zero the parse has failed for some reason
9797 position => V('position '), # The position reached in the input string
9798 match => V('parseMatch '), # The position of the matching bracket that did not match
9799 reason => V('parseReason'), # The reason code describing the failure if any
9800 symbols => DescribeTree, # The symbol tree produced by the parse
9801 length => V('s8 '), # The length of the source
9802 source => V('a8 '), # The source text address
9803 );
9804 }
9805  
9806 sub ParseUnisyn($$) # Parse a string of utf8 characters.
9807 0 ▶ {my ($a8, $s8) = @_; # Address of utf8 source string, size of utf8 source string in bytes
Subroutine ParseUnisyn: not called CC=1 SCAR=6.9
Pod documented
9808  
9809 0 my $p = Nasm::X86::Unisyn::DescribeParse; # Describe a parse - create a description of the parse on the stack
9810 0 $p->source->copy($a8); # Source
9811 0 $p->length->copy($s8); # Length
9812  
9813 my $s = Subroutine # Print a tree
9814 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
9815  
9816 0 &Nasm::X86::Unisyn::Parse($$s{parse});
9817  
9818 0 } structures => {parse => $p}, name => qq(Nasm::X86::Unisyn::Parse);
9819  
9820  
9821 0 $s->call(structures=>{parse => $p});
9822  
9823 0 $p
9824 }
9825  
9826 sub sortHashKeysByIntegerValues($) #P Sort the keys of a hash whose values are integers by those values returning the keys so sorted as an array.
9827 0 ▶ {my ($h) = @_; # Hash
Subroutine sortHashKeysByIntegerValues: not called CC=1 SCAR=6.9
Pod documented
9828 0 sort {$$h{$a} <=> $$h{$b}} sort keys %$h; # Done here to avoid collisions with the sort special variables,
9829 }
9830  
9831 sub Nasm::X86::Unisyn::Parse($) #P Parse a string of utf8 characters.
9832 0 ▶ {my ($pd) = @_; # Parse descriptor
Subroutine Parse: not called CC=3 SCAR=24.8
9833 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
9834  
9835 0 my $a8 = $pd->source; # Source to parse
9836 0 my $s8 = $pd->length; # Length of source in bytes
9837  
9838 0 my $parse = CreateArea; # The area in which the parse tree will be be built
9839  
9840 0 my $brackets = CreateArea(stack=>1); # Brackets stack of zmm
9841 0 my $stack = CreateArea(stack=>1); # Parse tree stack of double words
9842 0 my $symbols = $parse->CreateTree(stringTree=>1); # String tree of symbols encountered during the parse - they are stored along with the parse tree which refers to it.
9843  
9844 0 my $position = V 'pos ' => 0; # Position in input string
9845 0 my $last = V 'last ' => Nasm::X86::Unisyn::Lex::Number::S; # Last lexical type starting on this start symbol
9846  
9847 0 my $parseFail = V 'parseFail ' => 1; # If not zero the parse has failed for some reason
9848 0 my $parseReason = V 'parseReason' => 0; # The reason code describing the failure if L<parseFail> is not zero - we could probably merge these two fields
9849 0 my $parseMatch = V 'parseMatch ' => 0; # The position of the bracket we failed to match
9850 0 my $parseChar = V 'parseChar ' => 0; # The last character recognized held as utf32
9851 0 my $firstChar = V 'firstChar'; # First character recognized in a lexical item held as utf32
9852  
9853 0 my $startPos = V 'startPos ' => 0; # Start position of the last lexical item
9854 0 my $lastNew = V 'lastNew ' => -1; # Offset of the last lexical created in the parse stack
9855  
9856 0 my $itemLength = V 'itemLength' => 0; # Length of lexical item in unicode characters
9857  
9858 0 my $dWidth = RegisterSize eax; # Size of a dword
9859  
9860 0 my ($alphabetN, $alphabetA) = Nasm::X86::Unisyn::Lex::AlphabetsArray; # Mapping of characters to alphabets
9861 0 my ($letterToNumberN, $letterToNumberA) = # Map utf32 to letter number because it is smaller than a dword and so can be conveniently used to designate the lexical number of single character items
9862 Nasm::X86::Unisyn::Lex::letterToNumber;
9863  
9864 my $dumpStack = sub # Dump the parse stack
9865 0 ▶ {my $i = V i => 0; # Position in stack
Subroutine __ANON__: not called CC=1 SCAR=6.9
9866 0 PrintOutStringNL "Dump parse stack";
9867  
9868 $stack->stackVariableSize->for(sub # Each item on stack
9869 0 ▶ {my ($i, $start, $next, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
9870 0 my $o = $stack->stackVariable($i);
9871 0 $parse->getZmmBlock($o, 4);
9872 0 my $t = dFromZ(4, $dWidth * Nasm::X86::Unisyn::Lex::type);
9873 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::S), Then {PrintOutString "Start "};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9874 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::F), Then {PrintOutString "End "};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9875 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::A), Then {PrintOutString "ASCII "};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9876 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::l), Then {PrintOutString "Infix3 "};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9877 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::p), Then {PrintOutString "Prefix "};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9878 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::a), Then {PrintOutString "Assign "};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9879 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::v), Then {PrintOutString "Variable "};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9880 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::q), Then {PrintOutString "Suffix "};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9881 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::s), Then {PrintOutString "Seperator"};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9882 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::m), Then {PrintOutString "Infix4 "};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9883 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::b), Then {PrintOutString "Open "};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9884 0 ▶ If $t == K(t => Nasm::X86::Unisyn::Lex::Number::B), Then {PrintOutString "Close "};
Subroutine __ANON__: not called CC=1 SCAR=6.9
9885 0 });
9886 0 };
9887  
9888 my $updateLength = sub # Update the length of the previous lexical item
9889 0 ▶ {If $lastNew >= 0,
Subroutine __ANON__: not called CC=1 SCAR=6.9
9890 Then # Update the last lexical item if there was one
9891 0 ▶ {my $l = $position - $startPos; # Length of previous item
Subroutine __ANON__: not called CC=1 SCAR=6.9
9892 0 my $s = V 'lexicalItemNumber';
9893  
9894 If $itemLength == 1,
9895 Then # Single letter item so we use -its position in the alphabets as its lexical number as this is much faster than looking it up in a tree
9896 0 ▶ {my ($N, $A) = Nasm::X86::Unisyn::Lex::letterToNumber;
Subroutine __ANON__: not called CC=1 SCAR=6.9
9897  
9898 0 $A->setReg(rax); # Address array of single letters
9899 0 $firstChar->setReg(rsi); # The first and only character if the lexical item
9900 0 Mov edx, "[rax+4*rsi]"; # The smaller number representing the letter
9901 0 Neg rdx; # Count down from zero to differentiate from multi letter lexical items which count up from zero.
9902 0 $s->getReg(rdx); # Access routine via a single character operator name
9903 },
9904 Else # The lexical item has multiple characters in it so we look them up in the conventional manner
9905 0 ▶ {$s->copy($symbols->uniqueKeyString($a8+$startPos, $l)); # The symbol number of the previous lexical item
Subroutine __ANON__: not called CC=1 SCAR=6.9
9906 0 };
9907  
9908 0 $parse->getZmmBlock($lastNew, 0); # Reload the description of the last lexical item
9909 0 $s->dIntoZ(0, $dWidth * Nasm::X86::Unisyn::Lex::symbol); # Record lexical symbol number of previous item in its describing tree
9910 0 $l->dIntoZ(0, $dWidth * Nasm::X86::Unisyn::Lex::length); # Record length of previous item in its describing tree
9911 0 $parse->putZmmBlock($lastNew, 0); # Save the lexical item back into memory
9912 0 $lastNew->copy(-1); # Finished with this symbol
9913 0 };
9914 0 $startPos->copy($position); # Start of next lexical item
9915 0 };
9916  
9917 my $new = sub # Create a new lexical item
9918 0 ▶ {ClearRegisters zmm0;
Subroutine __ANON__: not called CC=1 SCAR=6.9
9919 0 $last ->dIntoZ(0, $dWidth * Nasm::X86::Unisyn::Lex::type); # Last lexical item recognized
9920 0 $position ->dIntoZ(0, $dWidth * Nasm::X86::Unisyn::Lex::position); # Position of lexical item
9921 0 my $o = $parse->appendZmm(0); # Save the lexical item in the parse tree
9922 0 $stack->push($o); # Save the offset of the latest lexical item on the stack
9923 0 $lastNew->copy($o); # Update last created lexical item
9924 0 $itemLength->copy(0); # Length of lexical item in unicode characters
9925 0 $firstChar->copy($parseChar); # Copy the utf32 value of the current character as it is the first character in the lexical item
9926 0 };
9927  
9928 0 &$new for 1..3; # Initialize the parse tree with three start symbols to act as sentinels
9929  
9930 my $prev = sub # Lexical item and type of the previous item on the parse stack
9931 0 ▶ {my $o = $stack->peek(1);
Subroutine __ANON__: not called CC=1 SCAR=6.9
9932 0 $parse->getZmmBlock($o, 1); # Reload the description of the last lexical item
9933 0 dFromZ(1, $dWidth * Nasm::X86::Unisyn::Lex::type); # Lexical type
9934 0 };
9935  
9936 my $prev2 = sub # Lexical item and type of the previous previous item on the parse stack
9937 0 ▶ {my $o = $stack->peek(2);
Subroutine __ANON__: not called CC=1 SCAR=6.9
9938 0 $parse->getZmmBlock($o, 2); # Reload the description of the last lexical item
9939 0 dFromZ(2, $dWidth * Nasm::X86::Unisyn::Lex::type); # Lexical type
9940 0 };
9941  
9942 my $double = sub # Double reduction - the right most item is placed 'left' under the second right most item
9943 0 ▶ {my $r = $stack->pop; # Right
Subroutine __ANON__: not called CC=1 SCAR=6.9
9944 0 my $l = $stack->peek(1); # Left
9945 0 $parse->getZmmBlock($l, 1); # Reload the description of the last lexical item
9946 0 $r->dIntoZ(1, $dWidth * Nasm::X86::Unisyn::Lex::left); # Address right from left via 'left' field
9947 0 $parse->putZmmBlock($l, 1); # Update parse tree in memory
9948 0 };
9949  
9950 my $triple = sub # Triple reduction
9951 0 ▶ {my $r = $stack->pop; # Right most
Subroutine __ANON__: not called CC=1 SCAR=6.9
9952 0 my $o = $stack->pop; # Operator
9953 0 my $l = $stack->pop; # Left operand
9954 0 $parse->getZmmBlock($o, 1); # Reload the description of the last lexical item
9955 0 $l->dIntoZ(1, $dWidth * Nasm::X86::Unisyn::Lex::left);
9956 0 $r->dIntoZ(1, $dWidth * Nasm::X86::Unisyn::Lex::right);
9957 0 $parse->putZmmBlock($o, 1); # Update parse tree in memory
9958 0 $stack->push($o);
9959 0 };
9960  
9961 my $a = sub # Dyad2 = right to left associative
9962 0 ▶ {#PrintErrStringNL "Type: a";
Subroutine __ANON__: not called CC=1 SCAR=6.9
9963 0 my $q = &$prev2; # Second previous item
9964 ifOr
9965 0 ▶ [sub {$q == K p => Nasm::X86::Unisyn::Lex::Number::l}, # Dyad2 preceded by dyad3 or dyad4
Subroutine __ANON__: not called CC=1 SCAR=6.9
9966 0 ▶ sub {$q == K p => Nasm::X86::Unisyn::Lex::Number::m}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
9967 Then
9968 0 ▶ {&$triple; # Reduce the stack before adding the assignment
Subroutine __ANON__: not called CC=1 SCAR=6.9
9969 0 };
9970 0 &$new; # Push dyad2
9971 0 };
9972  
9973 my $A = sub # Ascii
9974 0 ▶ {#PrintErrStringNL "Type: A";
Subroutine __ANON__: not called CC=1 SCAR=6.9
9975 0 my $p = &$prev;
9976 0 &$new;
9977 If $p == K(p => Nasm::X86::Unisyn::Lex::Number::p),
9978 Then # Previous is a prefix operator so we can append from it immediately
9979 0 ▶ {&$double;
Subroutine __ANON__: not called CC=1 SCAR=6.9
9980 0 };
9981 0 };
9982  
9983 my $b = sub # Open bracket
9984 0 ▶ {#PrintErrStringNL "Type: b";
Subroutine __ANON__: not called CC=1 SCAR=6.9
9985 0 &$new; # Push open bracket
9986 0 };
9987  
9988 my $B = sub # Close bracket
9989 0 ▶ {#PrintErrStringNL "Type: B";
Subroutine __ANON__: not called CC=1 SCAR=6.9
9990 0 my $p = &$prev;
9991 If $p == K(p => Nasm::X86::Unisyn::Lex::Number::s), # Pointless statement separator
9992 Then
9993 0 ▶ {$stack->pop;
Subroutine __ANON__: not called CC=1 SCAR=6.9
9994 0 };
9995 # Ef {$p == K(p => Nasm::X86::Unisyn::Lex::Number::b)} # Empty bracket pair
9996 # Then
9997 # {
9998 # };
9999 Block # Non empty pair of brackets - a single intervening bracket represents a previously collapsed bracketed expression
10000 0 ▶ {my ($end, $start) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10001 0 my $p = &$prev2;
10002 If $p == K(p => Nasm::X86::Unisyn::Lex::Number::b),
10003 Then # Single item in brackets
10004 0 ▶ {&$double;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10005 },
10006 0 ▶ Ef {$p != K(p => Nasm::X86::Unisyn::Lex::Number::S)}
Subroutine __ANON__: not called CC=1 SCAR=6.9
10007 Then # Triple reduce back to start
10008 0 ▶ {&$triple;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10009 0 Jmp $start; # Keep on reducing until we meet the matching opening bracket
10010 0 };
10011 0 };
10012 If &$prev2 == K(p => Nasm::X86::Unisyn::Lex::Number::p), # Prefix operator preceding brackets
10013 Then
10014 0 ▶ {&$double;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10015 0 };
10016 0 };
10017  
10018 0 ▶ my $d = sub {my $q = &$prev2; ifAnd [ # List all the operators that have higher priority than the operator mentioned
Subroutine __ANON__: not called CC=1 SCAR=6.9
10019 0 ▶ sub {$q >= K p => Nasm::X86::Unisyn::Lex::Number::d},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10020 0 ▶ sub {$q <= K p => Nasm::X86::Unisyn::Lex::Number::m},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10021 0 ▶ ], Then {&$triple}; &$new};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10022  
10023 0 ▶ my $e = sub {my $q = &$prev2; ifAnd [
Subroutine __ANON__: not called CC=1 SCAR=6.9
10024 0 ▶ sub {$q >= K p => Nasm::X86::Unisyn::Lex::Number::e},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10025 0 ▶ sub {$q <= K p => Nasm::X86::Unisyn::Lex::Number::m},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10026 0 ▶ ], Then {&$triple}; &$new};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10027  
10028 0 ▶ my $f = sub {my $q = &$prev2; ifAnd [
Subroutine __ANON__: not called CC=1 SCAR=6.9
10029 0 ▶ sub {$q >= K p => Nasm::X86::Unisyn::Lex::Number::f},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10030 0 ▶ sub {$q <= K p => Nasm::X86::Unisyn::Lex::Number::m},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10031 0 ▶ ], Then {&$triple}; &$new};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10032  
10033 0 ▶ my $g = sub {my $q = &$prev2; ifAnd [
Subroutine __ANON__: not called CC=1 SCAR=6.9
10034 0 ▶ sub {$q >= K p => Nasm::X86::Unisyn::Lex::Number::g},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10035 0 ▶ sub {$q <= K p => Nasm::X86::Unisyn::Lex::Number::m},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10036 0 ▶ ], Then {&$triple}; &$new};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10037  
10038 0 ▶ my $h = sub {my $q = &$prev2; ifAnd [
Subroutine __ANON__: not called CC=1 SCAR=6.9
10039 0 ▶ sub {$q >= K p => Nasm::X86::Unisyn::Lex::Number::h},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10040 0 ▶ sub {$q <= K p => Nasm::X86::Unisyn::Lex::Number::m},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10041 0 ▶ ], Then {&$triple}; &$new};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10042  
10043 0 ▶ my $i = sub {my $q = &$prev2; ifAnd [
Subroutine __ANON__: not called CC=1 SCAR=6.9
10044 0 ▶ sub {$q >= K p => Nasm::X86::Unisyn::Lex::Number::i},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10045 0 ▶ sub {$q <= K p => Nasm::X86::Unisyn::Lex::Number::m},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10046 0 ▶ ], Then {&$triple}; &$new};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10047  
10048 0 ▶ my $j = sub {my $q = &$prev2; ifAnd [
Subroutine __ANON__: not called CC=1 SCAR=6.9
10049 0 ▶ sub {$q >= K p => Nasm::X86::Unisyn::Lex::Number::j},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10050 0 ▶ sub {$q <= K p => Nasm::X86::Unisyn::Lex::Number::m},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10051 0 ▶ ], Then {&$triple}; &$new};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10052  
10053 0 ▶ my $k = sub {my $q = &$prev2; ifAnd [
Subroutine __ANON__: not called CC=1 SCAR=6.9
10054 0 ▶ sub {$q >= K p => Nasm::X86::Unisyn::Lex::Number::k},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10055 0 ▶ sub {$q <= K p => Nasm::X86::Unisyn::Lex::Number::m},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10056 0 ▶ ], Then {&$triple}; &$new};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10057  
10058 my $l = sub # Dyad3. This infix operator and all infix operators of higher priority
10059 0 ▶ {#PrintErrStringNL "Type: l";
Subroutine __ANON__: not called CC=1 SCAR=6.9
10060 0 my $q = &$prev2; # Second previous item
10061 ifOr
10062 0 ▶ [sub {$q == K p => Nasm::X86::Unisyn::Lex::Number::l}, # Dyad3 preceded by dyad3 or dyad4
Subroutine __ANON__: not called CC=1 SCAR=6.9
10063 0 ▶ sub {$q == K p => Nasm::X86::Unisyn::Lex::Number::m}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
10064 Then
10065 0 ▶ {&$triple; # Reduce
Subroutine __ANON__: not called CC=1 SCAR=6.9
10066 0 };
10067 0 &$new; # Push dyad3
10068 0 };
10069  
10070 my $m = sub # Dyad4
10071 0 ▶ {#PrintErrStringNL "Type: m";
Subroutine __ANON__: not called CC=1 SCAR=6.9
10072 0 my $q = &$prev2; # Second previous item
10073 If $q == K(p => Nasm::X86::Unisyn::Lex::Number::m),
10074 Then # Dyad4 preceded by dyad4
10075 0 ▶ {&$triple; # Reduce
Subroutine __ANON__: not called CC=1 SCAR=6.9
10076 0 };
10077 0 &$new; # Push dyad4
10078 0 };
10079  
10080 my $F = sub # Final: at this point there are no brackets left.
10081 0 ▶ {#PrintErrStringNL "Type: F";
Subroutine __ANON__: not called CC=1 SCAR=6.9
10082 0 &$updateLength; # Update the length of the previous lexical item
10083  
10084 Block # Reduce all the remaining items on the stack
10085 0 ▶ {my ($end, $start) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10086 If &$prev2 != K(p => Nasm::X86::Unisyn::Lex::Number::S),
10087 Then # Not at the end yet and room for a triple reduction
10088 0 ▶ {&$triple;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10089 0 Jmp $start;
10090 0 };
10091 # If &$prev2 == K(p => Nasm::X86::Unisyn::Lex::Number::S),
10092 # Then # Not at the end yet with room for a final double reduction
10093 # {PrintErrStringNL "FFFF111";
10094 # &$prev2;
10095 # $stack->stackVariableSize->d;
10096 # &$double;
10097 # $stack->stackVariableSize->d;
10098 # };
10099 0 };
10100 0 my $top = $stack->pop; # Top of the parse tree
10101 0 $stack->clear;
10102 0 $stack->push($top); # New top of the parse tree
10103 0 };
10104  
10105 my $p = sub # Prefix
10106 0 ▶ {#PrintErrStringNL "Type: p";
Subroutine __ANON__: not called CC=1 SCAR=6.9
10107 0 &$new; # Push prefix
10108 0 };
10109  
10110 my $q = sub # Suffix
10111 0 ▶ {#PrintErrStringNL "Type: q";
Subroutine __ANON__: not called CC=1 SCAR=6.9
10112 0 my $v = $stack->pop; # Pop currently top item
10113 0 &$new; # Push suffix operator
10114 0 $stack->push($v); # Restore current item to top
10115 0 &$double; # Place top under previous item leaving previous item on top of the stack
10116 0 };
10117  
10118 my $s = sub # Statement separator
10119 0 ▶ {#PrintErrStringNL "Type: s";
Subroutine __ANON__: not called CC=1 SCAR=6.9
10120 Block
10121 0 ▶ {my ($end, $start) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10122 0 my $p = &$prev; # Previous item
10123 ifOr # Separator preceded by open or start - do nothing
10124 0 ▶ [sub {$p == K p => Nasm::X86::Unisyn::Lex::Number::b},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10125 0 ▶ sub {$p == K p => Nasm::X86::Unisyn::Lex::Number::s},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10126 0 ▶ sub {$p == K p => Nasm::X86::Unisyn::Lex::Number::S}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
10127 Then # Eliminate useless statement separator
10128 0 ▶ {Jmp $end;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10129 0 };
10130 0 my $q = &$prev2; # Second previous item
10131 If $q == K(p => Nasm::X86::Unisyn::Lex::Number::s),
10132 Then # Second previous is a statement separator
10133 0 ▶ {&$triple; # Reduce
Subroutine __ANON__: not called CC=1 SCAR=6.9
10134 0 Jmp $end; # No need to push as we already have a statement separator on top of the stack
10135 0 };
10136 ifOr
10137 0 ▶ [sub {$q == K p => Nasm::X86::Unisyn::Lex::Number::b}, # Statement separator preceded by singleton
Subroutine __ANON__: not called CC=1 SCAR=6.9
10138 0 ▶ sub {$q == K p => Nasm::X86::Unisyn::Lex::Number::S}],
Subroutine __ANON__: not called CC=1 SCAR=6.9
10139 Then
10140 0 ▶ {&$new; # Push statement separator after singleton
Subroutine __ANON__: not called CC=1 SCAR=6.9
10141 0 Jmp $end;
10142 0 };
10143 0 &$triple; # An operator at a higher level than statement separator so we can reduce
10144 0 Jmp $start; # Keep on reducing until we meet the matching opening bracket or start
10145 }
10146 0 };
10147  
10148 my $v = sub # Variable
10149 0 ▶ {#PrintErrStringNL "Type: v";
Subroutine __ANON__: not called CC=1 SCAR=6.9
10150 0 my $p = &$prev;
10151 0 &$new;
10152 If $p == K(p => Nasm::X86::Unisyn::Lex::Number::p),
10153 Then # Previous is a prefix operator
10154 0 ▶ {&$double;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10155 0 };
10156 0 };
10157  
10158 my $w = sub # Whitespace - ignore it
10159 0 ▶ {#PrintErrStringNL "Type: w";
Subroutine __ANON__: not called CC=1 SCAR=0.0
10160 0 };
10161  
10162 my $S = sub # Start symbol
10163 0 ▶ {PrintErrTraceBack "Should not be able to reach type S";
Subroutine __ANON__: not called CC=1 SCAR=6.9
10164 0 };
10165  
10166 0 PushR my $lexType = r15, my $prevLexType = r14; # Current lexical type current, previous lexical item
10167  
10168 0 Mov $prevLexType, Nasm::X86::Unisyn::Lex::Number::S; # Start symbol
10169  
10170 $s8->for(sub # Process up to the maximum number of characters
10171 0 ▶ {my ($index, undef, undef, $end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10172 0 my ($char, $size, $fail) = GetNextUtf8CharAsUtf32 $a8 + $position; # Get the next UTF-8 encoded character from the addressed memory and return it as a UTF-32 char.
10173  
10174 0 if (0) # Debug
10175 {#PrintOutStringNL "AAAA";
10176 #$index->outNL;
10177 #$char->outNL;
10178 PrintErrStringNL "AAAA";
10179 $index->d;
10180 $char->d;
10181 #$stack->dump("Stack");
10182 #$parse->dump("Parse", 20);
10183 };
10184  
10185 0 $parseChar->copy($char); # Copy the current character
10186  
10187 If $fail > 0,
10188 Then # Failed to convert a utf8 character
10189 0 ▶ {$parseReason ->copy(Nasm::X86::Unisyn::Lex::Reason::BadUtf8);
Subroutine __ANON__: not called CC=1 SCAR=6.9
10190 0 Jmp $end;
10191 0 };
10192  
10193 0 $itemLength++; # Increment unicode length
10194  
10195 0 $char->setReg(rsi); # Character
10196  
10197 0 Cmp rsi, "[$alphabetN]"; # Compare with alphabet array limit
10198  
10199 IfGe
10200 Then # Utf32 character is out of range of the alphabets array
10201 0 ▶ {Mov $lexType, -1; # Show invalid character
Subroutine __ANON__: not called CC=1 SCAR=6.9
10202 },
10203 Else # Character is in range
10204 0 ▶ {Mov rdx, $alphabetA; # Classify character into an alphabet
Subroutine __ANON__: not called CC=1 SCAR=6.9
10205 0 Add rdx, $char->addressExpr; # Position in alphabets array
10206 0 Mov byteRegister rdx, "[rdx]"; # Classify letter
10207 0 And rdx, 0xFF; # Clear rest of register
10208  
10209 0 Cmp rdx, Nasm::X86::Unisyn::Lex::Number::w; # Check for white space
10210 0 Cmovne $lexType, rdx; # Update lexical type unless it is white space which is being ignored
10211 0 };
10212  
10213 0 Cmp $lexType, -1; # Check found - performance is not at issue because we terminate the parse if the character has not been found
10214 IfEq
10215 Then # Failed to classify character
10216 0 ▶ {$parseReason->copy(Nasm::X86::Unisyn::Lex::Reason::InvalidChar);
Subroutine __ANON__: not called CC=1 SCAR=6.9
10217 0 Jmp $end;
10218 0 };
10219  
10220 0 my $change = V change => 0; # Changing from one lexical item to the next
10221  
10222 Block # Classify character
10223 0 ▶ {my ($endClassify) = @_; # Code with labels supplied
Subroutine __ANON__: not called CC=1 SCAR=6.9
10224  
10225 0 Cmp $lexType, Nasm::X86::Unisyn::Lex::Number::b;
10226 IfEq
10227 Then # Opening bracket
10228 0 ▶ {ClearRegisters zmm1;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10229 0 $position ->qIntoZ(1, 0); # Details of opening bracket
10230 0 $char ->qIntoZ(1, 8); # Open
10231 0 ($char+1) ->qIntoZ(1, 0x10); # Close
10232 0 $brackets->pushZmm(zmm1); # Save bracket description on bracket stack
10233 0 $change->copy(1); # Changing because we are on a bracket
10234 0 Jmp $endClassify;
10235 0 };
10236  
10237 0 Cmp $lexType, Nasm::X86::Unisyn::Lex::Number::B;
10238 IfEq
10239 Then # Closing bracket
10240 0 ▶ {If $brackets->stackSize > 0, # Something to match with on the brackets stack
Subroutine __ANON__: not called CC=1 SCAR=6.9
10241 Then
10242 0 ▶ {$brackets->popZmm(1); # Details of matching bracket
Subroutine __ANON__: not called CC=1 SCAR=6.9
10243 0 my $close = qFromZ(zmm1, 0x10);
10244 If $close != $char, # Closing bracket did not match the closing bracket derived from the opening bracket
10245 Then
10246 0 ▶ {my $position = dFromZ(zmm1, 0);
Subroutine __ANON__: not called CC=1 SCAR=6.9
10247 0 $parseMatch ->copy($position);
10248 0 $parseReason->copy(Nasm::X86::Unisyn::Lex::Reason::Mismatch); # Mismatched bracket
10249 0 Jmp $end;
10250 0 };
10251 0 $change->copy(1); # Changing because we are on a bracket
10252 },
10253 Else
10254 0 ▶ {$parseReason->copy(Nasm::X86::Unisyn::Lex::Reason::TrailingClose);
Subroutine __ANON__: not called CC=1 SCAR=6.9
10255 0 Jmp $end;
10256 0 };
10257 0 Jmp $endClassify;
10258 0 };
10259  
10260 0 Cmp $lexType, $last->addressExpr;
10261 IfNe
10262 Then # Change of current lexical item
10263 0 ▶ {$change->copy(1); # Changing because we are on a different lexical item
Subroutine __ANON__: not called CC=1 SCAR=6.9
10264 0 Jmp $endClassify;
10265 0 };
10266  
10267 0 Cmp $lexType, Nasm::X86::Unisyn::Lex::Number::s;
10268 IfEq
10269 Then # Statement separator is always one character wide as more would be pointless
10270 0 ▶ {$change->copy(1); # Changing because we are on a different lexical item
Subroutine __ANON__: not called CC=1 SCAR=6.9
10271 0 };
10272 0 };
10273  
10274 If $change > 0, # Check the transition from the previous item
10275 Then # Change of current lexical item
10276 0 ▶ {Cmp $lexType, Nasm::X86::Unisyn::Lex::Number::w; # Do not transition on white space
Subroutine __ANON__: not called CC=1 SCAR=6.9
10277  
10278 IfNe
10279 Then # Not white space
10280 0 ▶ {Mov rsi, $prevLexType;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10281 0 Shl rsi, Nasm::X86::Unisyn::Lex::PermissibleTransitionsArrayBits;
10282 0 Add rsi, $lexType; # The index into the allowed transitions array
10283  
10284 0 my ($tN, $tA) = Nasm::X86::Unisyn::Lex::PermissibleTransitionsArray; # Load permissible transitions
10285 0 Mov rax, $tA;
10286 0 Add rsi, rax;
10287 0 Mov al, "[rsi]"; # Place transition symbol in low byte
10288  
10289 0 Cmp al, 0; # Test transition in low byte
10290 IfGt
10291 Then # The transition on this lexical type was a valid transition
10292 0 ▶ {Mov $prevLexType, $lexType; # New lexical type we will be transitioning on
Subroutine __ANON__: not called CC=1 SCAR=6.9
10293 0 $last->copy($lexType); # Treat unbroken sequences of a symbol as one lexical item
10294 },
10295 Else # The transition on this lexical type was an invalid transition
10296 0 ▶ {$parseReason->copy(Nasm::X86::Unisyn::Lex::Reason::InvalidTransition);
Subroutine __ANON__: not called CC=1 SCAR=6.9
10297 0 Jmp $end;
10298 0 };
10299 0 };
10300  
10301 0 &$updateLength; # Update the length of the previous lexical item
10302  
10303 Block # Parse each lexical item to produce a parse tree of trees
10304 0 ▶ {my ($end, $start) = @_; # Code with labels supplied
Subroutine __ANON__: not called CC=10 SCAR=47.0
10305  
10306 0 my %l = map {$_ => eval "Nasm::X86::Unisyn::Lex::Number::$_"} # Lexical items to lexical item numbers
10307 qw(w a A b B l m p q s v d e f g h i j k S F);
10308 0 my @l = sortHashKeysByIntegerValues \%l; # Sort the lexical item types into numerical order
10309 0 my @c; # Check numbers are unique and sequential
10310 my @L; # Labels
10311 0 my $jumpTable = Label; # Start of jump table
10312  
10313 0 Comment "Jump to table";
10314 0 $last->setReg(rax);
10315 0 Shl rax, 4;
10316 0 Mov rsi, $jumpTable;
10317 0 Add rax, rsi;
10318 0 Jmp rax;
10319  
10320 0 for my $L(@l) # Create code to process each lexical item depending on its type
10321 0 {my $n = eval "Nasm::X86::Unisyn::Lex::Number::$L";
10322 0 $c[$n]++;
10323 0 push @L, SetLabel;
10324 0 my $c = "&\$$L";
10325 0 Comment "Lexical $L";
10326 0 eval $c;
10327 0 ▶ confess $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
10328 0 Jmp $end;
10329 }
10330  
10331 0 ▶ confess "Lexical items do not start zero" unless defined $c[0]; # Check that the lexical item numbers can be used to create a jump table
Branch: 1 branch
BranchTrueFalseTotal
unless defined $c[0] 0 0 0
10332 0 ▶ confess "Gaps in lexical items numbers" unless @c == @l;
Branch: 1 branch
BranchTrueFalseTotal
unless @c == @l 0 0 0
10333 0 for my $i(@c)
10334 0 ▶ {confess "Missing lexical item at $i" unless ($c[$i]//0) == 1; # Each jump has one lexical item
Branch: 1 branch
BranchTrueFalseTotal
unless ($c[$i] // 0) == 1 0 0 0
Condition0%0/2
$c[$i] // 0
l!l
00
MC/DC0%0/1
$c[$i] // 0
$c[$i]
Truth table0%0/2
A
A= $c[$i]
Aresult
11
00
10335 }
10336  
10337 0 Comment "Jump Table target";
10338 0 Align 16;
10339 0 SetLabel $jumpTable;
10340 0 for my $L(@L) # The jump table
10341 0 {Jmp $L; # Jump to code that will process the lexical item
10342 0 Align 16;
10343 }
10344  
10345 0 Align 1024;
10346 0 ▶ PrintErrTraceBack "Unexpected lexical type" if $DebugMode; # Something unexpected came along
Branch: 1 branch
BranchTrueFalseTotal
if $Nasm::X86::DebugMode 0 0 0
10347 0 };
10348 0 }; # Else not required - we are continuing in the same lexical item
10349  
10350 0 $position->copy($position + $size); # Point to next character to be parsed
10351  
10352 If $position >= $s8,
10353 Then # We have reached the end of the input
10354 0 ▶ {Mov rsi, $prevLexType; # Lexical type to transition from
Subroutine __ANON__: not called CC=1 SCAR=6.9
10355 0 Shl rsi, Nasm::X86::Unisyn::Lex::PermissibleTransitionsArrayBits; # Two dimensional index
10356 0 Add rsi, Nasm::X86::Unisyn::Lex::Number::F; # Check we can transition to the final state from the current state
10357  
10358 0 my ($tN, $tA) = Nasm::X86::Unisyn::Lex::PermissibleTransitionsArray; # Load permissible transitions
10359 0 Mov rax, $tA;
10360 0 Add rsi, rax;
10361 0 Mov al, "[rsi]";
10362  
10363 0 Cmp al, 0;
10364 IfGt
10365 Then # We are able to transition to the final state
10366 0 ▶ {If $brackets->stackSize == 0, # Check that all the brackets have closed
Subroutine __ANON__: not called CC=1 SCAR=6.9
10367 Then # No outstanding brackets
10368 0 ▶ {&$F;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10369 0 $parseFail->copy(0); # Show success as a lack of failure
10370 },
10371 Else # Open brackets not yet closed
10372 0 ▶ {$parseFail->copy(Nasm::X86::Unisyn::Lex::Reason::BracketsNotClosed); # Error code
Subroutine __ANON__: not called CC=1 SCAR=6.9
10373 0 };
10374 },
10375 Else # We are not able to transition to the final state
10376 0 ▶ {$parseFail->copy(Nasm::X86::Unisyn::Lex::Reason::NotFinal); # Error code
Subroutine __ANON__: not called CC=1 SCAR=6.9
10377 0 };
10378 0 Jmp $end; # Cannot parse further
10379 0 };
10380 0 });
10381  
10382 0 PopR;
10383  
10384 0 my $parseTree = $stack->pop; $stack->free; $brackets->free; # Obtain the parse tree (which is not a conventional tree) and free the brackets stack and parse stack
10385  
10386 #$parse->dump("AA");
10387  
10388 0 $pd->area ->copyDescriptor($parse); # The area in which the parse tree was built
10389 0 $pd->tree ->copy($parseTree); # The offset of the start of the parse tree in the parse area - this is not a conventional Tree as defined elsewhere - it is specific to parsing.
10390 0 $pd->char ->copy($parseChar); # Last character processed
10391 0 $pd->fail ->copy($parseFail); # If not zero the parse has failed for some reason
10392 0 $pd->position ->copy($position); # The position reached in the input string
10393 0 $pd->match ->copy($parseMatch); # The position of the matching bracket that did not match
10394 0 $pd->reason ->copy($parseReason); # The reason code describing the failure if any
10395 0 $pd->symbols ->copyDescriptor($symbols); # The symbol tree produced by the parse
10396  
10397 } # Parse
10398  
10399 sub Nasm::X86::Unisyn::Parse::dumpParseResult($) # Dump the result of a parse
10400 0 ▶ {my ($parse) = @_; # Parse
Subroutine dumpParseResult: not called CC=2 SCAR=17.9
10401 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
10402  
10403 0 $parse->char ->outNL; # Print results
10404 0 $parse->fail ->outNL;
10405 0 $parse->position->outNL;
10406 0 $parse->match ->outNL;
10407 0 $parse->reason ->outNL;
10408  
10409 0 $parse->dump;
10410 }
10411  
10412 sub Nasm::X86::Unisyn::Parse::dump($) #P Dump a parse tree in order.
10413 0 ▶ {my ($parse) = @_; # Parse
Subroutine dump: not called CC=2 SCAR=17.9
10414 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
10415  
10416 0 my $w = RegisterSize(eax); # Width of an offset
10417  
10418 #$parse->area->dump("PPPP", 20);
10419  
10420 my $s = Subroutine # Print a tree
10421 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
10422  
10423 0 my $area = $$s{area}; # Area
10424 0 my $source = $$p{source}; # Source
10425 0 my $depth = $$p{depth}; # Depth
10426 0 my $offset = $$p{offset}; # Offset of node of parse tree in containing area
10427  
10428 If $depth < K(key => 99),
10429 Then
10430 0 ▶ {$area->getZmmBlock($offset, 1); # Load parse tree node
Subroutine __ANON__: not called CC=1 SCAR=6.9
10431  
10432 0 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of input
10433 0 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in input
10434 0 my $type = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::type); # Type of operator
10435 0 my $left = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::left); # Left operand found
10436 0 my $right = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::right); # Right operand found
10437  
10438 If $length > 0, # Source text of lexical item
10439 Then
10440 0 ▶ {$depth->for(sub
Subroutine __ANON__: not called CC=1 SCAR=6.9
10441 0 ▶ {PrintOutString "._";
Subroutine __ANON__: not called CC=1 SCAR=6.9
10442 0 });
10443  
10444 0 ($source + $position)->printOutMemoryNL($length); # Write source text corresponding to the source lexical item
10445 0 };
10446  
10447 If $left > 0,
10448 Then # There is a left sub tree
10449 0 ▶ {$sub->call(structures => {area => $area},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10450 parameters => {depth => $depth+1, offset => $left, source => $source});
10451 0 };
10452  
10453 If $right > 0,
10454 Then # There is a right sub tree
10455 0 ▶ {$sub->call(structures => {area => $area},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10456 parameters => {depth => $depth+1, offset => $right, source => $source});
10457 0 };
10458 0 };
10459 0 } structures => {area => $parse->area}, parameters=>[qw(depth offset source)],
10460 name => "Nasm::X86::Unisyn::Parse::dump";
10461  
10462 0 $s->call(structures => {area => $parse->area},
10463 parameters => {depth => K(depth => 0),
10464 offset => $parse->tree,
10465 source => $parse->source});
10466 }
10467  
10468 sub Nasm::X86::Unisyn::Parse::dumpPostOrder($) # Dump a parse tree in post order.
10469 0 ▶ {my ($parse) = @_; # Parse
Subroutine dumpPostOrder: not called CC=2 SCAR=17.9
10470 0 ▶ @_ == 1 or confess "One parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or confess("One parameter") 0 0 0
10471  
10472 0 my $w = RegisterSize(eax); # Width of an offset
10473  
10474 #$parse->area->dump("PPPP", 20);
10475  
10476 my $s = Subroutine # Print a tree
10477 0 ▶ {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
10478  
10479 0 my $area = $$s{area}; # Area
10480 0 my $source = $$p{source}; # Source
10481 0 my $depth = $$p{depth}; # Depth
10482 0 my $offset = $$p{offset}; # Offset of node of parse tree in containing area
10483  
10484 If $depth < K(key => 99),
10485 Then
10486 0 ▶ {$area->getZmmBlock($offset, 1); # Load parse tree node
Subroutine __ANON__: not called CC=1 SCAR=6.9
10487  
10488 0 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of input
10489 0 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in input
10490 0 my $type = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::type); # Type of operator
10491 0 my $left = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::left); # Left operand found
10492 0 my $right = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::right); # Right operand found
10493  
10494 If $left > 0,
10495 Then # There is a left sub tree
10496 0 ▶ {$sub->call(structures => {area => $area},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10497 parameters => {depth => $depth+1, offset => $left, source => $source});
10498 0 };
10499  
10500 If $right > 0,
10501 Then # There is a right sub tree
10502 0 ▶ {$sub->call(structures => {area => $area},
Subroutine __ANON__: not called CC=1 SCAR=6.9
10503 parameters => {depth => $depth+1, offset => $right, source => $source});
10504 0 };
10505  
10506 If $length > 0, # Source text of lexical item
10507 Then
10508 0 ▶ {$depth->for(sub
Subroutine __ANON__: not called CC=1 SCAR=6.9
10509 0 ▶ {PrintOutString "._";
Subroutine __ANON__: not called CC=1 SCAR=6.9
10510 0 });
10511  
10512 0 ($source + $position)->printOutMemoryNL($length); # Write source text corresponding to the source lexical item
10513 0 };
10514 0 };
10515 0 } structures => {area => $parse->area}, parameters=>[qw(depth offset source)],
10516 name => "Nasm::X86::Unisyn::Parse::dump";
10517  
10518 0 $s->call(structures => {area => $parse->area},
10519 parameters => {depth => K(depth => 0),
10520 offset => $parse->tree,
10521 source => $parse->source});
10522 }
10523  
10524 sub Nasm::X86::Unisyn::Parse::traverseApplyingLibraryOperators($$) # Traverse a parse tree, in post order, applying a library of operators.
10525 0 ▶ {my ($parse, $library) = @_; # Parse tree, area containing a library
Subroutine traverseApplyingLibraryOperators: not called CC=2 SCAR=17.9
10526 0 ▶ @_ == 2 or confess "Two parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or confess("Two parameters") 0 0 0
10527  
10528 0 my ($intersection, $subroutines) = # Create a tree mapping the subroutine numbers to subroutine offsets
10529 $library->readLibraryHeader
10530 ($parse->symbols, \&Nasm::X86::Unisyn::Lex::letterToNumber); # Include single letter mapping
10531  
10532 my $s = Subroutine # Print a tree
10533 0 ▶ {my ($parameters, $structures, $subroutine) = @_; # Parameters, structures, subroutine definition
Subroutine __ANON__: not called CC=1 SCAR=6.9
10534 0 my $parse = $$structures{parse}; # Parse tree
10535 0 my $intersection = $$structures{intersection}; # Intersection
10536 0 my $subroutines = $$structures{subroutines}; # Intersection
10537 0 my $library = $$structures{library}; # Library
10538 0 my $offset = $$parameters{offset}; # The offset in the containing area of the current node of the parse tree
10539  
10540 0 my $w = dSize;
10541 0 $parse->area->getZmmBlock($offset, 1); # Load parse tree node
10542 # my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of input
10543 # my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in input
10544 0 my $type = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::type); # Type of operator
10545 0 my $left = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::left); # Left operand found
10546 0 my $right = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::right); # Right operand found
10547 0 my $symbol = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::symbol); # Lexical symbol
10548  
10549 If $left > 0,
10550 Then # There is a left sub tree
10551 0 ▶ {$subroutine->call
Subroutine __ANON__: not called CC=1 SCAR=6.9
10552 (structures => {parse => $parse,
10553 library => $library,
10554 intersection => $intersection,
10555 subroutines => $subroutines},
10556 parameters => {offset => $left});
10557 0 };
10558  
10559 If $right > 0,
10560 Then # There is a right sub tree
10561 0 ▶ {$subroutine->call
Subroutine __ANON__: not called CC=1 SCAR=6.9
10562 (structures => {parse => $parse,
10563 library => $library,
10564 intersection => $intersection,
10565 subroutines => $subroutines},
10566 parameters => {offset => $right});
10567 0 };
10568  
10569 0 ▶ my $sub = Subroutine {} # Subroutine definition used to call library subroutines
Subroutine __ANON__: not called CC=1 SCAR=0.0
10570 0 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
10571 parameters => [qw(offset)];
10572  
10573 my $byType = sub # Process a lexical item by just its type
10574 0 ▶ {my ($name) = @_; # Library subroutine name for this lexical type
Subroutine __ANON__: not called CC=1 SCAR=6.9
10575 0 $subroutines->getKeyString(constantString($name)); # Locate processing routine by name
10576  
10577 If $subroutines->found > 0,
10578 Then # Located the subroutine for this lexical type
10579 0 ▶ {$sub->call(override => $library->address + $subroutines->data, # Call the library routine
Subroutine __ANON__: not called CC=1 SCAR=6.9
10580 parameters => {offset => $offset},
10581 structures => {parse => $parse});
10582 0 };
10583 0 };
10584  
10585 my $byName = sub # Look up method name that matches the lexical item
10586 0 ▶ {$intersection->find($symbol); # Lexical item number to library routine offset
Subroutine __ANON__: not called CC=1 SCAR=6.9
10587  
10588 If $intersection->found > 0,
10589 Then
10590 0 ▶ {$sub->call(override => $library->address + $intersection->data, # Call the library routine
Subroutine __ANON__: not called CC=1 SCAR=6.9
10591 parameters => {offset => $offset},
10592 structures => {parse => $parse});
10593 0 };
10594 0 };
10595  
10596 Block # Process lexical item by type
10597 0 ▶ {my ($end) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10598 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::A), Then {&$byType("Ascii"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10599 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::b), Then {&$byType("Open"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10600 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::B), Then {&$byType("Close"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10601 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::p), Then {&$byType("Prefix"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10602 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::q), Then {&$byType("Suffix"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10603 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::s), Then {&$byType("Separator"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10604 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::v), Then {&$byType("Variable"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10605  
10606 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::d), Then {&$byName("Dyad5 "); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10607 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::e), Then {&$byName("Dyad6 "); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10608 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::a), Then {&$byName("Assign"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10609 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::f), Then {&$byName("Dyad7 "); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10610 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::g), Then {&$byName("Dyad8 "); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10611 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::h), Then {&$byName("Dyad9 "); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10612 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::i), Then {&$byName("Dyad10"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10613 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::j), Then {&$byName("Dyad11"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10614 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::k), Then {&$byName("Dyad12"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10615 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::l), Then {&$byName("Dyad3"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10616 0 ▶ If $type == K(type => Nasm::X86::Unisyn::Lex::Number::m), Then {&$byName("Dyad4"); Jmp $end};
Subroutine __ANON__: not called CC=1 SCAR=6.9
10617 0 };
10618 0 } structures => {parse => $parse,
10619 library => $library,
10620 intersection => $intersection,
10621 subroutines => $subroutines},
10622 parameters => [qw(offset)],
10623 name => "Nasm::X86::Tree::traverseApplyingLibraryOperators";
10624  
10625 0 $s->call(structures => {parse => $parse, # Call
10626 library => $library,
10627 intersection => $intersection,
10628 subroutines => $subroutines},
10629 parameters=> {offset => $parse->tree});
10630 }
10631  
10632 #D1 Assemble # Assemble generated code
10633  
10634 sub CallC($@) # Call a C subroutine.
10635 0 ▶ {my ($sub, @parameters) = @_; # Name of the sub to call, parameters
Subroutine CallC: not called CC=3 SCAR=24.8
Pod documented
10636 my
10637 0 @order = (rdi, rsi, rdx, rcx, r8, r9, r15);
10638 0 PushR @order;
10639  
10640 0 for my $i(keys @parameters) # Load parameters into designated registers
10641 0 {Mov $order[$i], $parameters[$i];
10642 }
10643  
10644 0 Push rax; # Align stack on 16 bytes
10645 0 Mov rax, rsp; # Move stack pointer
10646 0 Shl rax, 60; # Get lowest nibble
10647 0 Shr rax, 60;
10648 IfEq # If we are 16 byte aligned push two twos
10649 Then
10650 0 ▶ {Mov rax, 2; Push rax; Push rax;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10651 },
10652 Else # If we are not 16 byte aligned push one one.
10653 0 ▶ {Mov rax, 1; Push rax;
Subroutine __ANON__: not called CC=1 SCAR=6.9
10654 0 };
10655  
10656 0 ▶ if (ref($sub)) # Where do we use this option?
Branch: 1 branch
BranchTrueFalseTotal
if (ref $sub) { } 0 0 0
10657 0 {Call $sub->start;
10658 }
10659 else # Call named subroutine
10660 0 {Call $sub;
10661 }
10662  
10663 0 Pop r15; # Decode and reset stack after 16 byte alignment
10664 0 Cmp r15, 2; # Check for double push
10665 0 Pop r15; # Single or double push
10666 0 ▶ IfEq Then {Pop r15}; # Double push
Subroutine __ANON__: not called CC=1 SCAR=6.9
10667 0 PopR @order;
10668 }
10669  
10670 sub Extern(@) # Name external references.
10671 0 ▶ {my (@externalReferences) = @_; # External references
Subroutine Extern: not called CC=1 SCAR=6.9
Pod documented
10672 0 push @extern, @_;
10673 }
10674  
10675 sub Link(@) # Libraries to link with.
10676 0 ▶ {my (@libraries) = @_; # Link library names which will be looked for on "LIBPATH"
Subroutine Link: not called CC=1 SCAR=6.9
Pod documented
10677 0 push @link, @_;
10678 }
10679  
10680 1 my $lastAsmFinishTime; # The last time we finished an assembly
10681  
10682 sub Start() # Initialize the assembler.
10683 0 ▶ {@bss = @data = @rodata = %rodata = %rodatas = %subroutines = @text =
Subroutine Start: not called CC=1 SCAR=6.9
Pod documented
10684 @PushR = @extern = @link = @VariableStack = %loadAreaIntoAssembly = ();
10685  
10686 0 $DebugMode = 0;
10687 0 $Labels = 0;
10688 0 $TraceMode = 0;
10689 0 SubroutineStartStack; # Number of variables at each lexical level
10690 0 $lastAsmFinishTime = time; # The last time we finished an assembly
10691 }
10692  
10693 sub Exit(;$) # Exit with the specified return code or zero if no return code supplied. Assemble() automatically adds a call to Exit(0) if the last operation in the program is not a call to Exit.
10694 1 ▶ {my ($c) = @_; # Return code
Subroutine Exit: called CC=2 SCAR=6.9
Pod documented
10695 1 ▶ $c //= 0;
Condition50%1/2
$c //= 0
l!l
10
MC/DC0%0/1
$c //= 0
$c
Truth table50%1/2
A
A= $c
Aresult
11
00
10696 my $s = Subroutine
10697 1 ▶ {Comment "Exit code: $c";
Subroutine __ANON__: called CC=1 SCAR=0.0
10698 1 PushR rax, rdi;
10699 1 Mov rdi, $c;
10700 1 Mov rax, 60;
10701 1 Syscall;
10702 1 PopR;
10703 1 } name => "Exit_$c";
10704  
10705 1 $s->call;
10706 }
10707  
10708 my $LocateIntelEmulator; # Location of Intel Software Development Emulator
10709  
10710 sub LocateIntelEmulator() #P Locate the Intel Software Development Emulator.
10711 0 ▶ {my @locations = qw(/var/isde/sde64 sde/sde64 ./sde64); # Locations at which we might find the emulator
Subroutine LocateIntelEmulator: not called CC=8 SCAR=42.8
Pod documented
10712 0 my $downloads = q(/home/phil/Downloads); # Downloads folder
10713  
10714 0 ▶ return $LocateIntelEmulator if defined $LocateIntelEmulator; # Location has already been discovered
Branch: 1 branch
BranchTrueFalseTotal
if defined $LocateIntelEmulator 0 0 0
10715  
10716 0 for my $l(@locations) # Try each locations
10717 0 ▶ {return $LocateIntelEmulator = $l if -e $l; # Found it - cache and return
Branch: 1 branch
BranchTrueFalseTotal
if -e $l 0 0 0
10718 }
10719  
10720 0 ▶ if (qx(sde64 -version) =~ m(Intel.R. Software Development Emulator)) # Try path
Branch: 1 branch
BranchTrueFalseTotal
if (`sde64 -version` =~ /Intel.R. Software Development Emulator/) 0 0 0
10721 0 {return $LocateIntelEmulator = "sde64";
10722 }
10723  
10724 0 ▶ return undef unless -e $downloads; # Skip local install if not developing
Branch: 1 branch
BranchTrueFalseTotal
unless -e $downloads 0 0 0
10725 0 my $install = <<END =~ s(\n) ( && )gsr =~ s(&&\s*\Z) ()sr; # Install sde
10726 cd $downloads
10727 curl https://software.intel.com/content/dam/develop/external/us/en/documents/downloads/sde-external-8.63.0-2021-01-18-lin.tar.bz2 > sde.tar.bz2
10728 tar -xf sde.tar.bz2
10729 sudo mkdir -p /var/isde/
10730 sudo cp -r * /var/isde/
10731 ls -ls /var/isde/
10732 END
10733  
10734 0 say STDERR qx($install); # Execute install
10735  
10736 0 for my $l(@locations) # Retry install locations after install
10737 0 ▶ {return $LocateIntelEmulator = $l if -e $l; # Found it - cache and return
Branch: 1 branch
BranchTrueFalseTotal
if -e $l 0 0 0
10738 }
10739 undef # Still not found - give up
10740 0 }
10741  
10742 sub getInstructionCount() #P Get the number of instructions executed from the emulator mix file.
10743 0 ▶ {return 0 unless -e $sdeMixOut;
Subroutine getInstructionCount: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless -e $Nasm::X86::sdeMixOut 0 0 0
10744 0 my $s = readFile $sdeMixOut;
10745 0 ▶ if ($s =~ m(\*total\s*(\d+))) {return $1}
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\*total\s*(\d+)/) 0 0 0
10746 0 confess;
10747 }
10748  
10749 sub OptimizePopPush(%) #P Perform code optimizations.
10750 0 ▶ {my (%options) = @_; # Options
Subroutine OptimizePopPush: not called CC=7 SCAR=40.3
Pod documented
10751 0 my %o = map {$_=>1} $options{optimize}->@*;
10752 0 if (1 or $o{if}) # Optimize if statements by looking for the unnecessary reload of the just stored result
10753 0 {for my $i(1..@text-2) # Each line
10754 0 {my $t = $text[$i];
10755 0 ▶ if ($t =~ m(\A\s+push\s+(r\d+)\s*\Z)i) # Push
Branch: 1 branch
BranchTrueFalseTotal
if ($t =~ /\A\s+push\s+(r\d+)\s*\Z/i) 0 0 0
10756 0 {my $R = $1; # Register being pushed
10757 0 my $s = $text[$i-1]; # Previous line
10758 0 ▶ if ($s =~ m(\A\s+pop\s+$R\s*\Z)i) # Matching push
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\A\s+pop\s+$R\s*\Z/i) 0 0 0
10759 0 {my $r = $text[$i-2];
10760 0 ▶ if ($r =~ m(\A\s+mov\s+\[rbp-8\*\((\d+)\)],\s*$R\s*\Z)i) # Save to variable
Branch: 1 branch
BranchTrueFalseTotal
if ($r =~ /\A\s+mov\s+\[rbp-8\*\((\d+)\)],\s*$R\s*\Z/i) 0 0 0
10761 0 {my $n = $1; # Variable number
10762 0 my $u = $text[$i+1];
10763 0 ▶ if ($u =~ m(\A\s+mov\s+$R,\s*\[rbp-8\*\($n\)]\s*\Z)i) # Reload register
Branch: 1 branch
BranchTrueFalseTotal
if ($u =~ /\A\s+mov\s+$R,\s*\[rbp-8\*\($n\)]\s*\Z/i) 0 0 0
10764 0 {for my $j($i-1..$i+1)
10765 0 {$text[$j] = '; out '. $text[$j];
10766 }
10767 }
10768 }
10769 }
10770 }
10771 }
10772 }
10773 }
10774  
10775 sub OptimizeReload(%) #P Reload: a = b; b = a; remove second - as redundant.
10776 1 ▶ {my (%options) = @_; # Options
Subroutine OptimizeReload: called CC=4 SCAR=17.9
Pod documented
10777 0 my %o = map {$_=>1} $options{optimize}->@*;
10778 1 if (1 or $o{reload})
10779 1 {for my $i(1..@text-1) # Each line
10780 345 {my $a = $text[$i-1];
10781 345 my $b = $text[$i];
10782 345 ▶ if ($a =~ m(\Amov (\[.*?\]), ([^\[\]].*?)\Z)) # Check a = b
Branch: 1 branch
BranchTrueFalseTotal
if ($a =~ /\Amov (\[.*?\]), ([^\[\]].*?)\Z/) 0 345 345
10783 0 {my $a1 = $1; my $a2 = $2;
10784 0 ▶ if ($b eq qq(mov $a2, $a1\n)) # Check b = a
Branch: 1 branch
BranchTrueFalseTotal
if ($b eq "mov $a2, $a1\n") 0 0 0
10785 0 {$text[$i] = q(; Reload removed: ).$text[$i];
10786 }
10787 }
10788 }
10789 }
10790 }
10791  
10792 1 my $hasAvx512;
10793  
10794 sub hasAvx512() #P Check whether the current device has avx512 instructions or not.
10795 0 ▶ {return $hasAvx512 if defined $hasAvx512;
Subroutine hasAvx512: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if defined $hasAvx512 0 0 0
10796 0 ▶ $hasAvx512 = qx(cat /proc/cpuinfo | grep avx512) =~ m(\S) ? 1 : 0; # Cache avx512 result
Branch: 1 branch
BranchTrueFalseTotal
`cat /proc/cpuinfo | grep avx512` =~ /\S/ ? : 0 0 0
10797 }
10798  
10799 sub lineNumbersToSubNamesFromSource #P Create a hash mapping line numbers to subroutine definitions.
10800 0 ▶ {my @s = readFile $0; # Read source file
Subroutine lineNumbersToSubNamesFromSource: not called CC=5 SCAR=34.0
Pod documented
10801 0 my %l; # Mapping from line number to current sub
10802 my $c; # The current sub
10803 0 for my $i(keys @s) # Each line number
10804 0 {my $s = $s[$i];
10805 0 ▶ if ($s =~ m(\Asub ([^ \(]+)))
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\Asub ([^ \(]+)/) 0 0 0
10806 0 {$c = $1 =~ s(\ANasm::X86::) ()r; # Subroutine name minus package name and parameters
10807 }
10808 0 ▶ if ($s =~ m(\A })) # End of sub
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\A }/) 0 0 0
10809 0 {$c = undef;
10810 }
10811 0 ▶ $l{$i+1} = $c if $c;
Branch: 1 branch
BranchTrueFalseTotal
if $c 0 0 0
10812 }
10813 %l
10814 0 }
10815  
10816 sub locateRunTimeErrorInDebugTraceOutput($) #P Locate the traceback of the last known good position in the trace file before the error occurred.
10817 0 ▶ {my ($trace) = @_; # Trace mode
Subroutine locateRunTimeErrorInDebugTraceOutput: not called CC=9 SCAR=45.0
Pod documented
10818 0 unlink $traceBack; # Traceback file
10819 0 ▶ return '' unless -e $sdeTraceOut; # Need a trace file to get a traceback
Branch: 1 branch
BranchTrueFalseTotal
unless -e $Nasm::X86::sdeTraceOut 0 0 0
10820 0 my @a = readFile $sdeTraceOut; # Read trace file
10821 0 my $s = 0; # Parse state
10822 0 my @p; # Position in source file
10823  
10824 0 for my $a(reverse @a) # Read backwards
10825 0 ▶ {if (!$s) # Looking for traceback start
Branch: 2 branches
BranchTrueFalseTotal
if (not $s) { } 0 0 0
elsif ($s == 1) { } 0 0 0
10826 0 ▶ {if ($a =~ m(\AINS 0x[[:xdigit:]]{16}\s+MMX\s+movq\sr11,\s+mm0))
Branch: 1 branch
BranchTrueFalseTotal
if ($a =~ /\AINS 0x[[:xdigit:]]{16}\s+MMX\s+movq\sr11,\s+mm0/) 0 0 0
10827 0 {$s = 1;
10828 }
10829 }
10830 elsif ($s == 1) # In the traceback
10831 0 ▶ {if ($a =~ m(\AINS\s+0x[[:xdigit:]]{16}\s+BASE\s+mov r11, (0x[[:xdigit:]]+)))
Branch: 1 branch
BranchTrueFalseTotal
if ($a =~ /\AINS\s+0x[[:xdigit:]]{16}\s+BASE\s+mov r11, (0x[[:xdigit:]]+)/) 0 0 0
10832 0 {unshift @p, eval $1;
10833 0 next;
10834 }
10835 0 last; # Finished the scan of the traceback
10836 }
10837 }
10838  
10839 0 push my @t, "TraceBack start: ", "_"x80; # Write the traceback
10840 0 my %l = lineNumbersToSubNamesFromSource();
10841 0 for my $i(keys @p)
10842 0 {my $p = $p[$i];
10843 0 ▶ push @t, sprintf "%6d %s called at $0 line %d", $p, pad($l{$p}//'.', 32), $p;
Condition0%0/2
$l{$p} // "."
l!l
00
MC/DC0%0/1
$l{$p} // "."
$l{$p}
Truth table0%0/2
A
A= $l{$p}
Aresult
11
00
10844 }
10845 0 push @t, "_" x 80;
10846 0 my $t = join "\n", @t;
10847 0 owf($traceBack, $t); # Place into a well known file
10848 0 say STDERR $t;
10849 0 $t
10850 }
10851  
10852 sub fixMixOutput #P Fix mix output so we know where the code comes from in the source file.
10853 0 ▶ {return '' unless -e $sdeMixOut; # Need a mix file to make this work
Subroutine fixMixOutput: not called CC=5 SCAR=34.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless -e $Nasm::X86::sdeMixOut 0 0 0
10854 0 my @a = readFile $sdeMixOut; # Read mix output
10855 0 my %l = lineNumbersToSubNamesFromSource();
10856  
10857 0 for my $i(keys @a) # Each line of output
10858 0 ▶ {if ($a[$i] =~ m(\AXDIS\s+[[:xdigit:]]{16}:\s+BASE\s+[[:xdigit:]]+\s+mov\s+r11,\s+(0x[[:xdigit:]]+)))
Branch: 1 branch
BranchTrueFalseTotal
if ($a[$i] =~ /\AXDIS\s+[[:xdigit:]]{16}:\s+BASE\s+[[:xdigit:]]+\s+mov\s+r11,\s+(0x[[:xdigit:]]+)/) 0 0 0
10859 0 {my $l = eval($1)+1;
10860 0 ▶ $a[$i] = sprintf " %s called at $0 line %d\n", pad($l{$l}//'', 32), $l;
Condition0%0/2
$l{$l} // ""
l!l
00
MC/DC0%0/1
$l{$l} // ""
$l{$l}
Truth table0%0/2
A
A= $l{$l}
Aresult
11
00
10861 }
10862 }
10863 0 my $a = join "", @a; # Updated mix out
10864 0 owf $sdeMixOut, join "", @a; # Save updated mix out
10865 0 $a
10866 }
10867  
10868 sub countComments($) #P Count the number of comments in the text of the program so we can see what code is being generated too often.
10869 0 ▶ {my ($count) = @_; # Comment count
Subroutine countComments: not called CC=7 SCAR=40.3
Pod documented
10870 0 ▶ if ($count) # Count the comments so we can see what code to put into subroutines
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 0 0 0
10871 0 {my %c; my %b; # The number of lines between the comments, the number of blocks
10872 0 for my $c(readFile $sourceFile)
10873 0 ▶ {next unless $c =~ m(\A;);
Branch: 1 branch
BranchTrueFalseTotal
unless $c =~ /\A;/ 0 0 0
10874 0 my @w = split /\s+/, $c, 3;
10875 0 $c{$w[1]}++;
10876 }
10877  
10878 0 my @c;
10879 0 for my $c(keys %c) # Remove comments that do not appear often
10880 0 ▶ {push @c, [$c{$c}, $b{$c}, $c] if $c{$c} >= $count;
Branch: 1 branch
BranchTrueFalseTotal
if $c{$c} >= $count 0 0 0
10881 }
10882 0 my @d = sort {$$b[0] <=> $$a[0]} @c;
10883 0 ▶ say STDERR formatTable(\@d, [qw(Lines Blocks Comment)]) if @d; # Print frequently appearing comments
Branch: 1 branch
BranchTrueFalseTotal
if @d 0 0 0
10884 }
10885 }
10886  
10887 sub numberWithUnderScores($) #P Place underscores in the string representation of a number.
10888 0 ▶ {my ($n) = @_; # Number to add commas to
Subroutine numberWithUnderScores: not called CC=1 SCAR=6.9
Pod documented
10889 0 scalar reverse join '_', unpack("(A3)*", reverse $n);
10890 }
10891  
10892 sub onGitHub #P Whether we are on GitHub or not.
10893 1 ▶ {$ENV{GITHUB_REPOSITORY_OWNER}
Subroutine onGitHub: called CC=1 SCAR=0.0
Pod documented
10894 1 }
10895  
10896 1 our $assembliesPerformed = 0; # Number of assemblies performed
10897 1 our $instructionsExecuted = 0; # Total number of instructions executed
10898 1 our $totalBytesAssembled = 0; # Total size of the output programs
10899 1 our $testsThatPassed = 0; # Number of runs that passed their test
10900 1 our $testsThatFailed = 0; # Number of runs that failed to pass their tests
10901  
10902 sub Assemble(%) # Assemble the generated code.
10903 1 ▶ {my (%options) = @_; # Options
Subroutine Assemble: called CC=74 SCAR=79.7
Pod documented
10904 1 my $avx512 = delete $options{avx512}; # Avx512 instruction set needed
10905 1 my $clocks = delete $options{clocks}; # Number of clocks required to execute this program - if a different number are required then a message is written to that effect. Set mix > 0 for this to take effect.
10906 1 ▶ my $count = delete $options{count} // 0; # Count the comments that occur more frequently than this number
Condition50%1/2
delete $options{"count"} // 0
l!l
01
MC/DC0%0/1
delete $options{"count"} // 0
delete $options{"count"}
Truth table50%1/2
A
A= delete $options{"count"}
Aresult
11
00
10907 1 ▶ my $debug = delete $options{debug} // 0; # Debug: 0 - print stderr and compare stdout to eq if present, 1 - print stdout and stderr and compare stderr to eq if present
Condition50%1/2
delete $options{"debug"} // 0
l!l
01
MC/DC0%0/1
delete $options{"debug"} // 0
delete $options{"debug"}
Truth table50%1/2
A
A= delete $options{"debug"}
Aresult
11
00
10908 1 my $eq = delete $options{eq}; # The expected output
10909 1 my $foot = delete $options{foot}; # Foot print required
10910 1 my $keep = delete $options{keep}; # Keep the executable rather than running it
10911 1 my $label = delete $options{label}; # Label for this test if provided
10912 1 my $library = delete $options{library}; # Create the named library if supplied from the supplied assembler code
10913 1 my $list = delete $options{list}; # Create and retain a listing file so we can see where a trace error occurs
10914 1 ▶ my $mix = delete $options{mix} // ($clocks ? 1 : 0); # Create mix output and fix with line number locations in source - required if we want clocks
Branch: 1 branch
BranchTrueFalseTotal
$clocks ? : 0 1 1
Condition50%1/2
delete $options{"mix"} // ($clocks ? 1 : 0)
l!l
01
MC/DC0%0/1
delete $options{"mix"} // ($clocks ? 1 : 0)
delete $options{"mix"}
Truth table50%1/2
A
A= delete $options{"mix"}
Aresult
11
00
10915 1 my $ptr = delete $options{ptr}; # Pointer check required
10916 1 ▶ my $trace = delete $options{trace} //0; # Trace: 0 - none (minimal output), 1 - trace with sde64 and create a listing file to match
Condition50%1/2
delete $options{"trace"} // 0
l!l
01
MC/DC0%0/1
delete $options{"trace"} // 0
delete $options{"trace"}
Truth table50%1/2
A
A= delete $options{"trace"}
Aresult
11
00
10917 1 ▶ confess "Invalid options: ".join(", ", sort keys %options) if keys %options; # Complain about any invalid options
Branch: 1 branch
BranchTrueFalseTotal
if keys %options 0 1 1
10918  
10919 1 ▶ my $execFile = $keep // q(z); # Executable file
Condition50%1/2
$keep // "z"
l!l
01
MC/DC0%0/1
$keep // "z"
$keep
Truth table50%1/2
A
A= $keep
Aresult
11
00
10920 1 my $listFile = q(z.txt); # Assembler listing
10921 1 ▶ my $objectFile = $library // q(z.o); # Object file
Condition50%1/2
$library // "z.o"
l!l
01
MC/DC0%0/1
$library // "z.o"
$library
Truth table50%1/2
A
A= $library
Aresult
11
00
10922 1 my $o1 = $programOut; # Stdout from run
10923 1 my $o2 = $programErr; # Stderr from run
10924  
10925 1 ▶ @PushR and confess "Mismatch PushR, PopR"; # Match PushR with PopR
Branch: 1 branch
BranchTrueFalseTotal
@PushR and confess("Mismatch PushR, PopR") 0 1 1
10926  
10927 1 unlink $o1, $o2, $objectFile, $execFile, $listFile, $sourceFile; # Remove output files
10928  
10929 1 ▶ Exit 0 unless $library or @text > 4 && $text[-4] =~ m(Exit code:); # Exit with code 0 if an exit was not the last thing coded in a program but ignore for a library.
Branch: 1 branch
BranchTrueFalseTotal
unless $library or @text > 4 and $text[-4] =~ /Exit code:/ 1 0 1
Condition33%2/6
$library or @text > 4 and $text[-4] =~ /Exit code:/
l!l&&r!l&&!r
001
@text > 4 and $text[-4] =~ /Exit code:/
!ll&&!rl&&r
010
MC/DC0%0/3
$library or @text > 4 and $text[-4] =~ /Exit code:/
$library @text > 4 $text[-4] =~ /Exit code:/
Truth table25%1/4
A or B and C
A= $libraryB= @text > 4C= $text[-4] =~ /Exit code:/
ABCresult
1XX1
0111
00X0
0100
10930  
10931 # Optimize(@_); # Perform any optimizations requested
10932 1 OptimizeReload(@_);
10933  
10934 1 if (1) # Concatenate source code
10935 1 {my $r = join "\n", map {s/\s+\Z//sr} @rodata;
10936 0 my $d = join "\n", map {s/\s+\Z//sr} @data;
10937 0 my $B = join "\n", map {s/\s+\Z//sr} @bss;
10938 1 my $t = join "\n", map {s/\s+\Z//sr} @text;
10939 0 my $x = join "\n", map {qq(extern $_)} @extern;
10940 1 my $N = $VariableStack[0]; # Number of variables needed on the stack
10941  
10942 1 my $A = <<END; # Source code
10943 bits 64
10944 default rel
10945 END
10946  
10947 1 ▶ $A .= <<END if $t and !$library;
Branch: 1 branch
BranchTrueFalseTotal
if $t and not $library 1 0 1
Condition33%1/3
$t and not $library
!ll&&!rl&&r
001
MC/DC0%0/2
$t and not $library
$t not $library
Truth table33%1/3
A and not(B)
A= $tB= not $library
ABresult
0X0
100
111
10948 global _start, main
10949 _start:
10950 main:
10951 Enter $N*8, 0
10952 $t
10953 Leave
10954 END
10955  
10956 1 ▶ $A .= <<END if $t and $library;
Branch: 1 branch
BranchTrueFalseTotal
if $t and $library 0 1 1
Condition33%1/3
$t and $library
!ll&&!rl&&r
010
MC/DC0%0/2
$t and $library
$t $library
Truth table33%1/3
A and B
A= $tB= $library
ABresult
0X0
100
111
10957 $t
10958 END
10959  
10960 1 ▶ $A .= <<END if $r;
Branch: 1 branch
BranchTrueFalseTotal
if $r 1 0 1
10961 section .rodata
10962 $r
10963 END
10964 1 ▶ $A .= <<END if $d;
Branch: 1 branch
BranchTrueFalseTotal
if $d 0 1 1
10965 section .data
10966 $d
10967 END
10968 1 ▶ $A .= <<END if $B;
Branch: 1 branch
BranchTrueFalseTotal
if $B 0 1 1
10969 section .bss
10970 $B
10971 $d
10972 END
10973 1 ▶ $A .= <<END if $x;
Branch: 1 branch
BranchTrueFalseTotal
if $x 0 1 1
10974 section .text
10975 $x
10976 END
10977  
10978 1 owf($sourceFile, $A); # Save source code to source file
10979 }
10980  
10981 1 ▶ if (!confirmHasCommandLineCommand(q(nasm))) # Check for network assembler
Branch: 1 branch
BranchTrueFalseTotal
unless (&confirmHasCommandLineCommand("nasm")) 1 0 1
10982 1 {my $f = fpf(currentDirectory, $sourceFile);
10983 1 say STDERR <<END;
10984 Assember code written to the following file:
10985  
10986 $f
10987  
10988 I cannot compile this file because you do not have Nasm installed, see:
10989  
10990 https://www.nasm.us/
10991 END
10992 1 return;
10993 }
10994  
10995 0 ▶ my $emulate = hasAvx512 ? 0 : ($avx512 // 1) ; # Emulate if necessary
Branch: 1 branch
BranchTrueFalseTotal
&hasAvx512() ? : 0 0 0
Condition0%0/2
$avx512 // 1
l!l
00
MC/DC0%0/1
$avx512 // 1
$avx512
Truth table0%0/2
A
A= $avx512
Aresult
11
00
10996 0 my $sde = LocateIntelEmulator; # Locate the emulator
10997 0 ▶ my $run = !$keep && !$library; # Are we actually going to run the resulting code?
Condition0%0/3
$keep || $library
l!l&&r!l&&!r
000
MC/DC0%0/2
$keep || $library
$keep $library
Truth table0%0/3
A || B
A= $keepB= $library
ABresult
1X1
011
000
10998  
10999 0 ▶ if ($run and $emulate and !$sde) # Complain about the emulator if we are going to run and we have not suppressed the emulator and the emulator is not present
Branch: 1 branch
BranchTrueFalseTotal
if ($run and $emulate and not $sde) 0 0 0
Condition0%0/6
$run and $emulate and not $sde
!ll&&!rl&&r
000
$run and $emulate
!ll&&!rl&&r
000
MC/DC0%0/3
$run and $emulate and not $sde
$run $emulate not $sde
Truth table0%0/4
A and B and not(C)
A= $runB= $emulateC= not $sde
ABCresult
0XX0
10X0
1100
1111
11000 0 {my $f = fpf(currentDirectory, $execFile);
11001 0 say STDERR <<END;
11002 Executable written to the following file:
11003  
11004 $f
11005  
11006 I am going to run this without using the Intel emulator. Your program will
11007 crash if it contains instructions not implemented on your computer.
11008  
11009 You can get the Intel emulator from:
11010  
11011 https://software.intel.com/content/dam/develop/external/us/en/documents/downloads/sde-external-8.63.0-2021-01-18-lin.tar.bz2
11012  
11013 To avoid this message, use option(1) below to produce just an executable
11014 without running it, or use the option(2) to run without the emulator:
11015  
11016 (1) Assemble(keep=>"executable file name")
11017  
11018 (2) Assemble(avx512=>0)
11019 END
11020 0 $emulate = 0;
11021 }
11022  
11023 0 ▶ if (my @emulatorFiles = searchDirectoryTreesForMatchingFiles(qw(. .txt))) # Remove prior emulator output files
Branch: 1 branch
BranchTrueFalseTotal
if (my(@emulatorFiles) = &searchDirectoryTreesForMatchingFiles((".", ".txt"))) 0 0 0
11024 0 {for my $f(@emulatorFiles)
11025 0 ▶ {unlink $f if $f =~ m(sde-mix-out);
Branch: 1 branch
BranchTrueFalseTotal
if $f =~ /sde-mix-out/ 0 0 0
11026 }
11027 }
11028 0 unlink $sdePtrCheck, $sdeMixOut, $sdeTraceOut, $traceBack;
11029 0 ▶ my $perlTime = 0; $perlTime = time - $lastAsmFinishTime if $lastAsmFinishTime;# Time we spent in Perl preparing for the assembly
Branch: 1 branch
BranchTrueFalseTotal
if $lastAsmFinishTime 0 0 0
11030  
11031 0 my $aStart = time;
11032  
11033 0 if (1) # Assemble
11034 0 ▶ {my $I = @link ? $interpreter : ''; # Interpreter only required if calling C
Branch: 1 branch
BranchTrueFalseTotal
@link ? : 0 0 0
11035 0 my $L = join " ", map {qq(-l$_)} @link; # List of libraries to link supplied via Link directive.
11036 0 my $e = $execFile;
11037 0 ▶ my $l = $trace || $list ? qq(-l $listFile) : q(); # Create a list file if we are tracing because otherwise it it is difficult to know what we are tracing
Branch: 1 branch
BranchTrueFalseTotal
$trace || $list ? : 0 0 0
Condition0%0/3
$trace or $list
l!l&&r!l&&!r
000
MC/DC0%0/2
$trace or $list
$trace $list
Truth table0%0/3
A or B
A= $traceB= $list
ABresult
1X1
011
000
11038 0 my $a = qq(nasm -O0 $l -o $objectFile $sourceFile); # Assembly options
11039  
11040 0 ▶ my $cmd = $library
Branch: 1 branch
BranchTrueFalseTotal
$library ? : 0 0 0
11041 ? qq($a -fbin)
11042 : qq($a -felf64 -g && ld $I $L -o $e $objectFile && chmod 744 $e);
11043  
11044 0 qx($cmd);
11045 0 ▶ confess "Assembly failed $?" if $?; # Stop if assembly failed
Branch: 1 branch
BranchTrueFalseTotal
if $? 0 0 0
11046 }
11047  
11048 0 my $aTime = time - $aStart;
11049  
11050 0 countComments $count; # Count the number of comments
11051  
11052 0 ▶ my $out = $run ? "1>$o1" : '';
Branch: 1 branch
BranchTrueFalseTotal
$run ? : 0 0 0
11053 0 ▶ my $err = $run ? "2>$o2" : '';
Branch: 1 branch
BranchTrueFalseTotal
$run ? : 0 0 0
11054  
11055 my $exec = sub # Execution string
11056 0 ▶ {my $o = qq($sde); # Emulator
Subroutine __ANON__: not called CC=11 SCAR=48.8
11057 0 ▶ $o = qq($o -ptr-check) if $ptr; # Emulator options - tracing
Branch: 1 branch
BranchTrueFalseTotal
if $ptr 0 0 0
11058 0 ▶ $o = qq($o -footprint) if $foot; # Emulator options - foot print
Branch: 1 branch
BranchTrueFalseTotal
if $foot 0 0 0
11059 0 ▶ $o = qq($o -debugtrace) if $trace; # Emulator options - tracing
Branch: 1 branch
BranchTrueFalseTotal
if $trace 0 0 0
11060 0 ▶ $o = qq($o -mix) if $mix; # Emulator options - mix histogram output
Branch: 1 branch
BranchTrueFalseTotal
if $mix 0 0 0
11061  
11062 0 ▶ if ($emulate && !hasAvx512 or $trace or $mix or $ptr or $foot) # Command to execute program via the emulator
Branch: 1 branch
BranchTrueFalseTotal
if ($emulate and not &hasAvx512() or $trace or $mix or $ptr or $foot) 0 0 0
Condition0%0/15
$emulate and not &hasAvx512() or $trace or $mix or $ptr or $foot
l!l&&r!l&&!r
000
$emulate and not &hasAvx512() or $trace or $mix or $ptr
l!l&&r!l&&!r
000
$emulate and not &hasAvx512() or $trace or $mix
l!l&&r!l&&!r
000
$emulate and not &hasAvx512() or $trace
l!l&&r!l&&!r
000
$emulate and not &hasAvx512()
!ll&&!rl&&r
000
MC/DC0%0/6
$emulate and not &hasAvx512() or $trace or $mix or $ptr or $foot
$emulate not &hasAvx512() $trace $mix $ptr $foot
Truth table0%0/11
A and not(B) or C or D or E or F
A= $emulateB= not &hasAvx512()C= $traceD= $mixE= $ptrF= $foot
ABCDEFresult
11XXXX1
0X1XXX1
101XXX1
0X01XX1
1001XX1
0X001X1
10001X1
0X00011
1000011
0X00000
1000000
11063 0 {return qq($o -- ./$execFile $err $out)
11064 }
11065  
11066 0 qq(./$execFile $err $out); # Command to execute program without the emulator
11067 0 }->();
11068  
11069 0 my $eStart = time;
11070  
11071 #lll $exec;
11072 0 ▶ qx(timeout 30s $exec) if $run; # Run unless suppressed by user or library
Branch: 1 branch
BranchTrueFalseTotal
if $run 0 0 0
11073  
11074 0 my $er = $?; # Execution result
11075 0 my $eTime = time - $eStart;
11076  
11077 0 ▶ if ($run) # Execution details
Branch: 1 branch
BranchTrueFalseTotal
if ($run) 0 0 0
11078 0 {my $instructions = getInstructionCount; # Instructions executed under emulator
11079 0 $instructionsExecuted += $instructions; # Count instructions executed
11080 0 my $p = $assembliesPerformed++; # Count assemblies
11081  
11082 0 ▶ my $bytes = (fileSize($execFile)//9448) - 9448; # Estimate the size of the output program
Condition0%0/2
&fileSize($execFile) // 9448
l!l
00
MC/DC0%0/1
&fileSize($execFile) // 9448
&fileSize($execFile)
Truth table0%0/2
A
A= &fileSize($execFile)
Aresult
11
00
11083 0 $totalBytesAssembled += $bytes; # Estimate total of all programs assembled
11084  
11085 0 my (undef, $file, $line) = caller(); # Line in caller
11086  
11087 0 ▶ say STDERR sprintf # Header if necessary
Branch: 1 branch
BranchTrueFalseTotal
if $Nasm::X86::assembliesPerformed % 100 == 1 0 0 0
11088 ("# Test %12s %12s %12s %12s %12s %12s %12s",
11089 "Clocks", "Bytes", "Total Clocks", "Total Bytes", "Run Time", "Assembler", "Perl")
11090 if $assembliesPerformed % 100 == 1;
11091  
11092 print STDERR # Rows
11093 sprintf("# %4s %12s %12s %12s %12s %12.4f %12.2f %12.2f at $file line $line",
11094 $label ? $label : sprintf("%4d", $assembliesPerformed),
11095 0 ▶ (map {numberWithUnderScores $_}
Branch: 1 branch
BranchTrueFalseTotal
$label ? : 0 0 0
11096 $instructions, $bytes, $instructionsExecuted, $totalBytesAssembled),
11097 $eTime, $aTime, $perlTime);
11098  
11099 0 ▶ if (my $i = $instructions) # Clocks
Branch: 1 branch
BranchTrueFalseTotal
if (my $i = $instructions) 0 0 0
11100 0 ▶ {if ($mix and my $c = $clocks)
Branch: 1 branch
BranchTrueFalseTotal
if ($mix and my $c = $clocks) 0 0 0
Condition0%0/3
$mix and my $c = $clocks
!ll&&!rl&&r
000
MC/DC0%0/2
$mix and my $c = $clocks
$mix my $c = $clocks
Truth table0%0/3
A and B
A= $mixB= my $c = $clocks
ABresult
0X0
100
111
11101 0 ▶ {if ($i != $c)
Branch: 1 branch
BranchTrueFalseTotal
if ($i != $c) 0 0 0
11102 0 {my $l = $c - $i;
11103 0 my $C = numberWithUnderScores $c;
11104 0 my $I = numberWithUnderScores $i;
11105 0 my $g = - $l;
11106 0 my $L = numberWithUnderScores $l;
11107 0 my $G = numberWithUnderScores $g;
11108 0 ▶ my $f = onGitHub ? " " : "\n";
Branch: 1 branch
BranchTrueFalseTotal
onGitHub() ? : 0 0 0
11109 0 ▶ print STDERR $f."Clocks were $C, but now $I, less $L" if $l > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $l > 0 0 0 0
11110 0 ▶ print STDERR $f."Clocks were $C, but now $I, greater by $G" if $g > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $g > 0 0 0 0
11111 }
11112 }
11113 }
11114 0 print STDERR "\n"; # Complete the execution detail line
11115 }
11116  
11117 0 ▶ if ($run and $debug == 0 and -e $o2 and my $s = readBinaryFile $o2) # Print only errors if not debugging
Branch: 1 branch
BranchTrueFalseTotal
if ($run and $debug == 0 and -e $o2 and my $s = &readBinaryFile($o2)) 0 0 0
Condition0%0/9
$run and $debug == 0 and -e $o2 and my $s = &readBinaryFile($o2)
!ll&&!rl&&r
000
$run and $debug == 0 and -e $o2
!ll&&!rl&&r
000
$run and $debug == 0
!ll&&!rl&&r
000
MC/DC0%0/4
$run and $debug == 0 and -e $o2 and my $s = &readBinaryFile($o2)
$run $debug == 0 -e $o2 my $s = &readBinaryFile($o2)
Truth table0%0/5
A and B and C and D
A= $runB= $debug == 0C= -e $o2D= my $s = &readBinaryFile($o2)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
11118 0 {print STDERR $s;
11119 }
11120  
11121 0 ▶ if ($run and $debug == 1) # Print files if soft debugging or error
Branch: 1 branch
BranchTrueFalseTotal
if ($run and $debug == 1) 0 0 0
Condition0%0/3
$run and $debug == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$run and $debug == 1
$run $debug == 1
Truth table0%0/3
A and B
A= $runB= $debug == 1
ABresult
0X0
100
111
11122 0 ▶ {print STDERR readFile($o1) if -e $o1;
Branch: 1 branch
BranchTrueFalseTotal
if -e $o1 0 0 0
11123 0 ▶ print STDERR readFile($o2) if -e $o2;
Branch: 1 branch
BranchTrueFalseTotal
if -e $o2 0 0 0
11124 }
11125  
11126 0 ▶ sub{my $a = fixMixOutput; say STDERR $a if $mix >= 2}->() if $run and $mix; # Fix mix output to show where code came from in the source file
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 2 branches
BranchTrueFalseTotal
if $run and $mix 0 0 0
if $mix >= 2 0 0 0
Condition0%0/3
$run and $mix
!ll&&!rl&&r
000
MC/DC0%0/2
$run and $mix
$run $mix
Truth table0%0/3
A and B
A= $runB= $mix
ABresult
0X0
100
111
11127  
11128 0 ▶ if ($run and $trace) # Locate last execution point
Branch: 1 branch
BranchTrueFalseTotal
if ($run and $trace) 0 0 0
Condition0%0/3
$run and $trace
!ll&&!rl&&r
000
MC/DC0%0/2
$run and $trace
$run $trace
Truth table0%0/3
A and B
A= $runB= $trace
ABresult
0X0
100
111
11129 0 {locateRunTimeErrorInDebugTraceOutput($trace);
11130 }
11131  
11132 0 ▶ unlink $objectFile unless $library; # Delete files
Branch: 1 branch
BranchTrueFalseTotal
unless $library 0 0 0
11133 0 ▶ unlink $execFile unless $keep; # Delete executable unless asked to keep it or its a library
Branch: 1 branch
BranchTrueFalseTotal
unless $keep 0 0 0
11134  
11135 0 Start; # Clear work areas for next assembly
11136  
11137 0 ▶ if ($run and defined(my $e = $eq)) # Diff results against expected
Branch: 1 branch
BranchTrueFalseTotal
if ($run and defined(my $e = $eq)) 0 0 0
Condition0%0/3
$run and defined(my $e = $eq)
!ll&&!rl&&r
000
MC/DC0%0/2
$run and defined(my $e = $eq)
$run defined(my $e = $eq)
Truth table0%0/3
A and B
A= $runB= defined(my $e = $eq)
ABresult
0X0
100
111
11138 0 ▶ {my $g = readFile($debug ? $o2 : $o1);
Branch: 1 branch
BranchTrueFalseTotal
$debug ? : 0 0 0
11139 0 $e =~ s(\s+#.*?\n) (\n)gs; # Remove comments so we can annotate listings
11140 0 s(Subroutine trace back.*) ()s for $e, $g; # Remove any trace back because the location of the subroutine in memory will vary
11141 0 ▶ if ($g ne $e)
Branch: 1 branch
BranchTrueFalseTotal
if ($g ne $e) { } 0 0 0
11142 0 {my ($s, $G, $E) = stringsAreNotEqual($g, $e);
11143 0 ▶ if (length($s))
Branch: 1 branch
BranchTrueFalseTotal
if (length $s) 0 0 0
11144 0 {my $line = 1 + length($s =~ s([^\n]) ()gsr);
11145 0 my $char = 1 + length($s =~ s(\A.*\n) ()sr);
11146 0 say STDERR "Comparing wanted with got failed at line: $line, character: $char";
11147 0 say STDERR "Start:\n$s";
11148 }
11149 0 my $b1 = '+' x 80;
11150 0 my $b2 = '_' x 80;
11151 0 say STDERR "Want $b1\n", firstNChars($E, 80);
11152 0 say STDERR "Got $b2\n", firstNChars($G, 80);
11153 0 say STDERR "Want: ", dump($e);
11154 0 say STDERR "Got : ", dump($g);
11155  
11156 0 if (0 and onGitHub) # Dump output files that might show why the failure occurred
11157 {for my $f($sdeMixOut, $sdePtrCheck, $sdeMixOut, $sdeTraceOut,
11158 $o1, $o2, $traceBack)
11159 {if (-e $f) # Dump the file if it exists
11160 {say STDERR qx(ls -la $f; cat $f);
11161 }
11162 }
11163 }
11164 0 $testsThatFailed++;
11165 0 ▶ confess "Test failed" unless onGitHub; # Test failed unless we are debugging test failures
Branch: 1 branch
BranchTrueFalseTotal
unless onGitHub() 0 0 0
11166 }
11167 else # Runs that passed
11168 0 {$testsThatPassed++;
11169 }
11170 0 return 1; # Test passed
11171 }
11172  
11173 0 ▶ return scalar(readFile($debug < 2 ? $o1 : $o2)) if $run; # Show stdout results unless stderr results requested
Branch: 2 branches
BranchTrueFalseTotal
if $run 0 0 0
$debug < 2 ? : 0 0 0
11174 0 $exec; # Retained output
11175 }
11176  
11177 sub totalBytesAssembled #P Total size in bytes of all files assembled during testing.
11178 0 ▶ {$totalBytesAssembled
Subroutine totalBytesAssembled: not called CC=1 SCAR=6.9
Pod documented
11179 }
11180  
11181 #d
11182 #-------------------------------------------------------------------------------
11183 # Export - eeee
11184 #-------------------------------------------------------------------------------
11185  
11186 1 if (0) # Print exports
11187 {my %e = map {$_=>1} @declarations;
11188 for my $a(readFile $0)
11189 {next unless $a =~ m(\Asub.*#); # Must be a sub and not a sub forward declaration
11190 next if $a =~ m(::); # Must be a high level sub
11191 next if $a =~ m(#P); # Must not be private
11192 $a =~ m(\s+(.*?)\() ? $e{$1}++ : 0; # Save sub name
11193 }
11194 say STDERR q/@EXPORT_OK = qw(/.join(' ', sort keys %e).q/);/;
11195 exit;
11196 }
11197  
11198 1 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
11199  
11200 1 ▶use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
11201  
11202 1 @ISA = qw(Exporter);
11203 1 @EXPORT = qw();
11204 1 @EXPORT_OK = qw(Add Align AllocateMemory And AndBlock Andn Assemble BinarySearchD Block Bsf Bsr Bswap Bt Btc Btr Bts Bzhi Call CallC ChooseRegisters ClearMemory ClearRegisters ClearZF CloseFile Cmova Cmovae Cmovb Cmovbe Cmovc Cmove Cmovg Cmovge Cmovl Cmovle Cmovna Cmovnae Cmovnb Cmovne Cmp Comment ConvertUtf8ToUtf32 CopyMemory CopyMemory4K CopyMemory64 Cpuid CreateArea Db Dd Dec DescribeArea Div Dq Ds Dw Ef Else Enter Exit Extern Fail For ForEver ForIn Fork FreeMemory GetNextUtf8CharAsUtf32 GetPPid GetPid GetPidInHex GetUid Hash Idiv If IfC IfEq IfGe IfGt IfLe IfLt IfNc IfNe IfNs IfNz IfS IfZ Imul Imul3 Inc Incbin Include InsertOneIntoRegisterAtPoint InsertZeroIntoRegisterAtPoint Ja Jae Jb Jbe Jc Jcxz Je Jecxz Jg Jge Jl Jle Jmp Jna Jnae Jnb Jnbe Jnc Jne Jng Jnge Jnl Jnle Jno Jnp Jns Jnz Jo Jp Jpe Jpo Jrcxz Js Jz K Kaddb Kaddd Kaddq Kaddw Kandb Kandd Kandnb Kandnd Kandnq Kandnw Kandq Kandw Kmovb Kmovd Kmovq Kmovw Knotb Knotd Knotq Knotw Korb Kord Korq Kortestb Kortestd Kortestq Kortestw Korw Kshiftlb Kshiftld Kshiftlq Kshiftlw Kshiftrb Kshiftrd Kshiftrq Kshiftrw Ktestb Ktestd Ktestq Ktestw Kunpckb Kunpckd Kunpckq Kunpckw Kxnorb Kxnord Kxnorq Kxnorw Kxorb Kxord Kxorq Kxorw Lahf Lea Leave Link LoadBitsIntoMaskRegister LoadConstantIntoMaskRegister LoadZmm Loop Lzcnt Mov Movd Movdqa Movq Movw Mulpd Neg Not OnSegv OpenRead OpenWrite Or OrBlock ParseUnisyn Pass Pdep Pext Pextrb Pextrd Pextrq Pextrw Pinsrb Pinsrd Pinsrq Pinsrw Pop PopR Popcnt Popfq PrintCString PrintCStringNL PrintErrOneRegisterInHex PrintErrOneRegisterInHexNL PrintErrRaxInHex PrintErrRaxInHexNL PrintErrRax_InHex PrintErrRax_InHexNL PrintErrRegisterInHex PrintErrRightInBin PrintErrRightInBinNL PrintErrRightInHex PrintErrRightInHexNL PrintErrTraceBack PrintMemory PrintMemoryInHex PrintMemory_InHex PrintNL PrintOneRegisterInHex PrintOutNL PrintOutOneRegisterInHex PrintOutOneRegisterInHexNL PrintOutRaxInHex PrintOutRaxInHexNL PrintOutRax_InHex PrintOutRax_InHexNL PrintOutRegisterInHex PrintOutRightInBin PrintOutRightInBinNL PrintOutRightInDec PrintOutRightInDecNL PrintOutRightInHex PrintOutRightInHexNL PrintOutSpace PrintOutString PrintOutStringNL PrintOutTraceBack PrintRaxAsChar PrintRaxAsText PrintRaxInDec PrintRaxInHex PrintRaxRightInDec PrintRax_InHex PrintRegisterInHex PrintRightInBin PrintRightInDec PrintRightInHex PrintSpace PrintString PrintStringNL PrintTraceBack Pslldq Psrldq Push Pushfq R RComment Rb Rd Rdtsc ReadArea ReadChar ReadFile ReadInteger ReadLine ReadTimeStampCounter RegisterSize RestoreFirstFour RestoreFirstFourExceptRax RestoreFirstSeven RestoreFirstSevenExceptRax Ret Rq Rs Rutf8 Rw Sal Sar SaveFirstFour SaveFirstSeven SaveRegIntoMm SetLabel SetMaskRegister SetZF Seta Setae Setb Setbe Setc Sete Setg Setge Setl Setle Setna Setnae Setnb Setnbe Setnc Setne Setng Setnge Setnl Setno Setnp Setns Setnz Seto Setp Setpe Setpo Sets Setz Shl Shr Start StatSize StringLength Sub Subroutine Syscall Test Then ToZero Tzcnt V Vaddd Vaddpd Valignb Valignd Valignq Valignw Variable Vcvtudq2pd Vcvtudq2ps Vcvtuqq2pd Vdpps Vgetmantps Vmovd Vmovdqa32 Vmovdqa64 Vmovdqu Vmovdqu32 Vmovdqu64 Vmovdqu8 Vmovq Vmulpd Vpaddb Vpaddd Vpaddq Vpaddw Vpandb Vpandd Vpandnb Vpandnd Vpandnq Vpandnw Vpandq Vpandw Vpbroadcastb Vpbroadcastd Vpbroadcastq Vpbroadcastw Vpcmpeqb Vpcmpeqd Vpcmpeqq Vpcmpeqw Vpcmpub Vpcmpud Vpcmpuq Vpcmpuw Vpcompressd Vpcompressq Vpexpandd Vpexpandq Vpextrb Vpextrd Vpextrq Vpextrw Vpgatherqd Vpgatherqq Vpinsrb Vpinsrd Vpinsrq Vpinsrw Vpmovb2m Vpmovd2m Vpmovm2b Vpmovm2d Vpmovm2q Vpmovm2w Vpmovq2m Vpmovw2m Vpmullb Vpmulld Vpmullq Vpmullw Vporb Vpord Vporq Vporvpcmpeqb Vporvpcmpeqd Vporvpcmpeqq Vporvpcmpeqw Vporw Vprolq Vpsubb Vpsubd Vpsubq Vpsubw Vptestb Vptestd Vptestq Vptestw Vpxorb Vpxord Vpxorq Vpxorw Vsqrtpd WaitPid Xchg Xor ah al ax bFromX bFromZ bRegFromZmm bRegIntoZmm bh bl bp bpl bx byteRegister ch checkZmmRegister cl constantString copyStructureMinusVariables countComments createBitNumberFromAlternatingPattern cs cx dFromPointInZ dFromX dFromZ dRegFromZmm dRegIntoZmm dWordRegister dh di dil dl ds dx eax ebp ebx ecx edi edx es esi esp executeFileViaBash extractRegisterNumberFromMM fs getBwdqFromMm gs ifAnd ifOr k0 k1 k2 k3 k4 k5 k6 k7 loadAreaIntoAssembly locateRunTimeErrorInDebugTraceOutput mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 opposingJump qFromX qFromZ r10 r10b r10d r10l r10w r11 r11b r11d r11l r11w r12 r12b r12d r12l r12w r13 r13b r13d r13l r13w r14 r14b r14d r14l r14w r15 r15b r15d r15l r15w r8 r8b r8d r8l r8w r9 r9b r9d r9l r9w rax rbp rbx rcx rdi rdx registerNameFromNumber rflags rip rsi rsp si sil sp spl ss st0 st1 st2 st3 st4 st5 st6 st7 unlinkFile uptoNTimes wFromX wFromZ wRegFromZmm wRegIntoZmm wordRegister xmm xmm0 xmm1 xmm10 xmm11 xmm12 xmm13 xmm14 xmm15 xmm16 xmm17 xmm18 xmm19 xmm2 xmm20 xmm21 xmm22 xmm23 xmm24 xmm25 xmm26 xmm27 xmm28 xmm29 xmm3 xmm30 xmm31 xmm4 xmm5 xmm6 xmm7 xmm8 xmm9 ymm ymm0 ymm1 ymm10 ymm11 ymm12 ymm13 ymm14 ymm15 ymm16 ymm17 ymm18 ymm19 ymm2 ymm20 ymm21 ymm22 ymm23 ymm24 ymm25 ymm26 ymm27 ymm28 ymm29 ymm3 ymm30 ymm31 ymm4 ymm5 ymm6 ymm7 ymm8 ymm9 zmm zmm0 zmm1 zmm10 zmm11 zmm12 zmm13 zmm14 zmm15 zmm16 zmm17 zmm18 zmm19 zmm2 zmm20 zmm21 zmm22 zmm23 zmm24 zmm25 zmm26 zmm27 zmm28 zmm29 zmm3 zmm30 zmm31 zmm4 zmm5 zmm6 zmm7 zmm8 zmm9 zmmM zmmMZ);
11205 1 %EXPORT_TAGS = (all=>[@EXPORT, @EXPORT_OK]);
11206  
11207  
11208 0 ▶sub extractDocumentationFlags {}
Subroutine extractDocumentationFlags: not called CC=1 SCAR=0.0
Pod undocumented
11209  
11210 # podDocumentation
11211 =pod
11212  
11213 =encoding utf-8
11214  
11215 =head1 Name
11216  
11217 Nasm::X86 - Generate X86 assembler code using Perl as a macro pre-processor.
11218  
11219 =head1 Synopsis
11220  
11221 Write and execute B<x64> B<Avx512> assembler code from L<perl> using L<perl> as
11222 a powerful macro assembler. The generated code can be run under the Intel
11223 emulator to obtain execution trace and instruction counts.
11224  
11225 Please see: L<https://github.com/philiprbrenan/NasmX86> for a complete working
11226 demonstration of how to run code produced by this module and foir examples of
11227 its use.
11228  
11229 While this module allows you to intermix Perl and Assembler code it is
11230 noticeable that the more Perl code that is written the less new Assembler code
11231 is required because there are more opportunities to call a Perl routine to
11232 generate the required Assembler code rather than writing the Assembler out by
11233 hand.
11234  
11235 Use B<Avx512> instructions to perform B<64> comparisons in parallel.
11236  
11237 my $P = "2F"; # Value to test for
11238 my $l = Rb 0; Rb $_ for 1..RegisterSize zmm0; # 0..63
11239 Vmovdqu8 zmm0, "[$l]"; # Load data to test
11240 PrintOutRegisterInHex zmm0;
11241  
11242 Mov rax, "0x$P"; # Broadcast the value to be tested
11243 Vpbroadcastb zmm1, rax;
11244 PrintOutRegisterInHex zmm1;
11245  
11246 for my $c(0..7) # Each possible test
11247 {my $m = "k$c";
11248 Vpcmpub $m, zmm1, zmm0, $c;
11249 PrintOutRegisterInHex $m;
11250 }
11251  
11252 Kmovq rax, k0; # Count the number of trailing zeros in k0
11253 Tzcnt rax, rax;
11254 PrintOutRegisterInHex rax;
11255  
11256 is_deeply Assemble, <<END; # Assemble and test
11257 zmm0: 3F3E 3D3C 3B3A 3938 3736 3534 3332 3130 2F2E 2D2C 2B2A 2928 2726 2524 2322 2120 1F1E 1D1C 1B1A 1918 1716 1514 1312 1110 0F0E 0D0C 0B0A 0908 0706 0504 0302 0100
11258 zmm1: 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F 2F2F
11259 k0: 0000 8000 0000 0000
11260 k1: FFFF 0000 0000 0000
11261 k2: FFFF 8000 0000 0000
11262 k3: 0000 0000 0000 0000
11263 k4: FFFF 7FFF FFFF FFFF
11264 k5: 0000 FFFF FFFF FFFF
11265 k6: 0000 7FFF FFFF FFFF
11266 k7: FFFF FFFF FFFF FFFF
11267 rax: 0000 0000 0000 002F
11268 END
11269  
11270 With the print statements removed, the Intel Emulator indicates that 26
11271 instructions were executed:
11272  
11273 CALL_NEAR 1
11274 ENTER 2
11275 JMP 1
11276 KMOVQ 1
11277 MOV 5
11278 POP 1
11279 PUSH 3
11280 SYSCALL 1
11281 TZCNT 1
11282 VMOVDQU8 1
11283 VPBROADCASTB 1
11284 VPCMPUB 8
11285  
11286 *total 26
11287  
11288 =head1 Description
11289  
11290 Generate X86 assembler code using Perl as a macro pre-processor.
11291  
11292  
11293 Version "20220712".
11294  
11295  
11296 The following sections describe the methods in each functional area of this
11297 module. For an alphabetic listing of all methods by name see L<Index|/Index>.
11298  
11299  
11300  
11301 =head1 Labels
11302  
11303 Create and set labels.
11304  
11305 =head2 Label()
11306  
11307 Create a unique label. Useful for constructing for and if statements.
11308  
11309  
11310 B<Example:>
11311  
11312  
11313 Mov rax, 1;
11314 Mov rdi, 1;
11315 SaveFirstFour;
11316 Mov rax, 2;
11317 Mov rdi, 2;
11318 SaveFirstSeven;
11319 Mov rax, 3;
11320 Mov rdi, 4;
11321 PrintOutRegisterInHex rax, rdi;
11322 RestoreFirstSeven;
11323 PrintOutRegisterInHex rax, rdi;
11324 RestoreFirstFour;
11325 PrintOutRegisterInHex rax, rdi;
11326  
11327 SaveFirstFour;
11328 Mov rax, 2;
11329 Mov rdi, 2;
11330 SaveFirstSeven;
11331 Mov rax, 3;
11332 Mov rdi, 4;
11333 PrintOutRegisterInHex rax, rdi;
11334 RestoreFirstSevenExceptRax;
11335 PrintOutRegisterInHex rax, rdi;
11336 RestoreFirstFourExceptRax;
11337 PrintOutRegisterInHex rax, rdi;
11338  
11339 SaveFirstFour;
11340 Mov rax, 2;
11341 Mov rdi, 2;
11342 SaveFirstSeven;
11343 Mov rax, 3;
11344 Mov rdi, 4;
11345 PrintOutRegisterInHex rax, rdi;
11346  
11347 Bswap rax;
11348 PrintOutRegisterInHex rax;
11349  
11350  
11351 my $l = Label; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11352  
11353 Jmp $l;
11354 SetLabel $l;
11355  
11356 ok Assemble eq => <<END, avx512=>0;
11357 rax: .... .... .... ...3
11358 rdi: .... .... .... ...4
11359 rax: .... .... .... ...2
11360 rdi: .... .... .... ...2
11361 rax: .... .... .... ...1
11362 rdi: .... .... .... ...1
11363 rax: .... .... .... ...3
11364 rdi: .... .... .... ...4
11365 rax: .... .... .... ...3
11366 rdi: .... .... .... ...2
11367 rax: .... .... .... ...3
11368 rdi: .... .... .... ...1
11369 rax: .... .... .... ...3
11370 rdi: .... .... .... ...4
11371 rax: .3.. .... .... ....
11372 END
11373  
11374 ok 8 == RegisterSize rax;
11375  
11376  
11377 =head2 SetLabel($l)
11378  
11379 Create (if necessary) and set a label in the code section returning the label so set.
11380  
11381 Parameter Description
11382 1 $l Label
11383  
11384 B<Example:>
11385  
11386  
11387 Mov rax, 1;
11388 Mov rdi, 1;
11389 SaveFirstFour;
11390 Mov rax, 2;
11391 Mov rdi, 2;
11392 SaveFirstSeven;
11393 Mov rax, 3;
11394 Mov rdi, 4;
11395 PrintOutRegisterInHex rax, rdi;
11396 RestoreFirstSeven;
11397 PrintOutRegisterInHex rax, rdi;
11398 RestoreFirstFour;
11399 PrintOutRegisterInHex rax, rdi;
11400  
11401 SaveFirstFour;
11402 Mov rax, 2;
11403 Mov rdi, 2;
11404 SaveFirstSeven;
11405 Mov rax, 3;
11406 Mov rdi, 4;
11407 PrintOutRegisterInHex rax, rdi;
11408 RestoreFirstSevenExceptRax;
11409 PrintOutRegisterInHex rax, rdi;
11410 RestoreFirstFourExceptRax;
11411 PrintOutRegisterInHex rax, rdi;
11412  
11413 SaveFirstFour;
11414 Mov rax, 2;
11415 Mov rdi, 2;
11416 SaveFirstSeven;
11417 Mov rax, 3;
11418 Mov rdi, 4;
11419 PrintOutRegisterInHex rax, rdi;
11420  
11421 Bswap rax;
11422 PrintOutRegisterInHex rax;
11423  
11424 my $l = Label;
11425 Jmp $l;
11426  
11427 SetLabel $l; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11428  
11429  
11430 ok Assemble eq => <<END, avx512=>0;
11431 rax: .... .... .... ...3
11432 rdi: .... .... .... ...4
11433 rax: .... .... .... ...2
11434 rdi: .... .... .... ...2
11435 rax: .... .... .... ...1
11436 rdi: .... .... .... ...1
11437 rax: .... .... .... ...3
11438 rdi: .... .... .... ...4
11439 rax: .... .... .... ...3
11440 rdi: .... .... .... ...2
11441 rax: .... .... .... ...3
11442 rdi: .... .... .... ...1
11443 rax: .... .... .... ...3
11444 rdi: .... .... .... ...4
11445 rax: .3.. .... .... ....
11446 END
11447  
11448 ok 8 == RegisterSize rax;
11449  
11450  
11451 =head1 Data
11452  
11453 Layout data
11454  
11455 =head2 Global variables
11456  
11457 Create variables in the data segment if you are willing to make your program non reentrant.
11458  
11459 =head3 Ds(@d)
11460  
11461 Layout bytes in memory and return their label.
11462  
11463 Parameter Description
11464 1 @d Data to be laid out
11465  
11466 B<Example:>
11467  
11468  
11469 my $q = Rs('a'..'z');
11470  
11471 Mov rax, Ds('0'x64); # Output area # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11472  
11473 Vmovdqu32(xmm0, "[$q]"); # Load
11474 Vprolq (xmm0, xmm0, 32); # Rotate double words in quad words
11475 Vmovdqu32("[rax]", xmm0); # Save
11476 Mov rdi, 16;
11477 PrintOutMemoryNL;
11478  
11479 ok Assemble eq=><<END;
11480 efghabcdmnopijkl
11481 END
11482  
11483  
11484 =head3 Db(@bytes)
11485  
11486 Layout bytes in the data segment and return their label.
11487  
11488 Parameter Description
11489 1 @bytes Bytes to layout
11490  
11491 B<Example:>
11492  
11493  
11494 my $s = Rb 0; Rb 1; Rw 2; Rd 3; Rq 4;
11495  
11496 my $t = Db 0; Db 1; Dw 2; Dd 3; Dq 4; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11497  
11498  
11499 Vmovdqu8 xmm0, "[$s]";
11500 Vmovdqu8 xmm1, "[$t]";
11501 PrintOutRegisterInHex xmm0;
11502 PrintOutRegisterInHex xmm1;
11503 Sub rsp, 16;
11504  
11505 Mov rax, rsp; # Copy memory, the target is addressed by rax, the length is in rdi, the source is addressed by rsi
11506 Mov rdi, 16;
11507 Mov rsi, $s;
11508 CopyMemory(V(source => rsi), V(target => rax), V size => rdi);
11509 PrintOutMemory_InHexNL;
11510  
11511 ok Assemble eq => <<END;
11512 xmm0: .... .... .... ...4 .... ...3 ...2 .1..
11513 xmm1: .... .... .... ...4 .... ...3 ...2 .1..
11514 __.1 .2__ .3__ ____ .4__ ____ ____ ____
11515 END
11516  
11517  
11518 =head3 Dw(@words)
11519  
11520 Layout words in the data segment and return their label.
11521  
11522 Parameter Description
11523 1 @words Words to layout
11524  
11525 B<Example:>
11526  
11527  
11528 my $s = Rb 0; Rb 1; Rw 2; Rd 3; Rq 4;
11529  
11530 my $t = Db 0; Db 1; Dw 2; Dd 3; Dq 4; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11531  
11532  
11533 Vmovdqu8 xmm0, "[$s]";
11534 Vmovdqu8 xmm1, "[$t]";
11535 PrintOutRegisterInHex xmm0;
11536 PrintOutRegisterInHex xmm1;
11537 Sub rsp, 16;
11538  
11539 Mov rax, rsp; # Copy memory, the target is addressed by rax, the length is in rdi, the source is addressed by rsi
11540 Mov rdi, 16;
11541 Mov rsi, $s;
11542 CopyMemory(V(source => rsi), V(target => rax), V size => rdi);
11543 PrintOutMemory_InHexNL;
11544  
11545 ok Assemble eq => <<END;
11546 xmm0: .... .... .... ...4 .... ...3 ...2 .1..
11547 xmm1: .... .... .... ...4 .... ...3 ...2 .1..
11548 __.1 .2__ .3__ ____ .4__ ____ ____ ____
11549 END
11550  
11551  
11552 =head3 Dd(@dwords)
11553  
11554 Layout double words in the data segment and return their label.
11555  
11556 Parameter Description
11557 1 @dwords Double words to layout
11558  
11559 B<Example:>
11560  
11561  
11562 my $s = Rb 0; Rb 1; Rw 2; Rd 3; Rq 4;
11563  
11564 my $t = Db 0; Db 1; Dw 2; Dd 3; Dq 4; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11565  
11566  
11567 Vmovdqu8 xmm0, "[$s]";
11568 Vmovdqu8 xmm1, "[$t]";
11569 PrintOutRegisterInHex xmm0;
11570 PrintOutRegisterInHex xmm1;
11571 Sub rsp, 16;
11572  
11573 Mov rax, rsp; # Copy memory, the target is addressed by rax, the length is in rdi, the source is addressed by rsi
11574 Mov rdi, 16;
11575 Mov rsi, $s;
11576 CopyMemory(V(source => rsi), V(target => rax), V size => rdi);
11577 PrintOutMemory_InHexNL;
11578  
11579 ok Assemble eq => <<END;
11580 xmm0: .... .... .... ...4 .... ...3 ...2 .1..
11581 xmm1: .... .... .... ...4 .... ...3 ...2 .1..
11582 __.1 .2__ .3__ ____ .4__ ____ ____ ____
11583 END
11584  
11585  
11586 =head3 Dq(@qwords)
11587  
11588 Layout quad words in the data segment and return their label.
11589  
11590 Parameter Description
11591 1 @qwords Quad words to layout
11592  
11593 B<Example:>
11594  
11595  
11596 my $s = Rb 0; Rb 1; Rw 2; Rd 3; Rq 4;
11597  
11598 my $t = Db 0; Db 1; Dw 2; Dd 3; Dq 4; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11599  
11600  
11601 Vmovdqu8 xmm0, "[$s]";
11602 Vmovdqu8 xmm1, "[$t]";
11603 PrintOutRegisterInHex xmm0;
11604 PrintOutRegisterInHex xmm1;
11605 Sub rsp, 16;
11606  
11607 Mov rax, rsp; # Copy memory, the target is addressed by rax, the length is in rdi, the source is addressed by rsi
11608 Mov rdi, 16;
11609 Mov rsi, $s;
11610 CopyMemory(V(source => rsi), V(target => rax), V size => rdi);
11611 PrintOutMemory_InHexNL;
11612  
11613 ok Assemble eq => <<END;
11614 xmm0: .... .... .... ...4 .... ...3 ...2 .1..
11615 xmm1: .... .... .... ...4 .... ...3 ...2 .1..
11616 __.1 .2__ .3__ ____ .4__ ____ ____ ____
11617 END
11618  
11619  
11620 =head2 Global constants
11621  
11622 Create constants in read only memory,
11623  
11624 =head3 Rb(@bytes)
11625  
11626 Layout bytes in the data segment and return their label.
11627  
11628 Parameter Description
11629 1 @bytes Bytes to layout
11630  
11631 B<Example:>
11632  
11633  
11634  
11635 my $s = Rb 0; Rb 1; Rw 2; Rd 3; Rq 4; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11636  
11637 my $t = Db 0; Db 1; Dw 2; Dd 3; Dq 4;
11638  
11639 Vmovdqu8 xmm0, "[$s]";
11640 Vmovdqu8 xmm1, "[$t]";
11641 PrintOutRegisterInHex xmm0;
11642 PrintOutRegisterInHex xmm1;
11643 Sub rsp, 16;
11644  
11645 Mov rax, rsp; # Copy memory, the target is addressed by rax, the length is in rdi, the source is addressed by rsi
11646 Mov rdi, 16;
11647 Mov rsi, $s;
11648 CopyMemory(V(source => rsi), V(target => rax), V size => rdi);
11649 PrintOutMemory_InHexNL;
11650  
11651 ok Assemble eq => <<END;
11652 xmm0: .... .... .... ...4 .... ...3 ...2 .1..
11653 xmm1: .... .... .... ...4 .... ...3 ...2 .1..
11654 __.1 .2__ .3__ ____ .4__ ____ ____ ____
11655 END
11656  
11657  
11658 =head3 Rw(@words)
11659  
11660 Layout words in the data segment and return their label.
11661  
11662 Parameter Description
11663 1 @words Words to layout
11664  
11665 B<Example:>
11666  
11667  
11668  
11669 my $s = Rb 0; Rb 1; Rw 2; Rd 3; Rq 4; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11670  
11671 my $t = Db 0; Db 1; Dw 2; Dd 3; Dq 4;
11672  
11673 Vmovdqu8 xmm0, "[$s]";
11674 Vmovdqu8 xmm1, "[$t]";
11675 PrintOutRegisterInHex xmm0;
11676 PrintOutRegisterInHex xmm1;
11677 Sub rsp, 16;
11678  
11679 Mov rax, rsp; # Copy memory, the target is addressed by rax, the length is in rdi, the source is addressed by rsi
11680 Mov rdi, 16;
11681 Mov rsi, $s;
11682 CopyMemory(V(source => rsi), V(target => rax), V size => rdi);
11683 PrintOutMemory_InHexNL;
11684  
11685 ok Assemble eq => <<END;
11686 xmm0: .... .... .... ...4 .... ...3 ...2 .1..
11687 xmm1: .... .... .... ...4 .... ...3 ...2 .1..
11688 __.1 .2__ .3__ ____ .4__ ____ ____ ____
11689 END
11690  
11691  
11692 =head3 Rd(@dwords)
11693  
11694 Layout double words in the data segment and return their label.
11695  
11696 Parameter Description
11697 1 @dwords Double words to layout
11698  
11699 B<Example:>
11700  
11701  
11702  
11703 my $s = Rb 0; Rb 1; Rw 2; Rd 3; Rq 4; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11704  
11705 my $t = Db 0; Db 1; Dw 2; Dd 3; Dq 4;
11706  
11707 Vmovdqu8 xmm0, "[$s]";
11708 Vmovdqu8 xmm1, "[$t]";
11709 PrintOutRegisterInHex xmm0;
11710 PrintOutRegisterInHex xmm1;
11711 Sub rsp, 16;
11712  
11713 Mov rax, rsp; # Copy memory, the target is addressed by rax, the length is in rdi, the source is addressed by rsi
11714 Mov rdi, 16;
11715 Mov rsi, $s;
11716 CopyMemory(V(source => rsi), V(target => rax), V size => rdi);
11717 PrintOutMemory_InHexNL;
11718  
11719 ok Assemble eq => <<END;
11720 xmm0: .... .... .... ...4 .... ...3 ...2 .1..
11721 xmm1: .... .... .... ...4 .... ...3 ...2 .1..
11722 __.1 .2__ .3__ ____ .4__ ____ ____ ____
11723 END
11724  
11725  
11726 =head3 Rq(@qwords)
11727  
11728 Layout quad words in the data segment and return their label.
11729  
11730 Parameter Description
11731 1 @qwords Quad words to layout
11732  
11733 B<Example:>
11734  
11735  
11736  
11737 my $s = Rb 0; Rb 1; Rw 2; Rd 3; Rq 4; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11738  
11739 my $t = Db 0; Db 1; Dw 2; Dd 3; Dq 4;
11740  
11741 Vmovdqu8 xmm0, "[$s]";
11742 Vmovdqu8 xmm1, "[$t]";
11743 PrintOutRegisterInHex xmm0;
11744 PrintOutRegisterInHex xmm1;
11745 Sub rsp, 16;
11746  
11747 Mov rax, rsp; # Copy memory, the target is addressed by rax, the length is in rdi, the source is addressed by rsi
11748 Mov rdi, 16;
11749 Mov rsi, $s;
11750 CopyMemory(V(source => rsi), V(target => rax), V size => rdi);
11751 PrintOutMemory_InHexNL;
11752  
11753 ok Assemble eq => <<END;
11754 xmm0: .... .... .... ...4 .... ...3 ...2 .1..
11755 xmm1: .... .... .... ...4 .... ...3 ...2 .1..
11756 __.1 .2__ .3__ ____ .4__ ____ ____ ____
11757 END
11758  
11759  
11760 =head3 Rs(@d)
11761  
11762 Layout bytes in read only memory and return their label.
11763  
11764 Parameter Description
11765 1 @d Data to be laid out
11766  
11767 B<Example:>
11768  
11769  
11770 Comment "Print a string from memory";
11771 my $s = "Hello World";
11772  
11773 Mov rax, Rs($s); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11774  
11775 Mov rdi, length $s;
11776 PrintOutMemory;
11777 Exit(0);
11778  
11779 ok Assemble(avx512=>0) =~ m(Hello World);
11780  
11781  
11782 my $q = Rs('abababab'); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11783  
11784 Mov r10, 0x10;
11785 Mov r11, 0x11;
11786 Mov r12, 0x12;
11787 Mov r13, 0x13;
11788 Mov r14, 0x14;
11789 Mov r15, 0x15;
11790 Mov r8, 0x08;
11791 Mov r9, 0x09;
11792 Mov rax, 1;
11793 Mov rbx, 2;
11794 Mov rcx, 3;
11795 Mov rdi, 4;
11796 Mov rdx, 5;
11797 Mov rsi, 6;
11798 PrintOutRegistersInHex;
11799  
11800 my $r = Assemble avx512=>0, eq=><<END;
11801 rfl: .... .... .... .2.2
11802 r10: .... .... .... ..10
11803 r11: .... .... .... .2.6
11804 r12: .... .... .... ..12
11805 r13: .... .... .... ..13
11806 r14: .... .... .... ..14
11807 r15: .... .... .... ..15
11808 r8: .... .... .... ...8
11809 r9: .... .... .... ...9
11810 rax: .... .... .... ...1
11811 rbx: .... .... .... ...2
11812 rcx: .... .... ..40 197F
11813 rdi: .... .... .... ...4
11814 rdx: .... .... .... ...5
11815 rsi: .... .... .... ...6
11816 END
11817  
11818  
11819 =head3 Rutf8(@d)
11820  
11821 Layout a utf8 encoded string as bytes in read only memory and return their label.
11822  
11823 Parameter Description
11824 1 @d Data to be laid out
11825  
11826 B<Example:>
11827  
11828  
11829 my ($out, $size, $fail);
11830  
11831 my $Chars = Rb(0x24, 0xc2, 0xa2, 0xc9, 0x91, 0xE2, 0x82, 0xAC, 0xF0, 0x90, 0x8D, 0x88);
11832 my $chars = V(chars => $Chars);
11833  
11834 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+0; # Dollar UTF-8 Encoding: 0x24 UTF-32 Encoding: 0x00000024
11835 $out->out('out1 : ');
11836 $size->outNL(' size : ');
11837  
11838 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+1; # Cents UTF-8 Encoding: 0xC2 0xA2 UTF-32 Encoding: 0x000000a2
11839 $out->out('out2 : '); $size->outNL(' size : ');
11840  
11841 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+3; # Alpha UTF-8 Encoding: 0xC9 0x91 UTF-32 Encoding: 0x00000251
11842 $out->out('out3 : '); $size->outNL(' size : ');
11843  
11844 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+5; # Euro UTF-8 Encoding: 0xE2 0x82 0xAC UTF-32 Encoding: 0x000020AC
11845 $out->out('out4 : '); $size->outNL(' size : ');
11846  
11847 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+8; # Gothic Letter Hwair UTF-8 Encoding 0xF0 0x90 0x8D 0x88 UTF-32 Encoding: 0x00010348
11848 $out->out('out5 : '); $size->outNL(' size : ');
11849  
11850 my $statement = qq(𝖺
11851 𝑎𝑠𝑠𝑖𝑔𝑛 【【𝖻 𝐩𝐥𝐮𝐬 𝖼】】
11852 AAAAAAAA); # A sample sentence to parse
11853  
11854  
11855 my $s = K(statement => Rutf8($statement)); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11856  
11857 my $l = StringLength $s;
11858  
11859 my $address = AllocateMemory $l; # Allocate enough memory for a copy of the string
11860 CopyMemory($s, $address, $l);
11861  
11862 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address;
11863 $out->out('outA : '); $size->outNL(' size : ');
11864  
11865 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+4;
11866 $out->out('outB : '); $size->outNL(' size : ');
11867  
11868 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+5;
11869 $out->out('outC : '); $size->outNL(' size : ');
11870  
11871 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+30;
11872 $out->out('outD : '); $size->outNL(' size : ');
11873  
11874 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+35;
11875 $out->out('outE : '); $size->outNL(' size : ');
11876  
11877 $address->printOutMemoryInHexNL($l);
11878  
11879 ok Assemble(debug => 0, eq => <<END, avx512=>0);
11880 out1 : .... .... .... ..24 size : .... .... .... ...1
11881 out2 : .... .... .... ..A2 size : .... .... .... ...2
11882 out3 : .... .... .... .251 size : .... .... .... ...2
11883 out4 : .... .... .... 20AC size : .... .... .... ...3
11884 out5 : .... .... ...1 .348 size : .... .... .... ...4
11885 outA : .... .... ...1 D5BA size : .... .... .... ...4
11886 outB : .... .... .... ...A size : .... .... .... ...1
11887 outC : .... .... .... ..20 size : .... .... .... ...1
11888 outD : .... .... .... ..20 size : .... .... .... ...1
11889 outE : .... .... .... ..10 size : .... .... .... ...2
11890 F09D 96BA .A20 F09D 918E F09D 91A0 F09D 91A0 F09D 9196 F09D 9194 F09D 919B 20E3 8090 E380 90F0 9D96 BB20 F09D 90A9 F09D 90A5 F09D 90AE F09D 90AC 20F0 9D96 BCE3 8091 E380 91.A 4141 4141 4141 4141 ....
11891 END
11892  
11893  
11894 =head1 Registers
11895  
11896 Operations on registers
11897  
11898 =head2 Size
11899  
11900 Sizes of each register
11901  
11902 =head3 RegisterSize($R)
11903  
11904 Return the size of a register.
11905  
11906 Parameter Description
11907 1 $R Register
11908  
11909 B<Example:>
11910  
11911  
11912 Mov rax, 1;
11913 Mov rdi, 1;
11914 SaveFirstFour;
11915 Mov rax, 2;
11916 Mov rdi, 2;
11917 SaveFirstSeven;
11918 Mov rax, 3;
11919 Mov rdi, 4;
11920 PrintOutRegisterInHex rax, rdi;
11921 RestoreFirstSeven;
11922 PrintOutRegisterInHex rax, rdi;
11923 RestoreFirstFour;
11924 PrintOutRegisterInHex rax, rdi;
11925  
11926 SaveFirstFour;
11927 Mov rax, 2;
11928 Mov rdi, 2;
11929 SaveFirstSeven;
11930 Mov rax, 3;
11931 Mov rdi, 4;
11932 PrintOutRegisterInHex rax, rdi;
11933 RestoreFirstSevenExceptRax;
11934 PrintOutRegisterInHex rax, rdi;
11935 RestoreFirstFourExceptRax;
11936 PrintOutRegisterInHex rax, rdi;
11937  
11938 SaveFirstFour;
11939 Mov rax, 2;
11940 Mov rdi, 2;
11941 SaveFirstSeven;
11942 Mov rax, 3;
11943 Mov rdi, 4;
11944 PrintOutRegisterInHex rax, rdi;
11945  
11946 Bswap rax;
11947 PrintOutRegisterInHex rax;
11948  
11949 my $l = Label;
11950 Jmp $l;
11951 SetLabel $l;
11952  
11953 ok Assemble eq => <<END, avx512=>0;
11954 rax: .... .... .... ...3
11955 rdi: .... .... .... ...4
11956 rax: .... .... .... ...2
11957 rdi: .... .... .... ...2
11958 rax: .... .... .... ...1
11959 rdi: .... .... .... ...1
11960 rax: .... .... .... ...3
11961 rdi: .... .... .... ...4
11962 rax: .... .... .... ...3
11963 rdi: .... .... .... ...2
11964 rax: .... .... .... ...3
11965 rdi: .... .... .... ...1
11966 rax: .... .... .... ...3
11967 rdi: .... .... .... ...4
11968 rax: .3.. .... .... ....
11969 END
11970  
11971  
11972 ok 8 == RegisterSize rax; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11973  
11974  
11975  
11976 =head2 Push and Pop
11977  
11978 Generic versions of push and pop with pop popping the last push.
11979  
11980 =head3 PushR(@r)
11981  
11982 Push registers onto the stack.
11983  
11984 Parameter Description
11985 1 @r Registers
11986  
11987 B<Example:>
11988  
11989  
11990 Mov rax, 0x11111111;
11991 Mov rbx, 0x22222222;
11992  
11993 PushR my @save = (rax, rbx); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
11994  
11995 Mov rax, 0x33333333;
11996 PopR;
11997 PrintOutRegisterInHex rax;
11998 PrintOutRegisterInHex rbx;
11999  
12000 ok Assemble eq => <<END, avx512=>0;
12001 rax: .... .... 1111 1111
12002 rbx: .... .... 2222 2222
12003 END
12004  
12005 LoadZmm(17, 0x10..0x50);
12006 PrintOutRegisterInHex zmm17;
12007 Mov r14, 2; Mov r15, 3;
12008 PrintOutRegisterInHex r14, r15;
12009  
12010 PushR 14, 15, 16..31; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12011  
12012 LoadZmm(17, 0x20..0x70);
12013 PrintOutRegisterInHex zmm17;
12014 Mov r14, 22; Mov r15, 33;
12015 PopR;
12016 PrintOutRegisterInHex zmm17;
12017 PrintOutRegisterInHex r14, r15;
12018 ok Assemble eq => <<END, avx512=>1;
12019 zmm17: 4F4E 4D4C 4B4A 4948 4746 4544 4342 4140 - 3F3E 3D3C 3B3A 3938 3736 3534 3332 3130 + 2F2E 2D2C 2B2A 2928 2726 2524 2322 2120 - 1F1E 1D1C 1B1A 1918 1716 1514 1312 1110
12020 r14: .... .... .... ...2
12021 r15: .... .... .... ...3
12022 zmm17: 5F5E 5D5C 5B5A 5958 5756 5554 5352 5150 - 4F4E 4D4C 4B4A 4948 4746 4544 4342 4140 + 3F3E 3D3C 3B3A 3938 3736 3534 3332 3130 - 2F2E 2D2C 2B2A 2928 2726 2524 2322 2120
12023 zmm17: 4F4E 4D4C 4B4A 4948 4746 4544 4342 4140 - 3F3E 3D3C 3B3A 3938 3736 3534 3332 3130 + 2F2E 2D2C 2B2A 2928 2726 2524 2322 2120 - 1F1E 1D1C 1B1A 1918 1716 1514 1312 1110
12024 r14: .... .... .... ...2
12025 r15: .... .... .... ...3
12026 END
12027  
12028  
12029 =head3 PopR(@r)
12030  
12031 Pop registers from the stack. Use the last stored set if none explicitly supplied. Pops are done in reverse order to match the original pushing order.
12032  
12033 Parameter Description
12034 1 @r Register
12035  
12036 B<Example:>
12037  
12038  
12039 Mov rax, 0x11111111;
12040 Mov rbx, 0x22222222;
12041 PushR my @save = (rax, rbx);
12042 Mov rax, 0x33333333;
12043  
12044 PopR; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12045  
12046 PrintOutRegisterInHex rax;
12047 PrintOutRegisterInHex rbx;
12048  
12049 ok Assemble eq => <<END, avx512=>0;
12050 rax: .... .... 1111 1111
12051 rbx: .... .... 2222 2222
12052 END
12053  
12054 LoadZmm(17, 0x10..0x50);
12055 PrintOutRegisterInHex zmm17;
12056 Mov r14, 2; Mov r15, 3;
12057 PrintOutRegisterInHex r14, r15;
12058 PushR 14, 15, 16..31;
12059 LoadZmm(17, 0x20..0x70);
12060 PrintOutRegisterInHex zmm17;
12061 Mov r14, 22; Mov r15, 33;
12062  
12063 PopR; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12064  
12065 PrintOutRegisterInHex zmm17;
12066 PrintOutRegisterInHex r14, r15;
12067 ok Assemble eq => <<END, avx512=>1;
12068 zmm17: 4F4E 4D4C 4B4A 4948 4746 4544 4342 4140 - 3F3E 3D3C 3B3A 3938 3736 3534 3332 3130 + 2F2E 2D2C 2B2A 2928 2726 2524 2322 2120 - 1F1E 1D1C 1B1A 1918 1716 1514 1312 1110
12069 r14: .... .... .... ...2
12070 r15: .... .... .... ...3
12071 zmm17: 5F5E 5D5C 5B5A 5958 5756 5554 5352 5150 - 4F4E 4D4C 4B4A 4948 4746 4544 4342 4140 + 3F3E 3D3C 3B3A 3938 3736 3534 3332 3130 - 2F2E 2D2C 2B2A 2928 2726 2524 2322 2120
12072 zmm17: 4F4E 4D4C 4B4A 4948 4746 4544 4342 4140 - 3F3E 3D3C 3B3A 3938 3736 3534 3332 3130 + 2F2E 2D2C 2B2A 2928 2726 2524 2322 2120 - 1F1E 1D1C 1B1A 1918 1716 1514 1312 1110
12073 r14: .... .... .... ...2
12074 r15: .... .... .... ...3
12075 END
12076  
12077  
12078 =head2 Save and Restore
12079  
12080 Saving and restoring registers via the stack
12081  
12082 =head3 SaveFirstFour(@keep)
12083  
12084 Save the first 4 parameter registers making any parameter registers read only.
12085  
12086 Parameter Description
12087 1 @keep Registers to mark as read only
12088  
12089 B<Example:>
12090  
12091  
12092 Mov rax, 1;
12093 Mov rdi, 1;
12094  
12095 SaveFirstFour; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12096  
12097 Mov rax, 2;
12098 Mov rdi, 2;
12099 SaveFirstSeven;
12100 Mov rax, 3;
12101 Mov rdi, 4;
12102 PrintOutRegisterInHex rax, rdi;
12103 RestoreFirstSeven;
12104 PrintOutRegisterInHex rax, rdi;
12105 RestoreFirstFour;
12106 PrintOutRegisterInHex rax, rdi;
12107  
12108  
12109 SaveFirstFour; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12110  
12111 Mov rax, 2;
12112 Mov rdi, 2;
12113 SaveFirstSeven;
12114 Mov rax, 3;
12115 Mov rdi, 4;
12116 PrintOutRegisterInHex rax, rdi;
12117 RestoreFirstSevenExceptRax;
12118 PrintOutRegisterInHex rax, rdi;
12119 RestoreFirstFourExceptRax;
12120 PrintOutRegisterInHex rax, rdi;
12121  
12122  
12123 SaveFirstFour; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12124  
12125 Mov rax, 2;
12126 Mov rdi, 2;
12127 SaveFirstSeven;
12128 Mov rax, 3;
12129 Mov rdi, 4;
12130 PrintOutRegisterInHex rax, rdi;
12131  
12132 Bswap rax;
12133 PrintOutRegisterInHex rax;
12134  
12135 my $l = Label;
12136 Jmp $l;
12137 SetLabel $l;
12138  
12139 ok Assemble eq => <<END, avx512=>0;
12140 rax: .... .... .... ...3
12141 rdi: .... .... .... ...4
12142 rax: .... .... .... ...2
12143 rdi: .... .... .... ...2
12144 rax: .... .... .... ...1
12145 rdi: .... .... .... ...1
12146 rax: .... .... .... ...3
12147 rdi: .... .... .... ...4
12148 rax: .... .... .... ...3
12149 rdi: .... .... .... ...2
12150 rax: .... .... .... ...3
12151 rdi: .... .... .... ...1
12152 rax: .... .... .... ...3
12153 rdi: .... .... .... ...4
12154 rax: .3.. .... .... ....
12155 END
12156  
12157 ok 8 == RegisterSize rax;
12158  
12159  
12160 =head3 RestoreFirstFour()
12161  
12162 Restore the first 4 parameter registers.
12163  
12164  
12165 B<Example:>
12166  
12167  
12168 Mov rax, 1;
12169 Mov rdi, 1;
12170 SaveFirstFour;
12171 Mov rax, 2;
12172 Mov rdi, 2;
12173 SaveFirstSeven;
12174 Mov rax, 3;
12175 Mov rdi, 4;
12176 PrintOutRegisterInHex rax, rdi;
12177 RestoreFirstSeven;
12178 PrintOutRegisterInHex rax, rdi;
12179  
12180 RestoreFirstFour; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12181  
12182 PrintOutRegisterInHex rax, rdi;
12183  
12184 SaveFirstFour;
12185 Mov rax, 2;
12186 Mov rdi, 2;
12187 SaveFirstSeven;
12188 Mov rax, 3;
12189 Mov rdi, 4;
12190 PrintOutRegisterInHex rax, rdi;
12191 RestoreFirstSevenExceptRax;
12192 PrintOutRegisterInHex rax, rdi;
12193 RestoreFirstFourExceptRax;
12194 PrintOutRegisterInHex rax, rdi;
12195  
12196 SaveFirstFour;
12197 Mov rax, 2;
12198 Mov rdi, 2;
12199 SaveFirstSeven;
12200 Mov rax, 3;
12201 Mov rdi, 4;
12202 PrintOutRegisterInHex rax, rdi;
12203  
12204 Bswap rax;
12205 PrintOutRegisterInHex rax;
12206  
12207 my $l = Label;
12208 Jmp $l;
12209 SetLabel $l;
12210  
12211 ok Assemble eq => <<END, avx512=>0;
12212 rax: .... .... .... ...3
12213 rdi: .... .... .... ...4
12214 rax: .... .... .... ...2
12215 rdi: .... .... .... ...2
12216 rax: .... .... .... ...1
12217 rdi: .... .... .... ...1
12218 rax: .... .... .... ...3
12219 rdi: .... .... .... ...4
12220 rax: .... .... .... ...3
12221 rdi: .... .... .... ...2
12222 rax: .... .... .... ...3
12223 rdi: .... .... .... ...1
12224 rax: .... .... .... ...3
12225 rdi: .... .... .... ...4
12226 rax: .3.. .... .... ....
12227 END
12228  
12229 ok 8 == RegisterSize rax;
12230  
12231  
12232 =head3 RestoreFirstFourExceptRax()
12233  
12234 Restore the first 4 parameter registers except rax so it can return its value.
12235  
12236  
12237 B<Example:>
12238  
12239  
12240 Mov rax, 1;
12241 Mov rdi, 1;
12242 SaveFirstFour;
12243 Mov rax, 2;
12244 Mov rdi, 2;
12245 SaveFirstSeven;
12246 Mov rax, 3;
12247 Mov rdi, 4;
12248 PrintOutRegisterInHex rax, rdi;
12249 RestoreFirstSeven;
12250 PrintOutRegisterInHex rax, rdi;
12251 RestoreFirstFour;
12252 PrintOutRegisterInHex rax, rdi;
12253  
12254 SaveFirstFour;
12255 Mov rax, 2;
12256 Mov rdi, 2;
12257 SaveFirstSeven;
12258 Mov rax, 3;
12259 Mov rdi, 4;
12260 PrintOutRegisterInHex rax, rdi;
12261 RestoreFirstSevenExceptRax;
12262 PrintOutRegisterInHex rax, rdi;
12263  
12264 RestoreFirstFourExceptRax; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12265  
12266 PrintOutRegisterInHex rax, rdi;
12267  
12268 SaveFirstFour;
12269 Mov rax, 2;
12270 Mov rdi, 2;
12271 SaveFirstSeven;
12272 Mov rax, 3;
12273 Mov rdi, 4;
12274 PrintOutRegisterInHex rax, rdi;
12275  
12276 Bswap rax;
12277 PrintOutRegisterInHex rax;
12278  
12279 my $l = Label;
12280 Jmp $l;
12281 SetLabel $l;
12282  
12283 ok Assemble eq => <<END, avx512=>0;
12284 rax: .... .... .... ...3
12285 rdi: .... .... .... ...4
12286 rax: .... .... .... ...2
12287 rdi: .... .... .... ...2
12288 rax: .... .... .... ...1
12289 rdi: .... .... .... ...1
12290 rax: .... .... .... ...3
12291 rdi: .... .... .... ...4
12292 rax: .... .... .... ...3
12293 rdi: .... .... .... ...2
12294 rax: .... .... .... ...3
12295 rdi: .... .... .... ...1
12296 rax: .... .... .... ...3
12297 rdi: .... .... .... ...4
12298 rax: .3.. .... .... ....
12299 END
12300  
12301 ok 8 == RegisterSize rax;
12302  
12303  
12304 =head3 SaveFirstSeven()
12305  
12306 Save the first 7 parameter registers.
12307  
12308  
12309 B<Example:>
12310  
12311  
12312 Mov rax, 1;
12313 Mov rdi, 1;
12314 SaveFirstFour;
12315 Mov rax, 2;
12316 Mov rdi, 2;
12317  
12318 SaveFirstSeven; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12319  
12320 Mov rax, 3;
12321 Mov rdi, 4;
12322 PrintOutRegisterInHex rax, rdi;
12323 RestoreFirstSeven;
12324 PrintOutRegisterInHex rax, rdi;
12325 RestoreFirstFour;
12326 PrintOutRegisterInHex rax, rdi;
12327  
12328 SaveFirstFour;
12329 Mov rax, 2;
12330 Mov rdi, 2;
12331  
12332 SaveFirstSeven; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12333  
12334 Mov rax, 3;
12335 Mov rdi, 4;
12336 PrintOutRegisterInHex rax, rdi;
12337 RestoreFirstSevenExceptRax;
12338 PrintOutRegisterInHex rax, rdi;
12339 RestoreFirstFourExceptRax;
12340 PrintOutRegisterInHex rax, rdi;
12341  
12342 SaveFirstFour;
12343 Mov rax, 2;
12344 Mov rdi, 2;
12345  
12346 SaveFirstSeven; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12347  
12348 Mov rax, 3;
12349 Mov rdi, 4;
12350 PrintOutRegisterInHex rax, rdi;
12351  
12352 Bswap rax;
12353 PrintOutRegisterInHex rax;
12354  
12355 my $l = Label;
12356 Jmp $l;
12357 SetLabel $l;
12358  
12359 ok Assemble eq => <<END, avx512=>0;
12360 rax: .... .... .... ...3
12361 rdi: .... .... .... ...4
12362 rax: .... .... .... ...2
12363 rdi: .... .... .... ...2
12364 rax: .... .... .... ...1
12365 rdi: .... .... .... ...1
12366 rax: .... .... .... ...3
12367 rdi: .... .... .... ...4
12368 rax: .... .... .... ...3
12369 rdi: .... .... .... ...2
12370 rax: .... .... .... ...3
12371 rdi: .... .... .... ...1
12372 rax: .... .... .... ...3
12373 rdi: .... .... .... ...4
12374 rax: .3.. .... .... ....
12375 END
12376  
12377 ok 8 == RegisterSize rax;
12378  
12379  
12380 =head3 RestoreFirstSeven()
12381  
12382 Restore the first 7 parameter registers.
12383  
12384  
12385 B<Example:>
12386  
12387  
12388 Mov rax, 1;
12389 Mov rdi, 1;
12390 SaveFirstFour;
12391 Mov rax, 2;
12392 Mov rdi, 2;
12393 SaveFirstSeven;
12394 Mov rax, 3;
12395 Mov rdi, 4;
12396 PrintOutRegisterInHex rax, rdi;
12397  
12398 RestoreFirstSeven; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12399  
12400 PrintOutRegisterInHex rax, rdi;
12401 RestoreFirstFour;
12402 PrintOutRegisterInHex rax, rdi;
12403  
12404 SaveFirstFour;
12405 Mov rax, 2;
12406 Mov rdi, 2;
12407 SaveFirstSeven;
12408 Mov rax, 3;
12409 Mov rdi, 4;
12410 PrintOutRegisterInHex rax, rdi;
12411 RestoreFirstSevenExceptRax;
12412 PrintOutRegisterInHex rax, rdi;
12413 RestoreFirstFourExceptRax;
12414 PrintOutRegisterInHex rax, rdi;
12415  
12416 SaveFirstFour;
12417 Mov rax, 2;
12418 Mov rdi, 2;
12419 SaveFirstSeven;
12420 Mov rax, 3;
12421 Mov rdi, 4;
12422 PrintOutRegisterInHex rax, rdi;
12423  
12424 Bswap rax;
12425 PrintOutRegisterInHex rax;
12426  
12427 my $l = Label;
12428 Jmp $l;
12429 SetLabel $l;
12430  
12431 ok Assemble eq => <<END, avx512=>0;
12432 rax: .... .... .... ...3
12433 rdi: .... .... .... ...4
12434 rax: .... .... .... ...2
12435 rdi: .... .... .... ...2
12436 rax: .... .... .... ...1
12437 rdi: .... .... .... ...1
12438 rax: .... .... .... ...3
12439 rdi: .... .... .... ...4
12440 rax: .... .... .... ...3
12441 rdi: .... .... .... ...2
12442 rax: .... .... .... ...3
12443 rdi: .... .... .... ...1
12444 rax: .... .... .... ...3
12445 rdi: .... .... .... ...4
12446 rax: .3.. .... .... ....
12447 END
12448  
12449 ok 8 == RegisterSize rax;
12450  
12451  
12452 =head3 RestoreFirstSevenExceptRax()
12453  
12454 Restore the first 7 parameter registers except rax which is being used to return the result.
12455  
12456  
12457 B<Example:>
12458  
12459  
12460 Mov rax, 1;
12461 Mov rdi, 1;
12462 SaveFirstFour;
12463 Mov rax, 2;
12464 Mov rdi, 2;
12465 SaveFirstSeven;
12466 Mov rax, 3;
12467 Mov rdi, 4;
12468 PrintOutRegisterInHex rax, rdi;
12469 RestoreFirstSeven;
12470 PrintOutRegisterInHex rax, rdi;
12471 RestoreFirstFour;
12472 PrintOutRegisterInHex rax, rdi;
12473  
12474 SaveFirstFour;
12475 Mov rax, 2;
12476 Mov rdi, 2;
12477 SaveFirstSeven;
12478 Mov rax, 3;
12479 Mov rdi, 4;
12480 PrintOutRegisterInHex rax, rdi;
12481  
12482 RestoreFirstSevenExceptRax; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12483  
12484 PrintOutRegisterInHex rax, rdi;
12485 RestoreFirstFourExceptRax;
12486 PrintOutRegisterInHex rax, rdi;
12487  
12488 SaveFirstFour;
12489 Mov rax, 2;
12490 Mov rdi, 2;
12491 SaveFirstSeven;
12492 Mov rax, 3;
12493 Mov rdi, 4;
12494 PrintOutRegisterInHex rax, rdi;
12495  
12496 Bswap rax;
12497 PrintOutRegisterInHex rax;
12498  
12499 my $l = Label;
12500 Jmp $l;
12501 SetLabel $l;
12502  
12503 ok Assemble eq => <<END, avx512=>0;
12504 rax: .... .... .... ...3
12505 rdi: .... .... .... ...4
12506 rax: .... .... .... ...2
12507 rdi: .... .... .... ...2
12508 rax: .... .... .... ...1
12509 rdi: .... .... .... ...1
12510 rax: .... .... .... ...3
12511 rdi: .... .... .... ...4
12512 rax: .... .... .... ...3
12513 rdi: .... .... .... ...2
12514 rax: .... .... .... ...3
12515 rdi: .... .... .... ...1
12516 rax: .... .... .... ...3
12517 rdi: .... .... .... ...4
12518 rax: .3.. .... .... ....
12519 END
12520  
12521 ok 8 == RegisterSize rax;
12522  
12523  
12524 =head3 ClearRegisters(@registers)
12525  
12526 Clear registers by setting them to zero.
12527  
12528 Parameter Description
12529 1 @registers Registers
12530  
12531 B<Example:>
12532  
12533  
12534 Mov rax,1;
12535 Kmovq k0, rax;
12536 Kaddb k0, k0, k0;
12537 Kaddb k0, k0, k0;
12538 Kaddb k0, k0, k0;
12539 Kmovq rax, k0;
12540 PushR k0;
12541  
12542 ClearRegisters k0; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12543  
12544 Kmovq k1, k0;
12545 PopR k0;
12546 PrintOutRegisterInHex k0;
12547 PrintOutRegisterInHex k1;
12548  
12549 ok Assemble( eq => <<END)
12550 k0: .... .... .... ...8
12551 k1: .... .... .... ...0
12552 END
12553  
12554  
12555 =head2 Zero flag
12556  
12557 Actions on the Zero Flag.
12558  
12559 =head3 SetZF()
12560  
12561 Set the zero flag.
12562  
12563  
12564 B<Example:>
12565  
12566  
12567  
12568 SetZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12569  
12570 PrintOutZF;
12571 ClearZF;
12572 PrintOutZF;
12573  
12574 SetZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12575  
12576 PrintOutZF;
12577  
12578 SetZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12579  
12580 PrintOutZF;
12581 ClearZF;
12582 PrintOutZF;
12583  
12584  
12585 SetZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12586  
12587 IfZ Then {PrintOutStringNL "Zero"}, Else {PrintOutStringNL "NOT zero"};
12588 ClearZF;
12589 IfNz Then {PrintOutStringNL "NOT zero"}, Else {PrintOutStringNL "Zero"};
12590  
12591 Mov r15, 5;
12592 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"};
12593 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"};
12594 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"};
12595 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"};
12596  
12597 ok Assemble eq => <<END, avx512=>0;
12598 ZF=1
12599 ZF=0
12600 ZF=1
12601 ZF=1
12602 ZF=0
12603 Zero
12604 NOT zero
12605 Carry
12606 NO carry
12607 Carry
12608 NO carry
12609 END
12610  
12611  
12612 =head3 ClearZF()
12613  
12614 Clear the zero flag.
12615  
12616  
12617 B<Example:>
12618  
12619  
12620 SetZF;
12621 PrintOutZF;
12622  
12623 ClearZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12624  
12625 PrintOutZF;
12626 SetZF;
12627 PrintOutZF;
12628 SetZF;
12629 PrintOutZF;
12630  
12631 ClearZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12632  
12633 PrintOutZF;
12634  
12635 SetZF;
12636 IfZ Then {PrintOutStringNL "Zero"}, Else {PrintOutStringNL "NOT zero"};
12637  
12638 ClearZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12639  
12640 IfNz Then {PrintOutStringNL "NOT zero"}, Else {PrintOutStringNL "Zero"};
12641  
12642 Mov r15, 5;
12643 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"};
12644 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"};
12645 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"};
12646 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"};
12647  
12648 ok Assemble eq => <<END, avx512=>0;
12649 ZF=1
12650 ZF=0
12651 ZF=1
12652 ZF=1
12653 ZF=0
12654 Zero
12655 NOT zero
12656 Carry
12657 NO carry
12658 Carry
12659 NO carry
12660 END
12661  
12662  
12663 =head2 x, y, zmm
12664  
12665 Actions specific to mm registers
12666  
12667 =head3 xmm(@r)
12668  
12669 Add xmm to the front of a list of register expressions.
12670  
12671 Parameter Description
12672 1 @r Register numbers
12673  
12674 B<Example:>
12675  
12676  
12677 Mov r15, 0x12345678;
12678 bRegIntoZmm(r15, 1, 0);
12679 bRegIntoZmm(r15, 1, 1);
12680 dRegIntoZmm(r15, 1, 4);
12681 dRegIntoZmm(r15, 1, 8);
12682 dRegIntoZmm(r15, 1, 12);
12683  
12684 PrintOutRegisterInHex xmm(1); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12685  
12686 PrintOutRegisterInHex zmm(1);
12687  
12688 bRegFromZmm(r15, 1, 1);
12689 PrintOutRegisterInHex r15;
12690  
12691 bFromX(1, 0)->outNL;
12692 bFromZ(1, 0)->outNL;
12693  
12694 dRegFromZmm(r14, 1, 3);
12695 PrintOutRegisterInHex r14;
12696  
12697 wRegFromZmm(r14, 1, 3);
12698 PrintOutRegisterInHex r14;
12699  
12700 bFromX(1, 0)->outNL;
12701 bFromZ(1, 1)->outNL;
12702 bFromZ(1, 2)->outNL;
12703  
12704 wFromX(1, 0)->outNL;
12705 wFromZ(1, 1)->outNL;
12706 wFromZ(1, 2)->outNL;
12707  
12708 dFromX(1, 0)->outNL;
12709 dFromZ(1, 1)->outNL;
12710 dFromZ(1, 2)->outNL;
12711  
12712 qFromX(1, 0)->outNL;
12713 qFromZ(1, 1)->outNL;
12714 dFromZ(1, 2)->outNL;
12715  
12716 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
12717  
12718 Mov r15, 2;
12719 Kmovq k7, r15;
12720 LoadZmm 2, map {0xff} 1..64;
12721 PrintOutRegisterInHex zmm2;
12722 Vmovdqu8 zmmM (2, 7), zmm(1);
12723 Vmovdqu8 zmmMZ(3, 7), zmm(1);
12724 PrintOutRegisterInHex zmm1, zmm2, zmm3;
12725  
12726 ok Assemble eq => <<END;
12727 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
12728 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
12729 r15: .... .... 1234 5678
12730 b at offset 0 in xmm1: .... .... .... ..78
12731 b at offset 0 in zmm1: .... .... .... ..78
12732 r14: .... .... 3456 78..
12733 r14: .... .... 3456 78..
12734 b at offset 0 in xmm1: .... .... .... ..78
12735 b at offset 1 in zmm1: .... .... .... ..78
12736 b at offset 2 in zmm1: .... .... .... ...0
12737 w at offset 0 in xmm1: .... .... .... 7878
12738 w at offset 1 in zmm1: .... .... .... ..78
12739 w at offset 2 in zmm1: .... .... .... ...0
12740 d at offset 0 in xmm1: .... .... .... 7878
12741 d at offset 1 in zmm1: .... .... 78.. ..78
12742 d at offset 2 in zmm1: .... .... 5678 ....
12743 q at offset 0 in xmm1: 1234 5678 .... 7878
12744 q at offset 1 in zmm1: 7812 3456 78.. ..78
12745 d at offset 2 in zmm1: .... .... 5678 ....
12746 d: .... .... .... ...0
12747 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
12748 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
12749 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
12750 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
12751 END
12752  
12753  
12754 =head3 ymm(@r)
12755  
12756 Add ymm to the front of a list of register expressions.
12757  
12758 Parameter Description
12759 1 @r Register numbers
12760  
12761 B<Example:>
12762  
12763  
12764 Mov r15, 0x12345678;
12765 bRegIntoZmm(r15, 1, 0);
12766 bRegIntoZmm(r15, 1, 1);
12767 dRegIntoZmm(r15, 1, 4);
12768 dRegIntoZmm(r15, 1, 8);
12769 dRegIntoZmm(r15, 1, 12);
12770 PrintOutRegisterInHex xmm(1);
12771 PrintOutRegisterInHex zmm(1);
12772  
12773 bRegFromZmm(r15, 1, 1);
12774 PrintOutRegisterInHex r15;
12775  
12776 bFromX(1, 0)->outNL;
12777 bFromZ(1, 0)->outNL;
12778  
12779 dRegFromZmm(r14, 1, 3);
12780 PrintOutRegisterInHex r14;
12781  
12782 wRegFromZmm(r14, 1, 3);
12783 PrintOutRegisterInHex r14;
12784  
12785 bFromX(1, 0)->outNL;
12786 bFromZ(1, 1)->outNL;
12787 bFromZ(1, 2)->outNL;
12788  
12789 wFromX(1, 0)->outNL;
12790 wFromZ(1, 1)->outNL;
12791 wFromZ(1, 2)->outNL;
12792  
12793 dFromX(1, 0)->outNL;
12794 dFromZ(1, 1)->outNL;
12795 dFromZ(1, 2)->outNL;
12796  
12797 qFromX(1, 0)->outNL;
12798 qFromZ(1, 1)->outNL;
12799 dFromZ(1, 2)->outNL;
12800  
12801 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
12802  
12803 Mov r15, 2;
12804 Kmovq k7, r15;
12805 LoadZmm 2, map {0xff} 1..64;
12806 PrintOutRegisterInHex zmm2;
12807 Vmovdqu8 zmmM (2, 7), zmm(1);
12808 Vmovdqu8 zmmMZ(3, 7), zmm(1);
12809 PrintOutRegisterInHex zmm1, zmm2, zmm3;
12810  
12811 ok Assemble eq => <<END;
12812 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
12813 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
12814 r15: .... .... 1234 5678
12815 b at offset 0 in xmm1: .... .... .... ..78
12816 b at offset 0 in zmm1: .... .... .... ..78
12817 r14: .... .... 3456 78..
12818 r14: .... .... 3456 78..
12819 b at offset 0 in xmm1: .... .... .... ..78
12820 b at offset 1 in zmm1: .... .... .... ..78
12821 b at offset 2 in zmm1: .... .... .... ...0
12822 w at offset 0 in xmm1: .... .... .... 7878
12823 w at offset 1 in zmm1: .... .... .... ..78
12824 w at offset 2 in zmm1: .... .... .... ...0
12825 d at offset 0 in xmm1: .... .... .... 7878
12826 d at offset 1 in zmm1: .... .... 78.. ..78
12827 d at offset 2 in zmm1: .... .... 5678 ....
12828 q at offset 0 in xmm1: 1234 5678 .... 7878
12829 q at offset 1 in zmm1: 7812 3456 78.. ..78
12830 d at offset 2 in zmm1: .... .... 5678 ....
12831 d: .... .... .... ...0
12832 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
12833 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
12834 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
12835 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
12836 END
12837  
12838  
12839 =head3 zmm(@r)
12840  
12841 Add zmm to the front of a list of register expressions.
12842  
12843 Parameter Description
12844 1 @r Register numbers
12845  
12846 B<Example:>
12847  
12848  
12849 LoadZmm 0, 0..63;
12850  
12851 PrintOutRegisterInHex zmm 0; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12852  
12853  
12854 ok Assemble(debug => 0, eq => <<END, avx512=>1);
12855 zmm0: 3F3E 3D3C 3B3A 3938 3736 3534 3332 3130 - 2F2E 2D2C 2B2A 2928 2726 2524 2322 2120 + 1F1E 1D1C 1B1A 1918 1716 1514 1312 1110 - .F.E .D.C .B.A .9.8 .7.6 .5.4 .3.2 .1..
12856 END
12857  
12858  
12859 =head3 zmmM($z, $m)
12860  
12861 Add zmm to the front of a register number and a mask after it.
12862  
12863 Parameter Description
12864 1 $z Zmm number
12865 2 $m Mask register
12866  
12867 B<Example:>
12868  
12869  
12870 Mov r15, 0x12345678;
12871 bRegIntoZmm(r15, 1, 0);
12872 bRegIntoZmm(r15, 1, 1);
12873 dRegIntoZmm(r15, 1, 4);
12874 dRegIntoZmm(r15, 1, 8);
12875 dRegIntoZmm(r15, 1, 12);
12876 PrintOutRegisterInHex xmm(1);
12877 PrintOutRegisterInHex zmm(1);
12878  
12879 bRegFromZmm(r15, 1, 1);
12880 PrintOutRegisterInHex r15;
12881  
12882 bFromX(1, 0)->outNL;
12883 bFromZ(1, 0)->outNL;
12884  
12885 dRegFromZmm(r14, 1, 3);
12886 PrintOutRegisterInHex r14;
12887  
12888 wRegFromZmm(r14, 1, 3);
12889 PrintOutRegisterInHex r14;
12890  
12891 bFromX(1, 0)->outNL;
12892 bFromZ(1, 1)->outNL;
12893 bFromZ(1, 2)->outNL;
12894  
12895 wFromX(1, 0)->outNL;
12896 wFromZ(1, 1)->outNL;
12897 wFromZ(1, 2)->outNL;
12898  
12899 dFromX(1, 0)->outNL;
12900 dFromZ(1, 1)->outNL;
12901 dFromZ(1, 2)->outNL;
12902  
12903 qFromX(1, 0)->outNL;
12904 qFromZ(1, 1)->outNL;
12905 dFromZ(1, 2)->outNL;
12906  
12907 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
12908  
12909 Mov r15, 2;
12910 Kmovq k7, r15;
12911 LoadZmm 2, map {0xff} 1..64;
12912 PrintOutRegisterInHex zmm2;
12913  
12914 Vmovdqu8 zmmM (2, 7), zmm(1); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
12915  
12916 Vmovdqu8 zmmMZ(3, 7), zmm(1);
12917 PrintOutRegisterInHex zmm1, zmm2, zmm3;
12918  
12919 ok Assemble eq => <<END;
12920 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
12921 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
12922 r15: .... .... 1234 5678
12923 b at offset 0 in xmm1: .... .... .... ..78
12924 b at offset 0 in zmm1: .... .... .... ..78
12925 r14: .... .... 3456 78..
12926 r14: .... .... 3456 78..
12927 b at offset 0 in xmm1: .... .... .... ..78
12928 b at offset 1 in zmm1: .... .... .... ..78
12929 b at offset 2 in zmm1: .... .... .... ...0
12930 w at offset 0 in xmm1: .... .... .... 7878
12931 w at offset 1 in zmm1: .... .... .... ..78
12932 w at offset 2 in zmm1: .... .... .... ...0
12933 d at offset 0 in xmm1: .... .... .... 7878
12934 d at offset 1 in zmm1: .... .... 78.. ..78
12935 d at offset 2 in zmm1: .... .... 5678 ....
12936 q at offset 0 in xmm1: 1234 5678 .... 7878
12937 q at offset 1 in zmm1: 7812 3456 78.. ..78
12938 d at offset 2 in zmm1: .... .... 5678 ....
12939 d: .... .... .... ...0
12940 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
12941 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
12942 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
12943 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
12944 END
12945  
12946  
12947 =head3 zmmMZ($z, $m)
12948  
12949 Add zmm to the front of a register number and mask and zero after it.
12950  
12951 Parameter Description
12952 1 $z Zmm number
12953 2 $m Mask register number
12954  
12955 B<Example:>
12956  
12957  
12958 Mov r15, 0x12345678;
12959 bRegIntoZmm(r15, 1, 0);
12960 bRegIntoZmm(r15, 1, 1);
12961 dRegIntoZmm(r15, 1, 4);
12962 dRegIntoZmm(r15, 1, 8);
12963 dRegIntoZmm(r15, 1, 12);
12964 PrintOutRegisterInHex xmm(1);
12965 PrintOutRegisterInHex zmm(1);
12966  
12967 bRegFromZmm(r15, 1, 1);
12968 PrintOutRegisterInHex r15;
12969  
12970 bFromX(1, 0)->outNL;
12971 bFromZ(1, 0)->outNL;
12972  
12973 dRegFromZmm(r14, 1, 3);
12974 PrintOutRegisterInHex r14;
12975  
12976 wRegFromZmm(r14, 1, 3);
12977 PrintOutRegisterInHex r14;
12978  
12979 bFromX(1, 0)->outNL;
12980 bFromZ(1, 1)->outNL;
12981 bFromZ(1, 2)->outNL;
12982  
12983 wFromX(1, 0)->outNL;
12984 wFromZ(1, 1)->outNL;
12985 wFromZ(1, 2)->outNL;
12986  
12987 dFromX(1, 0)->outNL;
12988 dFromZ(1, 1)->outNL;
12989 dFromZ(1, 2)->outNL;
12990  
12991 qFromX(1, 0)->outNL;
12992 qFromZ(1, 1)->outNL;
12993 dFromZ(1, 2)->outNL;
12994  
12995 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
12996  
12997 Mov r15, 2;
12998 Kmovq k7, r15;
12999 LoadZmm 2, map {0xff} 1..64;
13000 PrintOutRegisterInHex zmm2;
13001 Vmovdqu8 zmmM (2, 7), zmm(1);
13002  
13003 Vmovdqu8 zmmMZ(3, 7), zmm(1); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13004  
13005 PrintOutRegisterInHex zmm1, zmm2, zmm3;
13006  
13007 ok Assemble eq => <<END;
13008 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
13009 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13010 r15: .... .... 1234 5678
13011 b at offset 0 in xmm1: .... .... .... ..78
13012 b at offset 0 in zmm1: .... .... .... ..78
13013 r14: .... .... 3456 78..
13014 r14: .... .... 3456 78..
13015 b at offset 0 in xmm1: .... .... .... ..78
13016 b at offset 1 in zmm1: .... .... .... ..78
13017 b at offset 2 in zmm1: .... .... .... ...0
13018 w at offset 0 in xmm1: .... .... .... 7878
13019 w at offset 1 in zmm1: .... .... .... ..78
13020 w at offset 2 in zmm1: .... .... .... ...0
13021 d at offset 0 in xmm1: .... .... .... 7878
13022 d at offset 1 in zmm1: .... .... 78.. ..78
13023 d at offset 2 in zmm1: .... .... 5678 ....
13024 q at offset 0 in xmm1: 1234 5678 .... 7878
13025 q at offset 1 in zmm1: 7812 3456 78.. ..78
13026 d at offset 2 in zmm1: .... .... 5678 ....
13027 d: .... .... .... ...0
13028 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
13029 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13030 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
13031 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
13032 END
13033  
13034  
13035 =head3 Via general purpose registers
13036  
13037 Load zmm registers from data held in the general purpose registers.
13038  
13039 =head4 LoadZmm($zmm, @bytes)
13040  
13041 Load a numbered zmm with the specified bytes.
13042  
13043 Parameter Description
13044 1 $zmm Numbered zmm
13045 2 @bytes Bytes
13046  
13047 B<Example:>
13048  
13049  
13050  
13051 LoadZmm 0, 0..63; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13052  
13053 PrintOutRegisterInHex zmm 0;
13054  
13055 ok Assemble(debug => 0, eq => <<END, avx512=>1);
13056 zmm0: 3F3E 3D3C 3B3A 3938 3736 3534 3332 3130 - 2F2E 2D2C 2B2A 2928 2726 2524 2322 2120 + 1F1E 1D1C 1B1A 1918 1716 1514 1312 1110 - .F.E .D.C .B.A .9.8 .7.6 .5.4 .3.2 .1..
13057 END
13058  
13059  
13060 =head4 bRegFromZmm($register, $zmm, $offset)
13061  
13062 Load the specified register from the byte at the specified offset located in the numbered zmm.
13063  
13064 Parameter Description
13065 1 $register Register to load
13066 2 $zmm Numbered zmm register to load from
13067 3 $offset Constant offset in bytes
13068  
13069 B<Example:>
13070  
13071  
13072 Mov r15, 0x12345678;
13073 bRegIntoZmm(r15, 1, 0);
13074 bRegIntoZmm(r15, 1, 1);
13075 dRegIntoZmm(r15, 1, 4);
13076 dRegIntoZmm(r15, 1, 8);
13077 dRegIntoZmm(r15, 1, 12);
13078 PrintOutRegisterInHex xmm(1);
13079 PrintOutRegisterInHex zmm(1);
13080  
13081  
13082 bRegFromZmm(r15, 1, 1); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13083  
13084 PrintOutRegisterInHex r15;
13085  
13086 bFromX(1, 0)->outNL;
13087 bFromZ(1, 0)->outNL;
13088  
13089 dRegFromZmm(r14, 1, 3);
13090 PrintOutRegisterInHex r14;
13091  
13092 wRegFromZmm(r14, 1, 3);
13093 PrintOutRegisterInHex r14;
13094  
13095 bFromX(1, 0)->outNL;
13096 bFromZ(1, 1)->outNL;
13097 bFromZ(1, 2)->outNL;
13098  
13099 wFromX(1, 0)->outNL;
13100 wFromZ(1, 1)->outNL;
13101 wFromZ(1, 2)->outNL;
13102  
13103 dFromX(1, 0)->outNL;
13104 dFromZ(1, 1)->outNL;
13105 dFromZ(1, 2)->outNL;
13106  
13107 qFromX(1, 0)->outNL;
13108 qFromZ(1, 1)->outNL;
13109 dFromZ(1, 2)->outNL;
13110  
13111 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
13112  
13113 Mov r15, 2;
13114 Kmovq k7, r15;
13115 LoadZmm 2, map {0xff} 1..64;
13116 PrintOutRegisterInHex zmm2;
13117 Vmovdqu8 zmmM (2, 7), zmm(1);
13118 Vmovdqu8 zmmMZ(3, 7), zmm(1);
13119 PrintOutRegisterInHex zmm1, zmm2, zmm3;
13120  
13121 ok Assemble eq => <<END;
13122 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
13123 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13124 r15: .... .... 1234 5678
13125 b at offset 0 in xmm1: .... .... .... ..78
13126 b at offset 0 in zmm1: .... .... .... ..78
13127 r14: .... .... 3456 78..
13128 r14: .... .... 3456 78..
13129 b at offset 0 in xmm1: .... .... .... ..78
13130 b at offset 1 in zmm1: .... .... .... ..78
13131 b at offset 2 in zmm1: .... .... .... ...0
13132 w at offset 0 in xmm1: .... .... .... 7878
13133 w at offset 1 in zmm1: .... .... .... ..78
13134 w at offset 2 in zmm1: .... .... .... ...0
13135 d at offset 0 in xmm1: .... .... .... 7878
13136 d at offset 1 in zmm1: .... .... 78.. ..78
13137 d at offset 2 in zmm1: .... .... 5678 ....
13138 q at offset 0 in xmm1: 1234 5678 .... 7878
13139 q at offset 1 in zmm1: 7812 3456 78.. ..78
13140 d at offset 2 in zmm1: .... .... 5678 ....
13141 d: .... .... .... ...0
13142 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
13143 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13144 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
13145 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
13146 END
13147  
13148  
13149 =head4 bRegIntoZmm($register, $zmm, $offset)
13150  
13151 Put the byte content of the specified register into the byte in the numbered zmm at the specified offset in the zmm.
13152  
13153 Parameter Description
13154 1 $register Register to load
13155 2 $zmm Numbered zmm register to load from
13156 3 $offset Constant offset in bytes
13157  
13158 B<Example:>
13159  
13160  
13161 Mov r15, 0x12345678;
13162  
13163 bRegIntoZmm(r15, 1, 0); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13164  
13165  
13166 bRegIntoZmm(r15, 1, 1); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13167  
13168 dRegIntoZmm(r15, 1, 4);
13169 dRegIntoZmm(r15, 1, 8);
13170 dRegIntoZmm(r15, 1, 12);
13171 PrintOutRegisterInHex xmm(1);
13172 PrintOutRegisterInHex zmm(1);
13173  
13174 bRegFromZmm(r15, 1, 1);
13175 PrintOutRegisterInHex r15;
13176  
13177 bFromX(1, 0)->outNL;
13178 bFromZ(1, 0)->outNL;
13179  
13180 dRegFromZmm(r14, 1, 3);
13181 PrintOutRegisterInHex r14;
13182  
13183 wRegFromZmm(r14, 1, 3);
13184 PrintOutRegisterInHex r14;
13185  
13186 bFromX(1, 0)->outNL;
13187 bFromZ(1, 1)->outNL;
13188 bFromZ(1, 2)->outNL;
13189  
13190 wFromX(1, 0)->outNL;
13191 wFromZ(1, 1)->outNL;
13192 wFromZ(1, 2)->outNL;
13193  
13194 dFromX(1, 0)->outNL;
13195 dFromZ(1, 1)->outNL;
13196 dFromZ(1, 2)->outNL;
13197  
13198 qFromX(1, 0)->outNL;
13199 qFromZ(1, 1)->outNL;
13200 dFromZ(1, 2)->outNL;
13201  
13202 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
13203  
13204 Mov r15, 2;
13205 Kmovq k7, r15;
13206 LoadZmm 2, map {0xff} 1..64;
13207 PrintOutRegisterInHex zmm2;
13208 Vmovdqu8 zmmM (2, 7), zmm(1);
13209 Vmovdqu8 zmmMZ(3, 7), zmm(1);
13210 PrintOutRegisterInHex zmm1, zmm2, zmm3;
13211  
13212 ok Assemble eq => <<END;
13213 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
13214 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13215 r15: .... .... 1234 5678
13216 b at offset 0 in xmm1: .... .... .... ..78
13217 b at offset 0 in zmm1: .... .... .... ..78
13218 r14: .... .... 3456 78..
13219 r14: .... .... 3456 78..
13220 b at offset 0 in xmm1: .... .... .... ..78
13221 b at offset 1 in zmm1: .... .... .... ..78
13222 b at offset 2 in zmm1: .... .... .... ...0
13223 w at offset 0 in xmm1: .... .... .... 7878
13224 w at offset 1 in zmm1: .... .... .... ..78
13225 w at offset 2 in zmm1: .... .... .... ...0
13226 d at offset 0 in xmm1: .... .... .... 7878
13227 d at offset 1 in zmm1: .... .... 78.. ..78
13228 d at offset 2 in zmm1: .... .... 5678 ....
13229 q at offset 0 in xmm1: 1234 5678 .... 7878
13230 q at offset 1 in zmm1: 7812 3456 78.. ..78
13231 d at offset 2 in zmm1: .... .... 5678 ....
13232 d: .... .... .... ...0
13233 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
13234 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13235 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
13236 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
13237 END
13238  
13239  
13240 =head4 wRegFromZmm($register, $zmm, $offset)
13241  
13242 Load the specified register from the word at the specified offset located in the numbered zmm.
13243  
13244 Parameter Description
13245 1 $register Register to load
13246 2 $zmm Numbered zmm register to load from
13247 3 $offset Constant offset in bytes
13248  
13249 B<Example:>
13250  
13251  
13252 Mov r15, 0x12345678;
13253 bRegIntoZmm(r15, 1, 0);
13254 bRegIntoZmm(r15, 1, 1);
13255 dRegIntoZmm(r15, 1, 4);
13256 dRegIntoZmm(r15, 1, 8);
13257 dRegIntoZmm(r15, 1, 12);
13258 PrintOutRegisterInHex xmm(1);
13259 PrintOutRegisterInHex zmm(1);
13260  
13261 bRegFromZmm(r15, 1, 1);
13262 PrintOutRegisterInHex r15;
13263  
13264 bFromX(1, 0)->outNL;
13265 bFromZ(1, 0)->outNL;
13266  
13267 dRegFromZmm(r14, 1, 3);
13268 PrintOutRegisterInHex r14;
13269  
13270  
13271 wRegFromZmm(r14, 1, 3); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13272  
13273 PrintOutRegisterInHex r14;
13274  
13275 bFromX(1, 0)->outNL;
13276 bFromZ(1, 1)->outNL;
13277 bFromZ(1, 2)->outNL;
13278  
13279 wFromX(1, 0)->outNL;
13280 wFromZ(1, 1)->outNL;
13281 wFromZ(1, 2)->outNL;
13282  
13283 dFromX(1, 0)->outNL;
13284 dFromZ(1, 1)->outNL;
13285 dFromZ(1, 2)->outNL;
13286  
13287 qFromX(1, 0)->outNL;
13288 qFromZ(1, 1)->outNL;
13289 dFromZ(1, 2)->outNL;
13290  
13291 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
13292  
13293 Mov r15, 2;
13294 Kmovq k7, r15;
13295 LoadZmm 2, map {0xff} 1..64;
13296 PrintOutRegisterInHex zmm2;
13297 Vmovdqu8 zmmM (2, 7), zmm(1);
13298 Vmovdqu8 zmmMZ(3, 7), zmm(1);
13299 PrintOutRegisterInHex zmm1, zmm2, zmm3;
13300  
13301 ok Assemble eq => <<END;
13302 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
13303 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13304 r15: .... .... 1234 5678
13305 b at offset 0 in xmm1: .... .... .... ..78
13306 b at offset 0 in zmm1: .... .... .... ..78
13307 r14: .... .... 3456 78..
13308 r14: .... .... 3456 78..
13309 b at offset 0 in xmm1: .... .... .... ..78
13310 b at offset 1 in zmm1: .... .... .... ..78
13311 b at offset 2 in zmm1: .... .... .... ...0
13312 w at offset 0 in xmm1: .... .... .... 7878
13313 w at offset 1 in zmm1: .... .... .... ..78
13314 w at offset 2 in zmm1: .... .... .... ...0
13315 d at offset 0 in xmm1: .... .... .... 7878
13316 d at offset 1 in zmm1: .... .... 78.. ..78
13317 d at offset 2 in zmm1: .... .... 5678 ....
13318 q at offset 0 in xmm1: 1234 5678 .... 7878
13319 q at offset 1 in zmm1: 7812 3456 78.. ..78
13320 d at offset 2 in zmm1: .... .... 5678 ....
13321 d: .... .... .... ...0
13322 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
13323 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13324 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
13325 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
13326 END
13327  
13328  
13329 =head4 wRegIntoZmm($register, $zmm, $offset)
13330  
13331 Put the specified register into the word in the numbered zmm at the specified offset in the zmm.
13332  
13333 Parameter Description
13334 1 $register Register to load
13335 2 $zmm Numbered zmm register to load from
13336 3 $offset Constant offset in bytes
13337  
13338 B<Example:>
13339  
13340  
13341 Mov r15, 0x12345678;
13342 bRegIntoZmm(r15, 1, 0);
13343 bRegIntoZmm(r15, 1, 1);
13344 dRegIntoZmm(r15, 1, 4);
13345 dRegIntoZmm(r15, 1, 8);
13346 dRegIntoZmm(r15, 1, 12);
13347 PrintOutRegisterInHex xmm(1);
13348 PrintOutRegisterInHex zmm(1);
13349  
13350 bRegFromZmm(r15, 1, 1);
13351 PrintOutRegisterInHex r15;
13352  
13353 bFromX(1, 0)->outNL;
13354 bFromZ(1, 0)->outNL;
13355  
13356 dRegFromZmm(r14, 1, 3);
13357 PrintOutRegisterInHex r14;
13358  
13359 wRegFromZmm(r14, 1, 3);
13360 PrintOutRegisterInHex r14;
13361  
13362 bFromX(1, 0)->outNL;
13363 bFromZ(1, 1)->outNL;
13364 bFromZ(1, 2)->outNL;
13365  
13366 wFromX(1, 0)->outNL;
13367 wFromZ(1, 1)->outNL;
13368 wFromZ(1, 2)->outNL;
13369  
13370 dFromX(1, 0)->outNL;
13371 dFromZ(1, 1)->outNL;
13372 dFromZ(1, 2)->outNL;
13373  
13374 qFromX(1, 0)->outNL;
13375 qFromZ(1, 1)->outNL;
13376 dFromZ(1, 2)->outNL;
13377  
13378 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
13379  
13380 Mov r15, 2;
13381 Kmovq k7, r15;
13382 LoadZmm 2, map {0xff} 1..64;
13383 PrintOutRegisterInHex zmm2;
13384 Vmovdqu8 zmmM (2, 7), zmm(1);
13385 Vmovdqu8 zmmMZ(3, 7), zmm(1);
13386 PrintOutRegisterInHex zmm1, zmm2, zmm3;
13387  
13388 ok Assemble eq => <<END;
13389 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
13390 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13391 r15: .... .... 1234 5678
13392 b at offset 0 in xmm1: .... .... .... ..78
13393 b at offset 0 in zmm1: .... .... .... ..78
13394 r14: .... .... 3456 78..
13395 r14: .... .... 3456 78..
13396 b at offset 0 in xmm1: .... .... .... ..78
13397 b at offset 1 in zmm1: .... .... .... ..78
13398 b at offset 2 in zmm1: .... .... .... ...0
13399 w at offset 0 in xmm1: .... .... .... 7878
13400 w at offset 1 in zmm1: .... .... .... ..78
13401 w at offset 2 in zmm1: .... .... .... ...0
13402 d at offset 0 in xmm1: .... .... .... 7878
13403 d at offset 1 in zmm1: .... .... 78.. ..78
13404 d at offset 2 in zmm1: .... .... 5678 ....
13405 q at offset 0 in xmm1: 1234 5678 .... 7878
13406 q at offset 1 in zmm1: 7812 3456 78.. ..78
13407 d at offset 2 in zmm1: .... .... 5678 ....
13408 d: .... .... .... ...0
13409 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
13410 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13411 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
13412 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
13413 END
13414  
13415  
13416 =head4 dRegFromZmm($register, $zmm, $offset)
13417  
13418 Load the specified register from the double word at the specified offset located in the numbered zmm.
13419  
13420 Parameter Description
13421 1 $register Register to load
13422 2 $zmm Numbered zmm register to load from
13423 3 $offset Constant offset in bytes
13424  
13425 B<Example:>
13426  
13427  
13428 Mov r15, 0x12345678;
13429 bRegIntoZmm(r15, 1, 0);
13430 bRegIntoZmm(r15, 1, 1);
13431 dRegIntoZmm(r15, 1, 4);
13432 dRegIntoZmm(r15, 1, 8);
13433 dRegIntoZmm(r15, 1, 12);
13434 PrintOutRegisterInHex xmm(1);
13435 PrintOutRegisterInHex zmm(1);
13436  
13437 bRegFromZmm(r15, 1, 1);
13438 PrintOutRegisterInHex r15;
13439  
13440 bFromX(1, 0)->outNL;
13441 bFromZ(1, 0)->outNL;
13442  
13443  
13444 dRegFromZmm(r14, 1, 3); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13445  
13446 PrintOutRegisterInHex r14;
13447  
13448 wRegFromZmm(r14, 1, 3);
13449 PrintOutRegisterInHex r14;
13450  
13451 bFromX(1, 0)->outNL;
13452 bFromZ(1, 1)->outNL;
13453 bFromZ(1, 2)->outNL;
13454  
13455 wFromX(1, 0)->outNL;
13456 wFromZ(1, 1)->outNL;
13457 wFromZ(1, 2)->outNL;
13458  
13459 dFromX(1, 0)->outNL;
13460 dFromZ(1, 1)->outNL;
13461 dFromZ(1, 2)->outNL;
13462  
13463 qFromX(1, 0)->outNL;
13464 qFromZ(1, 1)->outNL;
13465 dFromZ(1, 2)->outNL;
13466  
13467 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
13468  
13469 Mov r15, 2;
13470 Kmovq k7, r15;
13471 LoadZmm 2, map {0xff} 1..64;
13472 PrintOutRegisterInHex zmm2;
13473 Vmovdqu8 zmmM (2, 7), zmm(1);
13474 Vmovdqu8 zmmMZ(3, 7), zmm(1);
13475 PrintOutRegisterInHex zmm1, zmm2, zmm3;
13476  
13477 ok Assemble eq => <<END;
13478 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
13479 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13480 r15: .... .... 1234 5678
13481 b at offset 0 in xmm1: .... .... .... ..78
13482 b at offset 0 in zmm1: .... .... .... ..78
13483 r14: .... .... 3456 78..
13484 r14: .... .... 3456 78..
13485 b at offset 0 in xmm1: .... .... .... ..78
13486 b at offset 1 in zmm1: .... .... .... ..78
13487 b at offset 2 in zmm1: .... .... .... ...0
13488 w at offset 0 in xmm1: .... .... .... 7878
13489 w at offset 1 in zmm1: .... .... .... ..78
13490 w at offset 2 in zmm1: .... .... .... ...0
13491 d at offset 0 in xmm1: .... .... .... 7878
13492 d at offset 1 in zmm1: .... .... 78.. ..78
13493 d at offset 2 in zmm1: .... .... 5678 ....
13494 q at offset 0 in xmm1: 1234 5678 .... 7878
13495 q at offset 1 in zmm1: 7812 3456 78.. ..78
13496 d at offset 2 in zmm1: .... .... 5678 ....
13497 d: .... .... .... ...0
13498 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
13499 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13500 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
13501 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
13502 END
13503  
13504  
13505 =head4 dRegIntoZmm($register, $zmm, $offset)
13506  
13507 Put the specified register into the double word in the numbered zmm at the specified offset in the zmm.
13508  
13509 Parameter Description
13510 1 $register Register to load
13511 2 $zmm Numbered zmm register to load from
13512 3 $offset Constant offset in bytes
13513  
13514 B<Example:>
13515  
13516  
13517 Mov r15, 0x12345678;
13518 bRegIntoZmm(r15, 1, 0);
13519 bRegIntoZmm(r15, 1, 1);
13520  
13521 dRegIntoZmm(r15, 1, 4); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13522  
13523  
13524 dRegIntoZmm(r15, 1, 8); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13525  
13526  
13527 dRegIntoZmm(r15, 1, 12); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13528  
13529 PrintOutRegisterInHex xmm(1);
13530 PrintOutRegisterInHex zmm(1);
13531  
13532 bRegFromZmm(r15, 1, 1);
13533 PrintOutRegisterInHex r15;
13534  
13535 bFromX(1, 0)->outNL;
13536 bFromZ(1, 0)->outNL;
13537  
13538 dRegFromZmm(r14, 1, 3);
13539 PrintOutRegisterInHex r14;
13540  
13541 wRegFromZmm(r14, 1, 3);
13542 PrintOutRegisterInHex r14;
13543  
13544 bFromX(1, 0)->outNL;
13545 bFromZ(1, 1)->outNL;
13546 bFromZ(1, 2)->outNL;
13547  
13548 wFromX(1, 0)->outNL;
13549 wFromZ(1, 1)->outNL;
13550 wFromZ(1, 2)->outNL;
13551  
13552 dFromX(1, 0)->outNL;
13553 dFromZ(1, 1)->outNL;
13554 dFromZ(1, 2)->outNL;
13555  
13556 qFromX(1, 0)->outNL;
13557 qFromZ(1, 1)->outNL;
13558 dFromZ(1, 2)->outNL;
13559  
13560 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
13561  
13562 Mov r15, 2;
13563 Kmovq k7, r15;
13564 LoadZmm 2, map {0xff} 1..64;
13565 PrintOutRegisterInHex zmm2;
13566 Vmovdqu8 zmmM (2, 7), zmm(1);
13567 Vmovdqu8 zmmMZ(3, 7), zmm(1);
13568 PrintOutRegisterInHex zmm1, zmm2, zmm3;
13569  
13570 ok Assemble eq => <<END;
13571 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
13572 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13573 r15: .... .... 1234 5678
13574 b at offset 0 in xmm1: .... .... .... ..78
13575 b at offset 0 in zmm1: .... .... .... ..78
13576 r14: .... .... 3456 78..
13577 r14: .... .... 3456 78..
13578 b at offset 0 in xmm1: .... .... .... ..78
13579 b at offset 1 in zmm1: .... .... .... ..78
13580 b at offset 2 in zmm1: .... .... .... ...0
13581 w at offset 0 in xmm1: .... .... .... 7878
13582 w at offset 1 in zmm1: .... .... .... ..78
13583 w at offset 2 in zmm1: .... .... .... ...0
13584 d at offset 0 in xmm1: .... .... .... 7878
13585 d at offset 1 in zmm1: .... .... 78.. ..78
13586 d at offset 2 in zmm1: .... .... 5678 ....
13587 q at offset 0 in xmm1: 1234 5678 .... 7878
13588 q at offset 1 in zmm1: 7812 3456 78.. ..78
13589 d at offset 2 in zmm1: .... .... 5678 ....
13590 d: .... .... .... ...0
13591 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
13592 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13593 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
13594 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
13595 END
13596  
13597  
13598 =head4 SaveRegIntoMm($mm, $offset, $reg)
13599  
13600 Save the specified register into the numbered zmm at the quad offset specified as a constant number.
13601  
13602 Parameter Description
13603 1 $mm Mm register
13604 2 $offset Offset in quads
13605 3 $reg General purpose register to load
13606  
13607 B<Example:>
13608  
13609  
13610  
13611 Mov rax, 1; SaveRegIntoMm(zmm0, 0, rax); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13612  
13613  
13614 Mov rax, 2; SaveRegIntoMm(zmm0, 1, rax); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13615  
13616  
13617 Mov rax, 3; SaveRegIntoMm(zmm0, 2, rax); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13618  
13619  
13620 Mov rax, 4; SaveRegIntoMm(zmm0, 3, rax); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13621  
13622  
13623 LoadRegFromMm(zmm0, 0, r15);
13624 LoadRegFromMm(zmm0, 1, r14);
13625 LoadRegFromMm(zmm0, 2, r13);
13626 LoadRegFromMm(zmm0, 3, r12);
13627  
13628 PrintOutRegisterInHex ymm0, r15, r14, r13, r12;
13629 ok Assemble(debug => 0, eq => <<END, avx512=>1);
13630 ymm0: .... .... .... ...4 .... .... .... ...3 - .... .... .... ...2 .... .... .... ...1
13631 r15: .... .... .... ...1
13632 r14: .... .... .... ...2
13633 r13: .... .... .... ...3
13634 r12: .... .... .... ...4
13635 END
13636  
13637  
13638 =head3 Via variables
13639  
13640 Load zmm registers from data held in variables
13641  
13642 =head4 bFromX($xmm, $offset)
13643  
13644 Get the byte from the numbered xmm register and return it in a variable.
13645  
13646 Parameter Description
13647 1 $xmm Numbered xmm
13648 2 $offset Offset in bytes
13649  
13650 B<Example:>
13651  
13652  
13653 Mov r15, 0x12345678;
13654 bRegIntoZmm(r15, 1, 0);
13655 bRegIntoZmm(r15, 1, 1);
13656 dRegIntoZmm(r15, 1, 4);
13657 dRegIntoZmm(r15, 1, 8);
13658 dRegIntoZmm(r15, 1, 12);
13659 PrintOutRegisterInHex xmm(1);
13660 PrintOutRegisterInHex zmm(1);
13661  
13662 bRegFromZmm(r15, 1, 1);
13663 PrintOutRegisterInHex r15;
13664  
13665  
13666 bFromX(1, 0)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13667  
13668 bFromZ(1, 0)->outNL;
13669  
13670 dRegFromZmm(r14, 1, 3);
13671 PrintOutRegisterInHex r14;
13672  
13673 wRegFromZmm(r14, 1, 3);
13674 PrintOutRegisterInHex r14;
13675  
13676  
13677 bFromX(1, 0)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13678  
13679 bFromZ(1, 1)->outNL;
13680 bFromZ(1, 2)->outNL;
13681  
13682 wFromX(1, 0)->outNL;
13683 wFromZ(1, 1)->outNL;
13684 wFromZ(1, 2)->outNL;
13685  
13686 dFromX(1, 0)->outNL;
13687 dFromZ(1, 1)->outNL;
13688 dFromZ(1, 2)->outNL;
13689  
13690 qFromX(1, 0)->outNL;
13691 qFromZ(1, 1)->outNL;
13692 dFromZ(1, 2)->outNL;
13693  
13694 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
13695  
13696 Mov r15, 2;
13697 Kmovq k7, r15;
13698 LoadZmm 2, map {0xff} 1..64;
13699 PrintOutRegisterInHex zmm2;
13700 Vmovdqu8 zmmM (2, 7), zmm(1);
13701 Vmovdqu8 zmmMZ(3, 7), zmm(1);
13702 PrintOutRegisterInHex zmm1, zmm2, zmm3;
13703  
13704 ok Assemble eq => <<END;
13705 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
13706 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13707 r15: .... .... 1234 5678
13708 b at offset 0 in xmm1: .... .... .... ..78
13709 b at offset 0 in zmm1: .... .... .... ..78
13710 r14: .... .... 3456 78..
13711 r14: .... .... 3456 78..
13712 b at offset 0 in xmm1: .... .... .... ..78
13713 b at offset 1 in zmm1: .... .... .... ..78
13714 b at offset 2 in zmm1: .... .... .... ...0
13715 w at offset 0 in xmm1: .... .... .... 7878
13716 w at offset 1 in zmm1: .... .... .... ..78
13717 w at offset 2 in zmm1: .... .... .... ...0
13718 d at offset 0 in xmm1: .... .... .... 7878
13719 d at offset 1 in zmm1: .... .... 78.. ..78
13720 d at offset 2 in zmm1: .... .... 5678 ....
13721 q at offset 0 in xmm1: 1234 5678 .... 7878
13722 q at offset 1 in zmm1: 7812 3456 78.. ..78
13723 d at offset 2 in zmm1: .... .... 5678 ....
13724 d: .... .... .... ...0
13725 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
13726 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13727 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
13728 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
13729 END
13730  
13731  
13732 =head4 wFromX($xmm, $offset)
13733  
13734 Get the word from the numbered xmm register and return it in a variable.
13735  
13736 Parameter Description
13737 1 $xmm Numbered xmm
13738 2 $offset Offset in bytes
13739  
13740 B<Example:>
13741  
13742  
13743 Mov r15, 0x12345678;
13744 bRegIntoZmm(r15, 1, 0);
13745 bRegIntoZmm(r15, 1, 1);
13746 dRegIntoZmm(r15, 1, 4);
13747 dRegIntoZmm(r15, 1, 8);
13748 dRegIntoZmm(r15, 1, 12);
13749 PrintOutRegisterInHex xmm(1);
13750 PrintOutRegisterInHex zmm(1);
13751  
13752 bRegFromZmm(r15, 1, 1);
13753 PrintOutRegisterInHex r15;
13754  
13755 bFromX(1, 0)->outNL;
13756 bFromZ(1, 0)->outNL;
13757  
13758 dRegFromZmm(r14, 1, 3);
13759 PrintOutRegisterInHex r14;
13760  
13761 wRegFromZmm(r14, 1, 3);
13762 PrintOutRegisterInHex r14;
13763  
13764 bFromX(1, 0)->outNL;
13765 bFromZ(1, 1)->outNL;
13766 bFromZ(1, 2)->outNL;
13767  
13768  
13769 wFromX(1, 0)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13770  
13771 wFromZ(1, 1)->outNL;
13772 wFromZ(1, 2)->outNL;
13773  
13774 dFromX(1, 0)->outNL;
13775 dFromZ(1, 1)->outNL;
13776 dFromZ(1, 2)->outNL;
13777  
13778 qFromX(1, 0)->outNL;
13779 qFromZ(1, 1)->outNL;
13780 dFromZ(1, 2)->outNL;
13781  
13782 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
13783  
13784 Mov r15, 2;
13785 Kmovq k7, r15;
13786 LoadZmm 2, map {0xff} 1..64;
13787 PrintOutRegisterInHex zmm2;
13788 Vmovdqu8 zmmM (2, 7), zmm(1);
13789 Vmovdqu8 zmmMZ(3, 7), zmm(1);
13790 PrintOutRegisterInHex zmm1, zmm2, zmm3;
13791  
13792 ok Assemble eq => <<END;
13793 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
13794 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13795 r15: .... .... 1234 5678
13796 b at offset 0 in xmm1: .... .... .... ..78
13797 b at offset 0 in zmm1: .... .... .... ..78
13798 r14: .... .... 3456 78..
13799 r14: .... .... 3456 78..
13800 b at offset 0 in xmm1: .... .... .... ..78
13801 b at offset 1 in zmm1: .... .... .... ..78
13802 b at offset 2 in zmm1: .... .... .... ...0
13803 w at offset 0 in xmm1: .... .... .... 7878
13804 w at offset 1 in zmm1: .... .... .... ..78
13805 w at offset 2 in zmm1: .... .... .... ...0
13806 d at offset 0 in xmm1: .... .... .... 7878
13807 d at offset 1 in zmm1: .... .... 78.. ..78
13808 d at offset 2 in zmm1: .... .... 5678 ....
13809 q at offset 0 in xmm1: 1234 5678 .... 7878
13810 q at offset 1 in zmm1: 7812 3456 78.. ..78
13811 d at offset 2 in zmm1: .... .... 5678 ....
13812 d: .... .... .... ...0
13813 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
13814 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13815 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
13816 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
13817 END
13818  
13819  
13820 =head4 dFromX($xmm, $offset)
13821  
13822 Get the double word from the numbered xmm register and return it in a variable.
13823  
13824 Parameter Description
13825 1 $xmm Numbered xmm
13826 2 $offset Offset in bytes
13827  
13828 B<Example:>
13829  
13830  
13831 Mov r15, 0x12345678;
13832 bRegIntoZmm(r15, 1, 0);
13833 bRegIntoZmm(r15, 1, 1);
13834 dRegIntoZmm(r15, 1, 4);
13835 dRegIntoZmm(r15, 1, 8);
13836 dRegIntoZmm(r15, 1, 12);
13837 PrintOutRegisterInHex xmm(1);
13838 PrintOutRegisterInHex zmm(1);
13839  
13840 bRegFromZmm(r15, 1, 1);
13841 PrintOutRegisterInHex r15;
13842  
13843 bFromX(1, 0)->outNL;
13844 bFromZ(1, 0)->outNL;
13845  
13846 dRegFromZmm(r14, 1, 3);
13847 PrintOutRegisterInHex r14;
13848  
13849 wRegFromZmm(r14, 1, 3);
13850 PrintOutRegisterInHex r14;
13851  
13852 bFromX(1, 0)->outNL;
13853 bFromZ(1, 1)->outNL;
13854 bFromZ(1, 2)->outNL;
13855  
13856 wFromX(1, 0)->outNL;
13857 wFromZ(1, 1)->outNL;
13858 wFromZ(1, 2)->outNL;
13859  
13860  
13861 dFromX(1, 0)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13862  
13863 dFromZ(1, 1)->outNL;
13864 dFromZ(1, 2)->outNL;
13865  
13866 qFromX(1, 0)->outNL;
13867 qFromZ(1, 1)->outNL;
13868 dFromZ(1, 2)->outNL;
13869  
13870 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
13871  
13872 Mov r15, 2;
13873 Kmovq k7, r15;
13874 LoadZmm 2, map {0xff} 1..64;
13875 PrintOutRegisterInHex zmm2;
13876 Vmovdqu8 zmmM (2, 7), zmm(1);
13877 Vmovdqu8 zmmMZ(3, 7), zmm(1);
13878 PrintOutRegisterInHex zmm1, zmm2, zmm3;
13879  
13880 ok Assemble eq => <<END;
13881 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
13882 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13883 r15: .... .... 1234 5678
13884 b at offset 0 in xmm1: .... .... .... ..78
13885 b at offset 0 in zmm1: .... .... .... ..78
13886 r14: .... .... 3456 78..
13887 r14: .... .... 3456 78..
13888 b at offset 0 in xmm1: .... .... .... ..78
13889 b at offset 1 in zmm1: .... .... .... ..78
13890 b at offset 2 in zmm1: .... .... .... ...0
13891 w at offset 0 in xmm1: .... .... .... 7878
13892 w at offset 1 in zmm1: .... .... .... ..78
13893 w at offset 2 in zmm1: .... .... .... ...0
13894 d at offset 0 in xmm1: .... .... .... 7878
13895 d at offset 1 in zmm1: .... .... 78.. ..78
13896 d at offset 2 in zmm1: .... .... 5678 ....
13897 q at offset 0 in xmm1: 1234 5678 .... 7878
13898 q at offset 1 in zmm1: 7812 3456 78.. ..78
13899 d at offset 2 in zmm1: .... .... 5678 ....
13900 d: .... .... .... ...0
13901 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
13902 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13903 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
13904 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
13905 END
13906  
13907  
13908 =head4 qFromX($xmm, $offset)
13909  
13910 Get the quad word from the numbered xmm register and return it in a variable.
13911  
13912 Parameter Description
13913 1 $xmm Numbered xmm
13914 2 $offset Offset in bytes
13915  
13916 B<Example:>
13917  
13918  
13919 Mov r15, 0x12345678;
13920 bRegIntoZmm(r15, 1, 0);
13921 bRegIntoZmm(r15, 1, 1);
13922 dRegIntoZmm(r15, 1, 4);
13923 dRegIntoZmm(r15, 1, 8);
13924 dRegIntoZmm(r15, 1, 12);
13925 PrintOutRegisterInHex xmm(1);
13926 PrintOutRegisterInHex zmm(1);
13927  
13928 bRegFromZmm(r15, 1, 1);
13929 PrintOutRegisterInHex r15;
13930  
13931 bFromX(1, 0)->outNL;
13932 bFromZ(1, 0)->outNL;
13933  
13934 dRegFromZmm(r14, 1, 3);
13935 PrintOutRegisterInHex r14;
13936  
13937 wRegFromZmm(r14, 1, 3);
13938 PrintOutRegisterInHex r14;
13939  
13940 bFromX(1, 0)->outNL;
13941 bFromZ(1, 1)->outNL;
13942 bFromZ(1, 2)->outNL;
13943  
13944 wFromX(1, 0)->outNL;
13945 wFromZ(1, 1)->outNL;
13946 wFromZ(1, 2)->outNL;
13947  
13948 dFromX(1, 0)->outNL;
13949 dFromZ(1, 1)->outNL;
13950 dFromZ(1, 2)->outNL;
13951  
13952  
13953 qFromX(1, 0)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
13954  
13955 qFromZ(1, 1)->outNL;
13956 dFromZ(1, 2)->outNL;
13957  
13958 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
13959  
13960 Mov r15, 2;
13961 Kmovq k7, r15;
13962 LoadZmm 2, map {0xff} 1..64;
13963 PrintOutRegisterInHex zmm2;
13964 Vmovdqu8 zmmM (2, 7), zmm(1);
13965 Vmovdqu8 zmmMZ(3, 7), zmm(1);
13966 PrintOutRegisterInHex zmm1, zmm2, zmm3;
13967  
13968 ok Assemble eq => <<END;
13969 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
13970 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13971 r15: .... .... 1234 5678
13972 b at offset 0 in xmm1: .... .... .... ..78
13973 b at offset 0 in zmm1: .... .... .... ..78
13974 r14: .... .... 3456 78..
13975 r14: .... .... 3456 78..
13976 b at offset 0 in xmm1: .... .... .... ..78
13977 b at offset 1 in zmm1: .... .... .... ..78
13978 b at offset 2 in zmm1: .... .... .... ...0
13979 w at offset 0 in xmm1: .... .... .... 7878
13980 w at offset 1 in zmm1: .... .... .... ..78
13981 w at offset 2 in zmm1: .... .... .... ...0
13982 d at offset 0 in xmm1: .... .... .... 7878
13983 d at offset 1 in zmm1: .... .... 78.. ..78
13984 d at offset 2 in zmm1: .... .... 5678 ....
13985 q at offset 0 in xmm1: 1234 5678 .... 7878
13986 q at offset 1 in zmm1: 7812 3456 78.. ..78
13987 d at offset 2 in zmm1: .... .... 5678 ....
13988 d: .... .... .... ...0
13989 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
13990 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
13991 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
13992 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
13993 END
13994  
13995  
13996 =head4 bFromZ($zmm, $offset, %options)
13997  
13998 Get the byte from the numbered zmm register and return it in a variable.
13999  
14000 Parameter Description
14001 1 $zmm Numbered zmm
14002 2 $offset Offset in bytes
14003 3 %options Options
14004  
14005 B<Example:>
14006  
14007  
14008 Mov r15, 0x12345678;
14009 bRegIntoZmm(r15, 1, 0);
14010 bRegIntoZmm(r15, 1, 1);
14011 dRegIntoZmm(r15, 1, 4);
14012 dRegIntoZmm(r15, 1, 8);
14013 dRegIntoZmm(r15, 1, 12);
14014 PrintOutRegisterInHex xmm(1);
14015 PrintOutRegisterInHex zmm(1);
14016  
14017 bRegFromZmm(r15, 1, 1);
14018 PrintOutRegisterInHex r15;
14019  
14020 bFromX(1, 0)->outNL;
14021  
14022 bFromZ(1, 0)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14023  
14024  
14025 dRegFromZmm(r14, 1, 3);
14026 PrintOutRegisterInHex r14;
14027  
14028 wRegFromZmm(r14, 1, 3);
14029 PrintOutRegisterInHex r14;
14030  
14031 bFromX(1, 0)->outNL;
14032  
14033 bFromZ(1, 1)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14034  
14035  
14036 bFromZ(1, 2)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14037  
14038  
14039 wFromX(1, 0)->outNL;
14040 wFromZ(1, 1)->outNL;
14041 wFromZ(1, 2)->outNL;
14042  
14043 dFromX(1, 0)->outNL;
14044 dFromZ(1, 1)->outNL;
14045 dFromZ(1, 2)->outNL;
14046  
14047 qFromX(1, 0)->outNL;
14048 qFromZ(1, 1)->outNL;
14049 dFromZ(1, 2)->outNL;
14050  
14051 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
14052  
14053 Mov r15, 2;
14054 Kmovq k7, r15;
14055 LoadZmm 2, map {0xff} 1..64;
14056 PrintOutRegisterInHex zmm2;
14057 Vmovdqu8 zmmM (2, 7), zmm(1);
14058 Vmovdqu8 zmmMZ(3, 7), zmm(1);
14059 PrintOutRegisterInHex zmm1, zmm2, zmm3;
14060  
14061 ok Assemble eq => <<END;
14062 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
14063 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
14064 r15: .... .... 1234 5678
14065 b at offset 0 in xmm1: .... .... .... ..78
14066 b at offset 0 in zmm1: .... .... .... ..78
14067 r14: .... .... 3456 78..
14068 r14: .... .... 3456 78..
14069 b at offset 0 in xmm1: .... .... .... ..78
14070 b at offset 1 in zmm1: .... .... .... ..78
14071 b at offset 2 in zmm1: .... .... .... ...0
14072 w at offset 0 in xmm1: .... .... .... 7878
14073 w at offset 1 in zmm1: .... .... .... ..78
14074 w at offset 2 in zmm1: .... .... .... ...0
14075 d at offset 0 in xmm1: .... .... .... 7878
14076 d at offset 1 in zmm1: .... .... 78.. ..78
14077 d at offset 2 in zmm1: .... .... 5678 ....
14078 q at offset 0 in xmm1: 1234 5678 .... 7878
14079 q at offset 1 in zmm1: 7812 3456 78.. ..78
14080 d at offset 2 in zmm1: .... .... 5678 ....
14081 d: .... .... .... ...0
14082 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
14083 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
14084 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
14085 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
14086 END
14087  
14088  
14089 =head4 wFromZ($zmm, $offset, %options)
14090  
14091 Get the word from the numbered zmm register and return it in a variable.
14092  
14093 Parameter Description
14094 1 $zmm Numbered zmm
14095 2 $offset Offset in bytes
14096 3 %options Options
14097  
14098 B<Example:>
14099  
14100  
14101 Mov r15, 0x12345678;
14102 bRegIntoZmm(r15, 1, 0);
14103 bRegIntoZmm(r15, 1, 1);
14104 dRegIntoZmm(r15, 1, 4);
14105 dRegIntoZmm(r15, 1, 8);
14106 dRegIntoZmm(r15, 1, 12);
14107 PrintOutRegisterInHex xmm(1);
14108 PrintOutRegisterInHex zmm(1);
14109  
14110 bRegFromZmm(r15, 1, 1);
14111 PrintOutRegisterInHex r15;
14112  
14113 bFromX(1, 0)->outNL;
14114 bFromZ(1, 0)->outNL;
14115  
14116 dRegFromZmm(r14, 1, 3);
14117 PrintOutRegisterInHex r14;
14118  
14119 wRegFromZmm(r14, 1, 3);
14120 PrintOutRegisterInHex r14;
14121  
14122 bFromX(1, 0)->outNL;
14123 bFromZ(1, 1)->outNL;
14124 bFromZ(1, 2)->outNL;
14125  
14126 wFromX(1, 0)->outNL;
14127  
14128 wFromZ(1, 1)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14129  
14130  
14131 wFromZ(1, 2)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14132  
14133  
14134 dFromX(1, 0)->outNL;
14135 dFromZ(1, 1)->outNL;
14136 dFromZ(1, 2)->outNL;
14137  
14138 qFromX(1, 0)->outNL;
14139 qFromZ(1, 1)->outNL;
14140 dFromZ(1, 2)->outNL;
14141  
14142 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
14143  
14144 Mov r15, 2;
14145 Kmovq k7, r15;
14146 LoadZmm 2, map {0xff} 1..64;
14147 PrintOutRegisterInHex zmm2;
14148 Vmovdqu8 zmmM (2, 7), zmm(1);
14149 Vmovdqu8 zmmMZ(3, 7), zmm(1);
14150 PrintOutRegisterInHex zmm1, zmm2, zmm3;
14151  
14152 ok Assemble eq => <<END;
14153 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
14154 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
14155 r15: .... .... 1234 5678
14156 b at offset 0 in xmm1: .... .... .... ..78
14157 b at offset 0 in zmm1: .... .... .... ..78
14158 r14: .... .... 3456 78..
14159 r14: .... .... 3456 78..
14160 b at offset 0 in xmm1: .... .... .... ..78
14161 b at offset 1 in zmm1: .... .... .... ..78
14162 b at offset 2 in zmm1: .... .... .... ...0
14163 w at offset 0 in xmm1: .... .... .... 7878
14164 w at offset 1 in zmm1: .... .... .... ..78
14165 w at offset 2 in zmm1: .... .... .... ...0
14166 d at offset 0 in xmm1: .... .... .... 7878
14167 d at offset 1 in zmm1: .... .... 78.. ..78
14168 d at offset 2 in zmm1: .... .... 5678 ....
14169 q at offset 0 in xmm1: 1234 5678 .... 7878
14170 q at offset 1 in zmm1: 7812 3456 78.. ..78
14171 d at offset 2 in zmm1: .... .... 5678 ....
14172 d: .... .... .... ...0
14173 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
14174 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
14175 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
14176 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
14177 END
14178  
14179  
14180 =head4 dFromZ($zmm, $offset, %options)
14181  
14182 Get the double word from the numbered zmm register and return it in a variable.
14183  
14184 Parameter Description
14185 1 $zmm Numbered zmm
14186 2 $offset Offset in bytes
14187 3 %options Options
14188  
14189 B<Example:>
14190  
14191  
14192 Mov r15, 0x12345678;
14193 bRegIntoZmm(r15, 1, 0);
14194 bRegIntoZmm(r15, 1, 1);
14195 dRegIntoZmm(r15, 1, 4);
14196 dRegIntoZmm(r15, 1, 8);
14197 dRegIntoZmm(r15, 1, 12);
14198 PrintOutRegisterInHex xmm(1);
14199 PrintOutRegisterInHex zmm(1);
14200  
14201 bRegFromZmm(r15, 1, 1);
14202 PrintOutRegisterInHex r15;
14203  
14204 bFromX(1, 0)->outNL;
14205 bFromZ(1, 0)->outNL;
14206  
14207 dRegFromZmm(r14, 1, 3);
14208 PrintOutRegisterInHex r14;
14209  
14210 wRegFromZmm(r14, 1, 3);
14211 PrintOutRegisterInHex r14;
14212  
14213 bFromX(1, 0)->outNL;
14214 bFromZ(1, 1)->outNL;
14215 bFromZ(1, 2)->outNL;
14216  
14217 wFromX(1, 0)->outNL;
14218 wFromZ(1, 1)->outNL;
14219 wFromZ(1, 2)->outNL;
14220  
14221 dFromX(1, 0)->outNL;
14222  
14223 dFromZ(1, 1)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14224  
14225  
14226 dFromZ(1, 2)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14227  
14228  
14229 qFromX(1, 0)->outNL;
14230 qFromZ(1, 1)->outNL;
14231  
14232 dFromZ(1, 2)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14233  
14234  
14235 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
14236  
14237 Mov r15, 2;
14238 Kmovq k7, r15;
14239 LoadZmm 2, map {0xff} 1..64;
14240 PrintOutRegisterInHex zmm2;
14241 Vmovdqu8 zmmM (2, 7), zmm(1);
14242 Vmovdqu8 zmmMZ(3, 7), zmm(1);
14243 PrintOutRegisterInHex zmm1, zmm2, zmm3;
14244  
14245 ok Assemble eq => <<END;
14246 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
14247 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
14248 r15: .... .... 1234 5678
14249 b at offset 0 in xmm1: .... .... .... ..78
14250 b at offset 0 in zmm1: .... .... .... ..78
14251 r14: .... .... 3456 78..
14252 r14: .... .... 3456 78..
14253 b at offset 0 in xmm1: .... .... .... ..78
14254 b at offset 1 in zmm1: .... .... .... ..78
14255 b at offset 2 in zmm1: .... .... .... ...0
14256 w at offset 0 in xmm1: .... .... .... 7878
14257 w at offset 1 in zmm1: .... .... .... ..78
14258 w at offset 2 in zmm1: .... .... .... ...0
14259 d at offset 0 in xmm1: .... .... .... 7878
14260 d at offset 1 in zmm1: .... .... 78.. ..78
14261 d at offset 2 in zmm1: .... .... 5678 ....
14262 q at offset 0 in xmm1: 1234 5678 .... 7878
14263 q at offset 1 in zmm1: 7812 3456 78.. ..78
14264 d at offset 2 in zmm1: .... .... 5678 ....
14265 d: .... .... .... ...0
14266 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
14267 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
14268 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
14269 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
14270 END
14271  
14272  
14273 =head4 qFromZ($zmm, $offset, %options)
14274  
14275 Get the quad word from the numbered zmm register and return it in a variable.
14276  
14277 Parameter Description
14278 1 $zmm Numbered zmm
14279 2 $offset Offset in bytes
14280 3 %options Options
14281  
14282 B<Example:>
14283  
14284  
14285 Mov r15, 0x12345678;
14286 bRegIntoZmm(r15, 1, 0);
14287 bRegIntoZmm(r15, 1, 1);
14288 dRegIntoZmm(r15, 1, 4);
14289 dRegIntoZmm(r15, 1, 8);
14290 dRegIntoZmm(r15, 1, 12);
14291 PrintOutRegisterInHex xmm(1);
14292 PrintOutRegisterInHex zmm(1);
14293  
14294 bRegFromZmm(r15, 1, 1);
14295 PrintOutRegisterInHex r15;
14296  
14297 bFromX(1, 0)->outNL;
14298 bFromZ(1, 0)->outNL;
14299  
14300 dRegFromZmm(r14, 1, 3);
14301 PrintOutRegisterInHex r14;
14302  
14303 wRegFromZmm(r14, 1, 3);
14304 PrintOutRegisterInHex r14;
14305  
14306 bFromX(1, 0)->outNL;
14307 bFromZ(1, 1)->outNL;
14308 bFromZ(1, 2)->outNL;
14309  
14310 wFromX(1, 0)->outNL;
14311 wFromZ(1, 1)->outNL;
14312 wFromZ(1, 2)->outNL;
14313  
14314 dFromX(1, 0)->outNL;
14315 dFromZ(1, 1)->outNL;
14316 dFromZ(1, 2)->outNL;
14317  
14318 qFromX(1, 0)->outNL;
14319  
14320 qFromZ(1, 1)->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14321  
14322 dFromZ(1, 2)->outNL;
14323  
14324 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL;
14325  
14326 Mov r15, 2;
14327 Kmovq k7, r15;
14328 LoadZmm 2, map {0xff} 1..64;
14329 PrintOutRegisterInHex zmm2;
14330 Vmovdqu8 zmmM (2, 7), zmm(1);
14331 Vmovdqu8 zmmMZ(3, 7), zmm(1);
14332 PrintOutRegisterInHex zmm1, zmm2, zmm3;
14333  
14334 ok Assemble eq => <<END;
14335 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
14336 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
14337 r15: .... .... 1234 5678
14338 b at offset 0 in xmm1: .... .... .... ..78
14339 b at offset 0 in zmm1: .... .... .... ..78
14340 r14: .... .... 3456 78..
14341 r14: .... .... 3456 78..
14342 b at offset 0 in xmm1: .... .... .... ..78
14343 b at offset 1 in zmm1: .... .... .... ..78
14344 b at offset 2 in zmm1: .... .... .... ...0
14345 w at offset 0 in xmm1: .... .... .... 7878
14346 w at offset 1 in zmm1: .... .... .... ..78
14347 w at offset 2 in zmm1: .... .... .... ...0
14348 d at offset 0 in xmm1: .... .... .... 7878
14349 d at offset 1 in zmm1: .... .... 78.. ..78
14350 d at offset 2 in zmm1: .... .... 5678 ....
14351 q at offset 0 in xmm1: 1234 5678 .... 7878
14352 q at offset 1 in zmm1: 7812 3456 78.. ..78
14353 d at offset 2 in zmm1: .... .... 5678 ....
14354 d: .... .... .... ...0
14355 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
14356 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
14357 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
14358 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
14359 END
14360  
14361  
14362 =head2 Mask
14363  
14364 Operations on mask registers
14365  
14366 =head3 SetMaskRegister($mask, $start, $length)
14367  
14368 Set the mask register to ones starting at the specified position for the specified length and zeroes elsewhere.
14369  
14370 Parameter Description
14371 1 $mask Number of mask register to set
14372 2 $start Register containing start position or 0 for position 0
14373 3 $length Register containing end position
14374  
14375 B<Example:>
14376  
14377  
14378 Mov rax, 8;
14379 Mov rsi, -1;
14380  
14381 Inc rsi; SetMaskRegister(0, rax, rsi); PrintOutRegisterInHex k0; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14382  
14383  
14384 Inc rsi; SetMaskRegister(1, rax, rsi); PrintOutRegisterInHex k1; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14385  
14386  
14387 Inc rsi; SetMaskRegister(2, rax, rsi); PrintOutRegisterInHex k2; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14388  
14389  
14390 Inc rsi; SetMaskRegister(3, rax, rsi); PrintOutRegisterInHex k3; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14391  
14392  
14393 Inc rsi; SetMaskRegister(4, rax, rsi); PrintOutRegisterInHex k4; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14394  
14395  
14396 Inc rsi; SetMaskRegister(5, rax, rsi); PrintOutRegisterInHex k5; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14397  
14398  
14399 Inc rsi; SetMaskRegister(6, rax, rsi); PrintOutRegisterInHex k6; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14400  
14401  
14402 Inc rsi; SetMaskRegister(7, rax, rsi); PrintOutRegisterInHex k7; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14403  
14404  
14405 ok Assemble eq => <<END;
14406 k0: .... .... .... ...0
14407 k1: .... .... .... .1..
14408 k2: .... .... .... .3..
14409 k3: .... .... .... .7..
14410 k4: .... .... .... .F..
14411 k5: .... .... .... 1F..
14412 k6: .... .... .... 3F..
14413 k7: .... .... .... 7F..
14414 END
14415  
14416  
14417 =head3 LoadBitsIntoMaskRegister($mask, $prefix, @values)
14418  
14419 Load a bit string specification into a mask register in two clocks.
14420  
14421 Parameter Description
14422 1 $mask Number of mask register to load
14423 2 $prefix Prefix bits
14424 3 @values +n 1 bits -n 0 bits
14425  
14426 B<Example:>
14427  
14428  
14429 for (0..7)
14430 {ClearRegisters "k$_";
14431 K($_,$_)->setMaskBit("k$_");
14432 PrintOutRegisterInHex "k$_";
14433 }
14434  
14435 ClearRegisters k7;
14436  
14437 LoadBitsIntoMaskRegister(7, '1010', -4, +4, -2, +2, -1, +1, -1, +1); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14438  
14439 PrintOutRegisterInHex "k7";
14440  
14441 ok Assemble(debug => 0, eq => <<END, avx512=>1);
14442 k0: .... .... .... ...1
14443 k1: .... .... .... ...2
14444 k2: .... .... .... ...4
14445 k3: .... .... .... ...8
14446 k4: .... .... .... ..10
14447 k5: .... .... .... ..20
14448 k6: .... .... .... ..40
14449 k7: .... .... .... ..80
14450 k7: .... .... ...A .F35
14451 END
14452  
14453  
14454 =head3 At a point
14455  
14456 Load data into a zmm register at the indoicated point and retrieve data fromn a zmm regisiter at the indicated ppint.
14457  
14458 =head4 InsertZeroIntoRegisterAtPoint($point, $in)
14459  
14460 Insert a zero into the specified register at the point indicated by another general purpose or mask register moving the higher bits one position to the left.
14461  
14462 Parameter Description
14463 1 $point Register with a single 1 at the insertion point
14464 2 $in Register to be inserted into.
14465  
14466 B<Example:>
14467  
14468  
14469 Mov r15, 0x100; # Given a register with a single one in it indicating the desired position,
14470 Mov r14, 0xFFDC; # Insert a zero into the register at that position shifting the bits above that position up left one to make space for the new zero.
14471 Mov r13, 0xF03F;
14472 PrintOutRegisterInHex r14, r15;
14473  
14474 InsertZeroIntoRegisterAtPoint r15, r14; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14475  
14476 PrintOutRegisterInHex r14;
14477 Or r14, r15; # Replace the inserted zero with a one
14478 PrintOutRegisterInHex r14;
14479 InsertOneIntoRegisterAtPoint r15, r13;
14480 PrintOutRegisterInHex r13;
14481 ok Assemble(debug => 0, eq => <<END, avx512=>0);
14482 r14: .... .... .... FFDC
14483 r15: .... .... .... .1..
14484 r14: .... .... ...1 FEDC
14485 r14: .... .... ...1 FFDC
14486 r13: .... .... ...1 E13F
14487 END
14488  
14489  
14490 =head4 InsertOneIntoRegisterAtPoint($point, $in)
14491  
14492 Insert a one into the specified register at the point indicated by another register.
14493  
14494 Parameter Description
14495 1 $point Register with a single 1 at the insertion point
14496 2 $in Register to be inserted into.
14497  
14498 B<Example:>
14499  
14500  
14501 Mov r15, 0x100; # Given a register with a single one in it indicating the desired position,
14502 Mov r14, 0xFFDC; # Insert a zero into the register at that position shifting the bits above that position up left one to make space for the new zero.
14503 Mov r13, 0xF03F;
14504 PrintOutRegisterInHex r14, r15;
14505 InsertZeroIntoRegisterAtPoint r15, r14;
14506 PrintOutRegisterInHex r14;
14507 Or r14, r15; # Replace the inserted zero with a one
14508 PrintOutRegisterInHex r14;
14509  
14510 InsertOneIntoRegisterAtPoint r15, r13; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14511  
14512 PrintOutRegisterInHex r13;
14513 ok Assemble(debug => 0, eq => <<END, avx512=>0);
14514 r14: .... .... .... FFDC
14515 r15: .... .... .... .1..
14516 r14: .... .... ...1 FEDC
14517 r14: .... .... ...1 FFDC
14518 r13: .... .... ...1 E13F
14519 END
14520  
14521  
14522 =head1 Comparison codes
14523  
14524 The codes used to specify what sort of comparison to perform
14525  
14526 =head1 Structured Programming
14527  
14528 Structured programming constructs
14529  
14530 =head2 If
14531  
14532 If statements
14533  
14534 =head3 If($jump, $then, $else)
14535  
14536 If statement.
14537  
14538 Parameter Description
14539 1 $jump Jump op code of variable
14540 2 $then Then - required
14541 3 $else Else - optional
14542  
14543 B<Example:>
14544  
14545  
14546 my $n0 = K(zero => 0);
14547  
14548 If $n0 == 0, # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14549  
14550 Then
14551 {PrintOutStringNL "zero == 0";
14552 },
14553 Ef {$n0 == 1}
14554 Then
14555 {PrintOutStringNL "zero == 1";
14556 },
14557 Else
14558 {PrintOutStringNL "zero == 2";
14559 };
14560  
14561 my $n1 = K(one => 1);
14562  
14563 If $n1 == 0, # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14564  
14565 Then
14566 {PrintOutStringNL "one == 0";
14567 },
14568 Ef {$n1 == 1}
14569 Then
14570 {PrintOutStringNL "one == 1";
14571 },
14572 Else
14573 {PrintOutStringNL "one == 2";
14574 };
14575  
14576 my $n2 = K(two => 2);
14577  
14578 If $n2 == 0, # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14579  
14580 Then
14581 {PrintOutStringNL "two == 0";
14582 },
14583 Ef {$n2 == 1}
14584 Then
14585 {PrintOutStringNL "two == 1";
14586 },
14587 Else
14588 {PrintOutStringNL "two == 2";
14589 };
14590  
14591 ok Assemble eq => <<END, avx512=>0;
14592 zero == 0
14593 one == 1
14594 two == 2
14595 END
14596  
14597 my $a = K(key => 1);
14598  
14599 If $a > 0, # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14600  
14601 Then {Mov rax, 1},
14602 Else {Mov rax, 2};
14603 PrintOutRegisterInHex rax;
14604  
14605 ok Assemble eq=><<END, avx512=>1;
14606 rax: .... .... .... ...1
14607 END
14608  
14609  
14610 =head3 Then($block)
14611  
14612 Then block for an If statement.
14613  
14614 Parameter Description
14615 1 $block Then block
14616  
14617 B<Example:>
14618  
14619  
14620 my $n0 = K(zero => 0);
14621 If $n0 == 0,
14622  
14623 Then # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14624  
14625 {PrintOutStringNL "zero == 0";
14626 },
14627 Ef {$n0 == 1}
14628  
14629 Then # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14630  
14631 {PrintOutStringNL "zero == 1";
14632 },
14633 Else
14634 {PrintOutStringNL "zero == 2";
14635 };
14636  
14637 my $n1 = K(one => 1);
14638 If $n1 == 0,
14639  
14640 Then # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14641  
14642 {PrintOutStringNL "one == 0";
14643 },
14644 Ef {$n1 == 1}
14645  
14646 Then # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14647  
14648 {PrintOutStringNL "one == 1";
14649 },
14650 Else
14651 {PrintOutStringNL "one == 2";
14652 };
14653  
14654 my $n2 = K(two => 2);
14655 If $n2 == 0,
14656  
14657 Then # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14658  
14659 {PrintOutStringNL "two == 0";
14660 },
14661 Ef {$n2 == 1}
14662  
14663 Then # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14664  
14665 {PrintOutStringNL "two == 1";
14666 },
14667 Else
14668 {PrintOutStringNL "two == 2";
14669 };
14670  
14671 ok Assemble eq => <<END, avx512=>0;
14672 zero == 0
14673 one == 1
14674 two == 2
14675 END
14676  
14677 my $a = K(key => 1);
14678 If $a > 0,
14679  
14680 Then {Mov rax, 1}, # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14681  
14682 Else {Mov rax, 2};
14683 PrintOutRegisterInHex rax;
14684  
14685 ok Assemble eq=><<END, avx512=>1;
14686 rax: .... .... .... ...1
14687 END
14688  
14689 PrintCString ($stdout, V(str => Rs("abc\0def")));
14690 PrintCStringNL($stdout, V(str => Rs("ABC\0DEF")));
14691 ok Assemble eq => <<END;
14692 abcABC
14693 END
14694  
14695 my $a = V(a => 3); $a->outNL;
14696 my $b = K(b => 2); $b->outNL;
14697 my $c = $a + $b; $c->outNL;
14698 my $d = $c - $a; $d->outNL;
14699 my $g = $a * $b; $g->outNL;
14700 my $h = $g / $b; $h->outNL;
14701 my $i = $a % $b; $i->outNL;
14702  
14703 If ($a == 3,
14704  
14705 Then # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14706  
14707 {PrintOutStringNL "a == 3"
14708 },
14709 Else
14710 {PrintOutStringNL "a != 3"
14711 });
14712  
14713 ++$a; $a->outNL;
14714 --$a; $a->outNL;
14715  
14716 ok Assemble eq => <<END, avx512=>0;
14717 a: .... .... .... ...3
14718 b: .... .... .... ...2
14719 (a add b): .... .... .... ...5
14720 ((a add b) sub a): .... .... .... ...2
14721 (a times b): .... .... .... ...6
14722 ((a times b) / b): .... .... .... ...3
14723 (a % b): .... .... .... ...1
14724 a == 3
14725 a: .... .... .... ...4
14726 a: .... .... .... ...3
14727 END
14728  
14729  
14730 =head3 Else($block)
14731  
14732 Else block for an If statement.
14733  
14734 Parameter Description
14735 1 $block Else block
14736  
14737 B<Example:>
14738  
14739  
14740 my $n0 = K(zero => 0);
14741 If $n0 == 0,
14742 Then
14743 {PrintOutStringNL "zero == 0";
14744 },
14745 Ef {$n0 == 1}
14746 Then
14747 {PrintOutStringNL "zero == 1";
14748 },
14749  
14750 Else # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14751  
14752 {PrintOutStringNL "zero == 2";
14753 };
14754  
14755 my $n1 = K(one => 1);
14756 If $n1 == 0,
14757 Then
14758 {PrintOutStringNL "one == 0";
14759 },
14760 Ef {$n1 == 1}
14761 Then
14762 {PrintOutStringNL "one == 1";
14763 },
14764  
14765 Else # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14766  
14767 {PrintOutStringNL "one == 2";
14768 };
14769  
14770 my $n2 = K(two => 2);
14771 If $n2 == 0,
14772 Then
14773 {PrintOutStringNL "two == 0";
14774 },
14775 Ef {$n2 == 1}
14776 Then
14777 {PrintOutStringNL "two == 1";
14778 },
14779  
14780 Else # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14781  
14782 {PrintOutStringNL "two == 2";
14783 };
14784  
14785 ok Assemble eq => <<END, avx512=>0;
14786 zero == 0
14787 one == 1
14788 two == 2
14789 END
14790  
14791 my $a = K(key => 1);
14792 If $a > 0,
14793 Then {Mov rax, 1},
14794  
14795 Else {Mov rax, 2}; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14796  
14797 PrintOutRegisterInHex rax;
14798  
14799 ok Assemble eq=><<END, avx512=>1;
14800 rax: .... .... .... ...1
14801 END
14802  
14803 PrintCString ($stdout, V(str => Rs("abc\0def")));
14804 PrintCStringNL($stdout, V(str => Rs("ABC\0DEF")));
14805 ok Assemble eq => <<END;
14806 abcABC
14807 END
14808  
14809 my $a = V(a => 3); $a->outNL;
14810 my $b = K(b => 2); $b->outNL;
14811 my $c = $a + $b; $c->outNL;
14812 my $d = $c - $a; $d->outNL;
14813 my $g = $a * $b; $g->outNL;
14814 my $h = $g / $b; $h->outNL;
14815 my $i = $a % $b; $i->outNL;
14816  
14817 If ($a == 3,
14818 Then
14819 {PrintOutStringNL "a == 3"
14820 },
14821  
14822 Else # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14823  
14824 {PrintOutStringNL "a != 3"
14825 });
14826  
14827 ++$a; $a->outNL;
14828 --$a; $a->outNL;
14829  
14830 ok Assemble eq => <<END, avx512=>0;
14831 a: .... .... .... ...3
14832 b: .... .... .... ...2
14833 (a add b): .... .... .... ...5
14834 ((a add b) sub a): .... .... .... ...2
14835 (a times b): .... .... .... ...6
14836 ((a times b) / b): .... .... .... ...3
14837 (a % b): .... .... .... ...1
14838 a == 3
14839 a: .... .... .... ...4
14840 a: .... .... .... ...3
14841 END
14842  
14843  
14844 =head3 ifOr($conditions, $Then, $Else)
14845  
14846 Execute then or else block based on a multiplicity of OR conditions executed until one succeeds.
14847  
14848 Parameter Description
14849 1 $conditions Array of conditions
14850 2 $Then Then sub
14851 3 $Else Else sub
14852  
14853 B<Example:>
14854  
14855  
14856 my $a = K key => 1;
14857 my $b = K key => 1;
14858  
14859  
14860 ifOr [sub{$a==$a}, sub{$a==$a}], # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14861  
14862 Then
14863 {PrintOutStringNL "AAAA11";
14864 },
14865 Else
14866 {PrintOutStringNL "AAAA22";
14867 };
14868  
14869  
14870 ifOr [sub{$a==$a}, sub{$a!=$a}], # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14871  
14872 Then
14873 {PrintOutStringNL "BBBB11";
14874 },
14875 Else
14876 {PrintOutStringNL "BBBB22";
14877 };
14878  
14879  
14880 ifOr [sub{$a!=$a}, sub{$a==$a}], # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14881  
14882 Then
14883 {PrintOutStringNL "CCCC11";
14884 },
14885 Else
14886 {PrintOutStringNL "CCCC22";
14887 };
14888  
14889  
14890 ifOr [sub{$a!=$b}, sub{$a!=$b}], # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14891  
14892 Then
14893 {PrintOutStringNL "DDDD11";
14894 },
14895 Else
14896 {PrintOutStringNL "DDDD22";
14897 };
14898  
14899 ok Assemble eq => <<END, avx512=>1;
14900 AAAA11
14901 BBBB11
14902 CCCC11
14903 DDDD22
14904 END
14905  
14906  
14907 =head3 ifAnd($conditions, $Then, $Else)
14908  
14909 Execute then or else block based on a multiplicity of AND conditions executed until one fails.
14910  
14911 Parameter Description
14912 1 $conditions Array of conditions
14913 2 $Then Then sub
14914 3 $Else Else sub
14915  
14916 B<Example:>
14917  
14918  
14919 #latest:
14920  
14921  
14922 =head3 Ef($condition, $then, $else)
14923  
14924 Else if block for an If statement.
14925  
14926 Parameter Description
14927 1 $condition Condition
14928 2 $then Then block
14929 3 $else Else block
14930  
14931 B<Example:>
14932  
14933  
14934 my $n0 = K(zero => 0);
14935 If $n0 == 0,
14936 Then
14937 {PrintOutStringNL "zero == 0";
14938 },
14939  
14940 Ef {$n0 == 1} # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14941  
14942 Then
14943 {PrintOutStringNL "zero == 1";
14944 },
14945 Else
14946 {PrintOutStringNL "zero == 2";
14947 };
14948  
14949 my $n1 = K(one => 1);
14950 If $n1 == 0,
14951 Then
14952 {PrintOutStringNL "one == 0";
14953 },
14954  
14955 Ef {$n1 == 1} # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14956  
14957 Then
14958 {PrintOutStringNL "one == 1";
14959 },
14960 Else
14961 {PrintOutStringNL "one == 2";
14962 };
14963  
14964 my $n2 = K(two => 2);
14965 If $n2 == 0,
14966 Then
14967 {PrintOutStringNL "two == 0";
14968 },
14969  
14970 Ef {$n2 == 1} # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
14971  
14972 Then
14973 {PrintOutStringNL "two == 1";
14974 },
14975 Else
14976 {PrintOutStringNL "two == 2";
14977 };
14978  
14979 ok Assemble eq => <<END, avx512=>0;
14980 zero == 0
14981 one == 1
14982 two == 2
14983 END
14984  
14985  
14986 =head3 Via flags
14987  
14988 If depending on the flags register.
14989  
14990 =head4 IfEq($then, $else)
14991  
14992 If equal execute the then block else the else block.
14993  
14994 Parameter Description
14995 1 $then Then - required
14996 2 $else Else - optional
14997  
14998 B<Example:>
14999  
15000  
15001 my $cmp = sub
15002 {my ($a, $b) = @_;
15003  
15004 for my $op(qw(eq ne lt le gt ge))
15005 {Mov rax, $a;
15006 Cmp rax, $b;
15007 my $Op = ucfirst $op;
15008 eval qq(If$Op Then {PrintOutStringNL("$a $op $b")}, Else {PrintOutStringNL("$a NOT $op $b")});
15009 $@ and confess $@;
15010 }
15011 };
15012 &$cmp(1,1);
15013 &$cmp(1,2);
15014 &$cmp(3,2);
15015 Assemble eq => <<END, avx512=>0;
15016 1 eq 1
15017 1 NOT ne 1
15018 1 NOT lt 1
15019 1 le 1
15020 1 NOT gt 1
15021 1 ge 1
15022 1 NOT eq 2
15023 1 ne 2
15024 1 lt 2
15025 1 le 2
15026 1 NOT gt 2
15027 1 NOT ge 2
15028 3 NOT eq 2
15029 3 ne 2
15030 3 NOT lt 2
15031 3 NOT le 2
15032 3 gt 2
15033 3 ge 2
15034 END
15035  
15036  
15037 =head4 IfNe($then, $else)
15038  
15039 If not equal execute the then block else the else block.
15040  
15041 Parameter Description
15042 1 $then Then - required
15043 2 $else Else - optional
15044  
15045 B<Example:>
15046  
15047  
15048 my $cmp = sub
15049 {my ($a, $b) = @_;
15050  
15051 for my $op(qw(eq ne lt le gt ge))
15052 {Mov rax, $a;
15053 Cmp rax, $b;
15054 my $Op = ucfirst $op;
15055 eval qq(If$Op Then {PrintOutStringNL("$a $op $b")}, Else {PrintOutStringNL("$a NOT $op $b")});
15056 $@ and confess $@;
15057 }
15058 };
15059 &$cmp(1,1);
15060 &$cmp(1,2);
15061 &$cmp(3,2);
15062 Assemble eq => <<END, avx512=>0;
15063 1 eq 1
15064 1 NOT ne 1
15065 1 NOT lt 1
15066 1 le 1
15067 1 NOT gt 1
15068 1 ge 1
15069 1 NOT eq 2
15070 1 ne 2
15071 1 lt 2
15072 1 le 2
15073 1 NOT gt 2
15074 1 NOT ge 2
15075 3 NOT eq 2
15076 3 ne 2
15077 3 NOT lt 2
15078 3 NOT le 2
15079 3 gt 2
15080 3 ge 2
15081 END
15082  
15083  
15084 =head4 IfNz($then, $else)
15085  
15086 If the zero flag is not set then execute the then block else the else block.
15087  
15088 Parameter Description
15089 1 $then Then - required
15090 2 $else Else - optional
15091  
15092 B<Example:>
15093  
15094  
15095 Mov rax, 0;
15096 Test rax,rax;
15097  
15098 IfNz # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15099  
15100 Then
15101 {PrintOutRegisterInHex rax;
15102 },
15103 Else
15104 {PrintOutRegisterInHex rbx;
15105 };
15106 Mov rax, 1;
15107 Test rax,rax;
15108  
15109 IfNz # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15110  
15111 Then
15112 {PrintOutRegisterInHex rcx;
15113 },
15114 Else
15115 {PrintOutRegisterInHex rdx;
15116 };
15117  
15118 ok Assemble(avx512=>0) =~ m(rbx.*rcx)s;
15119  
15120  
15121 =head4 IfZ($then, $else)
15122  
15123 If the zero flag is set then execute the then block else the else block.
15124  
15125 Parameter Description
15126 1 $then Then - required
15127 2 $else Else - optional
15128  
15129 B<Example:>
15130  
15131  
15132 SetZF;
15133 PrintOutZF;
15134 ClearZF;
15135 PrintOutZF;
15136 SetZF;
15137 PrintOutZF;
15138 SetZF;
15139 PrintOutZF;
15140 ClearZF;
15141 PrintOutZF;
15142  
15143 SetZF;
15144  
15145 IfZ Then {PrintOutStringNL "Zero"}, Else {PrintOutStringNL "NOT zero"}; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15146  
15147 ClearZF;
15148 IfNz Then {PrintOutStringNL "NOT zero"}, Else {PrintOutStringNL "Zero"};
15149  
15150 Mov r15, 5;
15151 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"};
15152 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"};
15153 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"};
15154 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"};
15155  
15156 ok Assemble eq => <<END, avx512=>0;
15157 ZF=1
15158 ZF=0
15159 ZF=1
15160 ZF=1
15161 ZF=0
15162 Zero
15163 NOT zero
15164 Carry
15165 NO carry
15166 Carry
15167 NO carry
15168 END
15169  
15170  
15171 =head4 IfC($then, $else)
15172  
15173 If the carry flag is set then execute the then block else the else block.
15174  
15175 Parameter Description
15176 1 $then Then - required
15177 2 $else Else - optional
15178  
15179 B<Example:>
15180  
15181  
15182 SetZF;
15183 PrintOutZF;
15184 ClearZF;
15185 PrintOutZF;
15186 SetZF;
15187 PrintOutZF;
15188 SetZF;
15189 PrintOutZF;
15190 ClearZF;
15191 PrintOutZF;
15192  
15193 SetZF;
15194 IfZ Then {PrintOutStringNL "Zero"}, Else {PrintOutStringNL "NOT zero"};
15195 ClearZF;
15196 IfNz Then {PrintOutStringNL "NOT zero"}, Else {PrintOutStringNL "Zero"};
15197  
15198 Mov r15, 5;
15199  
15200 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"}; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15201  
15202  
15203 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"}; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15204  
15205 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"};
15206 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"};
15207  
15208 ok Assemble eq => <<END, avx512=>0;
15209 ZF=1
15210 ZF=0
15211 ZF=1
15212 ZF=1
15213 ZF=0
15214 Zero
15215 NOT zero
15216 Carry
15217 NO carry
15218 Carry
15219 NO carry
15220 END
15221  
15222  
15223 =head4 IfNc($then, $else)
15224  
15225 If the carry flag is not set then execute the then block else the else block.
15226  
15227 Parameter Description
15228 1 $then Then - required
15229 2 $else Else - optional
15230  
15231 B<Example:>
15232  
15233  
15234 SetZF;
15235 PrintOutZF;
15236 ClearZF;
15237 PrintOutZF;
15238 SetZF;
15239 PrintOutZF;
15240 SetZF;
15241 PrintOutZF;
15242 ClearZF;
15243 PrintOutZF;
15244  
15245 SetZF;
15246 IfZ Then {PrintOutStringNL "Zero"}, Else {PrintOutStringNL "NOT zero"};
15247 ClearZF;
15248 IfNz Then {PrintOutStringNL "NOT zero"}, Else {PrintOutStringNL "Zero"};
15249  
15250 Mov r15, 5;
15251 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"};
15252 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"};
15253  
15254 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"}; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15255  
15256  
15257 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"}; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15258  
15259  
15260 ok Assemble eq => <<END, avx512=>0;
15261 ZF=1
15262 ZF=0
15263 ZF=1
15264 ZF=1
15265 ZF=0
15266 Zero
15267 NOT zero
15268 Carry
15269 NO carry
15270 Carry
15271 NO carry
15272 END
15273  
15274  
15275 =head4 IfLt($then, $else)
15276  
15277 If less than execute the then block else the else block.
15278  
15279 Parameter Description
15280 1 $then Then - required
15281 2 $else Else - optional
15282  
15283 B<Example:>
15284  
15285  
15286 my $cmp = sub
15287 {my ($a, $b) = @_;
15288  
15289 for my $op(qw(eq ne lt le gt ge))
15290 {Mov rax, $a;
15291 Cmp rax, $b;
15292 my $Op = ucfirst $op;
15293 eval qq(If$Op Then {PrintOutStringNL("$a $op $b")}, Else {PrintOutStringNL("$a NOT $op $b")});
15294 $@ and confess $@;
15295 }
15296 };
15297 &$cmp(1,1);
15298 &$cmp(1,2);
15299 &$cmp(3,2);
15300 Assemble eq => <<END, avx512=>0;
15301 1 eq 1
15302 1 NOT ne 1
15303 1 NOT lt 1
15304 1 le 1
15305 1 NOT gt 1
15306 1 ge 1
15307 1 NOT eq 2
15308 1 ne 2
15309 1 lt 2
15310 1 le 2
15311 1 NOT gt 2
15312 1 NOT ge 2
15313 3 NOT eq 2
15314 3 ne 2
15315 3 NOT lt 2
15316 3 NOT le 2
15317 3 gt 2
15318 3 ge 2
15319 END
15320  
15321  
15322 =head4 IfLe($then, $else)
15323  
15324 If less than or equal execute the then block else the else block.
15325  
15326 Parameter Description
15327 1 $then Then - required
15328 2 $else Else - optional
15329  
15330 B<Example:>
15331  
15332  
15333 my $cmp = sub
15334 {my ($a, $b) = @_;
15335  
15336 for my $op(qw(eq ne lt le gt ge))
15337 {Mov rax, $a;
15338 Cmp rax, $b;
15339 my $Op = ucfirst $op;
15340 eval qq(If$Op Then {PrintOutStringNL("$a $op $b")}, Else {PrintOutStringNL("$a NOT $op $b")});
15341 $@ and confess $@;
15342 }
15343 };
15344 &$cmp(1,1);
15345 &$cmp(1,2);
15346 &$cmp(3,2);
15347 Assemble eq => <<END, avx512=>0;
15348 1 eq 1
15349 1 NOT ne 1
15350 1 NOT lt 1
15351 1 le 1
15352 1 NOT gt 1
15353 1 ge 1
15354 1 NOT eq 2
15355 1 ne 2
15356 1 lt 2
15357 1 le 2
15358 1 NOT gt 2
15359 1 NOT ge 2
15360 3 NOT eq 2
15361 3 ne 2
15362 3 NOT lt 2
15363 3 NOT le 2
15364 3 gt 2
15365 3 ge 2
15366 END
15367  
15368  
15369 =head4 IfGt($then, $else)
15370  
15371 If greater than execute the then block else the else block.
15372  
15373 Parameter Description
15374 1 $then Then - required
15375 2 $else Else - optional
15376  
15377 B<Example:>
15378  
15379  
15380 my $cmp = sub
15381 {my ($a, $b) = @_;
15382  
15383 for my $op(qw(eq ne lt le gt ge))
15384 {Mov rax, $a;
15385 Cmp rax, $b;
15386 my $Op = ucfirst $op;
15387 eval qq(If$Op Then {PrintOutStringNL("$a $op $b")}, Else {PrintOutStringNL("$a NOT $op $b")});
15388 $@ and confess $@;
15389 }
15390 };
15391 &$cmp(1,1);
15392 &$cmp(1,2);
15393 &$cmp(3,2);
15394 Assemble eq => <<END, avx512=>0;
15395 1 eq 1
15396 1 NOT ne 1
15397 1 NOT lt 1
15398 1 le 1
15399 1 NOT gt 1
15400 1 ge 1
15401 1 NOT eq 2
15402 1 ne 2
15403 1 lt 2
15404 1 le 2
15405 1 NOT gt 2
15406 1 NOT ge 2
15407 3 NOT eq 2
15408 3 ne 2
15409 3 NOT lt 2
15410 3 NOT le 2
15411 3 gt 2
15412 3 ge 2
15413 END
15414  
15415  
15416 =head4 IfGe($then, $else)
15417  
15418 If greater than or equal execute the then block else the else block.
15419  
15420 Parameter Description
15421 1 $then Then - required
15422 2 $else Else - optional
15423  
15424 B<Example:>
15425  
15426  
15427 my $cmp = sub
15428 {my ($a, $b) = @_;
15429  
15430 for my $op(qw(eq ne lt le gt ge))
15431 {Mov rax, $a;
15432 Cmp rax, $b;
15433 my $Op = ucfirst $op;
15434 eval qq(If$Op Then {PrintOutStringNL("$a $op $b")}, Else {PrintOutStringNL("$a NOT $op $b")});
15435 $@ and confess $@;
15436 }
15437 };
15438 &$cmp(1,1);
15439 &$cmp(1,2);
15440 &$cmp(3,2);
15441 Assemble eq => <<END, avx512=>0;
15442 1 eq 1
15443 1 NOT ne 1
15444 1 NOT lt 1
15445 1 le 1
15446 1 NOT gt 1
15447 1 ge 1
15448 1 NOT eq 2
15449 1 ne 2
15450 1 lt 2
15451 1 le 2
15452 1 NOT gt 2
15453 1 NOT ge 2
15454 3 NOT eq 2
15455 3 ne 2
15456 3 NOT lt 2
15457 3 NOT le 2
15458 3 gt 2
15459 3 ge 2
15460 END
15461  
15462  
15463 =head2 Boolean Blocks
15464  
15465 Perform blocks depending on boolean conditions
15466  
15467 =head3 Pass($block)
15468  
15469 Pass block for an L<OrBlock>.
15470  
15471 Parameter Description
15472 1 $block Block
15473  
15474 B<Example:>
15475  
15476  
15477 Mov rax, 1;
15478 OrBlock
15479 {my ($pass, $end, $start) = @_;
15480 Cmp rax, 1;
15481 Je $pass;
15482 Cmp rax, 2;
15483 Je $pass;
15484 PrintOutStringNL "Fail";
15485 }
15486  
15487 Pass # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15488  
15489 {my ($end, $pass, $start) = @_;
15490  
15491 PrintOutStringNL "Pass"; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15492  
15493 };
15494  
15495 ok Assemble eq => <<END, avx512=>0;
15496  
15497 Pass # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15498  
15499 END
15500  
15501  
15502 =head3 Fail($block)
15503  
15504 Fail block for an L<AndBlock>.
15505  
15506 Parameter Description
15507 1 $block Block
15508  
15509 B<Example:>
15510  
15511  
15512 Mov rax, 1; Mov rdx, 2;
15513 AndBlock
15514 {my ($fail, $end, $start) = @_;
15515 Cmp rax, 1;
15516 Jne $fail;
15517 Cmp rdx, 2;
15518 Jne $fail;
15519 PrintOutStringNL "Pass";
15520 }
15521  
15522 Fail # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15523  
15524 {my ($end, $fail, $start) = @_;
15525  
15526 PrintOutStringNL "Fail"; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15527  
15528 };
15529  
15530 ok Assemble eq => <<END, avx512=>0;
15531 Pass
15532 END
15533  
15534  
15535 =head3 Block($code)
15536  
15537 Execute a block of code with labels supplied for the start and end of this code.
15538  
15539 Parameter Description
15540 1 $code Block of code
15541  
15542 B<Example:>
15543  
15544  
15545 #latest:
15546  
15547  
15548 =head3 AndBlock($test, $fail)
15549  
15550 Short circuit B<and>: execute a block of code to test conditions which, if all of them pass, allows the first block to continue successfully else if one of the conditions fails we execute the optional fail block.
15551  
15552 Parameter Description
15553 1 $test Block
15554 2 $fail Optional failure block
15555  
15556 B<Example:>
15557  
15558  
15559 Mov rax, 1; Mov rdx, 2;
15560  
15561 AndBlock # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15562  
15563 {my ($fail, $end, $start) = @_;
15564 Cmp rax, 1;
15565 Jne $fail;
15566 Cmp rdx, 2;
15567 Jne $fail;
15568 PrintOutStringNL "Pass";
15569 }
15570 Fail
15571 {my ($end, $fail, $start) = @_;
15572 PrintOutStringNL "Fail";
15573 };
15574  
15575 ok Assemble eq => <<END, avx512=>0;
15576 Pass
15577 END
15578  
15579  
15580 =head3 OrBlock($test, $pass)
15581  
15582 Short circuit B<or>: execute a block of code to test conditions which, if one of them is met, leads on to the execution of the pass block, if all of the tests fail we continue withe the test block.
15583  
15584 Parameter Description
15585 1 $test Tests
15586 2 $pass Optional block to execute on success
15587  
15588 B<Example:>
15589  
15590  
15591 Mov rax, 1;
15592  
15593 OrBlock # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15594  
15595 {my ($pass, $end, $start) = @_;
15596 Cmp rax, 1;
15597 Je $pass;
15598 Cmp rax, 2;
15599 Je $pass;
15600 PrintOutStringNL "Fail";
15601 }
15602 Pass
15603 {my ($end, $pass, $start) = @_;
15604 PrintOutStringNL "Pass";
15605 };
15606  
15607 ok Assemble eq => <<END, avx512=>0;
15608 Pass
15609 END
15610  
15611  
15612 =head2 Iteration
15613  
15614 Iterate with for loops
15615  
15616 =head3 For($block, $register, $limit, $increment)
15617  
15618 For - iterate the block as long as register is less than limit incrementing by increment each time. Nota Bene: The register is not explicitly set to zero as you might want to start at some other number.
15619  
15620 Parameter Description
15621 1 $block Block
15622 2 $register Register
15623 3 $limit Limit on loop
15624 4 $increment Increment on each iteration
15625  
15626 B<Example:>
15627  
15628  
15629  
15630 For # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15631  
15632 {my ($start, $end, $next) = @_;
15633 Cmp rax, 3;
15634 Jge $end;
15635 PrintOutRegisterInHex rax;
15636 } rax, 16, 1;
15637  
15638 ok Assemble eq => <<END, avx512=>0;
15639 rax: .... .... .... ...0
15640 rax: .... .... .... ...1
15641 rax: .... .... .... ...2
15642 END
15643  
15644  
15645 =head3 ToZero($block, $register)
15646  
15647 Iterate a block the number of times specified in the register which is decremented to zero.
15648  
15649 Parameter Description
15650 1 $block Block
15651 2 $register Limit register
15652  
15653 B<Example:>
15654  
15655  
15656 Mov rax, 3;
15657  
15658 ToZero # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15659  
15660 {PrintOutStringNL "AAAA";
15661 } rax;
15662 ok Assemble eq => <<END, clocks=>4374;
15663 AAAA
15664 AAAA
15665 AAAA
15666 END
15667  
15668  
15669 =head3 ForIn($full, $last, $register, $limitRegister, $increment)
15670  
15671 For - iterate the full block as long as register plus increment is less than than limit incrementing by increment each time then perform the last block with the remainder which might be of length zero.
15672  
15673 Parameter Description
15674 1 $full Block for full block
15675 2 $last Block for last block
15676 3 $register Register
15677 4 $limitRegister Register containing upper limit of loop
15678 5 $increment Increment on each iteration
15679  
15680 B<Example:>
15681  
15682  
15683 my $remainder = r15, my $offset = r14;
15684  
15685 Mov $offset, 0;
15686 Mov $remainder, 10;
15687  
15688  
15689 ForIn # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15690  
15691 {PrintOutStringNL "AAAA";
15692 PrintOutRegisterInHex $offset, $remainder;
15693 }
15694 Then
15695 {PrintOutStringNL "BBBB";
15696 PrintOutRegisterInHex $offset, $remainder;
15697 }, $offset, $remainder, 4;
15698  
15699 ok Assemble eq => <<END;
15700 AAAA
15701 r14: .... .... .... ...0
15702 r15: .... .... .... ...A
15703 AAAA
15704 r14: .... .... .... ...4
15705 r15: .... .... .... ...A
15706 BBBB
15707 r14: .... .... .... ...8
15708 r15: .... .... .... ...2
15709 END
15710  
15711  
15712 =head3 uptoNTimes($code, $register, $limit)
15713  
15714 Execute a block of code up to a constant number of times controlled by the named register.
15715  
15716 Parameter Description
15717 1 $code Block of code
15718 2 $register Register controlling loop
15719 3 $limit Constant limit
15720  
15721 B<Example:>
15722  
15723  
15724  
15725 uptoNTimes # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15726  
15727 {my ($end, $start) = @_;
15728 PrintOutRegisterInHex rax;
15729 } rax, 3;
15730  
15731 ok Assemble eq => <<END;
15732 rax: .... .... .... ...3
15733 rax: .... .... .... ...2
15734 rax: .... .... .... ...1
15735 END
15736  
15737  
15738 =head3 ForEver($block)
15739  
15740 Iterate for ever.
15741  
15742 Parameter Description
15743 1 $block Block to iterate
15744  
15745 B<Example:>
15746  
15747  
15748 my $e = q(readChar);
15749  
15750  
15751 ForEver # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15752  
15753 {my ($start, $end) = @_;
15754 ReadChar;
15755 Cmp rax, 0xa;
15756 Jle $end;
15757 PrintOutRaxAsChar;
15758 PrintOutRaxAsCharNL;
15759 };
15760 PrintOutNL;
15761  
15762 Assemble keep => $e;
15763  
15764 my $r = qx(echo "ABCDCBA" | ./$e);
15765 is_deeply $r, <<END;
15766 AA
15767 BB
15768 CC
15769 DD
15770 CC
15771 BB
15772 AA
15773  
15774 END
15775 unlink $e;
15776  
15777  
15778 =head2 Subroutine
15779  
15780 Create and call subroutines with the option of placing them into an area that can be writtento a file and reloaded and executed by another process.
15781  
15782 =head3 Subroutine($block, %options)
15783  
15784 Create a subroutine that can be called in assembler code.
15785  
15786 Parameter Description
15787 1 $block Block of code as a sub
15788 2 %options Options
15789  
15790 B<Example:>
15791  
15792  
15793 my $g = V g => 3;
15794  
15795 my $s = Subroutine # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15796  
15797 {my ($p, $s, $sub) = @_;
15798 my $g = $$p{g};
15799 $g->copy($g - 1);
15800 $g->outNL;
15801 If $g > 0,
15802 Then
15803 {$sub->call(parameters=>{g => $g});
15804 };
15805 } parameters=>[qw(g)], name => 'ref';
15806  
15807 $s->call(parameters=>{g => $g});
15808  
15809 ok Assemble eq => <<END;
15810 g: .... .... .... ...2
15811 g: .... .... .... ...1
15812 g: .... .... .... ...0
15813 END
15814  
15815 package InnerStructure # Test passing structures into a subroutine
15816 {use Data::Table::Text qw(:all);
15817 sub new($) # Create a new structure
15818 {my ($value) = @_; # Value for structure variable
15819 describe(value => Nasm::X86::V(var => $value))
15820 };
15821 sub describe(%) # Describe the components of a structure
15822 {my (%options) = @_; # Options
15823 genHash(__PACKAGE__,
15824 value => $options{value},
15825 );
15826 }
15827 }
15828  
15829 package OuterStructure
15830 {use Data::Table::Text qw(:all);
15831 sub new($$) # Create a new structure
15832 {my ($valueOuter, $valueInner) = @_; # Value for structure variable
15833 describe
15834 (value => Nasm::X86::V(var => $valueOuter),
15835 inner => InnerStructure::new($valueInner),
15836 )
15837 };
15838 sub describe(%) # Describe the components of a structure
15839 {my (%options) = @_; # Options
15840 genHash(__PACKAGE__,
15841 value => $options{value},
15842 inner => $options{inner},
15843 );
15844 }
15845 }
15846  
15847 my $t = OuterStructure::new(42, 4);
15848  
15849  
15850 my $s = Subroutine # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15851  
15852 {my ($parameters, $structures, $sub) = @_; # Variable parameters, structure variables, structure copies, subroutine description
15853  
15854 $$structures{test}->value->setReg(rax);
15855 Mov r15, 84;
15856 $$structures{test}->value->getReg(r15);
15857 Mov r15, 8;
15858 $$structures{test}->inner->value->getReg(r15);
15859  
15860 $$parameters{p}->setReg(rdx);
15861 } parameters=>[qw(p)], structures => {test => $t}, name => 'test';
15862  
15863 my $T = OuterStructure::new(42, 4);
15864 my $V = V parameter => 21;
15865  
15866 $s->call(parameters=>{p => $V}, structures=>{test => $T});
15867  
15868 PrintOutRaxInDecNL;
15869 Mov rax, rdx;
15870 PrintOutRaxInDecNL;
15871 $t->value->outInDecNL;
15872 $t->inner->value->outInDecNL;
15873 $T->value->outInDecNL;
15874 $T->inner->value->outInDecNL;
15875 ok Assemble eq => <<END, avx512=>0;
15876 42
15877 21
15878 var: 42
15879 var: 4
15880 var: 84
15881 var: 8
15882 END
15883  
15884  
15885 my $s = Subroutine # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15886  
15887  
15888  
15889 my $t = Subroutine # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
15890  
15891  
15892  
15893 =head3 Nasm::X86::Area::writeLibraryHeader($area, $subs)
15894  
15895 Load a hash of subroutine names and offsets into an area
15896  
15897 Parameter Description
15898 1 $area Area to load into
15899 2 $subs Hash of subroutine names to offsets
15900  
15901 B<Example:>
15902  
15903  
15904 my $a = CreateArea;
15905  
15906 my $u = $a->CreateTree(stringTree=>1);
15907 $u->putKeyString(constantString("ab"), K key => 1);
15908 $u->putKeyString(constantString("ac"), K key => 3);
15909 $u->putKeyString(constantString("𝕒𝕒"), K key => 4);
15910  
15911 my %s = (ab => 2, 𝕒𝕒 =>8, 𝗮𝗮𝗮=>12, 𝝰𝝰𝝰𝝰=>16); # Subroutine names and offsets
15912  
15913 $a->writeLibraryHeader({%s});
15914 my ($inter, $subroutines) = $a->readLibraryHeader($u);
15915  
15916 $inter->dump("TT");
15917  
15918 ok Assemble eq => <<END, clocks=>4374;
15919 TT
15920 At: 1C0 length: 2, data: 200, nodes: 240, first: 40, root, leaf
15921 Index: 0 1
15922 Keys : 1 4
15923 Data : 2 8
15924 end
15925 END
15926  
15927 my $a = CreateArea;
15928 my $t = $a->CreateTree;
15929  
15930 K(loop => 16)->for(sub
15931 {my ($i, $start, $next, $end) = @_;
15932 my $T = $a->CreateTree;
15933 $t->put($i, $T);
15934 $t->size->outNL;
15935 });
15936  
15937 K(loop => 16)->for(sub
15938 {my ($i, $start, $next, $end) = @_;
15939 $t->popSubTree;
15940 $t->size->outNL;
15941 });
15942  
15943 ok Assemble eq => <<END, avx512=>1;
15944 size of tree: .... .... .... ...1
15945 size of tree: .... .... .... ...2
15946 size of tree: .... .... .... ...3
15947 size of tree: .... .... .... ...4
15948 size of tree: .... .... .... ...5
15949 size of tree: .... .... .... ...6
15950 size of tree: .... .... .... ...7
15951 size of tree: .... .... .... ...8
15952 size of tree: .... .... .... ...9
15953 size of tree: .... .... .... ...A
15954 size of tree: .... .... .... ...B
15955 size of tree: .... .... .... ...C
15956 size of tree: .... .... .... ...D
15957 size of tree: .... .... .... ...E
15958 size of tree: .... .... .... ...F
15959 size of tree: .... .... .... ..10
15960 size of tree: .... .... .... ...F
15961 size of tree: .... .... .... ...E
15962 size of tree: .... .... .... ...D
15963 size of tree: .... .... .... ...C
15964 size of tree: .... .... .... ...B
15965 size of tree: .... .... .... ...A
15966 size of tree: .... .... .... ...9
15967 size of tree: .... .... .... ...8
15968 size of tree: .... .... .... ...7
15969 size of tree: .... .... .... ...6
15970 size of tree: .... .... .... ...5
15971 size of tree: .... .... .... ...4
15972 size of tree: .... .... .... ...3
15973 size of tree: .... .... .... ...2
15974 size of tree: .... .... .... ...1
15975 size of tree: .... .... .... ...0
15976 END
15977  
15978 my $a = CreateArea;
15979 my $t = $a->CreateTree;
15980 my $T = $a->CreateTree;
15981 $t->push($T);
15982 $a->dump("AA");
15983 $t->popSubTree;
15984 $a->dump("BB");
15985  
15986 ok Assemble eq => <<END, avx512=>1;
15987 AA
15988 Area Size: 4096 Used: 384
15989 .... .... .... ...0 | __10 ____ ____ ____ 80.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
15990 .... .... .... ..40 | C0__ ____ ____ ____ .1__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
15991 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
15992 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .1__ .1__ __.1 ____
15993 BB
15994 Area Size: 4096 Used: 384
15995 .... .... .... ...0 | __10 ____ ____ ____ 80.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
15996 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
15997 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
15998 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .1__ .1__ __.1 ____
15999 END
16000  
16001  
16002 =head3 Nasm::X86::Subroutine::call($sub, %options)
16003  
16004 Call a sub optionally passing it parameters.
16005  
16006 Parameter Description
16007 1 $sub Subroutine descriptor
16008 2 %options Options
16009  
16010 B<Example:>
16011  
16012  
16013  
16014 my $h = genHash("AAAA",
16015 a => V(a => 1),
16016 b => V(b => 2),
16017 c => V(c => 3),
16018 d => V(d => 4),
16019 e => V(e => 5),
16020 f => V(f => 6),
16021 g => V(g => 7),
16022 h => V(h => 8),
16023 i => V(i => 9),
16024 j => V(j => 10),
16025 k => V(k => 11),
16026 l => V(l => 12));
16027  
16028 my $i = genHash("AAAA",
16029 a => V(a => 0x011),
16030 b => V(b => 0x022),
16031 c => V(c => 0x033),
16032 d => V(d => 0x044),
16033 e => V(e => 0x055),
16034 f => V(f => 0x066),
16035 g => V(g => 0x077),
16036 h => V(h => 0x088),
16037 i => V(i => 0x099),
16038 j => V(j => 0x111),
16039 k => V(k => 0x222),
16040 l => V(l => 0x333));
16041  
16042 my $s = Subroutine
16043 {my ($p, $s, $sub) = @_;
16044 my $h = $$s{h};
16045 my $a = $$p{a};
16046 $$h{a}->outNL;
16047 $$h{b}->outNL;
16048 $$h{c}->outNL;
16049 $$h{d}->outNL;
16050 $$h{e}->outNL;
16051 $$h{f}->outNL;
16052 $$h{g}->outNL;
16053 $$h{h}->outNL;
16054 $$h{i}->outNL;
16055 $$h{j}->outNL;
16056 $$h{k}->outNL;
16057 $$h{l}->outNL;
16058 $$p{b}->outNL;
16059 } name => "s", structures => {h => $h}, parameters=>[qw(a b)];
16060  
16061 $s->call(structures => {h => $i}, parameters=>{a=>V(key => 1), b=>V(key => 0x111)});
16062 $s->call(structures => {h => $h}, parameters=>{a=>V(key => 2), b=>V(key => 0x222)});
16063  
16064 Assemble eq=><<END, clocks=>9151, label => 'aa';
16065 a: .... .... .... ..11
16066 b: .... .... .... ..22
16067 c: .... .... .... ..33
16068 d: .... .... .... ..44
16069 e: .... .... .... ..55
16070 f: .... .... .... ..66
16071 g: .... .... .... ..77
16072 h: .... .... .... ..88
16073 i: .... .... .... ..99
16074 j: .... .... .... .111
16075 k: .... .... .... .222
16076 l: .... .... .... .333
16077 b: .... .... .... .111
16078 a: .... .... .... ...1
16079 b: .... .... .... ...2
16080 c: .... .... .... ...3
16081 d: .... .... .... ...4
16082 e: .... .... .... ...5
16083 f: .... .... .... ...6
16084 g: .... .... .... ...7
16085 h: .... .... .... ...8
16086 i: .... .... .... ...9
16087 j: .... .... .... ...A
16088 k: .... .... .... ...B
16089 l: .... .... .... ...C
16090 b: .... .... .... .222
16091 END
16092  
16093  
16094 my $h = genHash("AAAA",
16095 a => V(a => 1),
16096 b => V(b => 2),
16097 c => V(c => 3),
16098 d => V(d => 4),
16099 e => V(e => 5),
16100 f => V(f => 6),
16101 g => V(g => 7),
16102 h => V(h => 8),
16103 i => V(i => 9),
16104 j => V(j => 10),
16105 k => V(k => 11),
16106 l => V(l => 12));
16107  
16108 my $s = Subroutine
16109 {my ($p, $s, $sub) = @_;
16110 my $h = $$s{h};
16111 my $a = $$p{a};
16112 $$h{a}->outNL;
16113 $$h{b}->outNL;
16114 $$h{c}->outNL;
16115 $$h{d}->outNL;
16116 $$h{e}->outNL;
16117 $$h{f}->outNL;
16118 $$h{g}->outNL;
16119 $$h{h}->outNL;
16120 $$h{i}->outNL;
16121 $$h{j}->outNL;
16122 $$h{k}->outNL;
16123 $$h{l}->outNL;
16124 If $a > 0,
16125 Then
16126 {$sub->call(structures => {h => $h}, parameters=>{a=>V(key => 0), b=>V(key => 0x111)});
16127 };
16128 } name => "s", structures => {h => $h}, parameters=>[qw(a b)];
16129  
16130 $s->call(structures => {h => $h}, parameters=>{a=>V(key => 2), b=>V(key => 0x222)});
16131  
16132 Assemble eq=><<END, clocks=>17609, label => 'aaa';
16133 a: .... .... .... ...1
16134 b: .... .... .... ...2
16135 c: .... .... .... ...3
16136 d: .... .... .... ...4
16137 e: .... .... .... ...5
16138 f: .... .... .... ...6
16139 g: .... .... .... ...7
16140 h: .... .... .... ...8
16141 i: .... .... .... ...9
16142 j: .... .... .... ...A
16143 k: .... .... .... ...B
16144 l: .... .... .... ...C
16145 a: .... .... .... ...1
16146 b: .... .... .... ...2
16147 c: .... .... .... ...3
16148 d: .... .... .... ...4
16149 e: .... .... .... ...5
16150 f: .... .... .... ...6
16151 g: .... .... .... ...7
16152 h: .... .... .... ...8
16153 i: .... .... .... ...9
16154 j: .... .... .... ...A
16155 k: .... .... .... ...B
16156 l: .... .... .... ...C
16157 END
16158  
16159  
16160 =head3 Nasm::X86::Subroutine::inline($sub, %options)
16161  
16162 Call a sub by in-lining it, optionally passing it parameters.
16163  
16164 Parameter Description
16165 1 $sub Subroutine descriptor
16166 2 %options Options
16167  
16168 B<Example:>
16169  
16170  
16171 my $s = Subroutine # Load and print rax
16172 {my ($p, $s, $sub) = @_;
16173 $$p{ppp}->outNL;
16174 } name => "s", parameters=>[qw(ppp)];
16175  
16176 $s->call (parameters => {ppp => V ppp => 0x99}); # Call 378
16177 $s->inline(parameters => {ppp => V ppp => 0xaa}); # Inline 364
16178  
16179 Assemble eq=><<END, avx512=>1;
16180 ppp: .... .... .... ..99
16181 ppp: .... .... .... ..AA
16182 END
16183  
16184  
16185 =head2 Trace back
16186  
16187 Generate a subroutine calll trace back
16188  
16189 =head3 PrintOutTraceBack($message)
16190  
16191 Print sub routine track back on stdout and then exit with a message.
16192  
16193 Parameter Description
16194 1 $message Reason why we are printing the trace back and then stopping
16195  
16196 B<Example:>
16197  
16198  
16199 my $d = V depth => 3; # Create a variable on the stack
16200  
16201 my $s = Subroutine
16202 {my ($p, $s, $sub) = @_; # Parameters, structures, subroutine descriptor
16203 $$p{depth}->outNL;
16204 my $d = $$p{depth}->copy($$p{depth} - 1); # Modify the variable referenced by the parameter
16205  
16206 If $d > 0,
16207 Then
16208 {$sub->call(parameters => {depth => $d}); # Recurse
16209 };
16210  
16211 } parameters =>[qw(depth)], name => 'ref';
16212  
16213 $s->call(parameters=>{depth => $d});
16214  
16215 $d->outNL;
16216 ok Assemble eq => <<END, avx512=>0;
16217 depth: .... .... .... ...3
16218 depth: .... .... .... ...2
16219 depth: .... .... .... ...1
16220 depth: .... .... .... ...0
16221 END
16222  
16223  
16224 =head3 OnSegv()
16225  
16226 Request a trace back followed by exit on a B<segv> signal.
16227  
16228  
16229 B<Example:>
16230  
16231  
16232  
16233 OnSegv(); # Request a trace back followed by exit on a segv signal. # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16234  
16235  
16236 my $t = Subroutine # Subroutine that will cause an error to occur to force a trace back to be printed
16237 {Mov r15, 0;
16238 Mov r15, "[r15]"; # Try to read an unmapped memory location
16239 } [qw(in)], name => 'sub that causes a segv'; # The name that will appear in the trace back
16240  
16241 $t->call(K(in, 42));
16242  
16243 ok Assemble(debug => 0, keep2 => 'signal', avx512=>0, eq => <<END, avx512=>0);# Cannot use the emulator because it does not understand signals
16244  
16245 Subroutine trace back, depth: 1
16246 0000 0000 0000 002A sub that causes a segv
16247  
16248 END
16249  
16250  
16251 =head2 Comments
16252  
16253 Inserts comments into the generated assember code.
16254  
16255 =head3 Comment(@comment)
16256  
16257 Insert a comment into the assembly code.
16258  
16259 Parameter Description
16260 1 @comment Text of comment
16261  
16262 B<Example:>
16263  
16264  
16265  
16266 Comment "Print a string from memory"; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16267  
16268 my $s = "Hello World";
16269 Mov rax, Rs($s);
16270 Mov rdi, length $s;
16271 PrintOutMemory;
16272 Exit(0);
16273  
16274 ok Assemble(avx512=>0) =~ m(Hello World);
16275  
16276  
16277 =head1 Print
16278  
16279 Print the values of registers and memory interspersed with constant strings. The print commands do not overwrite the free registers as doing so would make debugging difficult.
16280  
16281 =head2 Strings
16282  
16283 Print constant and variable strings
16284  
16285 =head3 PrintOutNL()
16286  
16287 Print a new line to stderr.
16288  
16289  
16290 B<Example:>
16291  
16292  
16293 Mov rax, 0x666;
16294 PrintOutRightInDec rax, 8;
16295  
16296 PrintOutNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16297  
16298  
16299 ok Assemble avx512=>0, eq=><<END;
16300 1638
16301 END
16302  
16303 my $q = Rs('abababab');
16304 Mov(rax, "[$q]");
16305 PrintOutString "rax: ";
16306 PrintOutRaxInHex;
16307  
16308 PrintOutNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16309  
16310 Xor rax, rax;
16311 PrintOutString "rax: ";
16312 PrintOutRaxInHex;
16313  
16314 PrintOutNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16315  
16316  
16317 ok Assemble avx512=>0, eq=><<END;
16318 rax: 6261 6261 6261 6261
16319 rax: .... .... .... ...0
16320 END
16321  
16322  
16323 =head3 PrintOutString(@string)
16324  
16325 Print a constant string to stdout.
16326  
16327 Parameter Description
16328 1 @string String
16329  
16330 B<Example:>
16331  
16332  
16333 Mov rax, 0x666;
16334 PrintOutRightInDec rax, 8;
16335 PrintOutNL;
16336  
16337 ok Assemble avx512=>0, eq=><<END;
16338 1638
16339 END
16340  
16341 my $q = Rs('abababab');
16342 Mov(rax, "[$q]");
16343  
16344 PrintOutString "rax: "; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16345  
16346 PrintOutRaxInHex;
16347 PrintOutNL;
16348 Xor rax, rax;
16349  
16350 PrintOutString "rax: "; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16351  
16352 PrintOutRaxInHex;
16353 PrintOutNL;
16354  
16355 ok Assemble avx512=>0, eq=><<END;
16356 rax: 6261 6261 6261 6261
16357 rax: .... .... .... ...0
16358 END
16359  
16360  
16361 =head3 PrintOutStringNL(@string)
16362  
16363 Print a constant string to stdout followed by a new line.
16364  
16365 Parameter Description
16366 1 @string String
16367  
16368 B<Example:>
16369  
16370  
16371  
16372 PrintOutStringNL "Hello World"; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16373  
16374  
16375 PrintOutStringNL "Hello
16376 World"; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16377  
16378 PrintErrStringNL "Hello World";
16379  
16380 ok Assemble eq => <<END, avx512=>0, label=>'t1';
16381 Hello World
16382 Hello
16383 World
16384 END
16385  
16386  
16387 =head3 PrintOutSpace($spaces)
16388  
16389 Print a constant number of spaces to stdout.
16390  
16391 Parameter Description
16392 1 $spaces Number of spaces if not one.
16393  
16394 B<Example:>
16395  
16396  
16397 Mov rax, 42;
16398 Mov rbx, 21;
16399 PrintOutRaxInDec;
16400  
16401 PrintOutSpace; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16402  
16403 PrintOutRaxInDecNL;
16404  
16405 PrintOutRax_InHex;
16406  
16407 PrintOutSpace; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16408  
16409 PrintOutRax_InHexNL;
16410  
16411 PrintOutRegisterInHex rbx;
16412 PrintOutNL;
16413  
16414 PrintOutRightInBin K(key => 17), K width => 16;
16415  
16416 PrintOutSpace; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16417  
16418 PrintOutRightInDec K(key => 17), K width => 2;
16419  
16420 PrintOutSpace; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16421  
16422 PrintOutRightInHex K(key => 17), K width => 2;
16423 PrintOutNL;
16424  
16425 ok Assemble eq => <<END;
16426 42 42
16427 ____ ____ ____ __2A ____ ____ ____ __2A
16428 rbx: .... .... .... ..15
16429  
16430 10001 17 11
16431 END
16432  
16433  
16434 =head2 Registers
16435  
16436 Print selected registers in a variety of formats.
16437  
16438 =head3 PrintOutRaxInHex()
16439  
16440 Write the content of register rax in hexadecimal in big endian notation to stout.
16441  
16442  
16443 B<Example:>
16444  
16445  
16446 Mov rax, 0x666;
16447 PrintOutRightInDec rax, 8;
16448 PrintOutNL;
16449  
16450 ok Assemble avx512=>0, eq=><<END;
16451 1638
16452 END
16453  
16454 my $q = Rs('abababab');
16455 Mov(rax, "[$q]");
16456 PrintOutString "rax: ";
16457  
16458 PrintOutRaxInHex; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16459  
16460 PrintOutNL;
16461 Xor rax, rax;
16462 PrintOutString "rax: ";
16463  
16464 PrintOutRaxInHex; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16465  
16466 PrintOutNL;
16467  
16468 ok Assemble avx512=>0, eq=><<END;
16469 rax: 6261 6261 6261 6261
16470 rax: .... .... .... ...0
16471 END
16472  
16473  
16474 =head3 PrintOutRaxInHexNL()
16475  
16476 Write the content of register rax in hexadecimal in big endian notation to stdout followed by a new line.
16477  
16478  
16479 B<Example:>
16480  
16481  
16482 my $s = Rb(0..255);
16483  
16484 Vmovdqu64 xmm1, "[$s]";
16485 PrintOutRegisterInHex xmm1;
16486 PrintOutRegisterInHex xmm1;
16487  
16488 Vmovdqu64 ymm1, "[$s]";
16489 PrintOutRegisterInHex ymm1;
16490 PrintOutRegisterInHex ymm1;
16491  
16492 Vmovdqu64 zmm1, "[$s]";
16493 PrintOutRegisterInHex zmm1;
16494 PrintOutRegisterInHex zmm1;
16495  
16496 ok Assemble eq =><<END;
16497 xmm1: .F.E .D.C .B.A .9.8 .7.6 .5.4 .3.2 .1..
16498 xmm1: .F.E .D.C .B.A .9.8 .7.6 .5.4 .3.2 .1..
16499 ymm1: 1F1E 1D1C 1B1A 1918 1716 1514 1312 1110 - .F.E .D.C .B.A .9.8 .7.6 .5.4 .3.2 .1..
16500 ymm1: 1F1E 1D1C 1B1A 1918 1716 1514 1312 1110 - .F.E .D.C .B.A .9.8 .7.6 .5.4 .3.2 .1..
16501 zmm1: 3F3E 3D3C 3B3A 3938 3736 3534 3332 3130 - 2F2E 2D2C 2B2A 2928 2726 2524 2322 2120 + 1F1E 1D1C 1B1A 1918 1716 1514 1312 1110 - .F.E .D.C .B.A .9.8 .7.6 .5.4 .3.2 .1..
16502 zmm1: 3F3E 3D3C 3B3A 3938 3736 3534 3332 3130 - 2F2E 2D2C 2B2A 2928 2726 2524 2322 2120 + 1F1E 1D1C 1B1A 1918 1716 1514 1312 1110 - .F.E .D.C .B.A .9.8 .7.6 .5.4 .3.2 .1..
16503 END
16504  
16505  
16506 =head3 PrintOutRax_InHex()
16507  
16508 Write the content of register rax in hexadecimal in big endian notation to stout.
16509  
16510  
16511 B<Example:>
16512  
16513  
16514 Mov rax, 42;
16515 Mov rbx, 21;
16516 PrintOutRaxInDec;
16517 PrintOutSpace;
16518 PrintOutRaxInDecNL;
16519  
16520  
16521 PrintOutRax_InHex; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16522  
16523 PrintOutSpace;
16524 PrintOutRax_InHexNL;
16525  
16526 PrintOutRegisterInHex rbx;
16527 PrintOutNL;
16528  
16529 PrintOutRightInBin K(key => 17), K width => 16;
16530 PrintOutSpace;
16531 PrintOutRightInDec K(key => 17), K width => 2;
16532 PrintOutSpace;
16533 PrintOutRightInHex K(key => 17), K width => 2;
16534 PrintOutNL;
16535  
16536 ok Assemble eq => <<END;
16537 42 42
16538 ____ ____ ____ __2A ____ ____ ____ __2A
16539 rbx: .... .... .... ..15
16540  
16541 10001 17 11
16542 END
16543  
16544  
16545 =head3 PrintOutRax_InHexNL()
16546  
16547 Write the content of register rax in hexadecimal in big endian notation to stdout followed by a new line.
16548  
16549  
16550 B<Example:>
16551  
16552  
16553 Mov rax, 42;
16554 Mov rbx, 21;
16555 PrintOutRaxInDec;
16556 PrintOutSpace;
16557 PrintOutRaxInDecNL;
16558  
16559 PrintOutRax_InHex;
16560 PrintOutSpace;
16561  
16562 PrintOutRax_InHexNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16563  
16564  
16565 PrintOutRegisterInHex rbx;
16566 PrintOutNL;
16567  
16568 PrintOutRightInBin K(key => 17), K width => 16;
16569 PrintOutSpace;
16570 PrintOutRightInDec K(key => 17), K width => 2;
16571 PrintOutSpace;
16572 PrintOutRightInHex K(key => 17), K width => 2;
16573 PrintOutNL;
16574  
16575 ok Assemble eq => <<END;
16576 42 42
16577 ____ ____ ____ __2A ____ ____ ____ __2A
16578 rbx: .... .... .... ..15
16579  
16580 10001 17 11
16581 END
16582  
16583  
16584 =head3 PrintOutRaxInReverseInHex()
16585  
16586 Write the content of register rax to stderr in hexadecimal in little endian notation.
16587  
16588  
16589 B<Example:>
16590  
16591  
16592 Mov rax, 0x07654321;
16593 Shl rax, 32;
16594 Or rax, 0x07654321;
16595 PushR rax;
16596  
16597 PrintOutRaxInHex;
16598 PrintOutNL;
16599  
16600 PrintOutRaxInReverseInHex; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16601  
16602 PrintOutNL;
16603  
16604 Mov rax, rsp;
16605 Mov rdi, 8;
16606 PrintOutMemoryInHex;
16607 PrintOutNL;
16608 PopR rax;
16609  
16610 Mov rax, 4096;
16611 PushR rax;
16612 Mov rax, rsp;
16613 Mov rdi, 8;
16614 PrintOutMemoryInHex;
16615 PrintOutNL;
16616 PopR rax;
16617  
16618 ok Assemble eq => <<END, avx512=>0;
16619 .765 4321 .765 4321
16620 2143 65.7 2143 65.7
16621 2143 65.7 2143 65.7
16622 ..10 .... .... ....
16623 END
16624  
16625  
16626 =head3 PrintOutOneRegisterInHex($r)
16627  
16628 Print the named register as a hex string on stdout.
16629  
16630 Parameter Description
16631 1 $r Register to print
16632  
16633 B<Example:>
16634  
16635  
16636 Mov rax, 0x22;
16637 Mov rbx, 0x33;
16638  
16639 PrintOutOneRegisterInHex rax; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16640  
16641 PrintOutOneRegisterInHexNL rbx;
16642  
16643 ok Assemble eq => <<END;
16644 .... .... .... ..22.... .... .... ..33
16645 END
16646  
16647 Mov rax, 0x61;
16648 PrintOutRaxAsChar;
16649 Mov rax, 0x62;
16650 PrintOutRaxAsCharNL;
16651  
16652 ok Assemble eq => <<END;
16653 ab
16654 END
16655  
16656  
16657 =head3 PrintOutOneRegisterInHexNL($r)
16658  
16659 Print the named register as a hex string on stdout followed by new line.
16660  
16661 Parameter Description
16662 1 $r Register to print
16663  
16664 B<Example:>
16665  
16666  
16667 Mov rax, 0x22;
16668 Mov rbx, 0x33;
16669 PrintOutOneRegisterInHex rax;
16670  
16671 PrintOutOneRegisterInHexNL rbx; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16672  
16673  
16674 ok Assemble eq => <<END;
16675 .... .... .... ..22.... .... .... ..33
16676 END
16677  
16678 Mov rax, 0x61;
16679 PrintOutRaxAsChar;
16680 Mov rax, 0x62;
16681 PrintOutRaxAsCharNL;
16682  
16683 ok Assemble eq => <<END;
16684 ab
16685 END
16686  
16687  
16688 =head3 PrintOutRegisterInHex(@r)
16689  
16690 Print the named registers as hex strings on stdout.
16691  
16692 Parameter Description
16693 1 @r Names of the registers to print
16694  
16695 B<Example:>
16696  
16697  
16698 Mov rax, 42;
16699 Mov rbx, 21;
16700 PrintOutRaxInDec;
16701 PrintOutSpace;
16702 PrintOutRaxInDecNL;
16703  
16704 PrintOutRax_InHex;
16705 PrintOutSpace;
16706 PrintOutRax_InHexNL;
16707  
16708  
16709 PrintOutRegisterInHex rbx; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16710  
16711 PrintOutNL;
16712  
16713 PrintOutRightInBin K(key => 17), K width => 16;
16714 PrintOutSpace;
16715 PrintOutRightInDec K(key => 17), K width => 2;
16716 PrintOutSpace;
16717 PrintOutRightInHex K(key => 17), K width => 2;
16718 PrintOutNL;
16719  
16720 ok Assemble eq => <<END;
16721 42 42
16722 ____ ____ ____ __2A ____ ____ ____ __2A
16723 rbx: .... .... .... ..15
16724  
16725 10001 17 11
16726 END
16727  
16728  
16729 =head3 PrintOutRegistersInHex()
16730  
16731 Print the general purpose registers in hex.
16732  
16733  
16734 B<Example:>
16735  
16736  
16737 my $q = Rs('abababab');
16738 Mov r10, 0x10;
16739 Mov r11, 0x11;
16740 Mov r12, 0x12;
16741 Mov r13, 0x13;
16742 Mov r14, 0x14;
16743 Mov r15, 0x15;
16744 Mov r8, 0x08;
16745 Mov r9, 0x09;
16746 Mov rax, 1;
16747 Mov rbx, 2;
16748 Mov rcx, 3;
16749 Mov rdi, 4;
16750 Mov rdx, 5;
16751 Mov rsi, 6;
16752  
16753 PrintOutRegistersInHex; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16754  
16755  
16756 my $r = Assemble avx512=>0, eq=><<END;
16757 rfl: .... .... .... .2.2
16758 r10: .... .... .... ..10
16759 r11: .... .... .... .2.6
16760 r12: .... .... .... ..12
16761 r13: .... .... .... ..13
16762 r14: .... .... .... ..14
16763 r15: .... .... .... ..15
16764 r8: .... .... .... ...8
16765 r9: .... .... .... ...9
16766 rax: .... .... .... ...1
16767 rbx: .... .... .... ...2
16768 rcx: .... .... ..40 197F
16769 rdi: .... .... .... ...4
16770 rdx: .... .... .... ...5
16771 rsi: .... .... .... ...6
16772 END
16773  
16774  
16775 =head2 Zero Flag
16776  
16777 Print zero flag
16778  
16779 =head3 PrintOutZF()
16780  
16781 Print the zero flag without disturbing it on stdout.
16782  
16783  
16784 B<Example:>
16785  
16786  
16787 SetZF;
16788  
16789 PrintOutZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16790  
16791 ClearZF;
16792  
16793 PrintOutZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16794  
16795 SetZF;
16796  
16797 PrintOutZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16798  
16799 SetZF;
16800  
16801 PrintOutZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16802  
16803 ClearZF;
16804  
16805 PrintOutZF; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16806  
16807  
16808 SetZF;
16809 IfZ Then {PrintOutStringNL "Zero"}, Else {PrintOutStringNL "NOT zero"};
16810 ClearZF;
16811 IfNz Then {PrintOutStringNL "NOT zero"}, Else {PrintOutStringNL "Zero"};
16812  
16813 Mov r15, 5;
16814 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"};
16815 Shr r15, 1; IfC Then {PrintOutStringNL "Carry"} , Else {PrintOutStringNL "NO carry"};
16816 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"};
16817 Shr r15, 1; IfNc Then {PrintOutStringNL "NO carry"}, Else {PrintOutStringNL "Carry"};
16818  
16819 ok Assemble eq => <<END, avx512=>0;
16820 ZF=1
16821 ZF=0
16822 ZF=1
16823 ZF=1
16824 ZF=0
16825 Zero
16826 NOT zero
16827 Carry
16828 NO carry
16829 Carry
16830 NO carry
16831 END
16832  
16833  
16834 =head2 Hexadecimal
16835  
16836 Print numbers in hexadecimal right justified in a field
16837  
16838 =head3 PrintOutRightInHex($number, $width)
16839  
16840 Write the specified variable in hexadecimal right justified in a field of specified width on stdout.
16841  
16842 Parameter Description
16843 1 $number Number as a variable
16844 2 $width Width of output field as a variable
16845  
16846 B<Example:>
16847  
16848  
16849 Mov rax, 42;
16850 Mov rbx, 21;
16851 PrintOutRaxInDec;
16852 PrintOutSpace;
16853 PrintOutRaxInDecNL;
16854  
16855 PrintOutRax_InHex;
16856 PrintOutSpace;
16857 PrintOutRax_InHexNL;
16858  
16859 PrintOutRegisterInHex rbx;
16860 PrintOutNL;
16861  
16862 PrintOutRightInBin K(key => 17), K width => 16;
16863 PrintOutSpace;
16864 PrintOutRightInDec K(key => 17), K width => 2;
16865 PrintOutSpace;
16866  
16867 PrintOutRightInHex K(key => 17), K width => 2; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16868  
16869 PrintOutNL;
16870  
16871 ok Assemble eq => <<END;
16872 42 42
16873 ____ ____ ____ __2A ____ ____ ____ __2A
16874 rbx: .... .... .... ..15
16875  
16876 10001 17 11
16877 END
16878  
16879  
16880 =head3 PrintOutRightInHexNL($number, $width)
16881  
16882 Write the specified variable in hexadecimal right justified in a field of specified width on stdout followed by a new line.
16883  
16884 Parameter Description
16885 1 $number Number as a variable
16886 2 $width Width of output field as a variable
16887  
16888 B<Example:>
16889  
16890  
16891 my $N = K number => 0x12345678;
16892  
16893 for my $i(reverse 1..16)
16894  
16895 {PrintOutRightInHexNL $N, $i; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16896  
16897 }
16898 ok Assemble eq => <<END;
16899 12345678
16900 12345678
16901 12345678
16902 12345678
16903 12345678
16904 12345678
16905 12345678
16906 12345678
16907 12345678
16908 2345678
16909 345678
16910 45678
16911 5678
16912 678
16913 78
16914 8
16915 END
16916  
16917 Mov rax, 0x2a;
16918 PrintOutRightInDecNL rax, 16;
16919  
16920 PrintOutRightInHexNL rax, 16; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16921  
16922 PrintOutRightInBinNL rax, 16;
16923  
16924 ok Assemble eq => <<END, avx512=>1;
16925 42
16926 2A
16927 101010
16928 END
16929  
16930  
16931 =head2 Binary
16932  
16933 Print numbers in binary right justified in a field
16934  
16935 =head3 PrintOutRightInBin($number, $width)
16936  
16937 Write the specified variable in binary right justified in a field of specified width on stdout.
16938  
16939 Parameter Description
16940 1 $number Number as a variable
16941 2 $width Width of output field as a variable
16942  
16943 B<Example:>
16944  
16945  
16946 Mov rax, 42;
16947 Mov rbx, 21;
16948 PrintOutRaxInDec;
16949 PrintOutSpace;
16950 PrintOutRaxInDecNL;
16951  
16952 PrintOutRax_InHex;
16953 PrintOutSpace;
16954 PrintOutRax_InHexNL;
16955  
16956 PrintOutRegisterInHex rbx;
16957 PrintOutNL;
16958  
16959  
16960 PrintOutRightInBin K(key => 17), K width => 16; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16961  
16962 PrintOutSpace;
16963 PrintOutRightInDec K(key => 17), K width => 2;
16964 PrintOutSpace;
16965 PrintOutRightInHex K(key => 17), K width => 2;
16966 PrintOutNL;
16967  
16968 ok Assemble eq => <<END;
16969 42 42
16970 ____ ____ ____ __2A ____ ____ ____ __2A
16971 rbx: .... .... .... ..15
16972  
16973 10001 17 11
16974 END
16975  
16976  
16977 =head3 PrintOutRightInBinNL($number, $width)
16978  
16979 Write the specified variable in binary right justified in a field of specified width on stdout followed by a new line.
16980  
16981 Parameter Description
16982 1 $number Number as a variable
16983 2 $width Width of output field as a variable
16984  
16985 B<Example:>
16986  
16987  
16988 K(count => 64)->for(sub
16989 {my ($index, $start, $next, $end) = @_;
16990  
16991 PrintOutRightInBinNL K(number => 0x99), K(max => 64) - $index; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
16992  
16993 });
16994 ok Assemble(avx512=>0, eq => <<END);
16995 10011001
16996 10011001
16997 10011001
16998 10011001
16999 10011001
17000 10011001
17001 10011001
17002 10011001
17003 10011001
17004 10011001
17005 10011001
17006 10011001
17007 10011001
17008 10011001
17009 10011001
17010 10011001
17011 10011001
17012 10011001
17013 10011001
17014 10011001
17015 10011001
17016 10011001
17017 10011001
17018 10011001
17019 10011001
17020 10011001
17021 10011001
17022 10011001
17023 10011001
17024 10011001
17025 10011001
17026 10011001
17027 10011001
17028 10011001
17029 10011001
17030 10011001
17031 10011001
17032 10011001
17033 10011001
17034 10011001
17035 10011001
17036 10011001
17037 10011001
17038 10011001
17039 10011001
17040 10011001
17041 10011001
17042 10011001
17043 10011001
17044 10011001
17045 10011001
17046 10011001
17047 10011001
17048 10011001
17049 10011001
17050 10011001
17051 10011001
17052 0011001
17053 011001
17054 11001
17055 1001
17056 001
17057 01
17058 1
17059 END
17060  
17061 Mov rax, 0x2a;
17062 PrintOutRightInDecNL rax, 16;
17063 PrintOutRightInHexNL rax, 16;
17064  
17065 PrintOutRightInBinNL rax, 16; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17066  
17067  
17068 ok Assemble eq => <<END, avx512=>1;
17069 42
17070 2A
17071 101010
17072 END
17073  
17074  
17075 =head2 Decimal
17076  
17077 Print numbers in decimal right justified in fields of specified width.
17078  
17079 =head3 PrintOutRaxInDec()
17080  
17081 Print rax in decimal on stdout.
17082  
17083  
17084 B<Example:>
17085  
17086  
17087 Mov rax, 42;
17088 Mov rbx, 21;
17089  
17090 PrintOutRaxInDec; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17091  
17092 PrintOutSpace;
17093 PrintOutRaxInDecNL;
17094  
17095 PrintOutRax_InHex;
17096 PrintOutSpace;
17097 PrintOutRax_InHexNL;
17098  
17099 PrintOutRegisterInHex rbx;
17100 PrintOutNL;
17101  
17102 PrintOutRightInBin K(key => 17), K width => 16;
17103 PrintOutSpace;
17104 PrintOutRightInDec K(key => 17), K width => 2;
17105 PrintOutSpace;
17106 PrintOutRightInHex K(key => 17), K width => 2;
17107 PrintOutNL;
17108  
17109 ok Assemble eq => <<END;
17110 42 42
17111 ____ ____ ____ __2A ____ ____ ____ __2A
17112 rbx: .... .... .... ..15
17113  
17114 10001 17 11
17115 END
17116  
17117  
17118 =head3 PrintOutRaxInDecNL()
17119  
17120 Print rax in decimal on stdout followed by a new line.
17121  
17122  
17123 B<Example:>
17124  
17125  
17126 Mov rax, 42;
17127 Mov rbx, 21;
17128 PrintOutRaxInDec;
17129 PrintOutSpace;
17130  
17131 PrintOutRaxInDecNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17132  
17133  
17134 PrintOutRax_InHex;
17135 PrintOutSpace;
17136 PrintOutRax_InHexNL;
17137  
17138 PrintOutRegisterInHex rbx;
17139 PrintOutNL;
17140  
17141 PrintOutRightInBin K(key => 17), K width => 16;
17142 PrintOutSpace;
17143 PrintOutRightInDec K(key => 17), K width => 2;
17144 PrintOutSpace;
17145 PrintOutRightInHex K(key => 17), K width => 2;
17146 PrintOutNL;
17147  
17148 ok Assemble eq => <<END;
17149 42 42
17150 ____ ____ ____ __2A ____ ____ ____ __2A
17151 rbx: .... .... .... ..15
17152  
17153 10001 17 11
17154 END
17155  
17156  
17157 =head3 PrintOutRightInDec($number, $width)
17158  
17159 Print a variable or register in decimal right justified in a field of the specified width on stdout.
17160  
17161 Parameter Description
17162 1 $number Number as a variable or a register
17163 2 $width Width as a variable or constant
17164  
17165 B<Example:>
17166  
17167  
17168 Mov rax, 42;
17169 Mov rbx, 21;
17170 PrintOutRaxInDec;
17171 PrintOutSpace;
17172 PrintOutRaxInDecNL;
17173  
17174 PrintOutRax_InHex;
17175 PrintOutSpace;
17176 PrintOutRax_InHexNL;
17177  
17178 PrintOutRegisterInHex rbx;
17179 PrintOutNL;
17180  
17181 PrintOutRightInBin K(key => 17), K width => 16;
17182 PrintOutSpace;
17183  
17184 PrintOutRightInDec K(key => 17), K width => 2; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17185  
17186 PrintOutSpace;
17187 PrintOutRightInHex K(key => 17), K width => 2;
17188 PrintOutNL;
17189  
17190 ok Assemble eq => <<END;
17191 42 42
17192 ____ ____ ____ __2A ____ ____ ____ __2A
17193 rbx: .... .... .... ..15
17194  
17195 10001 17 11
17196 END
17197  
17198  
17199 =head3 PrintOutRightInDecNL($number, $width)
17200  
17201 Print a variable or register in decimal right justified in a field of the specified width on stdout followed by a new line.
17202  
17203 Parameter Description
17204 1 $number Number as a variable or a register
17205 2 $width Width as a variable or constant
17206  
17207 B<Example:>
17208  
17209  
17210 Mov rax, 0x2a;
17211  
17212 PrintOutRightInDecNL rax, 16; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17213  
17214 PrintOutRightInHexNL rax, 16;
17215 PrintOutRightInBinNL rax, 16;
17216  
17217 ok Assemble eq => <<END, avx512=>1;
17218 42
17219 2A
17220 101010
17221 END
17222  
17223  
17224 =head2 Text
17225  
17226 Print the contents of a register as text.
17227  
17228 =head3 PrintOutRaxAsText()
17229  
17230 Print rax as text on stdout.
17231  
17232  
17233 B<Example:>
17234  
17235  
17236 Mov rax, 0x636261;
17237  
17238 PrintOutRaxAsText; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17239  
17240 Mov rax, 0x64636261;
17241 PrintOutRaxAsTextNL;
17242  
17243 ok Assemble eq => <<END;
17244 abcabcd
17245 END
17246  
17247  
17248 =head3 PrintOutRaxAsTextNL()
17249  
17250 Print rax as text on stdout followed by a new line.
17251  
17252  
17253 B<Example:>
17254  
17255  
17256 Mov rax, 0x636261;
17257 PrintOutRaxAsText;
17258 Mov rax, 0x64636261;
17259  
17260 PrintOutRaxAsTextNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17261  
17262  
17263 ok Assemble eq => <<END;
17264 abcabcd
17265 END
17266  
17267 my $t = Rs('abcdefghi');
17268 Mov rax, $t;
17269 Mov rax, "[rax]";
17270  
17271 PrintOutRaxAsTextNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17272  
17273 ok Assemble eq => <<END, avx512=>0;
17274 abcdefgh
17275 END
17276 }
17277  
17278 #latest:
17279 if (1) { ;
17280 my $e = q(parameters);
17281  
17282 (V string => "[rbp+8]")->outInDecNL;
17283 (V string => "[rbp+16]")->outCStringNL;
17284 (V string => "[rbp+24]")->outCStringNL;
17285 (V string => "[rbp+32]")->outCStringNL;
17286 (V string => "[rbp+40]")->outCStringNL;
17287 (V string => "[rbp+48]")->outInDecNL;
17288  
17289 (V string => "[rbp+8]")->for(sub
17290 {my ($index, $start, $next, $end) = @_;
17291 $index->setReg(rax);
17292 Inc rax;
17293 PrintOutRaxInDec;
17294 Inc rax;
17295 PrintOutString " : ";
17296 Shl rax, 3;
17297 (V string => "[rbp+rax]")->outCStringNL;
17298 });
17299  
17300 Assemble keep => $e;
17301  
17302 is_deeply scalar(qx(./$e AaAaAaAaAa BbCcDdEe 123456789)), <<END;
17303 string: 4
17304 ./parameters
17305 AaAaAaAaAa
17306 BbCcDdEe
17307 123456789
17308 string: 0
17309 1 : ./parameters
17310 2 : AaAaAaAaAa
17311 3 : BbCcDdEe
17312 4 : 123456789
17313 END
17314  
17315 unlink $e;
17316  
17317 K( loop => 16)->for(sub
17318 {my ($index, $start, $next, $end) = @_;
17319 $index->setReg(rax);
17320 Add rax, 0xb0; Shl rax, 16;
17321 Mov ax, 0x9d9d; Shl rax, 8;
17322 Mov al, 0xf0;
17323 PrintOutRaxAsText;
17324 });
17325 PrintOutNL;
17326  
17327 ok Assemble eq => <<END, avx512 => 0;
17328 𝝰𝝱𝝲𝝳𝝴𝝵𝝶𝝷𝝸𝝹𝝺𝝻𝝼𝝽𝝾𝝿
17329 END
17330  
17331  
17332 =head3 PrintOutRaxAsChar()
17333  
17334 Print the character in rax on stdout.
17335  
17336  
17337 B<Example:>
17338  
17339  
17340 my $e = q(readChar);
17341  
17342 ForEver
17343 {my ($start, $end) = @_;
17344 ReadChar;
17345 Cmp rax, 0xa;
17346 Jle $end;
17347  
17348 PrintOutRaxAsChar; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17349  
17350 PrintOutRaxAsCharNL;
17351 };
17352 PrintOutNL;
17353  
17354 Assemble keep => $e;
17355  
17356 my $r = qx(echo "ABCDCBA" | ./$e);
17357 is_deeply $r, <<END;
17358 AA
17359 BB
17360 CC
17361 DD
17362 CC
17363 BB
17364 AA
17365  
17366 END
17367 unlink $e;
17368  
17369  
17370 =head3 PrintOutRaxAsCharNL()
17371  
17372 Print the character in rax on stdout followed by a new line.
17373  
17374  
17375 B<Example:>
17376  
17377  
17378 my $e = q(readChar);
17379  
17380 ForEver
17381 {my ($start, $end) = @_;
17382 ReadChar;
17383 Cmp rax, 0xa;
17384 Jle $end;
17385 PrintOutRaxAsChar;
17386  
17387 PrintOutRaxAsCharNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17388  
17389 };
17390 PrintOutNL;
17391  
17392 Assemble keep => $e;
17393  
17394 my $r = qx(echo "ABCDCBA" | ./$e);
17395 is_deeply $r, <<END;
17396 AA
17397 BB
17398 CC
17399 DD
17400 CC
17401 BB
17402 AA
17403  
17404 END
17405 unlink $e;
17406  
17407  
17408 =head1 Variables
17409  
17410 Variable definitions and operations
17411  
17412 =head2 Definitions
17413  
17414 Variable definitions
17415  
17416 =head3 Nasm::X86::Variable::at($variable)
17417  
17418 Return a "[register expression]" to address the data in the variable in the current stack frame.
17419  
17420 Parameter Description
17421 1 $variable Variable descriptor
17422  
17423 B<Example:>
17424  
17425  
17426 if (1)
17427 {my $v = V var => 2;
17428 Mov rax, $v->at;
17429 PrintOutRegisterInHex rax;
17430 ok Assemble eq=><<END, avx512=>1;
17431 rax: .... .... .... ...2
17432 END
17433 }
17434  
17435 if (1)
17436 {my $a = V(key => 0x123);
17437 is_deeply $a->at, "[rbp-8*(2)]";
17438 is_deeply $a->addressExpr, "[rbp-8*(2)]";
17439  
17440 ok !$a->isRef;
17441  
17442 Mov rax, -1;
17443 Kmovq k1, rax;
17444 PrintOutRegisterInHex k1;
17445  
17446 K(key => 2)->clearBit(rax);
17447 PrintOutRegisterInHex rax;
17448  
17449 K(key => 2)->setBit(rax);
17450 PrintOutRegisterInHex rax;
17451  
17452 K(key => 3)->clearMaskBit(k1);
17453 PrintOutRegisterInHex k1;
17454  
17455 K(key => 3)->setMaskBit(k1);
17456 PrintOutRegisterInHex k1;
17457  
17458 K(key => 0)->clearMaskBit(k1);
17459 PrintOutRegisterInHex k1;
17460  
17461 ClearRegisters k1;
17462 K(key => 7)->setMaskFirst(k1);
17463 PrintOutRegisterInHex k1;
17464  
17465 K(key => 3)->spaces($stdout);
17466 PrintOutRegisterInHex k1;
17467  
17468 my $N = K size => 4096;
17469 my $A = $N->allocateMemory;
17470 $A->clearMemory($N);
17471 ClearMemory($A, $N);
17472  
17473 $A->setReg(rax);
17474 Mov "dword[rax]", 0x61626364;
17475 Mov "dword[rax+4]", 0x65666768;
17476  
17477 ($A+8)->copyMemory($A, K key => 8);
17478  
17479 $A->printOutMemory (K(key => 16));
17480 $A->printOutMemoryNL(K(key => 16));
17481  
17482 K(K => Rd(0..63))->loadZmm(1);
17483 PrintOutRegisterInHex zmm1;
17484  
17485 ok Assemble eq => <<END;
17486 k1: .... .... .... ..-1
17487 rax: FFFF FFFF FFFF FFFB
17488 rax: .... .... .... ..-1
17489 k1: FFFF FFFF FFFF FFF7
17490 k1: .... .... .... ..-1
17491 k1: FFFF FFFF FFFF FFFE
17492 k1: .... .... .... ..7F
17493 k1: .... .... .... ..7F
17494 dcbahgfedcbahgfedcbahgfedcbahgfe
17495 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
17496 END
17497 }
17498  
17499  
17500 =head3 K($name, $expr)
17501  
17502 Define a constant variable.
17503  
17504 Parameter Description
17505 1 $name Name of variable
17506 2 $expr Initializing expression
17507  
17508 B<Example:>
17509  
17510  
17511  
17512 my $a = K abc => 0x123; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17513  
17514 $a->out;
17515 PrintOutNL;
17516  
17517 $a->outInDec; PrintOutNL; $a->outInDecNL;
17518 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
17519 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
17520 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
17521  
17522 PrintOutString 'a';
17523  
17524 K(key => 2)->outSpaces; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17525  
17526 PrintOutStringNL 'b';
17527  
17528 ok Assemble eq => <<END, avx512=>1;
17529 abc: .... .... .... .123
17530 abc: 291
17531 abc: 291
17532 100100011
17533 100100011
17534 291
17535 291
17536 123
17537  
17538 a b
17539 END
17540  
17541 my $s = Subroutine
17542 {my ($p) = @_;
17543 $$p{v}->copy($$p{v} + $$p{k} + $$p{g} + 1);
17544 } name => 'add', parameters=>[qw(v k g)];
17545  
17546 my $v = V(v => 1);
17547  
17548 my $k = K(k => 2); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17549  
17550 my $g = V(g => 3);
17551 $s->call(parameters=>{v=>$v, k=>$k, g=>$g});
17552 $v->outNL;
17553  
17554 ok Assemble eq => <<END, avx512=>0;
17555 v: .... .... .... ...7
17556 END
17557  
17558 my $g = V g => 0;
17559 my $s = Subroutine
17560 {my ($p) = @_;
17561  
17562 $$p{g}->copy(K value => 1); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17563  
17564 } name => 'ref2', parameters=>[qw(g)];
17565  
17566 my $t = Subroutine
17567 {my ($p) = @_;
17568 $s->call(parameters=>{g=>$$p{g}});
17569 } name => 'ref', parameters=>[qw(g)];
17570  
17571 $t->call(parameters=>{g=>$g});
17572 $g->outNL;
17573  
17574 ok Assemble eq => <<END, avx512=>0;
17575 g: .... .... .... ...1
17576 END
17577  
17578 PrintCString ($stdout, V(str => Rs("abc\0def")));
17579 PrintCStringNL($stdout, V(str => Rs("ABC\0DEF")));
17580 ok Assemble eq => <<END;
17581 abcABC
17582 END
17583  
17584 my $a = V(a => 3); $a->outNL;
17585  
17586 my $b = K(b => 2); $b->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17587  
17588 my $c = $a + $b; $c->outNL;
17589 my $d = $c - $a; $d->outNL;
17590 my $g = $a * $b; $g->outNL;
17591 my $h = $g / $b; $h->outNL;
17592 my $i = $a % $b; $i->outNL;
17593  
17594 If ($a == 3,
17595 Then
17596 {PrintOutStringNL "a == 3"
17597 },
17598 Else
17599 {PrintOutStringNL "a != 3"
17600 });
17601  
17602 ++$a; $a->outNL;
17603 --$a; $a->outNL;
17604  
17605 ok Assemble eq => <<END, avx512=>0;
17606 a: .... .... .... ...3
17607 b: .... .... .... ...2
17608 (a add b): .... .... .... ...5
17609 ((a add b) sub a): .... .... .... ...2
17610 (a times b): .... .... .... ...6
17611 ((a times b) / b): .... .... .... ...3
17612 (a % b): .... .... .... ...1
17613 a == 3
17614 a: .... .... .... ...4
17615 a: .... .... .... ...3
17616 END
17617  
17618  
17619 =head3 V($name, $expr)
17620  
17621 Define a variable.
17622  
17623 Parameter Description
17624 1 $name Name of variable
17625 2 $expr Initializing expression
17626  
17627 B<Example:>
17628  
17629  
17630 my $a = K abc => 0x123;
17631 $a->out;
17632 PrintOutNL;
17633  
17634 $a->outInDec; PrintOutNL; $a->outInDecNL;
17635 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
17636 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
17637 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
17638  
17639 PrintOutString 'a';
17640 K(key => 2)->outSpaces;
17641 PrintOutStringNL 'b';
17642  
17643 ok Assemble eq => <<END, avx512=>1;
17644 abc: .... .... .... .123
17645 abc: 291
17646 abc: 291
17647 100100011
17648 100100011
17649 291
17650 291
17651 123
17652  
17653 a b
17654 END
17655  
17656 my $s = Subroutine
17657 {my ($p) = @_;
17658 $$p{v}->copy($$p{v} + $$p{k} + $$p{g} + 1);
17659 } name => 'add', parameters=>[qw(v k g)];
17660  
17661  
17662 my $v = V(v => 1); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17663  
17664 my $k = K(k => 2);
17665  
17666 my $g = V(g => 3); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17667  
17668 $s->call(parameters=>{v=>$v, k=>$k, g=>$g});
17669 $v->outNL;
17670  
17671 ok Assemble eq => <<END, avx512=>0;
17672 v: .... .... .... ...7
17673 END
17674  
17675  
17676 my $g = V g => 0; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17677  
17678 my $s = Subroutine
17679 {my ($p) = @_;
17680 $$p{g}->copy(K value => 1);
17681 } name => 'ref2', parameters=>[qw(g)];
17682  
17683 my $t = Subroutine
17684 {my ($p) = @_;
17685 $s->call(parameters=>{g=>$$p{g}});
17686 } name => 'ref', parameters=>[qw(g)];
17687  
17688 $t->call(parameters=>{g=>$g});
17689 $g->outNL;
17690  
17691 ok Assemble eq => <<END, avx512=>0;
17692 g: .... .... .... ...1
17693 END
17694  
17695  
17696 PrintCString ($stdout, V(str => Rs("abc\0def"))); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17697  
17698  
17699 PrintCStringNL($stdout, V(str => Rs("ABC\0DEF"))); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17700  
17701 ok Assemble eq => <<END;
17702 abcABC
17703 END
17704  
17705  
17706 my $a = V(a => 3); $a->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
17707  
17708 my $b = K(b => 2); $b->outNL;
17709 my $c = $a + $b; $c->outNL;
17710 my $d = $c - $a; $d->outNL;
17711 my $g = $a * $b; $g->outNL;
17712 my $h = $g / $b; $h->outNL;
17713 my $i = $a % $b; $i->outNL;
17714  
17715 If ($a == 3,
17716 Then
17717 {PrintOutStringNL "a == 3"
17718 },
17719 Else
17720 {PrintOutStringNL "a != 3"
17721 });
17722  
17723 ++$a; $a->outNL;
17724 --$a; $a->outNL;
17725  
17726 ok Assemble eq => <<END, avx512=>0;
17727 a: .... .... .... ...3
17728 b: .... .... .... ...2
17729 (a add b): .... .... .... ...5
17730 ((a add b) sub a): .... .... .... ...2
17731 (a times b): .... .... .... ...6
17732 ((a times b) / b): .... .... .... ...3
17733 (a % b): .... .... .... ...1
17734 a == 3
17735 a: .... .... .... ...4
17736 a: .... .... .... ...3
17737 END
17738  
17739  
17740 =head2 Print variables
17741  
17742 Print the values of variables or the memory addressed by them
17743  
17744 =head3 Nasm::X86::Variable::out($left, $title1, $title2)
17745  
17746 Dump the value of a variable on stdout.
17747  
17748 Parameter Description
17749 1 $left Left variable
17750 2 $title1 Optional leading title
17751 3 $title2 Optional trailing title
17752  
17753 B<Example:>
17754  
17755  
17756 my $a = V(a => 1);
17757 my $b = V(b => 2);
17758 my $c = $a + $b;
17759 Mov r15, 22;
17760 $a->getReg(r15);
17761 $b->copy($a);
17762 $b = $b + 1;
17763 $b->setReg(14);
17764 $a->outNL;
17765 $b->outNL;
17766 $c->out;
17767 PrintOutNL;
17768 PrintOutRegisterInHex r14, r15;
17769  
17770 ok Assemble eq => <<END, avx512=>0;
17771 a: .... .... .... ..16
17772 (b add 1): .... .... .... ..17
17773 (a add b): .... .... .... ...3
17774 r14: .... .... .... ..17
17775 r15: .... .... .... ..16
17776 END
17777  
17778 my $a = K abc => 0x123;
17779 $a->out;
17780 PrintOutNL;
17781  
17782 $a->outInDec; PrintOutNL; $a->outInDecNL;
17783 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
17784 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
17785 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
17786  
17787 PrintOutString 'a';
17788 K(key => 2)->outSpaces;
17789 PrintOutStringNL 'b';
17790  
17791 ok Assemble eq => <<END, avx512=>1;
17792 abc: .... .... .... .123
17793 abc: 291
17794 abc: 291
17795 100100011
17796 100100011
17797 291
17798 291
17799 123
17800  
17801 a b
17802 END
17803  
17804  
17805 =head3 Nasm::X86::Variable::outNL($left, $title1, $title2)
17806  
17807 Dump the value of a variable on stdout and append a new line.
17808  
17809 Parameter Description
17810 1 $left Left variable
17811 2 $title1 Optional leading title
17812 3 $title2 Optional trailing title
17813  
17814 B<Example:>
17815  
17816  
17817 my $a = V a => 0x1111;
17818 $a->outNL('');
17819 $a->outRightInBinNL;
17820 $a->outRightInDecNL;
17821 $a->outRightInHexNL;
17822 ok Assemble eq => <<END;
17823 .... .... .... 1111
17824 1000100010001
17825 4369
17826  
17827 END
17828  
17829 my $a = V(a => 1);
17830 my $b = V(b => 2);
17831 my $c = $a + $b;
17832 Mov r15, 22;
17833 $a->getReg(r15);
17834 $b->copy($a);
17835 $b = $b + 1;
17836 $b->setReg(14);
17837 $a->outNL;
17838 $b->outNL;
17839 $c->out;
17840 PrintOutNL;
17841 PrintOutRegisterInHex r14, r15;
17842  
17843 ok Assemble eq => <<END, avx512=>0;
17844 a: .... .... .... ..16
17845 (b add 1): .... .... .... ..17
17846 (a add b): .... .... .... ...3
17847 r14: .... .... .... ..17
17848 r15: .... .... .... ..16
17849 END
17850  
17851  
17852 =head3 Decimal representation
17853  
17854 Print out a variable as a decimal number
17855  
17856 =head4 Nasm::X86::Variable::outInDec($number, $title1, $title2)
17857  
17858 Dump the value of a variable on stdout in decimal.
17859  
17860 Parameter Description
17861 1 $number Number as variable
17862 2 $title1 Optional leading title
17863 3 $title2 Optional trailing title
17864  
17865 B<Example:>
17866  
17867  
17868 my $a = K abc => 0x123;
17869 $a->out;
17870 PrintOutNL;
17871  
17872 $a->outInDec; PrintOutNL; $a->outInDecNL;
17873 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
17874 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
17875 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
17876  
17877 PrintOutString 'a';
17878 K(key => 2)->outSpaces;
17879 PrintOutStringNL 'b';
17880  
17881 ok Assemble eq => <<END, avx512=>1;
17882 abc: .... .... .... .123
17883 abc: 291
17884 abc: 291
17885 100100011
17886 100100011
17887 291
17888 291
17889 123
17890  
17891 a b
17892 END
17893  
17894  
17895 =head4 Nasm::X86::Variable::outInDecNL($number, $title1, $title2)
17896  
17897 Dump the value of a variable on stdout in decimal followed by a new line.
17898  
17899 Parameter Description
17900 1 $number Number as variable
17901 2 $title1 Optional leading title
17902 3 $title2 Optional trailing title
17903  
17904 B<Example:>
17905  
17906  
17907 my $a = K abc => 0x123;
17908 $a->out;
17909 PrintOutNL;
17910  
17911 $a->outInDec; PrintOutNL; $a->outInDecNL;
17912 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
17913 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
17914 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
17915  
17916 PrintOutString 'a';
17917 K(key => 2)->outSpaces;
17918 PrintOutStringNL 'b';
17919  
17920 ok Assemble eq => <<END, avx512=>1;
17921 abc: .... .... .... .123
17922 abc: 291
17923 abc: 291
17924 100100011
17925 100100011
17926 291
17927 291
17928 123
17929  
17930 a b
17931 END
17932  
17933 my $e = q(parameters);
17934  
17935 (V string => "[rbp+8]")->outInDecNL;
17936 (V string => "[rbp+16]")->outCStringNL;
17937 (V string => "[rbp+24]")->outCStringNL;
17938 (V string => "[rbp+32]")->outCStringNL;
17939 (V string => "[rbp+40]")->outCStringNL;
17940 (V string => "[rbp+48]")->outInDecNL;
17941  
17942 (V string => "[rbp+8]")->for(sub
17943 {my ($index, $start, $next, $end) = @_;
17944 $index->setReg(rax);
17945 Inc rax;
17946 PrintOutRaxInDec;
17947 Inc rax;
17948 PrintOutString " : ";
17949 Shl rax, 3;
17950 (V string => "[rbp+rax]")->outCStringNL;
17951 });
17952  
17953 Assemble keep => $e;
17954  
17955 is_deeply scalar(qx(./$e AaAaAaAaAa BbCcDdEe 123456789)), <<END;
17956 string: 4
17957 ./parameters
17958 AaAaAaAaAa
17959 BbCcDdEe
17960 123456789
17961 string: 0
17962 1 : ./parameters
17963 2 : AaAaAaAaAa
17964 3 : BbCcDdEe
17965 4 : 123456789
17966 END
17967  
17968 unlink $e;
17969  
17970  
17971 =head3 Decimal representation right justified
17972  
17973 Print out a variable as a decimal number right adjusted in a field of specified width
17974  
17975 =head4 Nasm::X86::Variable::outRightInDec($number, $width)
17976  
17977 Dump the value of a variable on stdout as a decimal number right adjusted in a field of specified width.
17978  
17979 Parameter Description
17980 1 $number Number
17981 2 $width Width
17982  
17983 B<Example:>
17984  
17985  
17986 my $a = K abc => 0x123;
17987 $a->out;
17988 PrintOutNL;
17989  
17990 $a->outInDec; PrintOutNL; $a->outInDecNL;
17991 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
17992 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
17993 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
17994  
17995 PrintOutString 'a';
17996 K(key => 2)->outSpaces;
17997 PrintOutStringNL 'b';
17998  
17999 ok Assemble eq => <<END, avx512=>1;
18000 abc: .... .... .... .123
18001 abc: 291
18002 abc: 291
18003 100100011
18004 100100011
18005 291
18006 291
18007 123
18008  
18009 a b
18010 END
18011  
18012  
18013 =head4 Nasm::X86::Variable::outRightInDecNL($number, $width)
18014  
18015 Dump the value of a variable on stdout as a decimal number right adjusted in a field of specified width followed by a new line.
18016  
18017 Parameter Description
18018 1 $number Number
18019 2 $width Width
18020  
18021 B<Example:>
18022  
18023  
18024 my $a = K abc => 0x123;
18025 $a->out;
18026 PrintOutNL;
18027  
18028 $a->outInDec; PrintOutNL; $a->outInDecNL;
18029 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
18030 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
18031 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
18032  
18033 PrintOutString 'a';
18034 K(key => 2)->outSpaces;
18035 PrintOutStringNL 'b';
18036  
18037 ok Assemble eq => <<END, avx512=>1;
18038 abc: .... .... .... .123
18039 abc: 291
18040 abc: 291
18041 100100011
18042 100100011
18043 291
18044 291
18045 123
18046  
18047 a b
18048 END
18049  
18050  
18051 =head3 Hexadecimal representation, right justified
18052  
18053 Print number variables in hexadecimal right justified in fields of specified width.
18054  
18055 =head4 Nasm::X86::Variable::outRightInHex($number, $width)
18056  
18057 Write the specified variable number in hexadecimal right justified in a field of specified width to stdout.
18058  
18059 Parameter Description
18060 1 $number Number to print as a variable
18061 2 $width Width of output field
18062  
18063 B<Example:>
18064  
18065  
18066 my $a = K abc => 0x123;
18067 $a->out;
18068 PrintOutNL;
18069  
18070 $a->outInDec; PrintOutNL; $a->outInDecNL;
18071 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
18072 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
18073 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
18074  
18075 PrintOutString 'a';
18076 K(key => 2)->outSpaces;
18077 PrintOutStringNL 'b';
18078  
18079 ok Assemble eq => <<END, avx512=>1;
18080 abc: .... .... .... .123
18081 abc: 291
18082 abc: 291
18083 100100011
18084 100100011
18085 291
18086 291
18087 123
18088  
18089 a b
18090 END
18091  
18092  
18093 =head4 Nasm::X86::Variable::outRightInHexNL($number, $width)
18094  
18095 Write the specified variable number in hexadecimal right justified in a field of specified width to stdout followed by a new line.
18096  
18097 Parameter Description
18098 1 $number Number to print as a variable
18099 2 $width Width of output field
18100  
18101 B<Example:>
18102  
18103  
18104 my $a = K abc => 0x123;
18105 $a->out;
18106 PrintOutNL;
18107  
18108 $a->outInDec; PrintOutNL; $a->outInDecNL;
18109 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
18110 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
18111 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
18112  
18113 PrintOutString 'a';
18114 K(key => 2)->outSpaces;
18115 PrintOutStringNL 'b';
18116  
18117 ok Assemble eq => <<END, avx512=>1;
18118 abc: .... .... .... .123
18119 abc: 291
18120 abc: 291
18121 100100011
18122 100100011
18123 291
18124 291
18125 123
18126  
18127 a b
18128 END
18129  
18130  
18131 =head3 Binary representation, right justified
18132  
18133 Print number variables in binary right justified in fields of specified width.
18134  
18135 =head4 Nasm::X86::Variable::outRightInBin($number, $width)
18136  
18137 Write the specified variable number in binary right justified in a field of specified width to stdout.
18138  
18139 Parameter Description
18140 1 $number Number to print as a variable
18141 2 $width Width of output field
18142  
18143 B<Example:>
18144  
18145  
18146 my $a = K abc => 0x123;
18147 $a->out;
18148 PrintOutNL;
18149  
18150 $a->outInDec; PrintOutNL; $a->outInDecNL;
18151 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
18152 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
18153 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
18154  
18155 PrintOutString 'a';
18156 K(key => 2)->outSpaces;
18157 PrintOutStringNL 'b';
18158  
18159 ok Assemble eq => <<END, avx512=>1;
18160 abc: .... .... .... .123
18161 abc: 291
18162 abc: 291
18163 100100011
18164 100100011
18165 291
18166 291
18167 123
18168  
18169 a b
18170 END
18171  
18172  
18173 =head4 Nasm::X86::Variable::outRightInBinNL($number, $width)
18174  
18175 Write the specified variable number in binary right justified in a field of specified width to stdout followed by a new line.
18176  
18177 Parameter Description
18178 1 $number Number to print as a variable
18179 2 $width Width of output field
18180  
18181 B<Example:>
18182  
18183  
18184 my $a = K abc => 0x123;
18185 $a->out;
18186 PrintOutNL;
18187  
18188 $a->outInDec; PrintOutNL; $a->outInDecNL;
18189 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
18190 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
18191 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
18192  
18193 PrintOutString 'a';
18194 K(key => 2)->outSpaces;
18195 PrintOutStringNL 'b';
18196  
18197 ok Assemble eq => <<END, avx512=>1;
18198 abc: .... .... .... .123
18199 abc: 291
18200 abc: 291
18201 100100011
18202 100100011
18203 291
18204 291
18205 123
18206  
18207 a b
18208 END
18209  
18210  
18211 =head3 Spaces
18212  
18213 Print out a variable number of spaces.
18214  
18215 =head4 Nasm::X86::Variable::spaces($count, $channel)
18216  
18217 Print the specified number of spaces to the specified channel.
18218  
18219 Parameter Description
18220 1 $count Number of spaces
18221 2 $channel Channel
18222  
18223 B<Example:>
18224  
18225  
18226 if (1)
18227 {my $a = V(key => 0x123);
18228 is_deeply $a->at, "[rbp-8*(2)]";
18229 is_deeply $a->addressExpr, "[rbp-8*(2)]";
18230  
18231 ok !$a->isRef;
18232  
18233 Mov rax, -1;
18234 Kmovq k1, rax;
18235 PrintOutRegisterInHex k1;
18236  
18237 K(key => 2)->clearBit(rax);
18238 PrintOutRegisterInHex rax;
18239  
18240 K(key => 2)->setBit(rax);
18241 PrintOutRegisterInHex rax;
18242  
18243 K(key => 3)->clearMaskBit(k1);
18244 PrintOutRegisterInHex k1;
18245  
18246 K(key => 3)->setMaskBit(k1);
18247 PrintOutRegisterInHex k1;
18248  
18249 K(key => 0)->clearMaskBit(k1);
18250 PrintOutRegisterInHex k1;
18251  
18252 ClearRegisters k1;
18253 K(key => 7)->setMaskFirst(k1);
18254 PrintOutRegisterInHex k1;
18255  
18256 K(key => 3)->spaces($stdout);
18257 PrintOutRegisterInHex k1;
18258  
18259 my $N = K size => 4096;
18260 my $A = $N->allocateMemory;
18261 $A->clearMemory($N);
18262 ClearMemory($A, $N);
18263  
18264 $A->setReg(rax);
18265 Mov "dword[rax]", 0x61626364;
18266 Mov "dword[rax+4]", 0x65666768;
18267  
18268 ($A+8)->copyMemory($A, K key => 8);
18269  
18270 $A->printOutMemory (K(key => 16));
18271 $A->printOutMemoryNL(K(key => 16));
18272  
18273 K(K => Rd(0..63))->loadZmm(1);
18274 PrintOutRegisterInHex zmm1;
18275  
18276 ok Assemble eq => <<END;
18277 k1: .... .... .... ..-1
18278 rax: FFFF FFFF FFFF FFFB
18279 rax: .... .... .... ..-1
18280 k1: FFFF FFFF FFFF FFF7
18281 k1: .... .... .... ..-1
18282 k1: FFFF FFFF FFFF FFFE
18283 k1: .... .... .... ..7F
18284 k1: .... .... .... ..7F
18285 dcbahgfedcbahgfedcbahgfedcbahgfe
18286 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
18287 END
18288 }
18289  
18290  
18291 =head4 Nasm::X86::Variable::outSpaces($count)
18292  
18293 Print the specified number of spaces to stdout.
18294  
18295 Parameter Description
18296 1 $count Number of spaces
18297  
18298 B<Example:>
18299  
18300  
18301 my $a = K abc => 0x123;
18302 $a->out;
18303 PrintOutNL;
18304  
18305 $a->outInDec; PrintOutNL; $a->outInDecNL;
18306 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
18307 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
18308 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
18309  
18310 PrintOutString 'a';
18311 K(key => 2)->outSpaces;
18312 PrintOutStringNL 'b';
18313  
18314 ok Assemble eq => <<END, avx512=>1;
18315 abc: .... .... .... .123
18316 abc: 291
18317 abc: 291
18318 100100011
18319 100100011
18320 291
18321 291
18322 123
18323  
18324 a b
18325 END
18326  
18327  
18328 =head3 C style zero terminated strings
18329  
18330 Print out C style zero terminated strings.
18331  
18332 =head4 Nasm::X86::Variable::outCString($string)
18333  
18334 Print a zero terminated C style string addressed by a variable on stdout.
18335  
18336 Parameter Description
18337 1 $string String
18338  
18339 B<Example:>
18340  
18341  
18342 my $s = Rutf8 '𝝰𝝱𝝲𝝳';
18343 V(address => $s)->outCString; PrintOutNL;
18344 V(address => $s)->outCStringNL;
18345  
18346 ok Assemble(debug => 0, trace => 0, eq => <<END, avx512=>0);
18347 𝝰𝝱𝝲𝝳
18348 𝝰𝝱𝝲𝝳
18349 END
18350  
18351  
18352 =head4 Nasm::X86::Variable::outCStringNL($string)
18353  
18354 Print a zero terminated C style string addressed by a variable on stdout followed by a new line.
18355  
18356 Parameter Description
18357 1 $string String
18358  
18359 B<Example:>
18360  
18361  
18362 my $s = Rutf8 '𝝰𝝱𝝲𝝳';
18363 V(address => $s)->outCString; PrintOutNL;
18364 V(address => $s)->outCStringNL;
18365  
18366 ok Assemble(debug => 0, trace => 0, eq => <<END, avx512=>0);
18367 𝝰𝝱𝝲𝝳
18368 𝝰𝝱𝝲𝝳
18369 END
18370  
18371 my $e = q(parameters);
18372  
18373 (V string => "[rbp+8]")->outInDecNL;
18374 (V string => "[rbp+16]")->outCStringNL;
18375 (V string => "[rbp+24]")->outCStringNL;
18376 (V string => "[rbp+32]")->outCStringNL;
18377 (V string => "[rbp+40]")->outCStringNL;
18378 (V string => "[rbp+48]")->outInDecNL;
18379  
18380 (V string => "[rbp+8]")->for(sub
18381 {my ($index, $start, $next, $end) = @_;
18382 $index->setReg(rax);
18383 Inc rax;
18384 PrintOutRaxInDec;
18385 Inc rax;
18386 PrintOutString " : ";
18387 Shl rax, 3;
18388 (V string => "[rbp+rax]")->outCStringNL;
18389 });
18390  
18391 Assemble keep => $e;
18392  
18393 is_deeply scalar(qx(./$e AaAaAaAaAa BbCcDdEe 123456789)), <<END;
18394 string: 4
18395 ./parameters
18396 AaAaAaAaAa
18397 BbCcDdEe
18398 123456789
18399 string: 0
18400 1 : ./parameters
18401 2 : AaAaAaAaAa
18402 3 : BbCcDdEe
18403 4 : 123456789
18404 END
18405  
18406 unlink $e;
18407  
18408  
18409 =head2 Addressing
18410  
18411 Create references to variables and dereference variables
18412  
18413 =head3 Nasm::X86::Variable::address($source)
18414  
18415 Create a variable that contains the address of another variable.
18416  
18417 Parameter Description
18418 1 $source Source variable
18419  
18420 B<Example:>
18421  
18422  
18423 V(a => 2);
18424 V(a => 1);
18425 my $a = V(a => 0)->address;
18426 ($a+ 0)->dereference->outNL;
18427 ($a+ 8)->dereference->outNL;
18428 ($a+16)->dereference->outNL;
18429 ($a+16)->update(K key => 3);
18430 ($a+16)->dereference->outNL;
18431 ok Assemble eq => <<END;
18432 deref (addr a add 0): .... .... .... ...0
18433 deref (addr a add 8): .... .... .... ...1
18434 deref (addr a add 16): .... .... .... ...2
18435 deref (addr a add 16): .... .... .... ...3
18436 END
18437  
18438  
18439 =head3 Nasm::X86::Variable::dereference($address)
18440  
18441 Create a variable that contains the contents of the variable addressed by the specified variable.
18442  
18443 Parameter Description
18444 1 $address Source variable
18445  
18446 B<Example:>
18447  
18448  
18449 V(a => 2);
18450 V(a => 1);
18451 my $a = V(a => 0)->address;
18452 ($a+ 0)->dereference->outNL;
18453 ($a+ 8)->dereference->outNL;
18454 ($a+16)->dereference->outNL;
18455 ($a+16)->update(K key => 3);
18456 ($a+16)->dereference->outNL;
18457 ok Assemble eq => <<END;
18458 deref (addr a add 0): .... .... .... ...0
18459 deref (addr a add 8): .... .... .... ...1
18460 deref (addr a add 16): .... .... .... ...2
18461 deref (addr a add 16): .... .... .... ...3
18462 END
18463  
18464  
18465 =head3 Nasm::X86::Variable::update($address, $content)
18466  
18467 Update the content of the addressed variable with the content of the specified variable.
18468  
18469 Parameter Description
18470 1 $address Source variable
18471 2 $content Content
18472  
18473 B<Example:>
18474  
18475  
18476 V(a => 2);
18477 V(a => 1);
18478 my $a = V(a => 0)->address;
18479 ($a+ 0)->dereference->outNL;
18480 ($a+ 8)->dereference->outNL;
18481 ($a+16)->dereference->outNL;
18482 ($a+16)->update(K key => 3);
18483 ($a+16)->dereference->outNL;
18484 ok Assemble eq => <<END;
18485 deref (addr a add 0): .... .... .... ...0
18486 deref (addr a add 8): .... .... .... ...1
18487 deref (addr a add 16): .... .... .... ...2
18488 deref (addr a add 16): .... .... .... ...3
18489 END
18490  
18491  
18492 =head3 constantString($string)
18493  
18494 Return the address and length of a constant string as two variables.
18495  
18496 Parameter Description
18497 1 $string Constant utf8 string
18498  
18499 B<Example:>
18500  
18501  
18502  
18503 my ($t, $l) = constantString("Hello World"); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
18504  
18505 $t->printOutMemoryNL($l);
18506  
18507 ok Assemble eq => <<END, avx512=>1;
18508 Hello World
18509 END
18510  
18511  
18512 =head2 Operations
18513  
18514 Variable operations
18515  
18516 =head3 Nasm::X86::Variable::addressExpr($left, $offset)
18517  
18518 Create a register expression to address an offset form a variable.
18519  
18520 Parameter Description
18521 1 $left Left variable
18522 2 $offset Optional offset
18523  
18524 B<Example:>
18525  
18526  
18527 if (1)
18528 {my $a = V(key => 0x123);
18529 is_deeply $a->at, "[rbp-8*(2)]";
18530 is_deeply $a->addressExpr, "[rbp-8*(2)]";
18531  
18532 ok !$a->isRef;
18533  
18534 Mov rax, -1;
18535 Kmovq k1, rax;
18536 PrintOutRegisterInHex k1;
18537  
18538 K(key => 2)->clearBit(rax);
18539 PrintOutRegisterInHex rax;
18540  
18541 K(key => 2)->setBit(rax);
18542 PrintOutRegisterInHex rax;
18543  
18544 K(key => 3)->clearMaskBit(k1);
18545 PrintOutRegisterInHex k1;
18546  
18547 K(key => 3)->setMaskBit(k1);
18548 PrintOutRegisterInHex k1;
18549  
18550 K(key => 0)->clearMaskBit(k1);
18551 PrintOutRegisterInHex k1;
18552  
18553 ClearRegisters k1;
18554 K(key => 7)->setMaskFirst(k1);
18555 PrintOutRegisterInHex k1;
18556  
18557 K(key => 3)->spaces($stdout);
18558 PrintOutRegisterInHex k1;
18559  
18560 my $N = K size => 4096;
18561 my $A = $N->allocateMemory;
18562 $A->clearMemory($N);
18563 ClearMemory($A, $N);
18564  
18565 $A->setReg(rax);
18566 Mov "dword[rax]", 0x61626364;
18567 Mov "dword[rax+4]", 0x65666768;
18568  
18569 ($A+8)->copyMemory($A, K key => 8);
18570  
18571 $A->printOutMemory (K(key => 16));
18572 $A->printOutMemoryNL(K(key => 16));
18573  
18574 K(K => Rd(0..63))->loadZmm(1);
18575 PrintOutRegisterInHex zmm1;
18576  
18577 ok Assemble eq => <<END;
18578 k1: .... .... .... ..-1
18579 rax: FFFF FFFF FFFF FFFB
18580 rax: .... .... .... ..-1
18581 k1: FFFF FFFF FFFF FFF7
18582 k1: .... .... .... ..-1
18583 k1: FFFF FFFF FFFF FFFE
18584 k1: .... .... .... ..7F
18585 k1: .... .... .... ..7F
18586 dcbahgfedcbahgfedcbahgfedcbahgfe
18587 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
18588 END
18589 }
18590  
18591  
18592 =head3 Nasm::X86::Variable::clone($variable, $name)
18593  
18594 Clone a variable to make a new variable.
18595  
18596 Parameter Description
18597 1 $variable Variable to clone
18598 2 $name New name for variable
18599  
18600 B<Example:>
18601  
18602  
18603 my $a = V('a', 1);
18604 my $b = $a->clone('a');
18605  
18606 $_->outNL for $a, $b;
18607  
18608 ok Assemble(debug => 0, trace => 0, eq => <<END, avx512=>0);
18609 a: .... .... .... ...1
18610 a: .... .... .... ...1
18611 END
18612  
18613  
18614 =head3 Nasm::X86::Variable::copy($left, $right)
18615  
18616 Copy one variable into another.
18617  
18618 Parameter Description
18619 1 $left Left variable
18620 2 $right Right variable
18621  
18622 B<Example:>
18623  
18624  
18625 my $a = V(a => 1);
18626 my $b = V(b => 2);
18627 my $c = $a + $b;
18628 Mov r15, 22;
18629 $a->getReg(r15);
18630 $b->copy($a);
18631 $b = $b + 1;
18632 $b->setReg(14);
18633 $a->outNL;
18634 $b->outNL;
18635 $c->out;
18636 PrintOutNL;
18637 PrintOutRegisterInHex r14, r15;
18638  
18639 ok Assemble eq => <<END, avx512=>0;
18640 a: .... .... .... ..16
18641 (b add 1): .... .... .... ..17
18642 (a add b): .... .... .... ...3
18643 r14: .... .... .... ..17
18644 r15: .... .... .... ..16
18645 END
18646  
18647 my $a = K abc => 0x123;
18648 $a->out;
18649 PrintOutNL;
18650  
18651 $a->outInDec; PrintOutNL; $a->outInDecNL;
18652 $a->outRightInBin(16); PrintOutNL; $a->outRightInBinNL(16);
18653 $a->outRightInDec(16); PrintOutNL; $a->outRightInDecNL;
18654 $a->outRightInHex(16); PrintOutNL; $a->outRightInHexNL;
18655  
18656 PrintOutString 'a';
18657 K(key => 2)->outSpaces;
18658 PrintOutStringNL 'b';
18659  
18660 ok Assemble eq => <<END, avx512=>1;
18661 abc: .... .... .... .123
18662 abc: 291
18663 abc: 291
18664 100100011
18665 100100011
18666 291
18667 291
18668 123
18669  
18670 a b
18671 END
18672  
18673 my $s = Subroutine
18674 {my ($p) = @_;
18675 $$p{v}->copy($$p{v} + $$p{k} + $$p{g} + 1);
18676 } name => 'add', parameters=>[qw(v k g)];
18677  
18678 my $v = V(v => 1);
18679 my $k = K(k => 2);
18680 my $g = V(g => 3);
18681 $s->call(parameters=>{v=>$v, k=>$k, g=>$g});
18682 $v->outNL;
18683  
18684 ok Assemble eq => <<END, avx512=>0;
18685 v: .... .... .... ...7
18686 END
18687  
18688 my $g = V g => 0;
18689 my $s = Subroutine
18690 {my ($p) = @_;
18691 $$p{g}->copy(K value => 1);
18692 } name => 'ref2', parameters=>[qw(g)];
18693  
18694 my $t = Subroutine
18695 {my ($p) = @_;
18696 $s->call(parameters=>{g=>$$p{g}});
18697 } name => 'ref', parameters=>[qw(g)];
18698  
18699 $t->call(parameters=>{g=>$g});
18700 $g->outNL;
18701  
18702 ok Assemble eq => <<END, avx512=>0;
18703 g: .... .... .... ...1
18704 END
18705  
18706 my $a = V('a', 1);
18707 my $r = R('r')->copyRef($a);
18708 my $R = R('R')->copyRef($r);
18709  
18710 $a->outNL;
18711 $r->outNL;
18712 $R->outNL;
18713  
18714 $a->copy(2);
18715  
18716 $a->outNL;
18717 $r->outNL;
18718 $R->outNL;
18719  
18720 $r->copy(3);
18721  
18722 $a->outNL;
18723 $r->outNL;
18724 $R->outNL;
18725  
18726 $R->copy(4);
18727  
18728 $a->outNL;
18729 $r->outNL;
18730 $R->outNL;
18731  
18732 ok Assemble(debug => 0, trace => 0, eq => <<END, avx512=>0);
18733 a: .... .... .... ...1
18734 r: .... .... .... ...1
18735 R: .... .... .... ...1
18736 a: .... .... .... ...2
18737 r: .... .... .... ...2
18738 R: .... .... .... ...2
18739 a: .... .... .... ...3
18740 r: .... .... .... ...3
18741 R: .... .... .... ...3
18742 a: .... .... .... ...4
18743 r: .... .... .... ...4
18744 R: .... .... .... ...4
18745 END
18746  
18747  
18748 =head3 Nasm::X86::Variable::copyRef($left, $right)
18749  
18750 Copy a reference to a variable.
18751  
18752 Parameter Description
18753 1 $left Left variable
18754 2 $right Right variable
18755  
18756 B<Example:>
18757  
18758  
18759 my $a = V('a', 1);
18760 my $r = R('r')->copyRef($a);
18761 my $R = R('R')->copyRef($r);
18762  
18763 $a->outNL;
18764 $r->outNL;
18765 $R->outNL;
18766  
18767 $a->copy(2);
18768  
18769 $a->outNL;
18770 $r->outNL;
18771 $R->outNL;
18772  
18773 $r->copy(3);
18774  
18775 $a->outNL;
18776 $r->outNL;
18777 $R->outNL;
18778  
18779 $R->copy(4);
18780  
18781 $a->outNL;
18782 $r->outNL;
18783 $R->outNL;
18784  
18785 ok Assemble(debug => 0, trace => 0, eq => <<END, avx512=>0);
18786 a: .... .... .... ...1
18787 r: .... .... .... ...1
18788 R: .... .... .... ...1
18789 a: .... .... .... ...2
18790 r: .... .... .... ...2
18791 R: .... .... .... ...2
18792 a: .... .... .... ...3
18793 r: .... .... .... ...3
18794 R: .... .... .... ...3
18795 a: .... .... .... ...4
18796 r: .... .... .... ...4
18797 R: .... .... .... ...4
18798 END
18799  
18800  
18801 =head3 Nasm::X86::Variable::copyZF($var)
18802  
18803 Copy the current state of the zero flag into a variable.
18804  
18805 Parameter Description
18806 1 $var Variable
18807  
18808 B<Example:>
18809  
18810  
18811 Mov r15, 1;
18812 my $z = V(zf => undef);
18813 Cmp r15, 1; $z->copyZF; $z->outNL;
18814 Cmp r15, 2; $z->copyZF; $z->outNL;
18815 Cmp r15, 1; $z->copyZFInverted; $z->outNL;
18816 Cmp r15, 2; $z->copyZFInverted; $z->outNL;
18817  
18818 ok Assemble eq => <<END, avx512=>0;
18819 zf: .... .... .... ...1
18820 zf: .... .... .... ...0
18821 zf: .... .... .... ...0
18822 zf: .... .... .... ...1
18823 END
18824  
18825  
18826 =head3 Nasm::X86::Variable::copyZFInverted($var)
18827  
18828 Copy the opposite of the current state of the zero flag into a variable.
18829  
18830 Parameter Description
18831 1 $var Variable
18832  
18833 B<Example:>
18834  
18835  
18836 Mov r15, 1;
18837 my $z = V(zf => undef);
18838 Cmp r15, 1; $z->copyZF; $z->outNL;
18839 Cmp r15, 2; $z->copyZF; $z->outNL;
18840 Cmp r15, 1; $z->copyZFInverted; $z->outNL;
18841 Cmp r15, 2; $z->copyZFInverted; $z->outNL;
18842  
18843 ok Assemble eq => <<END, avx512=>0;
18844 zf: .... .... .... ...1
18845 zf: .... .... .... ...0
18846 zf: .... .... .... ...0
18847 zf: .... .... .... ...1
18848 END
18849  
18850  
18851 =head3 Nasm::X86::Variable::isRef($variable)
18852  
18853 Check whether the specified variable is a reference to another variable.
18854  
18855 Parameter Description
18856 1 $variable Variable
18857  
18858 B<Example:>
18859  
18860  
18861 if (1)
18862 {my $a = V(key => 0x123);
18863 is_deeply $a->at, "[rbp-8*(2)]";
18864 is_deeply $a->addressExpr, "[rbp-8*(2)]";
18865  
18866 ok !$a->isRef;
18867  
18868 Mov rax, -1;
18869 Kmovq k1, rax;
18870 PrintOutRegisterInHex k1;
18871  
18872 K(key => 2)->clearBit(rax);
18873 PrintOutRegisterInHex rax;
18874  
18875 K(key => 2)->setBit(rax);
18876 PrintOutRegisterInHex rax;
18877  
18878 K(key => 3)->clearMaskBit(k1);
18879 PrintOutRegisterInHex k1;
18880  
18881 K(key => 3)->setMaskBit(k1);
18882 PrintOutRegisterInHex k1;
18883  
18884 K(key => 0)->clearMaskBit(k1);
18885 PrintOutRegisterInHex k1;
18886  
18887 ClearRegisters k1;
18888 K(key => 7)->setMaskFirst(k1);
18889 PrintOutRegisterInHex k1;
18890  
18891 K(key => 3)->spaces($stdout);
18892 PrintOutRegisterInHex k1;
18893  
18894 my $N = K size => 4096;
18895 my $A = $N->allocateMemory;
18896 $A->clearMemory($N);
18897 ClearMemory($A, $N);
18898  
18899 $A->setReg(rax);
18900 Mov "dword[rax]", 0x61626364;
18901 Mov "dword[rax+4]", 0x65666768;
18902  
18903 ($A+8)->copyMemory($A, K key => 8);
18904  
18905 $A->printOutMemory (K(key => 16));
18906 $A->printOutMemoryNL(K(key => 16));
18907  
18908 K(K => Rd(0..63))->loadZmm(1);
18909 PrintOutRegisterInHex zmm1;
18910  
18911 ok Assemble eq => <<END;
18912 k1: .... .... .... ..-1
18913 rax: FFFF FFFF FFFF FFFB
18914 rax: .... .... .... ..-1
18915 k1: FFFF FFFF FFFF FFF7
18916 k1: .... .... .... ..-1
18917 k1: FFFF FFFF FFFF FFFE
18918 k1: .... .... .... ..7F
18919 k1: .... .... .... ..7F
18920 dcbahgfedcbahgfedcbahgfedcbahgfe
18921 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
18922 END
18923 }
18924  
18925  
18926 =head3 Nasm::X86::Variable::setReg($variable, $register)
18927  
18928 Set the named registers from the content of the variable.
18929  
18930 Parameter Description
18931 1 $variable Variable
18932 2 $register Register to load
18933  
18934 B<Example:>
18935  
18936  
18937 my $a = V(a => 1);
18938 my $b = V(b => 2);
18939 my $c = $a + $b;
18940 Mov r15, 22;
18941 $a->getReg(r15);
18942 $b->copy($a);
18943 $b = $b + 1;
18944 $b->setReg(14);
18945 $a->outNL;
18946 $b->outNL;
18947 $c->out;
18948 PrintOutNL;
18949 PrintOutRegisterInHex r14, r15;
18950  
18951 ok Assemble eq => <<END, avx512=>0;
18952 a: .... .... .... ..16
18953 (b add 1): .... .... .... ..17
18954 (a add b): .... .... .... ...3
18955 r14: .... .... .... ..17
18956 r15: .... .... .... ..16
18957 END
18958  
18959  
18960 =head3 Nasm::X86::Variable::getReg($variable, $register)
18961  
18962 Load the variable from a register expression.
18963  
18964 Parameter Description
18965 1 $variable Variable
18966 2 $register Register expression to load
18967  
18968 B<Example:>
18969  
18970  
18971 my $a = V(a => 1);
18972 my $b = V(b => 2);
18973 my $c = $a + $b;
18974 Mov r15, 22;
18975 $a->getReg(r15);
18976 $b->copy($a);
18977 $b = $b + 1;
18978 $b->setReg(14);
18979 $a->outNL;
18980 $b->outNL;
18981 $c->out;
18982 PrintOutNL;
18983 PrintOutRegisterInHex r14, r15;
18984  
18985 ok Assemble eq => <<END, avx512=>0;
18986 a: .... .... .... ..16
18987 (b add 1): .... .... .... ..17
18988 (a add b): .... .... .... ...3
18989 r14: .... .... .... ..17
18990 r15: .... .... .... ..16
18991 END
18992  
18993  
18994 =head3 Nasm::X86::Variable::min($left, $right)
18995  
18996 Minimum of two variables.
18997  
18998 Parameter Description
18999 1 $left Left variable
19000 2 $right Right variable or constant
19001  
19002 B<Example:>
19003  
19004  
19005 my $a = V("a", 1);
19006 my $b = V("b", 2);
19007 my $c = $a->min($b);
19008 my $d = $a->max($b);
19009 $a->outNL;
19010 $b->outNL;
19011 $c->outNL;
19012 $d->outNL;
19013  
19014 ok Assemble(debug => 0, eq => <<END, avx512=>0);
19015 a: .... .... .... ...1
19016 b: .... .... .... ...2
19017 min: .... .... .... ...1
19018 max: .... .... .... ...2
19019 END
19020  
19021  
19022 =head3 Nasm::X86::Variable::max($left, $right)
19023  
19024 Maximum of two variables.
19025  
19026 Parameter Description
19027 1 $left Left variable
19028 2 $right Right variable or constant
19029  
19030 B<Example:>
19031  
19032  
19033 my $a = V("a", 1);
19034 my $b = V("b", 2);
19035 my $c = $a->min($b);
19036 my $d = $a->max($b);
19037 $a->outNL;
19038 $b->outNL;
19039 $c->outNL;
19040 $d->outNL;
19041  
19042 ok Assemble(debug => 0, eq => <<END, avx512=>0);
19043 a: .... .... .... ...1
19044 b: .... .... .... ...2
19045 min: .... .... .... ...1
19046 max: .... .... .... ...2
19047 END
19048  
19049  
19050 =head3 Nasm::X86::Variable::setMask($start, $length, $mask)
19051  
19052 Set the mask register to ones starting at the specified position for the specified length and zeroes elsewhere.
19053  
19054 Parameter Description
19055 1 $start Variable containing start of mask
19056 2 $length Variable containing length of mask
19057 3 $mask Mask register
19058  
19059 B<Example:>
19060  
19061  
19062 my $start = V("Start", 7);
19063 my $length = V("Length", 3);
19064 $start->setMask($length, k7);
19065 PrintOutRegisterInHex k7;
19066  
19067 ok Assemble(debug => 0, eq => <<END, avx512=>1);
19068 k7: .... .... .... .380
19069 END
19070  
19071 my $z = V('zero', 0);
19072 my $o = V('one', 1);
19073 my $t = V('two', 2);
19074 $z->setMask($o, k7); PrintOutRegisterInHex k7;
19075 $z->setMask($t, k6); PrintOutRegisterInHex k6;
19076 $z->setMask($o+$t, k5); PrintOutRegisterInHex k5;
19077 $o->setMask($o, k4); PrintOutRegisterInHex k4;
19078 $o->setMask($t, k3); PrintOutRegisterInHex k3;
19079 $o->setMask($o+$t, k2); PrintOutRegisterInHex k2;
19080  
19081 $t->setMask($o, k1); PrintOutRegisterInHex k1;
19082 $t->setMask($t, k0); PrintOutRegisterInHex k0;
19083  
19084 ok Assemble(debug => 0, eq => <<END, avx512=>1);
19085 k7: .... .... .... ...1
19086 k6: .... .... .... ...3
19087 k5: .... .... .... ...7
19088 k4: .... .... .... ...2
19089 k3: .... .... .... ...6
19090 k2: .... .... .... ...E
19091 k1: .... .... .... ...4
19092 k0: .... .... .... ...C
19093 END
19094  
19095  
19096 =head3 Nasm::X86::Variable::setMaskFirst($length, $mask)
19097  
19098 Set the first bits in the specified mask register.
19099  
19100 Parameter Description
19101 1 $length Variable containing length to set
19102 2 $mask Mask register
19103  
19104 B<Example:>
19105  
19106  
19107 if (1)
19108 {my $a = V(key => 0x123);
19109 is_deeply $a->at, "[rbp-8*(2)]";
19110 is_deeply $a->addressExpr, "[rbp-8*(2)]";
19111  
19112 ok !$a->isRef;
19113  
19114 Mov rax, -1;
19115 Kmovq k1, rax;
19116 PrintOutRegisterInHex k1;
19117  
19118 K(key => 2)->clearBit(rax);
19119 PrintOutRegisterInHex rax;
19120  
19121 K(key => 2)->setBit(rax);
19122 PrintOutRegisterInHex rax;
19123  
19124 K(key => 3)->clearMaskBit(k1);
19125 PrintOutRegisterInHex k1;
19126  
19127 K(key => 3)->setMaskBit(k1);
19128 PrintOutRegisterInHex k1;
19129  
19130 K(key => 0)->clearMaskBit(k1);
19131 PrintOutRegisterInHex k1;
19132  
19133 ClearRegisters k1;
19134 K(key => 7)->setMaskFirst(k1);
19135 PrintOutRegisterInHex k1;
19136  
19137 K(key => 3)->spaces($stdout);
19138 PrintOutRegisterInHex k1;
19139  
19140 my $N = K size => 4096;
19141 my $A = $N->allocateMemory;
19142 $A->clearMemory($N);
19143 ClearMemory($A, $N);
19144  
19145 $A->setReg(rax);
19146 Mov "dword[rax]", 0x61626364;
19147 Mov "dword[rax+4]", 0x65666768;
19148  
19149 ($A+8)->copyMemory($A, K key => 8);
19150  
19151 $A->printOutMemory (K(key => 16));
19152 $A->printOutMemoryNL(K(key => 16));
19153  
19154 K(K => Rd(0..63))->loadZmm(1);
19155 PrintOutRegisterInHex zmm1;
19156  
19157 ok Assemble eq => <<END;
19158 k1: .... .... .... ..-1
19159 rax: FFFF FFFF FFFF FFFB
19160 rax: .... .... .... ..-1
19161 k1: FFFF FFFF FFFF FFF7
19162 k1: .... .... .... ..-1
19163 k1: FFFF FFFF FFFF FFFE
19164 k1: .... .... .... ..7F
19165 k1: .... .... .... ..7F
19166 dcbahgfedcbahgfedcbahgfedcbahgfe
19167 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
19168 END
19169 }
19170  
19171  
19172 =head3 Nasm::X86::Variable::setMaskBit($index, $mask)
19173  
19174 Set a bit in the specified mask register retaining the other bits.
19175  
19176 Parameter Description
19177 1 $index Variable containing bit position to set
19178 2 $mask Mask register
19179  
19180 B<Example:>
19181  
19182  
19183 if (1)
19184 {my $a = V(key => 0x123);
19185 is_deeply $a->at, "[rbp-8*(2)]";
19186 is_deeply $a->addressExpr, "[rbp-8*(2)]";
19187  
19188 ok !$a->isRef;
19189  
19190 Mov rax, -1;
19191 Kmovq k1, rax;
19192 PrintOutRegisterInHex k1;
19193  
19194 K(key => 2)->clearBit(rax);
19195 PrintOutRegisterInHex rax;
19196  
19197 K(key => 2)->setBit(rax);
19198 PrintOutRegisterInHex rax;
19199  
19200 K(key => 3)->clearMaskBit(k1);
19201 PrintOutRegisterInHex k1;
19202  
19203 K(key => 3)->setMaskBit(k1);
19204 PrintOutRegisterInHex k1;
19205  
19206 K(key => 0)->clearMaskBit(k1);
19207 PrintOutRegisterInHex k1;
19208  
19209 ClearRegisters k1;
19210 K(key => 7)->setMaskFirst(k1);
19211 PrintOutRegisterInHex k1;
19212  
19213 K(key => 3)->spaces($stdout);
19214 PrintOutRegisterInHex k1;
19215  
19216 my $N = K size => 4096;
19217 my $A = $N->allocateMemory;
19218 $A->clearMemory($N);
19219 ClearMemory($A, $N);
19220  
19221 $A->setReg(rax);
19222 Mov "dword[rax]", 0x61626364;
19223 Mov "dword[rax+4]", 0x65666768;
19224  
19225 ($A+8)->copyMemory($A, K key => 8);
19226  
19227 $A->printOutMemory (K(key => 16));
19228 $A->printOutMemoryNL(K(key => 16));
19229  
19230 K(K => Rd(0..63))->loadZmm(1);
19231 PrintOutRegisterInHex zmm1;
19232  
19233 ok Assemble eq => <<END;
19234 k1: .... .... .... ..-1
19235 rax: FFFF FFFF FFFF FFFB
19236 rax: .... .... .... ..-1
19237 k1: FFFF FFFF FFFF FFF7
19238 k1: .... .... .... ..-1
19239 k1: FFFF FFFF FFFF FFFE
19240 k1: .... .... .... ..7F
19241 k1: .... .... .... ..7F
19242 dcbahgfedcbahgfedcbahgfedcbahgfe
19243 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
19244 END
19245 }
19246  
19247  
19248 =head3 Nasm::X86::Variable::clearMaskBit($index, $mask)
19249  
19250 Clear a bit in the specified mask register retaining the other bits.
19251  
19252 Parameter Description
19253 1 $index Variable containing bit position to clear
19254 2 $mask Mask register
19255  
19256 B<Example:>
19257  
19258  
19259 if (1)
19260 {my $a = V(key => 0x123);
19261 is_deeply $a->at, "[rbp-8*(2)]";
19262 is_deeply $a->addressExpr, "[rbp-8*(2)]";
19263  
19264 ok !$a->isRef;
19265  
19266 Mov rax, -1;
19267 Kmovq k1, rax;
19268 PrintOutRegisterInHex k1;
19269  
19270 K(key => 2)->clearBit(rax);
19271 PrintOutRegisterInHex rax;
19272  
19273 K(key => 2)->setBit(rax);
19274 PrintOutRegisterInHex rax;
19275  
19276 K(key => 3)->clearMaskBit(k1);
19277 PrintOutRegisterInHex k1;
19278  
19279 K(key => 3)->setMaskBit(k1);
19280 PrintOutRegisterInHex k1;
19281  
19282 K(key => 0)->clearMaskBit(k1);
19283 PrintOutRegisterInHex k1;
19284  
19285 ClearRegisters k1;
19286 K(key => 7)->setMaskFirst(k1);
19287 PrintOutRegisterInHex k1;
19288  
19289 K(key => 3)->spaces($stdout);
19290 PrintOutRegisterInHex k1;
19291  
19292 my $N = K size => 4096;
19293 my $A = $N->allocateMemory;
19294 $A->clearMemory($N);
19295 ClearMemory($A, $N);
19296  
19297 $A->setReg(rax);
19298 Mov "dword[rax]", 0x61626364;
19299 Mov "dword[rax+4]", 0x65666768;
19300  
19301 ($A+8)->copyMemory($A, K key => 8);
19302  
19303 $A->printOutMemory (K(key => 16));
19304 $A->printOutMemoryNL(K(key => 16));
19305  
19306 K(K => Rd(0..63))->loadZmm(1);
19307 PrintOutRegisterInHex zmm1;
19308  
19309 ok Assemble eq => <<END;
19310 k1: .... .... .... ..-1
19311 rax: FFFF FFFF FFFF FFFB
19312 rax: .... .... .... ..-1
19313 k1: FFFF FFFF FFFF FFF7
19314 k1: .... .... .... ..-1
19315 k1: FFFF FFFF FFFF FFFE
19316 k1: .... .... .... ..7F
19317 k1: .... .... .... ..7F
19318 dcbahgfedcbahgfedcbahgfedcbahgfe
19319 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
19320 END
19321 }
19322  
19323  
19324 =head3 Nasm::X86::Variable::setBit($index, $mask)
19325  
19326 Set a bit in the specified register retaining the other bits.
19327  
19328 Parameter Description
19329 1 $index Variable containing bit position to set
19330 2 $mask Mask register
19331  
19332 B<Example:>
19333  
19334  
19335 if (1)
19336 {my $a = V(key => 0x123);
19337 is_deeply $a->at, "[rbp-8*(2)]";
19338 is_deeply $a->addressExpr, "[rbp-8*(2)]";
19339  
19340 ok !$a->isRef;
19341  
19342 Mov rax, -1;
19343 Kmovq k1, rax;
19344 PrintOutRegisterInHex k1;
19345  
19346 K(key => 2)->clearBit(rax);
19347 PrintOutRegisterInHex rax;
19348  
19349 K(key => 2)->setBit(rax);
19350 PrintOutRegisterInHex rax;
19351  
19352 K(key => 3)->clearMaskBit(k1);
19353 PrintOutRegisterInHex k1;
19354  
19355 K(key => 3)->setMaskBit(k1);
19356 PrintOutRegisterInHex k1;
19357  
19358 K(key => 0)->clearMaskBit(k1);
19359 PrintOutRegisterInHex k1;
19360  
19361 ClearRegisters k1;
19362 K(key => 7)->setMaskFirst(k1);
19363 PrintOutRegisterInHex k1;
19364  
19365 K(key => 3)->spaces($stdout);
19366 PrintOutRegisterInHex k1;
19367  
19368 my $N = K size => 4096;
19369 my $A = $N->allocateMemory;
19370 $A->clearMemory($N);
19371 ClearMemory($A, $N);
19372  
19373 $A->setReg(rax);
19374 Mov "dword[rax]", 0x61626364;
19375 Mov "dword[rax+4]", 0x65666768;
19376  
19377 ($A+8)->copyMemory($A, K key => 8);
19378  
19379 $A->printOutMemory (K(key => 16));
19380 $A->printOutMemoryNL(K(key => 16));
19381  
19382 K(K => Rd(0..63))->loadZmm(1);
19383 PrintOutRegisterInHex zmm1;
19384  
19385 ok Assemble eq => <<END;
19386 k1: .... .... .... ..-1
19387 rax: FFFF FFFF FFFF FFFB
19388 rax: .... .... .... ..-1
19389 k1: FFFF FFFF FFFF FFF7
19390 k1: .... .... .... ..-1
19391 k1: FFFF FFFF FFFF FFFE
19392 k1: .... .... .... ..7F
19393 k1: .... .... .... ..7F
19394 dcbahgfedcbahgfedcbahgfedcbahgfe
19395 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
19396 END
19397 }
19398  
19399  
19400 =head3 Nasm::X86::Variable::clearBit($index, $mask)
19401  
19402 Clear a bit in the specified mask register retaining the other bits.
19403  
19404 Parameter Description
19405 1 $index Variable containing bit position to clear
19406 2 $mask Mask register
19407  
19408 B<Example:>
19409  
19410  
19411 if (1)
19412 {my $a = V(key => 0x123);
19413 is_deeply $a->at, "[rbp-8*(2)]";
19414 is_deeply $a->addressExpr, "[rbp-8*(2)]";
19415  
19416 ok !$a->isRef;
19417  
19418 Mov rax, -1;
19419 Kmovq k1, rax;
19420 PrintOutRegisterInHex k1;
19421  
19422 K(key => 2)->clearBit(rax);
19423 PrintOutRegisterInHex rax;
19424  
19425 K(key => 2)->setBit(rax);
19426 PrintOutRegisterInHex rax;
19427  
19428 K(key => 3)->clearMaskBit(k1);
19429 PrintOutRegisterInHex k1;
19430  
19431 K(key => 3)->setMaskBit(k1);
19432 PrintOutRegisterInHex k1;
19433  
19434 K(key => 0)->clearMaskBit(k1);
19435 PrintOutRegisterInHex k1;
19436  
19437 ClearRegisters k1;
19438 K(key => 7)->setMaskFirst(k1);
19439 PrintOutRegisterInHex k1;
19440  
19441 K(key => 3)->spaces($stdout);
19442 PrintOutRegisterInHex k1;
19443  
19444 my $N = K size => 4096;
19445 my $A = $N->allocateMemory;
19446 $A->clearMemory($N);
19447 ClearMemory($A, $N);
19448  
19449 $A->setReg(rax);
19450 Mov "dword[rax]", 0x61626364;
19451 Mov "dword[rax+4]", 0x65666768;
19452  
19453 ($A+8)->copyMemory($A, K key => 8);
19454  
19455 $A->printOutMemory (K(key => 16));
19456 $A->printOutMemoryNL(K(key => 16));
19457  
19458 K(K => Rd(0..63))->loadZmm(1);
19459 PrintOutRegisterInHex zmm1;
19460  
19461 ok Assemble eq => <<END;
19462 k1: .... .... .... ..-1
19463 rax: FFFF FFFF FFFF FFFB
19464 rax: .... .... .... ..-1
19465 k1: FFFF FFFF FFFF FFF7
19466 k1: .... .... .... ..-1
19467 k1: FFFF FFFF FFFF FFFE
19468 k1: .... .... .... ..7F
19469 k1: .... .... .... ..7F
19470 dcbahgfedcbahgfedcbahgfedcbahgfe
19471 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
19472 END
19473 }
19474  
19475  
19476 =head3 Nasm::X86::Variable::setZmm($source, $zmm, $offset, $length)
19477  
19478 Load bytes from the memory addressed by specified source variable into the numbered zmm register at the offset in the specified offset moving the number of bytes in the specified variable.
19479  
19480 Parameter Description
19481 1 $source Variable containing the address of the source
19482 2 $zmm Number of zmm to load
19483 3 $offset Variable containing offset in zmm to move to
19484 4 $length Variable containing length of move
19485  
19486 B<Example:>
19487  
19488  
19489 my $s = Rb(0..128);
19490 my $source = V(Source=> $s);
19491  
19492 if (1) # First block
19493 {$source->setZmm(0, K(key => 7), K length => 3);
19494 }
19495  
19496 if (1) # Second block
19497 {$source->setZmm(0, K(key => 33), K key => 12);
19498 }
19499  
19500 PrintOutRegisterInHex zmm0;
19501  
19502 ok Assemble(debug => 0, eq => <<END, avx512=>1);
19503 zmm0: .... .... .... ...0 .... .... .... ...0 - .... ...B .A.9 .8.7 .6.5 .4.3 .2.1 .... + .... .... .... ...0 .... .... .... ...0 - .... .... .... .2.1 .... .... .... ...0
19504 END
19505  
19506  
19507 =head3 Load mm registers
19508  
19509 Load zmm registers fom variables and retrieve data from zmm registers into variables.
19510  
19511 =head4 Nasm::X86::Variable::loadZmm($source, $zmm)
19512  
19513 Load bytes from the memory addressed by the specified source variable into the numbered zmm register.
19514  
19515 Parameter Description
19516 1 $source Variable containing the address of the source
19517 2 $zmm Number of zmm to get
19518  
19519 B<Example:>
19520  
19521  
19522 if (1)
19523 {my $a = V(key => 0x123);
19524 is_deeply $a->at, "[rbp-8*(2)]";
19525 is_deeply $a->addressExpr, "[rbp-8*(2)]";
19526  
19527 ok !$a->isRef;
19528  
19529 Mov rax, -1;
19530 Kmovq k1, rax;
19531 PrintOutRegisterInHex k1;
19532  
19533 K(key => 2)->clearBit(rax);
19534 PrintOutRegisterInHex rax;
19535  
19536 K(key => 2)->setBit(rax);
19537 PrintOutRegisterInHex rax;
19538  
19539 K(key => 3)->clearMaskBit(k1);
19540 PrintOutRegisterInHex k1;
19541  
19542 K(key => 3)->setMaskBit(k1);
19543 PrintOutRegisterInHex k1;
19544  
19545 K(key => 0)->clearMaskBit(k1);
19546 PrintOutRegisterInHex k1;
19547  
19548 ClearRegisters k1;
19549 K(key => 7)->setMaskFirst(k1);
19550 PrintOutRegisterInHex k1;
19551  
19552 K(key => 3)->spaces($stdout);
19553 PrintOutRegisterInHex k1;
19554  
19555 my $N = K size => 4096;
19556 my $A = $N->allocateMemory;
19557 $A->clearMemory($N);
19558 ClearMemory($A, $N);
19559  
19560 $A->setReg(rax);
19561 Mov "dword[rax]", 0x61626364;
19562 Mov "dword[rax+4]", 0x65666768;
19563  
19564 ($A+8)->copyMemory($A, K key => 8);
19565  
19566 $A->printOutMemory (K(key => 16));
19567 $A->printOutMemoryNL(K(key => 16));
19568  
19569 K(K => Rd(0..63))->loadZmm(1);
19570 PrintOutRegisterInHex zmm1;
19571  
19572 ok Assemble eq => <<END;
19573 k1: .... .... .... ..-1
19574 rax: FFFF FFFF FFFF FFFB
19575 rax: .... .... .... ..-1
19576 k1: FFFF FFFF FFFF FFF7
19577 k1: .... .... .... ..-1
19578 k1: FFFF FFFF FFFF FFFE
19579 k1: .... .... .... ..7F
19580 k1: .... .... .... ..7F
19581 dcbahgfedcbahgfedcbahgfedcbahgfe
19582 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
19583 END
19584 }
19585  
19586  
19587 =head4 Nasm::X86::Variable::bFromZ($variable, $zmm, $offset)
19588  
19589 Get the byte from the numbered zmm register and put it in a variable.
19590  
19591 Parameter Description
19592 1 $variable Variable
19593 2 $zmm Numbered zmm
19594 3 $offset Offset in bytes
19595  
19596 B<Example:>
19597  
19598  
19599 Mov rax, 0x12345678;
19600 my $c = V("Content", rax);
19601 $c->bIntoX(1, 0);
19602 $c->bIntoX(1, 1);
19603 $c->wIntoX(1, 2);
19604 $c->dIntoX(1, 4);
19605 $c->qIntoX(1, 8);
19606 $c->bIntoZ(1, 16);
19607 $c->bIntoZ(1, 17);
19608 $c->dIntoZ(1, 20);
19609 $c->qIntoZ(1, 24);
19610 PrintOutRegisterInHex zmm1;
19611  
19612 my $q = V "var";
19613  
19614 $q->bFromZ(1, 16); $q->outNL;
19615 $q->bFromZ(1, 17); $q->outNL;
19616 $q->wFromZ(1, 18); $q->outNL;
19617 $q->dFromZ(1, 20); $q->outNL;
19618 $q->qFromZ(1, 20); $q->outNL;
19619  
19620 my $p = K key => 8;
19621 $p->dIntoPointInZ(1, K key => 0x22);
19622 $p->dFromPointInZ(1)->outNL;
19623  
19624 ok Assemble eq => <<END;
19625 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
19626 var: .... .... .... ..78
19627 var: .... .... .... ..78
19628 var: .... .... .... ...0
19629 var: .... .... 1234 5678
19630 var: 1234 5678 1234 5678
19631 d: .... .... .... ..22
19632 END
19633  
19634  
19635 =head4 Nasm::X86::Variable::wFromZ($variable, $zmm, $offset)
19636  
19637 Get the word from the numbered zmm register and put it in a variable.
19638  
19639 Parameter Description
19640 1 $variable Variable
19641 2 $zmm Numbered zmm
19642 3 $offset Offset in bytes
19643  
19644 B<Example:>
19645  
19646  
19647 Mov rax, 0x12345678;
19648 my $c = V("Content", rax);
19649 $c->bIntoX(1, 0);
19650 $c->bIntoX(1, 1);
19651 $c->wIntoX(1, 2);
19652 $c->dIntoX(1, 4);
19653 $c->qIntoX(1, 8);
19654 $c->bIntoZ(1, 16);
19655 $c->bIntoZ(1, 17);
19656 $c->dIntoZ(1, 20);
19657 $c->qIntoZ(1, 24);
19658 PrintOutRegisterInHex zmm1;
19659  
19660 my $q = V "var";
19661  
19662 $q->bFromZ(1, 16); $q->outNL;
19663 $q->bFromZ(1, 17); $q->outNL;
19664 $q->wFromZ(1, 18); $q->outNL;
19665 $q->dFromZ(1, 20); $q->outNL;
19666 $q->qFromZ(1, 20); $q->outNL;
19667  
19668 my $p = K key => 8;
19669 $p->dIntoPointInZ(1, K key => 0x22);
19670 $p->dFromPointInZ(1)->outNL;
19671  
19672 ok Assemble eq => <<END;
19673 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
19674 var: .... .... .... ..78
19675 var: .... .... .... ..78
19676 var: .... .... .... ...0
19677 var: .... .... 1234 5678
19678 var: 1234 5678 1234 5678
19679 d: .... .... .... ..22
19680 END
19681  
19682  
19683 =head4 Nasm::X86::Variable::dFromZ($variable, $zmm, $offset)
19684  
19685 Get the double word from the numbered zmm register and put it in a variable.
19686  
19687 Parameter Description
19688 1 $variable Variable
19689 2 $zmm Numbered zmm
19690 3 $offset Offset in bytes
19691  
19692 B<Example:>
19693  
19694  
19695 Mov rax, 0x12345678;
19696 my $c = V("Content", rax);
19697 $c->bIntoX(1, 0);
19698 $c->bIntoX(1, 1);
19699 $c->wIntoX(1, 2);
19700 $c->dIntoX(1, 4);
19701 $c->qIntoX(1, 8);
19702 $c->bIntoZ(1, 16);
19703 $c->bIntoZ(1, 17);
19704 $c->dIntoZ(1, 20);
19705 $c->qIntoZ(1, 24);
19706 PrintOutRegisterInHex zmm1;
19707  
19708 my $q = V "var";
19709  
19710 $q->bFromZ(1, 16); $q->outNL;
19711 $q->bFromZ(1, 17); $q->outNL;
19712 $q->wFromZ(1, 18); $q->outNL;
19713 $q->dFromZ(1, 20); $q->outNL;
19714 $q->qFromZ(1, 20); $q->outNL;
19715  
19716 my $p = K key => 8;
19717 $p->dIntoPointInZ(1, K key => 0x22);
19718 $p->dFromPointInZ(1)->outNL;
19719  
19720 ok Assemble eq => <<END;
19721 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
19722 var: .... .... .... ..78
19723 var: .... .... .... ..78
19724 var: .... .... .... ...0
19725 var: .... .... 1234 5678
19726 var: 1234 5678 1234 5678
19727 d: .... .... .... ..22
19728 END
19729  
19730  
19731 =head4 Nasm::X86::Variable::qFromZ($variable, $zmm, $offset)
19732  
19733 Get the quad word from the numbered zmm register and put it in a variable.
19734  
19735 Parameter Description
19736 1 $variable Variable
19737 2 $zmm Numbered zmm
19738 3 $offset Offset in bytes
19739  
19740 B<Example:>
19741  
19742  
19743 Mov rax, 0x12345678;
19744 my $c = V("Content", rax);
19745 $c->bIntoX(1, 0);
19746 $c->bIntoX(1, 1);
19747 $c->wIntoX(1, 2);
19748 $c->dIntoX(1, 4);
19749 $c->qIntoX(1, 8);
19750 $c->bIntoZ(1, 16);
19751 $c->bIntoZ(1, 17);
19752 $c->dIntoZ(1, 20);
19753 $c->qIntoZ(1, 24);
19754 PrintOutRegisterInHex zmm1;
19755  
19756 my $q = V "var";
19757  
19758 $q->bFromZ(1, 16); $q->outNL;
19759 $q->bFromZ(1, 17); $q->outNL;
19760 $q->wFromZ(1, 18); $q->outNL;
19761 $q->dFromZ(1, 20); $q->outNL;
19762 $q->qFromZ(1, 20); $q->outNL;
19763  
19764 my $p = K key => 8;
19765 $p->dIntoPointInZ(1, K key => 0x22);
19766 $p->dFromPointInZ(1)->outNL;
19767  
19768 ok Assemble eq => <<END;
19769 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
19770 var: .... .... .... ..78
19771 var: .... .... .... ..78
19772 var: .... .... .... ...0
19773 var: .... .... 1234 5678
19774 var: 1234 5678 1234 5678
19775 d: .... .... .... ..22
19776 END
19777  
19778  
19779 =head4 Nasm::X86::Variable::bIntoX($content, $xmm, $offset)
19780  
19781 Place the value of the content variable at the byte in the numbered xmm register.
19782  
19783 Parameter Description
19784 1 $content Variable with content
19785 2 $xmm Numbered xmm
19786 3 $offset Offset in bytes
19787  
19788 B<Example:>
19789  
19790  
19791 Mov rax, 0x12345678;
19792 my $c = V("Content", rax);
19793 $c->bIntoX(1, 0);
19794 $c->bIntoX(1, 1);
19795 $c->wIntoX(1, 2);
19796 $c->dIntoX(1, 4);
19797 $c->qIntoX(1, 8);
19798 $c->bIntoZ(1, 16);
19799 $c->bIntoZ(1, 17);
19800 $c->dIntoZ(1, 20);
19801 $c->qIntoZ(1, 24);
19802 PrintOutRegisterInHex zmm1;
19803  
19804 my $q = V "var";
19805  
19806 $q->bFromZ(1, 16); $q->outNL;
19807 $q->bFromZ(1, 17); $q->outNL;
19808 $q->wFromZ(1, 18); $q->outNL;
19809 $q->dFromZ(1, 20); $q->outNL;
19810 $q->qFromZ(1, 20); $q->outNL;
19811  
19812 my $p = K key => 8;
19813 $p->dIntoPointInZ(1, K key => 0x22);
19814 $p->dFromPointInZ(1)->outNL;
19815  
19816 ok Assemble eq => <<END;
19817 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
19818 var: .... .... .... ..78
19819 var: .... .... .... ..78
19820 var: .... .... .... ...0
19821 var: .... .... 1234 5678
19822 var: 1234 5678 1234 5678
19823 d: .... .... .... ..22
19824 END
19825  
19826  
19827 =head4 Nasm::X86::Variable::wIntoX($content, $xmm, $offset)
19828  
19829 Place the value of the content variable at the word in the numbered xmm register.
19830  
19831 Parameter Description
19832 1 $content Variable with content
19833 2 $xmm Numbered xmm
19834 3 $offset Offset in bytes
19835  
19836 B<Example:>
19837  
19838  
19839 Mov rax, 0x12345678;
19840 my $c = V("Content", rax);
19841 $c->bIntoX(1, 0);
19842 $c->bIntoX(1, 1);
19843 $c->wIntoX(1, 2);
19844 $c->dIntoX(1, 4);
19845 $c->qIntoX(1, 8);
19846 $c->bIntoZ(1, 16);
19847 $c->bIntoZ(1, 17);
19848 $c->dIntoZ(1, 20);
19849 $c->qIntoZ(1, 24);
19850 PrintOutRegisterInHex zmm1;
19851  
19852 my $q = V "var";
19853  
19854 $q->bFromZ(1, 16); $q->outNL;
19855 $q->bFromZ(1, 17); $q->outNL;
19856 $q->wFromZ(1, 18); $q->outNL;
19857 $q->dFromZ(1, 20); $q->outNL;
19858 $q->qFromZ(1, 20); $q->outNL;
19859  
19860 my $p = K key => 8;
19861 $p->dIntoPointInZ(1, K key => 0x22);
19862 $p->dFromPointInZ(1)->outNL;
19863  
19864 ok Assemble eq => <<END;
19865 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
19866 var: .... .... .... ..78
19867 var: .... .... .... ..78
19868 var: .... .... .... ...0
19869 var: .... .... 1234 5678
19870 var: 1234 5678 1234 5678
19871 d: .... .... .... ..22
19872 END
19873  
19874  
19875 =head4 Nasm::X86::Variable::dIntoX($content, $xmm, $offset)
19876  
19877 Place the value of the content variable at the double word in the numbered xmm register.
19878  
19879 Parameter Description
19880 1 $content Variable with content
19881 2 $xmm Numbered xmm
19882 3 $offset Offset in bytes
19883  
19884 B<Example:>
19885  
19886  
19887 Mov rax, 0x12345678;
19888 my $c = V("Content", rax);
19889 $c->bIntoX(1, 0);
19890 $c->bIntoX(1, 1);
19891 $c->wIntoX(1, 2);
19892 $c->dIntoX(1, 4);
19893 $c->qIntoX(1, 8);
19894 $c->bIntoZ(1, 16);
19895 $c->bIntoZ(1, 17);
19896 $c->dIntoZ(1, 20);
19897 $c->qIntoZ(1, 24);
19898 PrintOutRegisterInHex zmm1;
19899  
19900 my $q = V "var";
19901  
19902 $q->bFromZ(1, 16); $q->outNL;
19903 $q->bFromZ(1, 17); $q->outNL;
19904 $q->wFromZ(1, 18); $q->outNL;
19905 $q->dFromZ(1, 20); $q->outNL;
19906 $q->qFromZ(1, 20); $q->outNL;
19907  
19908 my $p = K key => 8;
19909 $p->dIntoPointInZ(1, K key => 0x22);
19910 $p->dFromPointInZ(1)->outNL;
19911  
19912 ok Assemble eq => <<END;
19913 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
19914 var: .... .... .... ..78
19915 var: .... .... .... ..78
19916 var: .... .... .... ...0
19917 var: .... .... 1234 5678
19918 var: 1234 5678 1234 5678
19919 d: .... .... .... ..22
19920 END
19921  
19922  
19923 =head4 Nasm::X86::Variable::qIntoX($content, $xmm, $offset)
19924  
19925 Place the value of the content variable at the quad word in the numbered xmm register.
19926  
19927 Parameter Description
19928 1 $content Variable with content
19929 2 $xmm Numbered xmm
19930 3 $offset Offset in bytes
19931  
19932 B<Example:>
19933  
19934  
19935 Mov rax, 0x12345678;
19936 my $c = V("Content", rax);
19937 $c->bIntoX(1, 0);
19938 $c->bIntoX(1, 1);
19939 $c->wIntoX(1, 2);
19940 $c->dIntoX(1, 4);
19941 $c->qIntoX(1, 8);
19942 $c->bIntoZ(1, 16);
19943 $c->bIntoZ(1, 17);
19944 $c->dIntoZ(1, 20);
19945 $c->qIntoZ(1, 24);
19946 PrintOutRegisterInHex zmm1;
19947  
19948 my $q = V "var";
19949  
19950 $q->bFromZ(1, 16); $q->outNL;
19951 $q->bFromZ(1, 17); $q->outNL;
19952 $q->wFromZ(1, 18); $q->outNL;
19953 $q->dFromZ(1, 20); $q->outNL;
19954 $q->qFromZ(1, 20); $q->outNL;
19955  
19956 my $p = K key => 8;
19957 $p->dIntoPointInZ(1, K key => 0x22);
19958 $p->dFromPointInZ(1)->outNL;
19959  
19960 ok Assemble eq => <<END;
19961 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
19962 var: .... .... .... ..78
19963 var: .... .... .... ..78
19964 var: .... .... .... ...0
19965 var: .... .... 1234 5678
19966 var: 1234 5678 1234 5678
19967 d: .... .... .... ..22
19968 END
19969  
19970  
19971 =head4 Nasm::X86::Variable::bIntoZ($content, $zmm, $offset)
19972  
19973 Place the value of the content variable at the byte in the numbered zmm register.
19974  
19975 Parameter Description
19976 1 $content Variable with content
19977 2 $zmm Numbered zmm
19978 3 $offset Offset in bytes
19979  
19980 B<Example:>
19981  
19982  
19983 my $s = Rb(0..8);
19984 my $c = V("Content", "[$s]");
19985 $c->bIntoZ (0, 4);
19986 $c->putWIntoZmm(0, 6);
19987 $c->dIntoZ(0, 10);
19988 $c->qIntoZ(0, 16);
19989 PrintOutRegisterInHex zmm0;
19990 bFromZ(zmm0, 12)->outNL;
19991 wFromZ(zmm0, 12)->outNL;
19992 dFromZ(zmm0, 12)->outNL;
19993 qFromZ(zmm0, 12)->outNL;
19994  
19995 ok Assemble(debug => 0, eq => <<END, avx512=>1);
19996 zmm0: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .7.6 .5.4 .3.2 .1.. - .... .3.2 .1.. .... .1.. .... .... ....
19997 b at offset 12 in zmm0: .... .... .... ...2
19998 w at offset 12 in zmm0: .... .... .... .3.2
19999 d at offset 12 in zmm0: .... .... .... .3.2
20000 q at offset 12 in zmm0: .3.2 .1.. .... .3.2
20001 END
20002  
20003 Mov rax, 0x12345678;
20004 my $c = V("Content", rax);
20005 $c->bIntoX(1, 0);
20006 $c->bIntoX(1, 1);
20007 $c->wIntoX(1, 2);
20008 $c->dIntoX(1, 4);
20009 $c->qIntoX(1, 8);
20010 $c->bIntoZ(1, 16);
20011 $c->bIntoZ(1, 17);
20012 $c->dIntoZ(1, 20);
20013 $c->qIntoZ(1, 24);
20014 PrintOutRegisterInHex zmm1;
20015  
20016 my $q = V "var";
20017  
20018 $q->bFromZ(1, 16); $q->outNL;
20019 $q->bFromZ(1, 17); $q->outNL;
20020 $q->wFromZ(1, 18); $q->outNL;
20021 $q->dFromZ(1, 20); $q->outNL;
20022 $q->qFromZ(1, 20); $q->outNL;
20023  
20024 my $p = K key => 8;
20025 $p->dIntoPointInZ(1, K key => 0x22);
20026 $p->dFromPointInZ(1)->outNL;
20027  
20028 ok Assemble eq => <<END;
20029 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
20030 var: .... .... .... ..78
20031 var: .... .... .... ..78
20032 var: .... .... .... ...0
20033 var: .... .... 1234 5678
20034 var: 1234 5678 1234 5678
20035 d: .... .... .... ..22
20036 END
20037  
20038  
20039 =head4 Nasm::X86::Variable::putWIntoZmm($content, $zmm, $offset)
20040  
20041 Place the value of the content variable at the word in the numbered zmm register.
20042  
20043 Parameter Description
20044 1 $content Variable with content
20045 2 $zmm Numbered zmm
20046 3 $offset Offset in bytes
20047  
20048 B<Example:>
20049  
20050  
20051 my $s = Rb(0..8);
20052 my $c = V("Content", "[$s]");
20053 $c->bIntoZ (0, 4);
20054 $c->putWIntoZmm(0, 6);
20055 $c->dIntoZ(0, 10);
20056 $c->qIntoZ(0, 16);
20057 PrintOutRegisterInHex zmm0;
20058 bFromZ(zmm0, 12)->outNL;
20059 wFromZ(zmm0, 12)->outNL;
20060 dFromZ(zmm0, 12)->outNL;
20061 qFromZ(zmm0, 12)->outNL;
20062  
20063 ok Assemble(debug => 0, eq => <<END, avx512=>1);
20064 zmm0: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .7.6 .5.4 .3.2 .1.. - .... .3.2 .1.. .... .1.. .... .... ....
20065 b at offset 12 in zmm0: .... .... .... ...2
20066 w at offset 12 in zmm0: .... .... .... .3.2
20067 d at offset 12 in zmm0: .... .... .... .3.2
20068 q at offset 12 in zmm0: .3.2 .1.. .... .3.2
20069 END
20070  
20071  
20072 =head4 Nasm::X86::Variable::dIntoZ($content, $zmm, $offset)
20073  
20074 Place the value of the content variable at the double word in the numbered zmm register.
20075  
20076 Parameter Description
20077 1 $content Variable with content
20078 2 $zmm Numbered zmm
20079 3 $offset Offset in bytes
20080  
20081 B<Example:>
20082  
20083  
20084 my $s = Rb(0..8);
20085 my $c = V("Content", "[$s]");
20086 $c->bIntoZ (0, 4);
20087 $c->putWIntoZmm(0, 6);
20088 $c->dIntoZ(0, 10);
20089 $c->qIntoZ(0, 16);
20090 PrintOutRegisterInHex zmm0;
20091 bFromZ(zmm0, 12)->outNL;
20092 wFromZ(zmm0, 12)->outNL;
20093 dFromZ(zmm0, 12)->outNL;
20094 qFromZ(zmm0, 12)->outNL;
20095  
20096 ok Assemble(debug => 0, eq => <<END, avx512=>1);
20097 zmm0: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .7.6 .5.4 .3.2 .1.. - .... .3.2 .1.. .... .1.. .... .... ....
20098 b at offset 12 in zmm0: .... .... .... ...2
20099 w at offset 12 in zmm0: .... .... .... .3.2
20100 d at offset 12 in zmm0: .... .... .... .3.2
20101 q at offset 12 in zmm0: .3.2 .1.. .... .3.2
20102 END
20103  
20104 Mov rax, 0x12345678;
20105 my $c = V("Content", rax);
20106 $c->bIntoX(1, 0);
20107 $c->bIntoX(1, 1);
20108 $c->wIntoX(1, 2);
20109 $c->dIntoX(1, 4);
20110 $c->qIntoX(1, 8);
20111 $c->bIntoZ(1, 16);
20112 $c->bIntoZ(1, 17);
20113 $c->dIntoZ(1, 20);
20114 $c->qIntoZ(1, 24);
20115 PrintOutRegisterInHex zmm1;
20116  
20117 my $q = V "var";
20118  
20119 $q->bFromZ(1, 16); $q->outNL;
20120 $q->bFromZ(1, 17); $q->outNL;
20121 $q->wFromZ(1, 18); $q->outNL;
20122 $q->dFromZ(1, 20); $q->outNL;
20123 $q->qFromZ(1, 20); $q->outNL;
20124  
20125 my $p = K key => 8;
20126 $p->dIntoPointInZ(1, K key => 0x22);
20127 $p->dFromPointInZ(1)->outNL;
20128  
20129 ok Assemble eq => <<END;
20130 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
20131 var: .... .... .... ..78
20132 var: .... .... .... ..78
20133 var: .... .... .... ...0
20134 var: .... .... 1234 5678
20135 var: 1234 5678 1234 5678
20136 d: .... .... .... ..22
20137 END
20138  
20139  
20140 =head4 Nasm::X86::Variable::qIntoZ($content, $zmm, $offset)
20141  
20142 Place the value of the content variable at the quad word in the numbered zmm register.
20143  
20144 Parameter Description
20145 1 $content Variable with content
20146 2 $zmm Numbered zmm
20147 3 $offset Offset in bytes
20148  
20149 B<Example:>
20150  
20151  
20152 my $s = Rb(0..8);
20153 my $c = V("Content", "[$s]");
20154 $c->bIntoZ (0, 4);
20155 $c->putWIntoZmm(0, 6);
20156 $c->dIntoZ(0, 10);
20157 $c->qIntoZ(0, 16);
20158 PrintOutRegisterInHex zmm0;
20159 bFromZ(zmm0, 12)->outNL;
20160 wFromZ(zmm0, 12)->outNL;
20161 dFromZ(zmm0, 12)->outNL;
20162 qFromZ(zmm0, 12)->outNL;
20163  
20164 ok Assemble(debug => 0, eq => <<END, avx512=>1);
20165 zmm0: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .7.6 .5.4 .3.2 .1.. - .... .3.2 .1.. .... .1.. .... .... ....
20166 b at offset 12 in zmm0: .... .... .... ...2
20167 w at offset 12 in zmm0: .... .... .... .3.2
20168 d at offset 12 in zmm0: .... .... .... .3.2
20169 q at offset 12 in zmm0: .3.2 .1.. .... .3.2
20170 END
20171  
20172 Mov rax, 0x12345678;
20173 my $c = V("Content", rax);
20174 $c->bIntoX(1, 0);
20175 $c->bIntoX(1, 1);
20176 $c->wIntoX(1, 2);
20177 $c->dIntoX(1, 4);
20178 $c->qIntoX(1, 8);
20179 $c->bIntoZ(1, 16);
20180 $c->bIntoZ(1, 17);
20181 $c->dIntoZ(1, 20);
20182 $c->qIntoZ(1, 24);
20183 PrintOutRegisterInHex zmm1;
20184  
20185 my $q = V "var";
20186  
20187 $q->bFromZ(1, 16); $q->outNL;
20188 $q->bFromZ(1, 17); $q->outNL;
20189 $q->wFromZ(1, 18); $q->outNL;
20190 $q->dFromZ(1, 20); $q->outNL;
20191 $q->qFromZ(1, 20); $q->outNL;
20192  
20193 my $p = K key => 8;
20194 $p->dIntoPointInZ(1, K key => 0x22);
20195 $p->dFromPointInZ(1)->outNL;
20196  
20197 ok Assemble eq => <<END;
20198 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
20199 var: .... .... .... ..78
20200 var: .... .... .... ..78
20201 var: .... .... .... ...0
20202 var: .... .... 1234 5678
20203 var: 1234 5678 1234 5678
20204 d: .... .... .... ..22
20205 END
20206  
20207  
20208 =head3 At a point
20209  
20210 Place data into mm registers and retrieve data from them at the indicated point.
20211  
20212 =head4 Nasm::X86::Variable::dFromPointInZ($point, $zmm, %options)
20213  
20214 Get the double word from the numbered zmm register at a point specified by the variable and return it in a variable.
20215  
20216 Parameter Description
20217 1 $point Point
20218 2 $zmm Numbered zmm
20219 3 %options Options
20220  
20221 B<Example:>
20222  
20223  
20224 Mov rax, 0x12345678;
20225 my $c = V("Content", rax);
20226 $c->bIntoX(1, 0);
20227 $c->bIntoX(1, 1);
20228 $c->wIntoX(1, 2);
20229 $c->dIntoX(1, 4);
20230 $c->qIntoX(1, 8);
20231 $c->bIntoZ(1, 16);
20232 $c->bIntoZ(1, 17);
20233 $c->dIntoZ(1, 20);
20234 $c->qIntoZ(1, 24);
20235 PrintOutRegisterInHex zmm1;
20236  
20237 my $q = V "var";
20238  
20239 $q->bFromZ(1, 16); $q->outNL;
20240 $q->bFromZ(1, 17); $q->outNL;
20241 $q->wFromZ(1, 18); $q->outNL;
20242 $q->dFromZ(1, 20); $q->outNL;
20243 $q->qFromZ(1, 20); $q->outNL;
20244  
20245 my $p = K key => 8;
20246 $p->dIntoPointInZ(1, K key => 0x22);
20247 $p->dFromPointInZ(1)->outNL;
20248  
20249 ok Assemble eq => <<END;
20250 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
20251 var: .... .... .... ..78
20252 var: .... .... .... ..78
20253 var: .... .... .... ...0
20254 var: .... .... 1234 5678
20255 var: 1234 5678 1234 5678
20256 d: .... .... .... ..22
20257 END
20258  
20259 my $tree = DescribeTree(length => 7);
20260  
20261 my $K = 31;
20262  
20263 K(K => Rd(0..15))->loadZmm($K);
20264  
20265 PrintOutRegisterInHex zmm $K;
20266 K( offset => 1 << 5)->dFromPointInZ($K)->outNL;
20267  
20268 ok Assemble eq => <<END, avx512=>1;
20269 zmm31: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
20270 d: .... .... .... ...5
20271 END
20272  
20273  
20274 =head4 Nasm::X86::Variable::dIntoPointInZ($point, $zmm, $content)
20275  
20276 Put the variable double word content into the numbered zmm register at a point specified by the variable.
20277  
20278 Parameter Description
20279 1 $point Point
20280 2 $zmm Numbered zmm
20281 3 $content Content to be inserted as a variable
20282  
20283 B<Example:>
20284  
20285  
20286 Mov rax, 0x12345678;
20287 my $c = V("Content", rax);
20288 $c->bIntoX(1, 0);
20289 $c->bIntoX(1, 1);
20290 $c->wIntoX(1, 2);
20291 $c->dIntoX(1, 4);
20292 $c->qIntoX(1, 8);
20293 $c->bIntoZ(1, 16);
20294 $c->bIntoZ(1, 17);
20295 $c->dIntoZ(1, 20);
20296 $c->qIntoZ(1, 24);
20297 PrintOutRegisterInHex zmm1;
20298  
20299 my $q = V "var";
20300  
20301 $q->bFromZ(1, 16); $q->outNL;
20302 $q->bFromZ(1, 17); $q->outNL;
20303 $q->wFromZ(1, 18); $q->outNL;
20304 $q->dFromZ(1, 20); $q->outNL;
20305 $q->qFromZ(1, 20); $q->outNL;
20306  
20307 my $p = K key => 8;
20308 $p->dIntoPointInZ(1, K key => 0x22);
20309 $p->dFromPointInZ(1)->outNL;
20310  
20311 ok Assemble eq => <<END;
20312 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... 1234 5678 1234 5678 .... 7878 - .... .... 1234 5678 1234 5678 5678 7878
20313 var: .... .... .... ..78
20314 var: .... .... .... ..78
20315 var: .... .... .... ...0
20316 var: .... .... 1234 5678
20317 var: 1234 5678 1234 5678
20318 d: .... .... .... ..22
20319 END
20320  
20321  
20322 =head2 Memory
20323  
20324 Actions on memory described by variables
20325  
20326 =head3 Nasm::X86::Variable::clearMemory($address, $size)
20327  
20328 Clear the memory described in this variable.
20329  
20330 Parameter Description
20331 1 $address Address of memory to clear
20332 2 $size Size of the memory to clear
20333  
20334 B<Example:>
20335  
20336  
20337 if (1)
20338 {my $a = V(key => 0x123);
20339 is_deeply $a->at, "[rbp-8*(2)]";
20340 is_deeply $a->addressExpr, "[rbp-8*(2)]";
20341  
20342 ok !$a->isRef;
20343  
20344 Mov rax, -1;
20345 Kmovq k1, rax;
20346 PrintOutRegisterInHex k1;
20347  
20348 K(key => 2)->clearBit(rax);
20349 PrintOutRegisterInHex rax;
20350  
20351 K(key => 2)->setBit(rax);
20352 PrintOutRegisterInHex rax;
20353  
20354 K(key => 3)->clearMaskBit(k1);
20355 PrintOutRegisterInHex k1;
20356  
20357 K(key => 3)->setMaskBit(k1);
20358 PrintOutRegisterInHex k1;
20359  
20360 K(key => 0)->clearMaskBit(k1);
20361 PrintOutRegisterInHex k1;
20362  
20363 ClearRegisters k1;
20364 K(key => 7)->setMaskFirst(k1);
20365 PrintOutRegisterInHex k1;
20366  
20367 K(key => 3)->spaces($stdout);
20368 PrintOutRegisterInHex k1;
20369  
20370 my $N = K size => 4096;
20371 my $A = $N->allocateMemory;
20372 $A->clearMemory($N);
20373 ClearMemory($A, $N);
20374  
20375 $A->setReg(rax);
20376 Mov "dword[rax]", 0x61626364;
20377 Mov "dword[rax+4]", 0x65666768;
20378  
20379 ($A+8)->copyMemory($A, K key => 8);
20380  
20381 $A->printOutMemory (K(key => 16));
20382 $A->printOutMemoryNL(K(key => 16));
20383  
20384 K(K => Rd(0..63))->loadZmm(1);
20385 PrintOutRegisterInHex zmm1;
20386  
20387 ok Assemble eq => <<END;
20388 k1: .... .... .... ..-1
20389 rax: FFFF FFFF FFFF FFFB
20390 rax: .... .... .... ..-1
20391 k1: FFFF FFFF FFFF FFF7
20392 k1: .... .... .... ..-1
20393 k1: FFFF FFFF FFFF FFFE
20394 k1: .... .... .... ..7F
20395 k1: .... .... .... ..7F
20396 dcbahgfedcbahgfedcbahgfedcbahgfe
20397 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
20398 END
20399 }
20400  
20401  
20402 =head3 Nasm::X86::Variable::copyMemory($target, $source, $size)
20403  
20404 Copy from one block of memory to another.
20405  
20406 Parameter Description
20407 1 $target Address of target
20408 2 $source Address of source
20409 3 $size Length to copy
20410  
20411 B<Example:>
20412  
20413  
20414 if (1)
20415 {my $a = V(key => 0x123);
20416 is_deeply $a->at, "[rbp-8*(2)]";
20417 is_deeply $a->addressExpr, "[rbp-8*(2)]";
20418  
20419 ok !$a->isRef;
20420  
20421 Mov rax, -1;
20422 Kmovq k1, rax;
20423 PrintOutRegisterInHex k1;
20424  
20425 K(key => 2)->clearBit(rax);
20426 PrintOutRegisterInHex rax;
20427  
20428 K(key => 2)->setBit(rax);
20429 PrintOutRegisterInHex rax;
20430  
20431 K(key => 3)->clearMaskBit(k1);
20432 PrintOutRegisterInHex k1;
20433  
20434 K(key => 3)->setMaskBit(k1);
20435 PrintOutRegisterInHex k1;
20436  
20437 K(key => 0)->clearMaskBit(k1);
20438 PrintOutRegisterInHex k1;
20439  
20440 ClearRegisters k1;
20441 K(key => 7)->setMaskFirst(k1);
20442 PrintOutRegisterInHex k1;
20443  
20444 K(key => 3)->spaces($stdout);
20445 PrintOutRegisterInHex k1;
20446  
20447 my $N = K size => 4096;
20448 my $A = $N->allocateMemory;
20449 $A->clearMemory($N);
20450 ClearMemory($A, $N);
20451  
20452 $A->setReg(rax);
20453 Mov "dword[rax]", 0x61626364;
20454 Mov "dword[rax+4]", 0x65666768;
20455  
20456 ($A+8)->copyMemory($A, K key => 8);
20457  
20458 $A->printOutMemory (K(key => 16));
20459 $A->printOutMemoryNL(K(key => 16));
20460  
20461 K(K => Rd(0..63))->loadZmm(1);
20462 PrintOutRegisterInHex zmm1;
20463  
20464 ok Assemble eq => <<END;
20465 k1: .... .... .... ..-1
20466 rax: FFFF FFFF FFFF FFFB
20467 rax: .... .... .... ..-1
20468 k1: FFFF FFFF FFFF FFF7
20469 k1: .... .... .... ..-1
20470 k1: FFFF FFFF FFFF FFFE
20471 k1: .... .... .... ..7F
20472 k1: .... .... .... ..7F
20473 dcbahgfedcbahgfedcbahgfedcbahgfe
20474 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
20475 END
20476 }
20477  
20478  
20479 =head3 Nasm::X86::Variable::printOutMemory($address, $size)
20480  
20481 Print the specified number of bytes of the memory addressed by the variable on stdout.
20482  
20483 Parameter Description
20484 1 $address Address of memory
20485 2 $size Number of bytes to print
20486  
20487 B<Example:>
20488  
20489  
20490 if (1)
20491 {my $a = V(key => 0x123);
20492 is_deeply $a->at, "[rbp-8*(2)]";
20493 is_deeply $a->addressExpr, "[rbp-8*(2)]";
20494  
20495 ok !$a->isRef;
20496  
20497 Mov rax, -1;
20498 Kmovq k1, rax;
20499 PrintOutRegisterInHex k1;
20500  
20501 K(key => 2)->clearBit(rax);
20502 PrintOutRegisterInHex rax;
20503  
20504 K(key => 2)->setBit(rax);
20505 PrintOutRegisterInHex rax;
20506  
20507 K(key => 3)->clearMaskBit(k1);
20508 PrintOutRegisterInHex k1;
20509  
20510 K(key => 3)->setMaskBit(k1);
20511 PrintOutRegisterInHex k1;
20512  
20513 K(key => 0)->clearMaskBit(k1);
20514 PrintOutRegisterInHex k1;
20515  
20516 ClearRegisters k1;
20517 K(key => 7)->setMaskFirst(k1);
20518 PrintOutRegisterInHex k1;
20519  
20520 K(key => 3)->spaces($stdout);
20521 PrintOutRegisterInHex k1;
20522  
20523 my $N = K size => 4096;
20524 my $A = $N->allocateMemory;
20525 $A->clearMemory($N);
20526 ClearMemory($A, $N);
20527  
20528 $A->setReg(rax);
20529 Mov "dword[rax]", 0x61626364;
20530 Mov "dword[rax+4]", 0x65666768;
20531  
20532 ($A+8)->copyMemory($A, K key => 8);
20533  
20534 $A->printOutMemory (K(key => 16));
20535 $A->printOutMemoryNL(K(key => 16));
20536  
20537 K(K => Rd(0..63))->loadZmm(1);
20538 PrintOutRegisterInHex zmm1;
20539  
20540 ok Assemble eq => <<END;
20541 k1: .... .... .... ..-1
20542 rax: FFFF FFFF FFFF FFFB
20543 rax: .... .... .... ..-1
20544 k1: FFFF FFFF FFFF FFF7
20545 k1: .... .... .... ..-1
20546 k1: FFFF FFFF FFFF FFFE
20547 k1: .... .... .... ..7F
20548 k1: .... .... .... ..7F
20549 dcbahgfedcbahgfedcbahgfedcbahgfe
20550 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
20551 END
20552 }
20553  
20554  
20555 =head3 Nasm::X86::Variable::printOutMemoryNL($address, $size)
20556  
20557 Print the specified number of bytes of the memory addressed by the variable on stdout followed by a new line.
20558  
20559 Parameter Description
20560 1 $address Address of memory
20561 2 $size Number of bytes to print
20562  
20563 B<Example:>
20564  
20565  
20566 if (1)
20567 {my $a = V(key => 0x123);
20568 is_deeply $a->at, "[rbp-8*(2)]";
20569 is_deeply $a->addressExpr, "[rbp-8*(2)]";
20570  
20571 ok !$a->isRef;
20572  
20573 Mov rax, -1;
20574 Kmovq k1, rax;
20575 PrintOutRegisterInHex k1;
20576  
20577 K(key => 2)->clearBit(rax);
20578 PrintOutRegisterInHex rax;
20579  
20580 K(key => 2)->setBit(rax);
20581 PrintOutRegisterInHex rax;
20582  
20583 K(key => 3)->clearMaskBit(k1);
20584 PrintOutRegisterInHex k1;
20585  
20586 K(key => 3)->setMaskBit(k1);
20587 PrintOutRegisterInHex k1;
20588  
20589 K(key => 0)->clearMaskBit(k1);
20590 PrintOutRegisterInHex k1;
20591  
20592 ClearRegisters k1;
20593 K(key => 7)->setMaskFirst(k1);
20594 PrintOutRegisterInHex k1;
20595  
20596 K(key => 3)->spaces($stdout);
20597 PrintOutRegisterInHex k1;
20598  
20599 my $N = K size => 4096;
20600 my $A = $N->allocateMemory;
20601 $A->clearMemory($N);
20602 ClearMemory($A, $N);
20603  
20604 $A->setReg(rax);
20605 Mov "dword[rax]", 0x61626364;
20606 Mov "dword[rax+4]", 0x65666768;
20607  
20608 ($A+8)->copyMemory($A, K key => 8);
20609  
20610 $A->printOutMemory (K(key => 16));
20611 $A->printOutMemoryNL(K(key => 16));
20612  
20613 K(K => Rd(0..63))->loadZmm(1);
20614 PrintOutRegisterInHex zmm1;
20615  
20616 ok Assemble eq => <<END;
20617 k1: .... .... .... ..-1
20618 rax: FFFF FFFF FFFF FFFB
20619 rax: .... .... .... ..-1
20620 k1: FFFF FFFF FFFF FFF7
20621 k1: .... .... .... ..-1
20622 k1: FFFF FFFF FFFF FFFE
20623 k1: .... .... .... ..7F
20624 k1: .... .... .... ..7F
20625 dcbahgfedcbahgfedcbahgfedcbahgfe
20626 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
20627 END
20628 }
20629  
20630  
20631 =head3 Nasm::X86::Variable::printOutMemoryInHexNL($address, $size)
20632  
20633 Write the memory addressed by a variable to stdout.
20634  
20635 Parameter Description
20636 1 $address Address of memory
20637 2 $size Number of bytes to print
20638  
20639 B<Example:>
20640  
20641  
20642 my $u = Rd(ord('𝝰'), ord('𝝱'), ord('𝝲'), ord('𝝳'));
20643 Mov rax, $u;
20644 my $address = V address=>rax;
20645 $address->printOutMemoryInHexNL(K size => 16);
20646  
20647 ok Assemble(debug => 0, trace => 0, eq => <<END, avx512=>0);
20648 70D7 .1.. 71D7 .1.. 72D7 .1.. 73D7 .1..
20649 END
20650  
20651 my $v = V var => 2;
20652  
20653 If $v == 0, Then {Mov rax, 0},
20654 Ef {$v == 1} Then {Mov rax, 1},
20655 Ef {$v == 2} Then {Mov rax, 2},
20656 Else {Mov rax, 3};
20657 PrintOutRegisterInHex rax;
20658 ok Assemble(debug => 0, trace => 0, eq => <<END, avx512=>0);
20659 rax: .... .... .... ...2
20660 END
20661  
20662  
20663 =head3 Nasm::X86::Variable::freeMemory($address, $size)
20664  
20665 Free the memory addressed by this variable for the specified length.
20666  
20667 Parameter Description
20668 1 $address Address of memory to free
20669 2 $size Size of the memory to free
20670  
20671 B<Example:>
20672  
20673  
20674 my $N = K size => 2048;
20675 my $q = Rs('a'..'p');
20676 my $address = $N->allocateMemory;
20677  
20678 Vmovdqu8 xmm0, "[$q]";
20679 $address->setReg(rax);
20680 Vmovdqu8 "[rax]", xmm0;
20681 Mov rdi, 16;
20682 PrintOutMemory;
20683 PrintOutNL;
20684  
20685 $address->freeMemory($N);
20686  
20687 ok Assemble eq => <<END;
20688 abcdefghijklmnop
20689 END
20690  
20691  
20692 =head3 Nasm::X86::Variable::allocateMemory($size)
20693  
20694 Allocate a variable amount of memory via mmap and return its address.
20695  
20696 Parameter Description
20697 1 $size Size as a variable
20698  
20699 B<Example:>
20700  
20701  
20702 my $N = K size => 2048;
20703 my $q = Rs('a'..'p');
20704 my $address = $N->allocateMemory;
20705  
20706 Vmovdqu8 xmm0, "[$q]";
20707 $address->setReg(rax);
20708 Vmovdqu8 "[rax]", xmm0;
20709 Mov rdi, 16;
20710 PrintOutMemory;
20711 PrintOutNL;
20712  
20713 $address->freeMemory($N);
20714  
20715 ok Assemble eq => <<END;
20716 abcdefghijklmnop
20717 END
20718  
20719  
20720 =head2 Structured Programming with variables
20721  
20722 Structured programming operations driven off variables.
20723  
20724 =head3 Nasm::X86::Variable::for($limit, $block)
20725  
20726 Iterate a block a variable number of times.
20727  
20728 Parameter Description
20729 1 $limit Number of times
20730 2 $block Block
20731  
20732 B<Example:>
20733  
20734  
20735 V(limit => 10)->for(sub
20736 {my ($i, $start, $next, $end) = @_;
20737 $i->outNL;
20738 });
20739  
20740 ok Assemble(debug => 0, eq => <<END, avx512=>0);
20741 index: .... .... .... ...0
20742 index: .... .... .... ...1
20743 index: .... .... .... ...2
20744 index: .... .... .... ...3
20745 index: .... .... .... ...4
20746 index: .... .... .... ...5
20747 index: .... .... .... ...6
20748 index: .... .... .... ...7
20749 index: .... .... .... ...8
20750 index: .... .... .... ...9
20751 END
20752  
20753  
20754 =head1 Operating system
20755  
20756 Interacting with the operating system.
20757  
20758 =head2 Processes
20759  
20760 Create and manage processes
20761  
20762 =head3 Fork()
20763  
20764 Fork: create and execute a copy of the current process.
20765  
20766  
20767 B<Example:>
20768  
20769  
20770  
20771 Fork; # Fork # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
20772  
20773  
20774 Test rax,rax;
20775 IfNz # Parent
20776 Then
20777 {Mov rbx, rax;
20778 WaitPid;
20779 GetPid; # Pid of parent as seen in parent
20780 Mov rcx,rax;
20781 PrintOutRegisterInHex rax, rbx, rcx;
20782 },
20783 Else # Child
20784 {Mov r8,rax;
20785 GetPid; # Child pid as seen in child
20786 Mov r9,rax;
20787 GetPPid; # Parent pid as seen in child
20788 Mov r10,rax;
20789 PrintOutRegisterInHex r8, r9, r10;
20790 };
20791  
20792 my $r = Assemble(avx512=>0);
20793  
20794 # r8: 0000 0000 0000 0000 #1 Return from fork as seen by child
20795 # r9: 0000 0000 0003 0C63 #2 Pid of child
20796 # r10: 0000 0000 0003 0C60 #3 Pid of parent from child
20797 # rax: 0000 0000 0003 0C63 #4 Return from fork as seen by parent
20798 # rbx: 0000 0000 0003 0C63 #5 Wait for child pid result
20799 # rcx: 0000 0000 0003 0C60 #6 Pid of parent
20800  
20801 if ($r =~ m(r8:( 0000){4}.*r9:(.*)\s{5,}r10:(.*)\s{5,}rax:(.*)\s{5,}rbx:(.*)\s{5,}rcx:(.*)\s{2,})s)
20802 {ok $2 eq $4;
20803 ok $2 eq $5;
20804 ok $3 eq $6;
20805 ok $2 gt $6;
20806 }
20807  
20808  
20809 =head3 GetPid()
20810  
20811 Get process identifier.
20812  
20813  
20814 B<Example:>
20815  
20816  
20817 Fork; # Fork
20818  
20819 Test rax,rax;
20820 IfNz # Parent
20821 Then
20822 {Mov rbx, rax;
20823 WaitPid;
20824  
20825 GetPid; # Pid of parent as seen in parent # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
20826  
20827 Mov rcx,rax;
20828 PrintOutRegisterInHex rax, rbx, rcx;
20829 },
20830 Else # Child
20831 {Mov r8,rax;
20832  
20833 GetPid; # Child pid as seen in child # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
20834  
20835 Mov r9,rax;
20836 GetPPid; # Parent pid as seen in child
20837 Mov r10,rax;
20838 PrintOutRegisterInHex r8, r9, r10;
20839 };
20840  
20841 my $r = Assemble(avx512=>0);
20842  
20843 # r8: 0000 0000 0000 0000 #1 Return from fork as seen by child
20844 # r9: 0000 0000 0003 0C63 #2 Pid of child
20845 # r10: 0000 0000 0003 0C60 #3 Pid of parent from child
20846 # rax: 0000 0000 0003 0C63 #4 Return from fork as seen by parent
20847 # rbx: 0000 0000 0003 0C63 #5 Wait for child pid result
20848 # rcx: 0000 0000 0003 0C60 #6 Pid of parent
20849  
20850 if ($r =~ m(r8:( 0000){4}.*r9:(.*)\s{5,}r10:(.*)\s{5,}rax:(.*)\s{5,}rbx:(.*)\s{5,}rcx:(.*)\s{2,})s)
20851 {ok $2 eq $4;
20852 ok $2 eq $5;
20853 ok $3 eq $6;
20854 ok $2 gt $6;
20855 }
20856  
20857  
20858 =head3 GetPidInHex()
20859  
20860 Get process identifier in hex as 8 zero terminated bytes in rax.
20861  
20862  
20863 B<Example:>
20864  
20865  
20866  
20867 GetPidInHex; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
20868  
20869 Mov r15, rax;
20870  
20871  
20872 GetPidInHex; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
20873  
20874 Cmp r15, rax;
20875 IfEq Then {PrintOutStringNL "Same"}, Else {PrintOutStringNL "Diff"};
20876  
20877 ok Assemble eq => <<END, avx512=>0;
20878 Same
20879 END
20880  
20881  
20882 =head3 GetPPid()
20883  
20884 Get parent process identifier.
20885  
20886  
20887 B<Example:>
20888  
20889  
20890 Fork; # Fork
20891  
20892 Test rax,rax;
20893 IfNz # Parent
20894 Then
20895 {Mov rbx, rax;
20896 WaitPid;
20897 GetPid; # Pid of parent as seen in parent
20898 Mov rcx,rax;
20899 PrintOutRegisterInHex rax, rbx, rcx;
20900 },
20901 Else # Child
20902 {Mov r8,rax;
20903 GetPid; # Child pid as seen in child
20904 Mov r9,rax;
20905  
20906 GetPPid; # Parent pid as seen in child # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
20907  
20908 Mov r10,rax;
20909 PrintOutRegisterInHex r8, r9, r10;
20910 };
20911  
20912 my $r = Assemble(avx512=>0);
20913  
20914 # r8: 0000 0000 0000 0000 #1 Return from fork as seen by child
20915 # r9: 0000 0000 0003 0C63 #2 Pid of child
20916 # r10: 0000 0000 0003 0C60 #3 Pid of parent from child
20917 # rax: 0000 0000 0003 0C63 #4 Return from fork as seen by parent
20918 # rbx: 0000 0000 0003 0C63 #5 Wait for child pid result
20919 # rcx: 0000 0000 0003 0C60 #6 Pid of parent
20920  
20921 if ($r =~ m(r8:( 0000){4}.*r9:(.*)\s{5,}r10:(.*)\s{5,}rax:(.*)\s{5,}rbx:(.*)\s{5,}rcx:(.*)\s{2,})s)
20922 {ok $2 eq $4;
20923 ok $2 eq $5;
20924 ok $3 eq $6;
20925 ok $2 gt $6;
20926 }
20927  
20928  
20929 =head3 GetUid()
20930  
20931 Get userid of current process.
20932  
20933  
20934 B<Example:>
20935  
20936  
20937 if (!onGitHub) {
20938  
20939  
20940 =head3 WaitPid()
20941  
20942 Wait for the pid in rax to complete.
20943  
20944  
20945 B<Example:>
20946  
20947  
20948 Fork; # Fork
20949  
20950 Test rax,rax;
20951 IfNz # Parent
20952 Then
20953 {Mov rbx, rax;
20954  
20955 WaitPid; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
20956  
20957 GetPid; # Pid of parent as seen in parent
20958 Mov rcx,rax;
20959 PrintOutRegisterInHex rax, rbx, rcx;
20960 },
20961 Else # Child
20962 {Mov r8,rax;
20963 GetPid; # Child pid as seen in child
20964 Mov r9,rax;
20965 GetPPid; # Parent pid as seen in child
20966 Mov r10,rax;
20967 PrintOutRegisterInHex r8, r9, r10;
20968 };
20969  
20970 my $r = Assemble(avx512=>0);
20971  
20972 # r8: 0000 0000 0000 0000 #1 Return from fork as seen by child
20973 # r9: 0000 0000 0003 0C63 #2 Pid of child
20974 # r10: 0000 0000 0003 0C60 #3 Pid of parent from child
20975 # rax: 0000 0000 0003 0C63 #4 Return from fork as seen by parent
20976 # rbx: 0000 0000 0003 0C63 #5 Wait for child pid result
20977 # rcx: 0000 0000 0003 0C60 #6 Pid of parent
20978  
20979 if ($r =~ m(r8:( 0000){4}.*r9:(.*)\s{5,}r10:(.*)\s{5,}rax:(.*)\s{5,}rbx:(.*)\s{5,}rcx:(.*)\s{2,})s)
20980 {ok $2 eq $4;
20981 ok $2 eq $5;
20982 ok $3 eq $6;
20983 ok $2 gt $6;
20984 }
20985  
20986  
20987 =head3 ReadTimeStampCounter()
20988  
20989 Read the time stamp counter and return the time in nanoseconds in rax.
20990  
20991  
20992 B<Example:>
20993  
20994  
20995 for(1..10)
20996  
20997 {ReadTimeStampCounter; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
20998  
20999 PrintOutRegisterInHex rax;
21000 }
21001  
21002 my @s = split /
21003 /, Assemble(avx512=>0);
21004 my @S = sort @s;
21005 is_deeply \@s, \@S;
21006  
21007  
21008 =head2 Memory
21009  
21010 Allocate and print memory
21011  
21012 =head3 PrintOutMemoryInHex()
21013  
21014 Dump memory from the address in rax for the length in rdi on stdout.
21015  
21016  
21017 B<Example:>
21018  
21019  
21020 Mov rax, 0x07654321;
21021 Shl rax, 32;
21022 Or rax, 0x07654321;
21023 PushR rax;
21024  
21025 PrintOutRaxInHex;
21026 PrintOutNL;
21027 PrintOutRaxInReverseInHex;
21028 PrintOutNL;
21029  
21030 Mov rax, rsp;
21031 Mov rdi, 8;
21032  
21033 PrintOutMemoryInHex; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21034  
21035 PrintOutNL;
21036 PopR rax;
21037  
21038 Mov rax, 4096;
21039 PushR rax;
21040 Mov rax, rsp;
21041 Mov rdi, 8;
21042  
21043 PrintOutMemoryInHex; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21044  
21045 PrintOutNL;
21046 PopR rax;
21047  
21048 ok Assemble eq => <<END, avx512=>0;
21049 .765 4321 .765 4321
21050 2143 65.7 2143 65.7
21051 2143 65.7 2143 65.7
21052 ..10 .... .... ....
21053 END
21054  
21055  
21056 =head3 PrintOutMemoryInHexNL()
21057  
21058 Dump memory from the address in rax for the length in rdi and then print a new line.
21059  
21060  
21061 B<Example:>
21062  
21063  
21064 my $N = 256;
21065 my $s = Rb 0..$N-1;
21066 my $a = AllocateMemory K size => $N;
21067 CopyMemory(V(source => $s), $a, K(size => $N));
21068  
21069 my $b = AllocateMemory K size => $N;
21070 CopyMemory($a, $b, K size => $N);
21071  
21072 $b->setReg(rax);
21073 Mov rdi, $N;
21074 PrintOutMemory_InHexNL;
21075  
21076 ok Assemble eq => <<END, avx512=>0;
21077 __.1 .2.3 .4.5 .6.7 .8.9 .A.B .C.D .E.F 1011 1213 1415 1617 1819 1A1B 1C1D 1E1F 2021 2223 2425 2627 2829 2A2B 2C2D 2E2F 3031 3233 3435 3637 3839 3A3B 3C3D 3E3F 4041 4243 4445 4647 4849 4A4B 4C4D 4E4F 5051 5253 5455 5657 5859 5A5B 5C5D 5E5F 6061 6263 6465 6667 6869 6A6B 6C6D 6E6F 7071 7273 7475 7677 7879 7A7B 7C7D 7E7F 8081 8283 8485 8687 8889 8A8B 8C8D 8E8F 9091 9293 9495 9697 9899 9A9B 9C9D 9E9F A0A1 A2A3 A4A5 A6A7 A8A9 AAAB ACAD AEAF B0B1 B2B3 B4B5 B6B7 B8B9 BABB BCBD BEBF C0C1 C2C3 C4C5 C6C7 C8C9 CACB CCCD CECF D0D1 D2D3 D4D5 D6D7 D8D9 DADB DCDD DEDF E0E1 E2E3 E4E5 E6E7 E8E9 EAEB ECED EEEF F0F1 F2F3 F4F5 F6F7 F8F9 FAFB FCFD FEFF
21078 END
21079  
21080  
21081 =head3 PrintOutMemory_InHex()
21082  
21083 Dump memory from the address in rax for the length in rdi on stdout.
21084  
21085  
21086 B<Example:>
21087  
21088  
21089 K(loop => 8+1)->for(sub
21090 {my ($index, $start, $next, $end) = @_;
21091 $index->setReg(15);
21092 Push r15;
21093 });
21094  
21095 Mov rax, rsp;
21096 Mov rdi, 8*9;
21097 PrintOutMemory_InHexNL;
21098 ClearMemory(V(address => rax), K(size => 8*9));
21099  
21100 PrintOutMemory_InHex; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21101  
21102 PrintOutNL;
21103  
21104 ok Assemble eq => <<END;
21105 .8__ ____ ____ ____ .7__ ____ ____ ____ .6__ ____ ____ ____ .5__ ____ ____ ____ .4__ ____ ____ ____ .3__ ____ ____ ____ .2__ ____ ____ ____ .1__ ____ ____ ____ ____ ____ ____ ____
21106 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
21107 END
21108  
21109  
21110 =head3 PrintOutMemory_InHexNL()
21111  
21112 Dump memory from the address in rax for the length in rdi and then print a new line.
21113  
21114  
21115 B<Example:>
21116  
21117  
21118 K(loop => 8+1)->for(sub
21119 {my ($index, $start, $next, $end) = @_;
21120 $index->setReg(15);
21121 Push r15;
21122 });
21123  
21124 Mov rax, rsp;
21125 Mov rdi, 8*9;
21126  
21127 PrintOutMemory_InHexNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21128  
21129 ClearMemory(V(address => rax), K(size => 8*9));
21130 PrintOutMemory_InHex;
21131 PrintOutNL;
21132  
21133 ok Assemble eq => <<END;
21134 .8__ ____ ____ ____ .7__ ____ ____ ____ .6__ ____ ____ ____ .5__ ____ ____ ____ .4__ ____ ____ ____ .3__ ____ ____ ____ .2__ ____ ____ ____ .1__ ____ ____ ____ ____ ____ ____ ____
21135 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
21136 END
21137  
21138  
21139 =head3 PrintOutMemory()
21140  
21141 Print the memory addressed by rax for a length of rdi on stdout.
21142  
21143  
21144 B<Example:>
21145  
21146  
21147 Comment "Print a string from memory";
21148 my $s = "Hello World";
21149 Mov rax, Rs($s);
21150 Mov rdi, length $s;
21151  
21152 PrintOutMemory; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21153  
21154 Exit(0);
21155  
21156 ok Assemble(avx512=>0) =~ m(Hello World);
21157  
21158  
21159 =head3 PrintOutMemoryNL()
21160  
21161 Print the memory addressed by rax for a length of rdi followed by a new line on stdout.
21162  
21163  
21164 B<Example:>
21165  
21166  
21167 my $s = Rs("Hello World
21168  
21169 Hello Skye");
21170 my $l = StringLength(my $t = V string => $s);
21171 $t->setReg(rax);
21172 $l->setReg(rdi);
21173  
21174 PrintOutMemoryNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21175  
21176  
21177 ok Assemble eq => <<END, avx512=>0;
21178 Hello World
21179  
21180 Hello Skye
21181 END
21182  
21183  
21184 =head3 AllocateMemory($size)
21185  
21186 Allocate the variable specified amount of memory via mmap and return its address as a variable.
21187  
21188 Parameter Description
21189 1 $size Size as a variable
21190  
21191 B<Example:>
21192  
21193  
21194 my $N = K size => 2048;
21195 my $q = Rs('a'..'p');
21196  
21197 my $address = AllocateMemory $N; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21198  
21199  
21200 Vmovdqu8 xmm0, "[$q]";
21201 $address->setReg(rax);
21202 Vmovdqu8 "[rax]", xmm0;
21203 Mov rdi, 16;
21204 PrintOutMemory;
21205 PrintOutNL;
21206  
21207 FreeMemory $address, $N;
21208  
21209 ok Assemble eq => <<END;
21210 abcdefghijklmnop
21211 END
21212  
21213 my $N = K size => 4096; # Size of the initial allocation which should be one or more pages
21214  
21215  
21216 my $A = AllocateMemory $N; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21217  
21218  
21219 ClearMemory($A, $N);
21220  
21221 $A->setReg(rax);
21222 Mov rdi, 128;
21223 PrintOutMemory_InHexNL;
21224  
21225 FreeMemory $A, $N;
21226  
21227 ok Assemble eq => <<END;
21228 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
21229 END
21230  
21231 my $N = 256;
21232 my $s = Rb 0..$N-1;
21233  
21234 my $a = AllocateMemory K size => $N; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21235  
21236 CopyMemory(V(source => $s), $a, K(size => $N));
21237  
21238  
21239 my $b = AllocateMemory K size => $N; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21240  
21241 CopyMemory($a, $b, K size => $N);
21242  
21243 $b->setReg(rax);
21244 Mov rdi, $N;
21245 PrintOutMemory_InHexNL;
21246  
21247 ok Assemble eq => <<END, avx512=>0;
21248 __.1 .2.3 .4.5 .6.7 .8.9 .A.B .C.D .E.F 1011 1213 1415 1617 1819 1A1B 1C1D 1E1F 2021 2223 2425 2627 2829 2A2B 2C2D 2E2F 3031 3233 3435 3637 3839 3A3B 3C3D 3E3F 4041 4243 4445 4647 4849 4A4B 4C4D 4E4F 5051 5253 5455 5657 5859 5A5B 5C5D 5E5F 6061 6263 6465 6667 6869 6A6B 6C6D 6E6F 7071 7273 7475 7677 7879 7A7B 7C7D 7E7F 8081 8283 8485 8687 8889 8A8B 8C8D 8E8F 9091 9293 9495 9697 9899 9A9B 9C9D 9E9F A0A1 A2A3 A4A5 A6A7 A8A9 AAAB ACAD AEAF B0B1 B2B3 B4B5 B6B7 B8B9 BABB BCBD BEBF C0C1 C2C3 C4C5 C6C7 C8C9 CACB CCCD CECF D0D1 D2D3 D4D5 D6D7 D8D9 DADB DCDD DEDF E0E1 E2E3 E4E5 E6E7 E8E9 EAEB ECED EEEF F0F1 F2F3 F4F5 F6F7 F8F9 FAFB FCFD FEFF
21249 END
21250  
21251  
21252 =head3 FreeMemory($address, $size)
21253  
21254 Free memory specified by variables.
21255  
21256 Parameter Description
21257 1 $address Variable address of memory
21258 2 $size Variable size of memory
21259  
21260 B<Example:>
21261  
21262  
21263 my $N = K size => 2048;
21264 my $q = Rs('a'..'p');
21265 my $address = AllocateMemory $N;
21266  
21267 Vmovdqu8 xmm0, "[$q]";
21268 $address->setReg(rax);
21269 Vmovdqu8 "[rax]", xmm0;
21270 Mov rdi, 16;
21271 PrintOutMemory;
21272 PrintOutNL;
21273  
21274  
21275 FreeMemory $address, $N; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21276  
21277  
21278 ok Assemble eq => <<END;
21279 abcdefghijklmnop
21280 END
21281  
21282 my $N = K size => 4096; # Size of the initial allocation which should be one or more pages
21283  
21284 my $A = AllocateMemory $N;
21285  
21286 ClearMemory($A, $N);
21287  
21288 $A->setReg(rax);
21289 Mov rdi, 128;
21290 PrintOutMemory_InHexNL;
21291  
21292  
21293 FreeMemory $A, $N; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21294  
21295  
21296 ok Assemble eq => <<END;
21297 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
21298 END
21299  
21300  
21301 =head3 ClearMemory($address, $size)
21302  
21303 Clear memory with a variable address and variable length.
21304  
21305 Parameter Description
21306 1 $address Address of memory as a variable
21307 2 $size Size of memory as a variable
21308  
21309 B<Example:>
21310  
21311  
21312 K(loop => 8+1)->for(sub
21313 {my ($index, $start, $next, $end) = @_;
21314 $index->setReg(15);
21315 Push r15;
21316 });
21317  
21318 Mov rax, rsp;
21319 Mov rdi, 8*9;
21320 PrintOutMemory_InHexNL;
21321  
21322 ClearMemory(V(address => rax), K(size => 8*9)); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21323  
21324 PrintOutMemory_InHex;
21325 PrintOutNL;
21326  
21327 ok Assemble eq => <<END;
21328 .8__ ____ ____ ____ .7__ ____ ____ ____ .6__ ____ ____ ____ .5__ ____ ____ ____ .4__ ____ ____ ____ .3__ ____ ____ ____ .2__ ____ ____ ____ .1__ ____ ____ ____ ____ ____ ____ ____
21329 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
21330 END
21331  
21332 my $N = K size => 4096; # Size of the initial allocation which should be one or more pages
21333  
21334 my $A = AllocateMemory $N;
21335  
21336  
21337 ClearMemory($A, $N); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21338  
21339  
21340 $A->setReg(rax);
21341 Mov rdi, 128;
21342 PrintOutMemory_InHexNL;
21343  
21344 FreeMemory $A, $N;
21345  
21346 ok Assemble eq => <<END;
21347 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
21348 END
21349  
21350  
21351 =head3 CopyMemory($source, $target, $size)
21352  
21353 Copy memory.
21354  
21355 Parameter Description
21356 1 $source Source address variable
21357 2 $target Target address variable
21358 3 $size Length variable
21359  
21360 B<Example:>
21361  
21362  
21363 my $s = Rb 0; Rb 1; Rw 2; Rd 3; Rq 4;
21364 my $t = Db 0; Db 1; Dw 2; Dd 3; Dq 4;
21365  
21366 Vmovdqu8 xmm0, "[$s]";
21367 Vmovdqu8 xmm1, "[$t]";
21368 PrintOutRegisterInHex xmm0;
21369 PrintOutRegisterInHex xmm1;
21370 Sub rsp, 16;
21371  
21372 Mov rax, rsp; # Copy memory, the target is addressed by rax, the length is in rdi, the source is addressed by rsi
21373 Mov rdi, 16;
21374 Mov rsi, $s;
21375  
21376 CopyMemory(V(source => rsi), V(target => rax), V size => rdi); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21377  
21378 PrintOutMemory_InHexNL;
21379  
21380 ok Assemble eq => <<END;
21381 xmm0: .... .... .... ...4 .... ...3 ...2 .1..
21382 xmm1: .... .... .... ...4 .... ...3 ...2 .1..
21383 __.1 .2__ .3__ ____ .4__ ____ ____ ____
21384 END
21385  
21386 my $N = 256;
21387 my $s = Rb 0..$N-1;
21388 my $a = AllocateMemory K size => $N;
21389  
21390 CopyMemory(V(source => $s), $a, K(size => $N)); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21391  
21392  
21393 my $b = AllocateMemory K size => $N;
21394  
21395 CopyMemory($a, $b, K size => $N); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21396  
21397  
21398 $b->setReg(rax);
21399 Mov rdi, $N;
21400 PrintOutMemory_InHexNL;
21401  
21402 ok Assemble eq => <<END, avx512=>0;
21403 __.1 .2.3 .4.5 .6.7 .8.9 .A.B .C.D .E.F 1011 1213 1415 1617 1819 1A1B 1C1D 1E1F 2021 2223 2425 2627 2829 2A2B 2C2D 2E2F 3031 3233 3435 3637 3839 3A3B 3C3D 3E3F 4041 4243 4445 4647 4849 4A4B 4C4D 4E4F 5051 5253 5455 5657 5859 5A5B 5C5D 5E5F 6061 6263 6465 6667 6869 6A6B 6C6D 6E6F 7071 7273 7475 7677 7879 7A7B 7C7D 7E7F 8081 8283 8485 8687 8889 8A8B 8C8D 8E8F 9091 9293 9495 9697 9899 9A9B 9C9D 9E9F A0A1 A2A3 A4A5 A6A7 A8A9 AAAB ACAD AEAF B0B1 B2B3 B4B5 B6B7 B8B9 BABB BCBD BEBF C0C1 C2C3 C4C5 C6C7 C8C9 CACB CCCD CECF D0D1 D2D3 D4D5 D6D7 D8D9 DADB DCDD DEDF E0E1 E2E3 E4E5 E6E7 E8E9 EAEB ECED EEEF F0F1 F2F3 F4F5 F6F7 F8F9 FAFB FCFD FEFF
21404 END
21405  
21406  
21407 =head3 CopyMemory64($source, $target, $size)
21408  
21409 Copy memory in 64 byte blocks.
21410  
21411 Parameter Description
21412 1 $source Source address variable
21413 2 $target Target address variable
21414 3 $size Number of 64 byte blocks to move
21415  
21416 B<Example:>
21417  
21418  
21419 my ($s, $l) =
21420  
21421  
21422 =head2 Files
21423  
21424 Interact with the operating system via files.
21425  
21426 =head3 OpenRead()
21427  
21428 Open a file, whose name is addressed by rax, for read and return the file descriptor in rax.
21429  
21430  
21431 B<Example:>
21432  
21433  
21434 Mov rax, Rs($0); # File to read
21435  
21436 OpenRead; # Open file # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21437  
21438 PrintOutRegisterInHex rax;
21439 CloseFile; # Close file
21440 PrintOutRegisterInHex rax;
21441  
21442 Mov rax, Rs(my $f = "zzzTemporaryFile.txt"); # File to write
21443 OpenWrite; # Open file
21444 CloseFile; # Close file
21445  
21446 ok Assemble eq => <<END;
21447 rax: .... .... .... ...3
21448 rax: .... .... .... ...0
21449 END
21450 ok -e $f; # Created file
21451 unlink $f;
21452  
21453  
21454 =head3 OpenWrite()
21455  
21456 Create the file named by the terminated string addressed by rax for write. The file handle will be returned in rax.
21457  
21458  
21459 B<Example:>
21460  
21461  
21462 if (1)
21463 {my $s = "zzzCreated.data";
21464 my $f = Rs $s;
21465 Mov rax, $f;
21466  
21467 OpenWrite; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21468  
21469 Mov r15, rax;
21470 Mov rax, $f;
21471 Mov rdi, length $s;
21472 PrintMemory r15;
21473 CloseFile;
21474 ok Assemble eq=><<END, avx512=>1;
21475 END
21476 ok -e $s;
21477 unlink $s;
21478 }
21479  
21480 Mov rax, Rs($0); # File to read
21481 OpenRead; # Open file
21482 PrintOutRegisterInHex rax;
21483 CloseFile; # Close file
21484 PrintOutRegisterInHex rax;
21485  
21486 Mov rax, Rs(my $f = "zzzTemporaryFile.txt"); # File to write
21487  
21488 OpenWrite; # Open file # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21489  
21490 CloseFile; # Close file
21491  
21492 ok Assemble eq => <<END;
21493 rax: .... .... .... ...3
21494 rax: .... .... .... ...0
21495 END
21496 ok -e $f; # Created file
21497 unlink $f;
21498  
21499  
21500 =head3 CloseFile()
21501  
21502 Close the file whose descriptor is in rax.
21503  
21504  
21505 B<Example:>
21506  
21507  
21508 if (1)
21509 {my $s = "zzzCreated.data";
21510 my $f = Rs $s;
21511 Mov rax, $f;
21512 OpenWrite;
21513 Mov r15, rax;
21514 Mov rax, $f;
21515 Mov rdi, length $s;
21516 PrintMemory r15;
21517  
21518 CloseFile; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21519  
21520 ok Assemble eq=><<END, avx512=>1;
21521 END
21522 ok -e $s;
21523 unlink $s;
21524 }
21525  
21526 Mov rax, Rs($0); # File to read
21527 OpenRead; # Open file
21528 PrintOutRegisterInHex rax;
21529  
21530 CloseFile; # Close file # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21531  
21532 PrintOutRegisterInHex rax;
21533  
21534 Mov rax, Rs(my $f = "zzzTemporaryFile.txt"); # File to write
21535 OpenWrite; # Open file
21536  
21537 CloseFile; # Close file # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21538  
21539  
21540 ok Assemble eq => <<END;
21541 rax: .... .... .... ...3
21542 rax: .... .... .... ...0
21543 END
21544 ok -e $f; # Created file
21545 unlink $f;
21546  
21547  
21548 =head3 StatSize()
21549  
21550 Stat a file whose name is addressed by rax to get its size in rax.
21551  
21552  
21553 B<Example:>
21554  
21555  
21556 Mov rax, Rs $0; # File to stat
21557  
21558 StatSize; # Stat the file # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21559  
21560 PrintOutRegisterInHex rax;
21561  
21562 my $r = Assemble(avx512=>0) =~ s( ) ()gsr;
21563 if ($r =~ m(rax:([0-9a-f]{16}))is) # Compare file size obtained with that from fileSize()
21564 {is_deeply $1, sprintf("%016X", fileSize($0));
21565 }
21566  
21567  
21568 =head3 ReadChar()
21569  
21570 Read a character from stdin and return it in rax else return -1 in rax if no character was read.
21571  
21572  
21573 B<Example:>
21574  
21575  
21576 my $e = q(readChar);
21577  
21578 ForEver
21579 {my ($start, $end) = @_;
21580  
21581 ReadChar; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21582  
21583 Cmp rax, 0xa;
21584 Jle $end;
21585 PrintOutRaxAsChar;
21586 PrintOutRaxAsCharNL;
21587 };
21588 PrintOutNL;
21589  
21590 Assemble keep => $e;
21591  
21592 my $r = qx(echo "ABCDCBA" | ./$e);
21593 is_deeply $r, <<END;
21594 AA
21595 BB
21596 CC
21597 DD
21598 CC
21599 BB
21600 AA
21601  
21602 END
21603 unlink $e;
21604  
21605  
21606 =head3 ReadLine()
21607  
21608 Reads up to 8 characters followed by a terminating return and place them into rax.
21609  
21610  
21611 B<Example:>
21612  
21613  
21614 my $e = q(readLine);
21615 my $f = writeTempFile("hello
21616 world
21617 ");
21618  
21619  
21620 ReadLine; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21621  
21622 PrintOutRaxAsTextNL;
21623  
21624 ReadLine; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21625  
21626 PrintOutRaxAsTextNL;
21627  
21628 Assemble keep => $e;
21629  
21630 is_deeply scalar(qx(./$e < $f)), <<END;
21631 hello
21632 world
21633 END
21634 unlink $f;
21635 }
21636  
21637 #latest:
21638 if (1) {
21639 my $e = q(readInteger);
21640 my $f = writeTempFile("11
21641 22
21642 ");
21643  
21644 ReadInteger;
21645 Shl rax, 1;
21646 PrintOutRaxInDecNL;
21647 ReadInteger;
21648 Shl rax, 1;
21649 PrintOutRaxInDecNL;
21650  
21651 Assemble keep => $e;
21652  
21653 is_deeply scalar(qx(./$e < $f)), <<END;
21654 22
21655 44
21656 END
21657  
21658 unlink $e, $f;
21659  
21660  
21661 =head3 ReadInteger()
21662  
21663 Reads an integer in decimal and returns it in rax.
21664  
21665  
21666 B<Example:>
21667  
21668  
21669 my $e = q(readInteger);
21670 my $f = writeTempFile("11
21671 22
21672 ");
21673  
21674  
21675 ReadInteger; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21676  
21677 Shl rax, 1;
21678 PrintOutRaxInDecNL;
21679  
21680 ReadInteger; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21681  
21682 Shl rax, 1;
21683 PrintOutRaxInDecNL;
21684  
21685 Assemble keep => $e;
21686  
21687 is_deeply scalar(qx(./$e < $f)), <<END;
21688 22
21689 44
21690 END
21691  
21692 unlink $e, $f;
21693  
21694  
21695 =head3 ReadFile($File)
21696  
21697 Read a file into memory.
21698  
21699 Parameter Description
21700 1 $File Variable addressing a zero terminated string naming the file to be read in by mapping it
21701  
21702 B<Example:>
21703  
21704  
21705 if (!!onGitHub) {
21706  
21707  
21708 =head3 executeFileViaBash($file)
21709  
21710 Execute the file named in a variable.
21711  
21712 Parameter Description
21713 1 $file File variable
21714  
21715 B<Example:>
21716  
21717  
21718 if (0 and !onGitHub) { # Execute the content of an area
21719  
21720  
21721 =head3 unlinkFile($file)
21722  
21723 Unlink the named file.
21724  
21725 Parameter Description
21726 1 $file File variable
21727  
21728 B<Example:>
21729  
21730  
21731 if (0 and !onGitHub) { # Execute the content of an area
21732  
21733  
21734 =head1 Hash functions
21735  
21736 Hash functions
21737  
21738 =head2 Hash()
21739  
21740 Hash a string addressed by rax with length held in rdi and return the hash code in r15.
21741  
21742  
21743 B<Example:>
21744  
21745  
21746 # Make hash accept parameters at:
21747  
21748 Mov rax, "[rbp+24]"; # Address of string as parameter
21749 StringLength(V string => rax)->setReg(rdi); # Length of string to hash
21750  
21751 Hash(); # Hash string # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21752  
21753  
21754 PrintOutRegisterInHex r15;
21755  
21756 my $e = Assemble keep => 'hash'; # Assemble to the specified file name
21757 say STDERR qx($e "");
21758 say STDERR qx($e "a");
21759 ok qx($e "") =~ m(r15: 0000 3F80 0000 3F80); # Test well known hashes
21760 ok qx($e "a") =~ m(r15: 0000 3F80 C000 45B2);
21761  
21762  
21763 if (0) # Hash various strings # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21764  
21765 {my %r; my %f; my $count = 0;
21766 my $N = RegisterSize zmm0;
21767  
21768 if (1) # Fixed blocks
21769 {for my $l(qw(a ab abc abcd), 'a a', 'a a')
21770 {for my $i(1..$N)
21771 {my $t = $l x $i;
21772 last if $N < length $t;
21773 my $s = substr($t.(' ' x $N), 0, $N);
21774 next if $f{$s}++;
21775 my $r = qx($e "$s");
21776 say STDERR "$count $r";
21777 if ($r =~ m(^.*r15:\s*(.*)$)m)
21778 {push $r{$1}->@*, $s;
21779 ++$count;
21780 }
21781 }
21782 }
21783 }
21784  
21785 if (1) # Variable blocks
21786 {for my $l(qw(a ab abc abcd), '', 'a a', 'a a')
21787 {for my $i(1..$N)
21788 {my $t = $l x $i;
21789 next if $f{$t}++;
21790 my $r = qx($e "$t");
21791 say STDERR "$count $r";
21792 if ($r =~ m(^.*r15:\s*(.*)$)m)
21793 {push $r{$1}->@*, $t;
21794 ++$count;
21795 }
21796 }
21797 }
21798 }
21799 for my $r(keys %r)
21800 {delete $r{$r} if $r{$r}->@* < 2;
21801 }
21802  
21803 say STDERR dump(\%r);
21804 say STDERR "Keys hashed: ", $count;
21805 confess "Duplicates : ", scalar keys(%r);
21806 }
21807  
21808 unlink 'hash';
21809  
21810  
21811 =head1 Unicode
21812  
21813 Convert between utf8 and utf32
21814  
21815 =head2 GetNextUtf8CharAsUtf32($in)
21816  
21817 Get the next UTF-8 encoded character from the addressed memory and return it as a UTF-32 character as a variable along with the size of the input character and a variable indicating the success - 1 - or failure - 0 - of the operation.
21818  
21819 Parameter Description
21820 1 $in Address of utf8 character as a variable
21821  
21822 B<Example:>
21823  
21824  
21825 my ($out, $size, $fail);
21826  
21827 my $Chars = Rb(0x24, 0xc2, 0xa2, 0xc9, 0x91, 0xE2, 0x82, 0xAC, 0xF0, 0x90, 0x8D, 0x88);
21828 my $chars = V(chars => $Chars);
21829  
21830  
21831 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+0; # Dollar UTF-8 Encoding: 0x24 UTF-32 Encoding: 0x00000024 # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21832  
21833 $out->out('out1 : ');
21834 $size->outNL(' size : ');
21835  
21836  
21837 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+1; # Cents UTF-8 Encoding: 0xC2 0xA2 UTF-32 Encoding: 0x000000a2 # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21838  
21839 $out->out('out2 : '); $size->outNL(' size : ');
21840  
21841  
21842 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+3; # Alpha UTF-8 Encoding: 0xC9 0x91 UTF-32 Encoding: 0x00000251 # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21843  
21844 $out->out('out3 : '); $size->outNL(' size : ');
21845  
21846  
21847 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+5; # Euro UTF-8 Encoding: 0xE2 0x82 0xAC UTF-32 Encoding: 0x000020AC # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21848  
21849 $out->out('out4 : '); $size->outNL(' size : ');
21850  
21851  
21852 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+8; # Gothic Letter Hwair UTF-8 Encoding 0xF0 0x90 0x8D 0x88 UTF-32 Encoding: 0x00010348 # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21853  
21854 $out->out('out5 : '); $size->outNL(' size : ');
21855  
21856 my $statement = qq(𝖺
21857 𝑎𝑠𝑠𝑖𝑔𝑛 【【𝖻 𝐩𝐥𝐮𝐬 𝖼】】
21858 AAAAAAAA); # A sample sentence to parse
21859  
21860 my $s = K(statement => Rutf8($statement));
21861 my $l = StringLength $s;
21862  
21863 my $address = AllocateMemory $l; # Allocate enough memory for a copy of the string
21864 CopyMemory($s, $address, $l);
21865  
21866  
21867 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21868  
21869 $out->out('outA : '); $size->outNL(' size : ');
21870  
21871  
21872 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+4; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21873  
21874 $out->out('outB : '); $size->outNL(' size : ');
21875  
21876  
21877 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+5; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21878  
21879 $out->out('outC : '); $size->outNL(' size : ');
21880  
21881  
21882 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+30; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21883  
21884 $out->out('outD : '); $size->outNL(' size : ');
21885  
21886  
21887 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+35; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
21888  
21889 $out->out('outE : '); $size->outNL(' size : ');
21890  
21891 $address->printOutMemoryInHexNL($l);
21892  
21893 ok Assemble(debug => 0, eq => <<END, avx512=>0);
21894 out1 : .... .... .... ..24 size : .... .... .... ...1
21895 out2 : .... .... .... ..A2 size : .... .... .... ...2
21896 out3 : .... .... .... .251 size : .... .... .... ...2
21897 out4 : .... .... .... 20AC size : .... .... .... ...3
21898 out5 : .... .... ...1 .348 size : .... .... .... ...4
21899 outA : .... .... ...1 D5BA size : .... .... .... ...4
21900 outB : .... .... .... ...A size : .... .... .... ...1
21901 outC : .... .... .... ..20 size : .... .... .... ...1
21902 outD : .... .... .... ..20 size : .... .... .... ...1
21903 outE : .... .... .... ..10 size : .... .... .... ...2
21904 F09D 96BA .A20 F09D 918E F09D 91A0 F09D 91A0 F09D 9196 F09D 9194 F09D 919B 20E3 8090 E380 90F0 9D96 BB20 F09D 90A9 F09D 90A5 F09D 90AE F09D 90AC 20F0 9D96 BCE3 8091 E380 91.A 4141 4141 4141 4141 ....
21905 END
21906  
21907  
21908 =head2 ConvertUtf8ToUtf32($a8, $s8)
21909  
21910 Convert an allocated string of utf8 to an allocated string of utf32 and return its address and length.
21911  
21912 Parameter Description
21913 1 $a8 Utf8 string address variable
21914 2 $s8 Utf8 length variable
21915  
21916 B<Example:>
21917  
21918  
21919 my ($out, $size, $fail);
21920  
21921 my $Chars = Rb(0x24, 0xc2, 0xa2, 0xc9, 0x91, 0xE2, 0x82, 0xAC, 0xF0, 0x90, 0x8D, 0x88);
21922 my $chars = V(chars => $Chars);
21923  
21924 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+0; # Dollar UTF-8 Encoding: 0x24 UTF-32 Encoding: 0x00000024
21925 $out->out('out1 : ');
21926 $size->outNL(' size : ');
21927  
21928 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+1; # Cents UTF-8 Encoding: 0xC2 0xA2 UTF-32 Encoding: 0x000000a2
21929 $out->out('out2 : '); $size->outNL(' size : ');
21930  
21931 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+3; # Alpha UTF-8 Encoding: 0xC9 0x91 UTF-32 Encoding: 0x00000251
21932 $out->out('out3 : '); $size->outNL(' size : ');
21933  
21934 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+5; # Euro UTF-8 Encoding: 0xE2 0x82 0xAC UTF-32 Encoding: 0x000020AC
21935 $out->out('out4 : '); $size->outNL(' size : ');
21936  
21937 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $chars+8; # Gothic Letter Hwair UTF-8 Encoding 0xF0 0x90 0x8D 0x88 UTF-32 Encoding: 0x00010348
21938 $out->out('out5 : '); $size->outNL(' size : ');
21939  
21940 my $statement = qq(𝖺
21941 𝑎𝑠𝑠𝑖𝑔𝑛 【【𝖻 𝐩𝐥𝐮𝐬 𝖼】】
21942 AAAAAAAA); # A sample sentence to parse
21943  
21944 my $s = K(statement => Rutf8($statement));
21945 my $l = StringLength $s;
21946  
21947 my $address = AllocateMemory $l; # Allocate enough memory for a copy of the string
21948 CopyMemory($s, $address, $l);
21949  
21950 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address;
21951 $out->out('outA : '); $size->outNL(' size : ');
21952  
21953 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+4;
21954 $out->out('outB : '); $size->outNL(' size : ');
21955  
21956 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+5;
21957 $out->out('outC : '); $size->outNL(' size : ');
21958  
21959 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+30;
21960 $out->out('outD : '); $size->outNL(' size : ');
21961  
21962 ($out, $size, $fail) = GetNextUtf8CharAsUtf32 $address+35;
21963 $out->out('outE : '); $size->outNL(' size : ');
21964  
21965 $address->printOutMemoryInHexNL($l);
21966  
21967 ok Assemble(debug => 0, eq => <<END, avx512=>0);
21968 out1 : .... .... .... ..24 size : .... .... .... ...1
21969 out2 : .... .... .... ..A2 size : .... .... .... ...2
21970 out3 : .... .... .... .251 size : .... .... .... ...2
21971 out4 : .... .... .... 20AC size : .... .... .... ...3
21972 out5 : .... .... ...1 .348 size : .... .... .... ...4
21973 outA : .... .... ...1 D5BA size : .... .... .... ...4
21974 outB : .... .... .... ...A size : .... .... .... ...1
21975 outC : .... .... .... ..20 size : .... .... .... ...1
21976 outD : .... .... .... ..20 size : .... .... .... ...1
21977 outE : .... .... .... ..10 size : .... .... .... ...2
21978 F09D 96BA .A20 F09D 918E F09D 91A0 F09D 91A0 F09D 9196 F09D 9194 F09D 919B 20E3 8090 E380 90F0 9D96 BB20 F09D 90A9 F09D 90A5 F09D 90AE F09D 90AC 20F0 9D96 BCE3 8091 E380 91.A 4141 4141 4141 4141 ....
21979 END
21980  
21981  
21982 =head1 C Strings
21983  
21984 C strings are a series of bytes terminated by a zero byte.
21985  
21986 =head2 StringLength($string)
21987  
21988 Length of a zero terminated string.
21989  
21990 Parameter Description
21991 1 $string String
21992  
21993 B<Example:>
21994  
21995  
21996 my $s = Rs("Hello World
21997  
21998 Hello Skye");
21999  
22000 my $l = StringLength(my $t = V string => $s); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22001  
22002 $t->setReg(rax);
22003 $l->setReg(rdi);
22004 PrintOutMemoryNL;
22005  
22006 ok Assemble eq => <<END, avx512=>0;
22007 Hello World
22008  
22009 Hello Skye
22010 END
22011  
22012  
22013 StringLength(V string => Rs("abcd"))->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22014  
22015 Assemble eq => <<END, avx512=>0;
22016 size: .... .... .... ...4
22017 END
22018  
22019  
22020 =head1 Areas
22021  
22022 An area is single extensible block of memory which contains other data structures such as strings, arrays, trees within it.
22023  
22024 =head2 Constructors
22025  
22026 Construct an area either in memory or by reading it from a file or by incorporating it into an assembly.
22027  
22028 =head3 CreateArea(%options)
22029  
22030 Create an relocatable area and returns its address in rax. We add a chain header so that 64 byte blocks of memory can be freed and reused within the area.
22031  
22032 Parameter Description
22033 1 %options Free=>1 adds a free chain.
22034  
22035 B<Example:>
22036  
22037  
22038  
22039 my $a = CreateArea; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22040  
22041 $a->q('aa');
22042 $a->outNL;
22043 $a->ql('bb');
22044 $a->out;
22045 ok Assemble eq => <<END, avx512=>0;
22046 aa
22047 aabb
22048 END
22049  
22050  
22051 my $a = CreateArea; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22052  
22053  
22054 my $b = CreateArea; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22055  
22056 $a->q('aa');
22057 $b->q('bb');
22058 $a->out;
22059 PrintOutNL;
22060 $b->out;
22061 PrintOutNL;
22062 ok Assemble eq => <<END, avx512=>0;
22063 aa
22064 bb
22065 END
22066  
22067  
22068 my $a = CreateArea; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22069  
22070  
22071 my $b = CreateArea; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22072  
22073 $a->q('aa');
22074 $a->q('AA');
22075 $a->out;
22076 PrintOutNL;
22077 ok Assemble eq => <<END, avx512=>0;
22078 aaAA
22079 END
22080  
22081  
22082 my $a = CreateArea; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22083  
22084  
22085 my $b = CreateArea; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22086  
22087 $a->q('aa');
22088 $b->q('bb');
22089 $a->q('AA');
22090 $b->q('BB');
22091 $a->q('aa');
22092 $b->q('bb');
22093 $a->out;
22094 $b->out;
22095 PrintOutNL;
22096 ok Assemble eq => <<END, avx512=>0;
22097 aaAAaabbBBbb
22098 END
22099  
22100  
22101 my $a = CreateArea; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22102  
22103 $a->q('ab');
22104  
22105 my $b = CreateArea; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22106  
22107 $b->append($a);
22108 $b->append($a);
22109 $a->append($b);
22110 $b->append($a);
22111 $a->append($b);
22112 $b->append($a);
22113 $b->append($a);
22114 $b->append($a);
22115 $b->append($a);
22116  
22117  
22118 $a->out; PrintOutNL;
22119 $b->outNL;
22120 my $sa = $a->used; $sa->outNL;
22121 my $sb = $b->used; $sb->outNL;
22122 $a->clear;
22123 my $sA = $a->used; $sA->outNL;
22124 my $sB = $b->used; $sB->outNL;
22125  
22126 ok Assemble eq => <<END, avx512=>0;
22127 abababababababab
22128 ababababababababababababababababababababababababababababababababababababab
22129 area used up: .... .... .... ..10
22130 area used up: .... .... .... ..4A
22131 area used up: .... .... .... ...0
22132 area used up: .... .... .... ..4A
22133 END
22134  
22135  
22136 =head3 ReadArea($file)
22137  
22138 Read an area stored in a file into memory and return an area descriptor for the area so created.
22139  
22140 Parameter Description
22141 1 $file Name of file to read
22142  
22143 B<Example:>
22144  
22145  
22146 if (1)
22147 {LoadZmm 0, 61..61+63;
22148  
22149 my $a = CreateArea;
22150 $a->appendZmm(0);
22151 $a->printOut(0x44, 2);
22152 $a->dump("AA");
22153 $a->write(my $f = "aaa.txt");
22154  
22155  
22156 my $A = ReadArea $f; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22157  
22158 $A->dump("BB");
22159 ok Assemble eq => <<END;
22160 AB
22161 AA
22162 Area Size: 4096 Used: 128
22163 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22164 .... .... .... ..40 | 3D3E 3F40 4142 4344 4546 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 5758 595A 5B5C 5D5E 5F60 6162 6364 6566 6768 696A 6B6C 6D6E 6F70 7172 7374 7576 7778 797A 7B7C
22165 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22166 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22167 BB
22168 Area Size: 4096 Used: 128
22169 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22170 .... .... .... ..40 | 3D3E 3F40 4142 4344 4546 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 5758 595A 5B5C 5D5E 5F60 6162 6364 6566 6768 696A 6B6C 6D6E 6F70 7172 7374 7576 7778 797A 7B7C
22171 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22172 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22173 END
22174 }
22175  
22176  
22177 =head3 loadAreaIntoAssembly($file)
22178  
22179 Load an area into the current assembly and return a descriptor for it.
22180  
22181 Parameter Description
22182 1 $file File containing an area
22183  
22184 B<Example:>
22185  
22186  
22187 unlink my $f = q(zzzArea.data);
22188 my $sub = "abcd";
22189  
22190 my $s = Subroutine
22191 {my ($p, $s, $sub) = @_;
22192  
22193 my $a = Subroutine
22194 {my ($p, $s, $sub) = @_;
22195 Mov rax, 0x111;
22196 PrintOutRegisterInHex rax;
22197 } name => 'a', parameters=>[qw(a)];
22198  
22199 my $b = Subroutine
22200 {my ($p, $s, $sub) = @_;
22201 $$p{a}->setReg(rax);
22202 PrintOutRegisterInHex rax;
22203 } name => 'b', parameters=>[qw(a)];
22204  
22205 PrintOutStringNL "abcd";
22206 $$p{a}->outNL;
22207 } name => $sub, parameters=>[qw(a)], export => $f; # Export the library
22208  
22209 my $t = Subroutine {} name => "t", parameters=>[qw(a)];
22210  
22211 my sub mapSubroutines # Create a string tree mapping subroutine names to subroutine numbers
22212 {my $n = CreateArea->CreateTree(stringTree=>1);
22213 $n->putKeyString(constantString("abcd"), K offset => 0);
22214 $n->putKeyString(constantString("a"), K offset => 1);
22215 $n->putKeyString(constantString("b"), K offset => 2);
22216 $n
22217 }
22218  
22219 if (1) # Read a library and call the subroutines there-in
22220 {my $a = ReadArea $f; # Reload the area elsewhere
22221 my ($inter, $symbols) = $a->readLibraryHeader(mapSubroutines); # Create a tree mapping the subroutine numbers to subroutine offsets
22222  
22223 $inter->find(K sub => 1); # Look up the offset of the first subroutine
22224  
22225 If $inter->found > 0,
22226 Then
22227 {$t->call(parameters=>{a => K key => 0x9999}, # Call position independent code
22228 override => $a->address + $inter->data);
22229 },
22230 Else
22231 {PrintOutStringNL "Unable to locate subroutine 'a'";
22232 };
22233  
22234 $inter->find(K sub => 2); # Look up the offset of the second subroutine
22235  
22236 If $inter->found > 0,
22237 Then
22238 {$t->call(parameters=>{a => K key => 0x9999}, # Call position independent code
22239 override => $a->address + $inter->data);
22240 },
22241 Else
22242 {PrintOutStringNL "Unable to locate subroutine 'b'";
22243 };
22244 }
22245  
22246 ok Assemble eq=><<END, avx512=>1;
22247 rax: .... .... .... .111
22248 rax: .... .... .... 9999
22249 END
22250 ok -e $f; # Confirm we have created the library
22251  
22252 if (1) # Include a library in a program
22253  
22254 {my $a = loadAreaIntoAssembly $f; # Load the library from the file it was exported to # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
22255  
22256 my ($inter, $subroutines) = $a->readLibraryHeader(mapSubroutines); # Create a tree mapping the subroutine numbers to subroutine offsets
22257  
22258 $inter->find(K sub => 0); # Look up the offset of the containing subroutine
22259 $t->call(parameters=>{a => K key => 0x6666}, # Call position independent code
22260 override => $a->address + $inter->data);
22261  
22262 $inter->find(K sub => 1); # Look up the offset of the first subroutine
22263 $t->call(parameters=>{a => K key => 0x7777}, # Call position independent code
22264 override => $a->address + $inter->data);
22265  
22266 $inter->find(K sub => 2); # Look up the offset of the second subroutine
22267 $t->call(parameters=>{a => K key => 0x8888}, # Call position independent code
22268 override => $a->address + $inter->data);
22269 }
22270  
22271 ok Assemble eq=><<END, avx512=>1;
22272 abcd
22273 a: .... .... .... 6666
22274 rax: .... .... .... .111
22275 rax: .... .... .... 8888
22276 END
22277  
22278 unlink $f;
22279  
22280  
22281 =head3 Nasm::X86::Area::free($area)
22282  
22283 Free an area.
22284  
22285 Parameter Description
22286 1 $area Area descriptor
22287  
22288 B<Example:>
22289  
22290  
22291 my $a = CreateArea;
22292  
22293 $a->q("a" x 255);
22294 $a->used->outNL;
22295 $a->size->outNL;
22296 $a->dump('A');
22297 $a->clear;
22298 $a->used->outNL;
22299 $a->size->outNL;
22300 $a->dump('B');
22301  
22302 $a->q("a" x 4095);
22303 $a->used->outNL;
22304 $a->size->outNL;
22305 $a->dump('C');
22306 $a->clear;
22307 $a->used->outNL;
22308 $a->size->outNL;
22309 $a->dump('D');
22310  
22311 $a->free;
22312  
22313 ok Assemble(debug => 0, eq => <<END, avx512=>1);
22314 area used up: .... .... .... ..FF
22315 size of area: .... .... .... 10..
22316 A
22317 Area Size: 4096 Used: 319
22318 .... .... .... ...0 | __10 ____ ____ ____ 3F.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22319 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22320 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22321 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22322 area used up: .... .... .... ...0
22323 size of area: .... .... .... 10..
22324 B
22325 Area Size: 4096 Used: 64
22326 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22327 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22328 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22329 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22330 area used up: .... .... .... .FFF
22331 size of area: .... .... .... 20..
22332 C
22333 Area Size: 8192 Used: 4159
22334 .... .... .... ...0 | __20 ____ ____ ____ 3F10 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22335 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22336 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22337 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22338 area used up: .... .... .... ...0
22339 size of area: .... .... .... 20..
22340 D
22341 Area Size: 8192 Used: 64
22342 .... .... .... ...0 | __20 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22343 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22344 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22345 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22346 END
22347  
22348  
22349 =head2 Memory
22350  
22351 Manage memory controlled by an area.
22352  
22353 =head3 Nasm::X86::Area::used($area)
22354  
22355 Return the currently used size of an area as a variable.
22356  
22357 Parameter Description
22358 1 $area Area descriptor
22359  
22360 B<Example:>
22361  
22362  
22363 my $a = CreateArea;
22364  
22365 $a->q("a" x 255);
22366 $a->used->outNL;
22367 $a->size->outNL;
22368 $a->dump('A');
22369 $a->clear;
22370 $a->used->outNL;
22371 $a->size->outNL;
22372 $a->dump('B');
22373  
22374 $a->q("a" x 4095);
22375 $a->used->outNL;
22376 $a->size->outNL;
22377 $a->dump('C');
22378 $a->clear;
22379 $a->used->outNL;
22380 $a->size->outNL;
22381 $a->dump('D');
22382  
22383 $a->free;
22384  
22385 ok Assemble(debug => 0, eq => <<END, avx512=>1);
22386 area used up: .... .... .... ..FF
22387 size of area: .... .... .... 10..
22388 A
22389 Area Size: 4096 Used: 319
22390 .... .... .... ...0 | __10 ____ ____ ____ 3F.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22391 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22392 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22393 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22394 area used up: .... .... .... ...0
22395 size of area: .... .... .... 10..
22396 B
22397 Area Size: 4096 Used: 64
22398 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22399 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22400 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22401 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22402 area used up: .... .... .... .FFF
22403 size of area: .... .... .... 20..
22404 C
22405 Area Size: 8192 Used: 4159
22406 .... .... .... ...0 | __20 ____ ____ ____ 3F10 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22407 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22408 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22409 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22410 area used up: .... .... .... ...0
22411 size of area: .... .... .... 20..
22412 D
22413 Area Size: 8192 Used: 64
22414 .... .... .... ...0 | __20 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22415 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22416 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22417 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22418 END
22419  
22420  
22421 =head3 Nasm::X86::Area::size($area)
22422  
22423 Get the size of an area as a variable.
22424  
22425 Parameter Description
22426 1 $area Area descriptor
22427  
22428 B<Example:>
22429  
22430  
22431 my $a = CreateArea;
22432  
22433 $a->q("a" x 255);
22434 $a->used->outNL;
22435 $a->size->outNL;
22436 $a->dump('A');
22437 $a->clear;
22438 $a->used->outNL;
22439 $a->size->outNL;
22440 $a->dump('B');
22441  
22442 $a->q("a" x 4095);
22443 $a->used->outNL;
22444 $a->size->outNL;
22445 $a->dump('C');
22446 $a->clear;
22447 $a->used->outNL;
22448 $a->size->outNL;
22449 $a->dump('D');
22450  
22451 $a->free;
22452  
22453 ok Assemble(debug => 0, eq => <<END, avx512=>1);
22454 area used up: .... .... .... ..FF
22455 size of area: .... .... .... 10..
22456 A
22457 Area Size: 4096 Used: 319
22458 .... .... .... ...0 | __10 ____ ____ ____ 3F.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22459 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22460 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22461 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22462 area used up: .... .... .... ...0
22463 size of area: .... .... .... 10..
22464 B
22465 Area Size: 4096 Used: 64
22466 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22467 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22468 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22469 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22470 area used up: .... .... .... .FFF
22471 size of area: .... .... .... 20..
22472 C
22473 Area Size: 8192 Used: 4159
22474 .... .... .... ...0 | __20 ____ ____ ____ 3F10 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22475 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22476 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22477 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22478 area used up: .... .... .... ...0
22479 size of area: .... .... .... 20..
22480 D
22481 Area Size: 8192 Used: 64
22482 .... .... .... ...0 | __20 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22483 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22484 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22485 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
22486 END
22487  
22488  
22489 =head3 Nasm::X86::Area::makeReadOnly($area)
22490  
22491 Make an area read only.
22492  
22493 Parameter Description
22494 1 $area Area descriptor
22495  
22496 B<Example:>
22497  
22498  
22499 my $s = CreateArea; # Create an area
22500 $s->q("Hello"); # Write data to area
22501 $s->makeReadOnly; # Make area read only - tested above
22502 $s->makeWriteable; # Make area writable again
22503 $s->q(" World"); # Try to write to area
22504 $s->outNL;
22505  
22506 ok Assemble(avx512=>0, eq => <<END);
22507 Hello World
22508 END
22509  
22510  
22511 =head3 Nasm::X86::Area::makeWriteable($area)
22512  
22513 Make an area writable.
22514  
22515 Parameter Description
22516 1 $area Area descriptor
22517  
22518 B<Example:>
22519  
22520  
22521 my $s = CreateArea; # Create an area
22522 $s->q("Hello"); # Write data to area
22523 $s->makeReadOnly; # Make area read only - tested above
22524 $s->makeWriteable; # Make area writable again
22525 $s->q(" World"); # Try to write to area
22526 $s->outNL;
22527  
22528 ok Assemble(avx512=>0, eq => <<END);
22529 Hello World
22530 END
22531  
22532  
22533 =head2 Alloc/Free
22534  
22535 Allocate and free memory in an area, either once only but in variable size blocks or reusably in zmm sized blocks via the free block chain.
22536  
22537 =head3 Nasm::X86::Area::allocate($area, $Size)
22538  
22539 Allocate the variable amount of space in the variable addressed area and return the offset of the allocation in the area as a variable.
22540  
22541 Parameter Description
22542 1 $area Area descriptor
22543 2 $Size Variable amount of allocation
22544  
22545 B<Example:>
22546  
22547  
22548 my $s = CreateArea;
22549 my $o1 = $s->allocate(0x20);
22550 my $o2 = $s->allocate(0x30);
22551 my $o3 = $s->allocate(0x10);
22552 $o1->outNL;
22553 $o2->outNL;
22554 $o3->outNL;
22555  
22556 ok Assemble eq => <<END, avx512=>0;
22557 offset: .... .... .... ..40
22558 offset: .... .... .... ..60
22559 offset: .... .... .... ..90
22560 END
22561  
22562  
22563 =head3 Nasm::X86::Area::allocZmmBlock($area)
22564  
22565 Allocate a block to hold a zmm register in the specified area and return the offset of the block as a variable.
22566  
22567 Parameter Description
22568 1 $area Area
22569  
22570 B<Example:>
22571  
22572  
22573 my $a = CreateArea;
22574  
22575 my $m = $a->allocZmmBlock;
22576 K(K => Rd(1..16))->loadZmm(31);
22577  
22578 $a->putZmmBlock ($m, 31);
22579 $a->dump("A");
22580  
22581 $a->getZmmBlock ($m, 30);
22582 $a->clearZmmBlock($m);
22583 $a->getZmmBlock ($m, 29);
22584  
22585 $a->clearZmmBlock($m);
22586 PrintOutRegisterInHex 31, 30, 29;
22587  
22588 ok Assemble eq => <<END, avx512=>1;
22589 A
22590 Area Size: 4096 Used: 128
22591 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22592 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
22593 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22594 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22595 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22596 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22597 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
22598 END
22599  
22600 my $a = CreateArea;
22601  
22602 K(loop => 3)->for(sub
22603 {my ($i, $start, $next, $end) = @_;
22604 $i->outNL;
22605 my $m1 = $a->allocZmmBlock;
22606 my $m2 = $a->allocZmmBlock;
22607  
22608 K(K => Rd(1..16))->loadZmm(31);
22609 K(K => Rd(17..32))->loadZmm(30);
22610 PrintOutRegisterInHex 31, 30;
22611  
22612 $a->putZmmBlock($m1, 31);
22613 $a->putZmmBlock($m2, 30);
22614 $a->dump("A");
22615  
22616 $a->getZmmBlock($m1, 30);
22617 $a->getZmmBlock($m2, 31);
22618 PrintOutRegisterInHex 31, 30;
22619  
22620 $a->clearZmmBlock($m1);
22621 $a->freeZmmBlock($m1);
22622 $a->dump("B");
22623  
22624 $a->freeZmmBlock($m2);
22625 $a->dump("C");
22626 });
22627  
22628 ok Assemble eq => <<END, avx512=>1;
22629 index: .... .... .... ...0
22630 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22631 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22632 A
22633 Area Size: 4096 Used: 192
22634 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22635 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
22636 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22637 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22638 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22639 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22640 B
22641 Area Size: 4096 Used: 192
22642 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22643 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22644 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22645 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22646 C
22647 Area Size: 4096 Used: 192
22648 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22649 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22650 .... .... .... ..80 | 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22651 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22652 index: .... .... .... ...1
22653 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22654 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22655 A
22656 Area Size: 4096 Used: 192
22657 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22658 .... .... .... ..40 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22659 .... .... .... ..80 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
22660 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22661 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22662 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22663 B
22664 Area Size: 4096 Used: 192
22665 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22666 .... .... .... ..40 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22667 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22668 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22669 C
22670 Area Size: 4096 Used: 192
22671 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22672 .... .... .... ..40 | 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22673 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22674 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22675 index: .... .... .... ...2
22676 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22677 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22678 A
22679 Area Size: 4096 Used: 192
22680 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22681 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
22682 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22683 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22684 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22685 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22686 B
22687 Area Size: 4096 Used: 192
22688 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22689 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22690 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22691 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22692 C
22693 Area Size: 4096 Used: 192
22694 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22695 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22696 .... .... .... ..80 | 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22697 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22698 END
22699  
22700  
22701 =head3 Nasm::X86::Area::freeZmmBlock($area, $offset)
22702  
22703 Free a block in an area by placing it on the free chain.
22704  
22705 Parameter Description
22706 1 $area Area descriptor
22707 2 $offset Offset of zmm block to be freed
22708  
22709 B<Example:>
22710  
22711  
22712 my $a = CreateArea;
22713  
22714 my $m = $a->allocZmmBlock;
22715 K(K => Rd(1..16))->loadZmm(31);
22716  
22717 $a->putZmmBlock ($m, 31);
22718 $a->dump("A");
22719  
22720 $a->getZmmBlock ($m, 30);
22721 $a->clearZmmBlock($m);
22722 $a->getZmmBlock ($m, 29);
22723  
22724 $a->clearZmmBlock($m);
22725 PrintOutRegisterInHex 31, 30, 29;
22726  
22727 ok Assemble eq => <<END, avx512=>1;
22728 A
22729 Area Size: 4096 Used: 128
22730 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22731 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
22732 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22733 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22734 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22735 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22736 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
22737 END
22738  
22739 my $a = CreateArea;
22740  
22741 K(loop => 3)->for(sub
22742 {my ($i, $start, $next, $end) = @_;
22743 $i->outNL;
22744 my $m1 = $a->allocZmmBlock;
22745 my $m2 = $a->allocZmmBlock;
22746  
22747 K(K => Rd(1..16))->loadZmm(31);
22748 K(K => Rd(17..32))->loadZmm(30);
22749 PrintOutRegisterInHex 31, 30;
22750  
22751 $a->putZmmBlock($m1, 31);
22752 $a->putZmmBlock($m2, 30);
22753 $a->dump("A");
22754  
22755 $a->getZmmBlock($m1, 30);
22756 $a->getZmmBlock($m2, 31);
22757 PrintOutRegisterInHex 31, 30;
22758  
22759 $a->clearZmmBlock($m1);
22760 $a->freeZmmBlock($m1);
22761 $a->dump("B");
22762  
22763 $a->freeZmmBlock($m2);
22764 $a->dump("C");
22765 });
22766  
22767 ok Assemble eq => <<END, avx512=>1;
22768 index: .... .... .... ...0
22769 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22770 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22771 A
22772 Area Size: 4096 Used: 192
22773 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22774 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
22775 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22776 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22777 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22778 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22779 B
22780 Area Size: 4096 Used: 192
22781 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22782 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22783 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22784 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22785 C
22786 Area Size: 4096 Used: 192
22787 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22788 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22789 .... .... .... ..80 | 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22790 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22791 index: .... .... .... ...1
22792 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22793 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22794 A
22795 Area Size: 4096 Used: 192
22796 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22797 .... .... .... ..40 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22798 .... .... .... ..80 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
22799 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22800 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22801 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22802 B
22803 Area Size: 4096 Used: 192
22804 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22805 .... .... .... ..40 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22806 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22807 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22808 C
22809 Area Size: 4096 Used: 192
22810 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22811 .... .... .... ..40 | 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22812 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22813 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22814 index: .... .... .... ...2
22815 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22816 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22817 A
22818 Area Size: 4096 Used: 192
22819 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22820 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
22821 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22822 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22823 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22824 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22825 B
22826 Area Size: 4096 Used: 192
22827 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22828 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22829 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22830 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22831 C
22832 Area Size: 4096 Used: 192
22833 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22834 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22835 .... .... .... ..80 | 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22836 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22837 END
22838  
22839  
22840 =head3 Nasm::X86::Area::freeChainSpace($area)
22841  
22842 Count the number of blocks available on the free chain.
22843  
22844 Parameter Description
22845 1 $area Area descriptor
22846  
22847 B<Example:>
22848  
22849  
22850 my $a = CreateArea;
22851 my $t = $a->CreateTree;
22852 my $N = K loop => 16;
22853  
22854 $N->for(sub {my ($i) = @_; $t->push($i+1)});
22855 $t->size->out("t: ", " ");
22856 $a->used->out("u: ", " ");
22857 $a->freeChainSpace->out("f: ", " ");
22858 $a->size->outNL;
22859 $t->clear;
22860 $t->size->out("t: ", " ");
22861 $a->used->out("u: ", " ");
22862 $a->freeChainSpace->out("f: ", " ");
22863 $a->size->outNL;
22864  
22865 $N->for(sub {my ($i) = @_; $t->push($i+1)});
22866 $t->size->out("t: ", " ");
22867 $a->used->out("u: ", " ");
22868 $a->freeChainSpace->out("f: ", " ");
22869 $a->size->outNL;
22870 $t->clear;
22871 $t->size->out("t: ", " ");
22872 $a->used->out("u: ", " ");
22873 $a->freeChainSpace->out("f: ", " ");
22874 $a->size->outNL;
22875  
22876 $N->for(sub {my ($i) = @_; $t->push($i+1)});
22877 $t->free;
22878 $a->used->out("Clear tree: u: ");
22879 $a->freeChainSpace->out(" f: ", " ");
22880 $a->size->outNL;
22881  
22882 $a->clear;
22883 $a->used->out("Clear area: u: ");
22884 $a->freeChainSpace->out(" f: ", " ");
22885 $a->size->outNL;
22886  
22887 ok Assemble eq => <<END, label=>'t5';
22888 t: .... .... .... ..10 u: .... .... .... .280 f: .... .... .... ...0 size of area: .... .... .... 10..
22889 t: .... .... .... ...0 u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
22890 t: .... .... .... ..10 u: .... .... .... .280 f: .... .... .... ...0 size of area: .... .... .... 10..
22891 t: .... .... .... ...0 u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
22892 Clear tree: u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
22893 Clear area: u: .... .... .... ...0 f: .... .... .... ...0 size of area: .... .... .... 10..
22894 END
22895  
22896  
22897 =head3 Nasm::X86::Area::getZmmBlock($area, $block, $zmm)
22898  
22899 Get the block with the specified offset in the specified string and return it in the numbered zmm.
22900  
22901 Parameter Description
22902 1 $area Area descriptor
22903 2 $block Offset of the block as a variable or register
22904 3 $zmm Number of zmm register to contain block
22905  
22906 B<Example:>
22907  
22908  
22909 my $a = CreateArea;
22910  
22911 my $m = $a->allocZmmBlock;
22912 K(K => Rd(1..16))->loadZmm(31);
22913  
22914 $a->putZmmBlock ($m, 31);
22915 $a->dump("A");
22916  
22917 $a->getZmmBlock ($m, 30);
22918 $a->clearZmmBlock($m);
22919 $a->getZmmBlock ($m, 29);
22920  
22921 $a->clearZmmBlock($m);
22922 PrintOutRegisterInHex 31, 30, 29;
22923  
22924 ok Assemble eq => <<END, avx512=>1;
22925 A
22926 Area Size: 4096 Used: 128
22927 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22928 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
22929 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22930 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22931 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22932 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22933 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
22934 END
22935  
22936 my $a = CreateArea;
22937  
22938 K(loop => 3)->for(sub
22939 {my ($i, $start, $next, $end) = @_;
22940 $i->outNL;
22941 my $m1 = $a->allocZmmBlock;
22942 my $m2 = $a->allocZmmBlock;
22943  
22944 K(K => Rd(1..16))->loadZmm(31);
22945 K(K => Rd(17..32))->loadZmm(30);
22946 PrintOutRegisterInHex 31, 30;
22947  
22948 $a->putZmmBlock($m1, 31);
22949 $a->putZmmBlock($m2, 30);
22950 $a->dump("A");
22951  
22952 $a->getZmmBlock($m1, 30);
22953 $a->getZmmBlock($m2, 31);
22954 PrintOutRegisterInHex 31, 30;
22955  
22956 $a->clearZmmBlock($m1);
22957 $a->freeZmmBlock($m1);
22958 $a->dump("B");
22959  
22960 $a->freeZmmBlock($m2);
22961 $a->dump("C");
22962 });
22963  
22964 ok Assemble eq => <<END, avx512=>1;
22965 index: .... .... .... ...0
22966 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22967 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22968 A
22969 Area Size: 4096 Used: 192
22970 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22971 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
22972 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22973 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22974 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22975 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22976 B
22977 Area Size: 4096 Used: 192
22978 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22979 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22980 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22981 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22982 C
22983 Area Size: 4096 Used: 192
22984 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22985 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22986 .... .... .... ..80 | 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22987 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22988 index: .... .... .... ...1
22989 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22990 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22991 A
22992 Area Size: 4096 Used: 192
22993 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22994 .... .... .... ..40 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
22995 .... .... .... ..80 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
22996 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
22997 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
22998 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
22999 B
23000 Area Size: 4096 Used: 192
23001 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23002 .... .... .... ..40 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23003 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23004 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23005 C
23006 Area Size: 4096 Used: 192
23007 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23008 .... .... .... ..40 | 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23009 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23010 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23011 index: .... .... .... ...2
23012 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23013 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23014 A
23015 Area Size: 4096 Used: 192
23016 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23017 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
23018 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23019 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23020 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23021 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23022 B
23023 Area Size: 4096 Used: 192
23024 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23025 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23026 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23027 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23028 C
23029 Area Size: 4096 Used: 192
23030 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23031 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23032 .... .... .... ..80 | 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23033 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23034 END
23035  
23036  
23037 =head3 Nasm::X86::Area::putZmmBlock($area, $block, $zmm)
23038  
23039 Write the numbered zmm to the block at the specified offset in the specified area.
23040  
23041 Parameter Description
23042 1 $area Area descriptor
23043 2 $block Offset of the block as a variable
23044 3 $zmm Number of zmm register to contain block
23045  
23046 B<Example:>
23047  
23048  
23049 my $a = CreateArea;
23050  
23051 my $m = $a->allocZmmBlock;
23052 K(K => Rd(1..16))->loadZmm(31);
23053  
23054 $a->putZmmBlock ($m, 31);
23055 $a->dump("A");
23056  
23057 $a->getZmmBlock ($m, 30);
23058 $a->clearZmmBlock($m);
23059 $a->getZmmBlock ($m, 29);
23060  
23061 $a->clearZmmBlock($m);
23062 PrintOutRegisterInHex 31, 30, 29;
23063  
23064 ok Assemble eq => <<END, avx512=>1;
23065 A
23066 Area Size: 4096 Used: 128
23067 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23068 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
23069 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23070 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23071 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23072 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23073 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
23074 END
23075  
23076 my $a = CreateArea;
23077  
23078 K(loop => 3)->for(sub
23079 {my ($i, $start, $next, $end) = @_;
23080 $i->outNL;
23081 my $m1 = $a->allocZmmBlock;
23082 my $m2 = $a->allocZmmBlock;
23083  
23084 K(K => Rd(1..16))->loadZmm(31);
23085 K(K => Rd(17..32))->loadZmm(30);
23086 PrintOutRegisterInHex 31, 30;
23087  
23088 $a->putZmmBlock($m1, 31);
23089 $a->putZmmBlock($m2, 30);
23090 $a->dump("A");
23091  
23092 $a->getZmmBlock($m1, 30);
23093 $a->getZmmBlock($m2, 31);
23094 PrintOutRegisterInHex 31, 30;
23095  
23096 $a->clearZmmBlock($m1);
23097 $a->freeZmmBlock($m1);
23098 $a->dump("B");
23099  
23100 $a->freeZmmBlock($m2);
23101 $a->dump("C");
23102 });
23103  
23104 ok Assemble eq => <<END, avx512=>1;
23105 index: .... .... .... ...0
23106 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23107 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23108 A
23109 Area Size: 4096 Used: 192
23110 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23111 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
23112 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23113 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23114 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23115 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23116 B
23117 Area Size: 4096 Used: 192
23118 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23119 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23120 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23121 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23122 C
23123 Area Size: 4096 Used: 192
23124 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23125 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23126 .... .... .... ..80 | 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23127 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23128 index: .... .... .... ...1
23129 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23130 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23131 A
23132 Area Size: 4096 Used: 192
23133 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23134 .... .... .... ..40 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23135 .... .... .... ..80 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
23136 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23137 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23138 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23139 B
23140 Area Size: 4096 Used: 192
23141 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23142 .... .... .... ..40 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23143 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23144 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23145 C
23146 Area Size: 4096 Used: 192
23147 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23148 .... .... .... ..40 | 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23149 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23150 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23151 index: .... .... .... ...2
23152 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23153 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23154 A
23155 Area Size: 4096 Used: 192
23156 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23157 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
23158 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23159 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23160 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23161 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23162 B
23163 Area Size: 4096 Used: 192
23164 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23165 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23166 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23167 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23168 C
23169 Area Size: 4096 Used: 192
23170 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23171 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23172 .... .... .... ..80 | 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23173 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23174 END
23175  
23176  
23177 =head3 Nasm::X86::Area::clearZmmBlock($area, $offset)
23178  
23179 Clear the zmm block at the specified offset in the area.
23180  
23181 Parameter Description
23182 1 $area Area descriptor
23183 2 $offset Offset of the block as a variable
23184  
23185 B<Example:>
23186  
23187  
23188 my $a = CreateArea;
23189  
23190 my $m = $a->allocZmmBlock;
23191 K(K => Rd(1..16))->loadZmm(31);
23192  
23193 $a->putZmmBlock ($m, 31);
23194 $a->dump("A");
23195  
23196 $a->getZmmBlock ($m, 30);
23197 $a->clearZmmBlock($m);
23198 $a->getZmmBlock ($m, 29);
23199  
23200 $a->clearZmmBlock($m);
23201 PrintOutRegisterInHex 31, 30, 29;
23202  
23203 ok Assemble eq => <<END, avx512=>1;
23204 A
23205 Area Size: 4096 Used: 128
23206 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23207 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
23208 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23209 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23210 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23211 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23212 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
23213 END
23214  
23215  
23216 =head2 Yggdrasil
23217  
23218 The world tree from which we can address so many other things
23219  
23220 =head3 Nasm::X86::Area::yggdrasil($area)
23221  
23222 Return a tree descriptor to the Yggdrasil world tree for an area creating the world tree Yggdrasil if it has not already been created.
23223  
23224 Parameter Description
23225 1 $area Area descriptor
23226  
23227 B<Example:>
23228  
23229  
23230 my $A = CreateArea;
23231 my $t = $A->checkYggdrasilCreated;
23232 $t->found->outNL;
23233 my $y = $A->yggdrasil;
23234 my $T = $A->checkYggdrasilCreated;
23235 $T->found->outNL;
23236 ok Assemble debug => 0, eq => <<END, avx512=>1;
23237 found : .... .... .... ...0
23238 found : .... .... .... ...1
23239 END
23240  
23241  
23242 =head2 Areas as Strings
23243  
23244 Use the memory supplied by the area as a string - however, in general, this is too slow unless coupled with another slow operation such as executing a command, mapping a file or writing to a file.
23245  
23246 =head3 Nasm::X86::Area::appendMemory($area, $address, $size)
23247  
23248 Append the variable addressed content in memory of variable size to the specified area and return its offset in that area. Pre-pack data as much as possible before using this routine to optimize processing.
23249  
23250 Parameter Description
23251 1 $area Area descriptor
23252 2 $address Variable address of content
23253 3 $size Variable length of content
23254  
23255 B<Example:>
23256  
23257  
23258 my $a = CreateArea;
23259 $a->appendMemory(constantString("aaaa")); # 82 48
23260 $a->dump("AA");
23261  
23262 ok Assemble eq => <<END, clocks=>12_391;
23263 AA
23264 Area Size: 4096 Used: 68
23265 .... .... .... ...0 | __10 ____ ____ ____ 44__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23266 .... .... .... ..40 | 6161 6161 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23267 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23268 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23269 END
23270  
23271  
23272 =head3 Nasm::X86::Area::appendZmm($area, $zmm)
23273  
23274 Append the contents of the specified zmm to the specified area and returns its offset in that area as a variable,
23275  
23276 Parameter Description
23277 1 $area Area descriptor
23278 2 $zmm Zmm number
23279  
23280 B<Example:>
23281  
23282  
23283 if (1)
23284 {LoadZmm 0, 61..61+63;
23285  
23286 my $a = CreateArea;
23287 $a->appendZmm(0);
23288 $a->printOut(0x44, 2);
23289 $a->dump("AA");
23290 $a->write(my $f = "aaa.txt");
23291  
23292 my $A = ReadArea $f;
23293 $A->dump("BB");
23294 ok Assemble eq => <<END;
23295 AB
23296 AA
23297 Area Size: 4096 Used: 128
23298 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23299 .... .... .... ..40 | 3D3E 3F40 4142 4344 4546 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 5758 595A 5B5C 5D5E 5F60 6162 6364 6566 6768 696A 6B6C 6D6E 6F70 7172 7374 7576 7778 797A 7B7C
23300 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23301 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23302 BB
23303 Area Size: 4096 Used: 128
23304 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23305 .... .... .... ..40 | 3D3E 3F40 4142 4344 4546 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 5758 595A 5B5C 5D5E 5F60 6162 6364 6566 6768 696A 6B6C 6D6E 6F70 7172 7374 7576 7778 797A 7B7C
23306 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23307 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23308 END
23309 }
23310  
23311  
23312 =head3 Nasm::X86::Area::appendVar($area, $var)
23313  
23314 Append the contents of a variable to the specified area
23315  
23316 Parameter Description
23317 1 $area Area descriptor
23318 2 $var Variable
23319  
23320 B<Example:>
23321  
23322  
23323 if (1) # Place parser tables into an area
23324 {my $a = CreateArea;
23325 my ($alphabetN, $alphabetA) = Nasm::X86::Unisyn::Lex::AlphabetsArray;
23326 my ($transitionsN, $transitionsA) = Nasm::X86::Unisyn::Lex::PermissibleTransitionsArray;
23327  
23328 $a->appendVar(V address => "[$transitionsN]");
23329 $a->appendVar(V address => "[$alphabetN]"); # Save sizes at start if area where they can be easily found
23330  
23331 $a->appendMemory(V(address => $transitionsA), V size => "[$transitionsN]"); # Save transitions
23332 $a->appendMemory(V(address => $alphabetA), V size => "[$alphabetN]"); # Save alphabets classification
23333  
23334 $a->write("z123.txt"); # Save the area to the named file
23335 ok Assemble eq => <<END;
23336 END
23337 }
23338  
23339  
23340 =head3 Nasm::X86::Area::q($area, $string)
23341  
23342 Append a constant string to the area.
23343  
23344 Parameter Description
23345 1 $area Area descriptor
23346 2 $string String
23347  
23348 B<Example:>
23349  
23350  
23351 my $a = CreateArea;
23352 $a->q('aa');
23353 $a->outNL;
23354 $a->ql('bb');
23355 $a->out;
23356 ok Assemble eq => <<END, avx512=>0;
23357 aa
23358 aabb
23359 END
23360  
23361  
23362 =head3 Nasm::X86::Area::ql($area, $const)
23363  
23364 Append a constant quoted string containing new line characters to the specified area.
23365  
23366 Parameter Description
23367 1 $area Area
23368 2 $const Constant
23369  
23370 B<Example:>
23371  
23372  
23373 my $a = CreateArea;
23374 $a->q('aa');
23375 $a->outNL;
23376 $a->ql('bb');
23377 $a->out;
23378 ok Assemble eq => <<END, avx512=>0;
23379 aa
23380 aabb
23381 END
23382  
23383  
23384 =head3 Nasm::X86::Area::char($area, $char)
23385  
23386 Append a constant character expressed as a decimal number to the specified area.
23387  
23388 Parameter Description
23389 1 $area Area descriptor
23390 2 $char Number of character to be appended
23391  
23392 B<Example:>
23393  
23394  
23395 if (1)
23396 {my $a = CreateArea;
23397 $a->char('a');
23398 $a->nl;
23399 $a->dump("AA");
23400 ok Assemble eq => <<END;
23401 AA
23402 Area Size: 4096 Used: 66
23403 .... .... .... ...0 | __10 ____ ____ ____ 42__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23404 .... .... .... ..40 | 61.A ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23405 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23406 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23407 END
23408 }
23409  
23410 if (1)
23411 {my $a = CreateArea;
23412 $a->char('a');
23413 $a->nl;
23414 $a->dump("AA");
23415 ok Assemble eq => <<END;
23416 AA
23417 Area Size: 4096 Used: 66
23418 .... .... .... ...0 | __10 ____ ____ ____ 42__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23419 .... .... .... ..40 | 61.A ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23420 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23421 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23422 END
23423 }
23424  
23425  
23426 =head3 Nasm::X86::Area::nl($area)
23427  
23428 Append a new line to the area addressed by rax.
23429  
23430 Parameter Description
23431 1 $area Area descriptor
23432  
23433 B<Example:>
23434  
23435  
23436 if (1)
23437 {my $a = CreateArea;
23438 $a->char('a');
23439 $a->nl;
23440 $a->dump("AA");
23441 ok Assemble eq => <<END;
23442 AA
23443 Area Size: 4096 Used: 66
23444 .... .... .... ...0 | __10 ____ ____ ____ 42__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23445 .... .... .... ..40 | 61.A ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23446 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23447 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23448 END
23449 }
23450  
23451 if (1)
23452 {my $a = CreateArea;
23453 $a->char('a');
23454 $a->nl;
23455 $a->dump("AA");
23456 ok Assemble eq => <<END;
23457 AA
23458 Area Size: 4096 Used: 66
23459 .... .... .... ...0 | __10 ____ ____ ____ 42__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23460 .... .... .... ..40 | 61.A ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23461 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23462 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23463 END
23464 }
23465  
23466  
23467 =head3 Nasm::X86::Area::append($target, $source)
23468  
23469 Append one area to another.
23470  
23471 Parameter Description
23472 1 $target Target area descriptor
23473 2 $source Source area descriptor
23474  
23475 B<Example:>
23476  
23477  
23478 my $a = CreateArea;
23479 $a->q('ab');
23480 my $b = CreateArea;
23481 $b->append($a);
23482 $b->append($a);
23483 $a->append($b);
23484 $b->append($a);
23485 $a->append($b);
23486 $b->append($a);
23487 $b->append($a);
23488 $b->append($a);
23489 $b->append($a);
23490  
23491  
23492 $a->out; PrintOutNL;
23493 $b->outNL;
23494 my $sa = $a->used; $sa->outNL;
23495 my $sb = $b->used; $sb->outNL;
23496 $a->clear;
23497 my $sA = $a->used; $sA->outNL;
23498 my $sB = $b->used; $sB->outNL;
23499  
23500 ok Assemble eq => <<END, avx512=>0;
23501 abababababababab
23502 ababababababababababababababababababababababababababababababababababababab
23503 area used up: .... .... .... ..10
23504 area used up: .... .... .... ..4A
23505 area used up: .... .... .... ...0
23506 area used up: .... .... .... ..4A
23507 END
23508  
23509  
23510 =head3 Nasm::X86::Area::clear($area)
23511  
23512 Clear an area but keep it at the same size.
23513  
23514 Parameter Description
23515 1 $area Area descriptor
23516  
23517 B<Example:>
23518  
23519  
23520 my $a = CreateArea;
23521 $a->q('ab');
23522 my $b = CreateArea;
23523 $b->append($a);
23524 $b->append($a);
23525 $a->append($b);
23526 $b->append($a);
23527 $a->append($b);
23528 $b->append($a);
23529 $b->append($a);
23530 $b->append($a);
23531 $b->append($a);
23532  
23533  
23534 $a->out; PrintOutNL;
23535 $b->outNL;
23536 my $sa = $a->used; $sa->outNL;
23537 my $sb = $b->used; $sb->outNL;
23538 $a->clear;
23539 my $sA = $a->used; $sA->outNL;
23540 my $sB = $b->used; $sB->outNL;
23541  
23542 ok Assemble eq => <<END, avx512=>0;
23543 abababababababab
23544 ababababababababababababababababababababababababababababababababababababab
23545 area used up: .... .... .... ..10
23546 area used up: .... .... .... ..4A
23547 area used up: .... .... .... ...0
23548 area used up: .... .... .... ..4A
23549 END
23550  
23551 my $a = CreateArea;
23552  
23553 $a->q("a" x 255);
23554 $a->used->outNL;
23555 $a->size->outNL;
23556 $a->dump('A');
23557 $a->clear;
23558 $a->used->outNL;
23559 $a->size->outNL;
23560 $a->dump('B');
23561  
23562 $a->q("a" x 4095);
23563 $a->used->outNL;
23564 $a->size->outNL;
23565 $a->dump('C');
23566 $a->clear;
23567 $a->used->outNL;
23568 $a->size->outNL;
23569 $a->dump('D');
23570  
23571 $a->free;
23572  
23573 ok Assemble(debug => 0, eq => <<END, avx512=>1);
23574 area used up: .... .... .... ..FF
23575 size of area: .... .... .... 10..
23576 A
23577 Area Size: 4096 Used: 319
23578 .... .... .... ...0 | __10 ____ ____ ____ 3F.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23579 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23580 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23581 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23582 area used up: .... .... .... ...0
23583 size of area: .... .... .... 10..
23584 B
23585 Area Size: 4096 Used: 64
23586 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23587 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23588 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23589 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23590 area used up: .... .... .... .FFF
23591 size of area: .... .... .... 20..
23592 C
23593 Area Size: 8192 Used: 4159
23594 .... .... .... ...0 | __20 ____ ____ ____ 3F10 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23595 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23596 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23597 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23598 area used up: .... .... .... ...0
23599 size of area: .... .... .... 20..
23600 D
23601 Area Size: 8192 Used: 64
23602 .... .... .... ...0 | __20 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23603 .... .... .... ..40 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23604 .... .... .... ..80 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23605 .... .... .... ..C0 | 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161 6161
23606 END
23607  
23608 my $a = CreateArea;
23609 my $t = $a->CreateTree;
23610 my $N = K loop => 16;
23611  
23612 $N->for(sub {my ($i) = @_; $t->push($i+1)});
23613 $t->size->out("t: ", " ");
23614 $a->used->out("u: ", " ");
23615 $a->freeChainSpace->out("f: ", " ");
23616 $a->size->outNL;
23617 $t->clear;
23618 $t->size->out("t: ", " ");
23619 $a->used->out("u: ", " ");
23620 $a->freeChainSpace->out("f: ", " ");
23621 $a->size->outNL;
23622  
23623 $N->for(sub {my ($i) = @_; $t->push($i+1)});
23624 $t->size->out("t: ", " ");
23625 $a->used->out("u: ", " ");
23626 $a->freeChainSpace->out("f: ", " ");
23627 $a->size->outNL;
23628 $t->clear;
23629 $t->size->out("t: ", " ");
23630 $a->used->out("u: ", " ");
23631 $a->freeChainSpace->out("f: ", " ");
23632 $a->size->outNL;
23633  
23634 $N->for(sub {my ($i) = @_; $t->push($i+1)});
23635 $t->free;
23636 $a->used->out("Clear tree: u: ");
23637 $a->freeChainSpace->out(" f: ", " ");
23638 $a->size->outNL;
23639  
23640 $a->clear;
23641 $a->used->out("Clear area: u: ");
23642 $a->freeChainSpace->out(" f: ", " ");
23643 $a->size->outNL;
23644  
23645 ok Assemble eq => <<END, label=>'t5';
23646 t: .... .... .... ..10 u: .... .... .... .280 f: .... .... .... ...0 size of area: .... .... .... 10..
23647 t: .... .... .... ...0 u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
23648 t: .... .... .... ..10 u: .... .... .... .280 f: .... .... .... ...0 size of area: .... .... .... 10..
23649 t: .... .... .... ...0 u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
23650 Clear tree: u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
23651 Clear area: u: .... .... .... ...0 f: .... .... .... ...0 size of area: .... .... .... 10..
23652 END
23653  
23654  
23655 =head3 Nasm::X86::Area::read($area, $file)
23656  
23657 Read a file specified by a variable addressed zero terminated string and append its content to the specified area.
23658  
23659 Parameter Description
23660 1 $area Area descriptor
23661 2 $file Variable addressing file name
23662  
23663 B<Example:>
23664  
23665  
23666 my $a = CreateArea;
23667 my $f = owf q(zzzArea.txt), "AA
23668 ";
23669 $a->read(V file => Rs $f);
23670 $a->dump("AA");
23671  
23672 ok Assemble(debug => 0, eq => <<END, avx512=>1);
23673 AA
23674 Area Size: 4096 Used: 67
23675 .... .... .... ...0 | __10 ____ ____ ____ 43__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23676 .... .... .... ..40 | 4141 .A__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23677 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23678 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23679 END
23680  
23681  
23682 =head3 Nasm::X86::Area::write($area, $file)
23683  
23684 Write the content of the specified area to a file specified by a zero terminated string.
23685  
23686 Parameter Description
23687 1 $area Area descriptor
23688 2 $file Variable addressing zero terminated file name
23689  
23690 B<Example:>
23691  
23692  
23693 if (1)
23694 {LoadZmm 0, 61..61+63;
23695  
23696 my $a = CreateArea;
23697 $a->appendZmm(0);
23698 $a->printOut(0x44, 2);
23699 $a->dump("AA");
23700 $a->write(my $f = "aaa.txt");
23701  
23702 my $A = ReadArea $f;
23703 $A->dump("BB");
23704 ok Assemble eq => <<END;
23705 AB
23706 AA
23707 Area Size: 4096 Used: 128
23708 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23709 .... .... .... ..40 | 3D3E 3F40 4142 4344 4546 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 5758 595A 5B5C 5D5E 5F60 6162 6364 6566 6768 696A 6B6C 6D6E 6F70 7172 7374 7576 7778 797A 7B7C
23710 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23711 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23712 BB
23713 Area Size: 4096 Used: 128
23714 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23715 .... .... .... ..40 | 3D3E 3F40 4142 4344 4546 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 5758 595A 5B5C 5D5E 5F60 6162 6364 6566 6768 696A 6B6C 6D6E 6F70 7172 7374 7576 7778 797A 7B7C
23716 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23717 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23718 END
23719 }
23720  
23721  
23722 =head3 Nasm::X86::Area::out($area)
23723  
23724 Print the specified area on sysout.
23725  
23726 Parameter Description
23727 1 $area Area descriptor
23728  
23729 B<Example:>
23730  
23731  
23732 my $a = CreateArea;
23733 $a->q('aa');
23734 $a->outNL;
23735 $a->ql('bb');
23736 $a->out;
23737 ok Assemble eq => <<END, avx512=>0;
23738 aa
23739 aabb
23740 END
23741  
23742 my $a = CreateArea;
23743 $a->q('ab');
23744 my $b = CreateArea;
23745 $b->append($a);
23746 $b->append($a);
23747 $a->append($b);
23748 $b->append($a);
23749 $a->append($b);
23750 $b->append($a);
23751 $b->append($a);
23752 $b->append($a);
23753 $b->append($a);
23754  
23755  
23756 $a->out; PrintOutNL;
23757 $b->outNL;
23758 my $sa = $a->used; $sa->outNL;
23759 my $sb = $b->used; $sb->outNL;
23760 $a->clear;
23761 my $sA = $a->used; $sA->outNL;
23762 my $sB = $b->used; $sB->outNL;
23763  
23764 ok Assemble eq => <<END, avx512=>0;
23765 abababababababab
23766 ababababababababababababababababababababababababababababababababababababab
23767 area used up: .... .... .... ..10
23768 area used up: .... .... .... ..4A
23769 area used up: .... .... .... ...0
23770 area used up: .... .... .... ..4A
23771 END
23772  
23773  
23774 =head3 Nasm::X86::Area::outNL($area)
23775  
23776 Print the specified area on sysout followed by a new line.
23777  
23778 Parameter Description
23779 1 $area Area descriptor
23780  
23781 B<Example:>
23782  
23783  
23784 my $a = CreateArea;
23785 $a->q('aa');
23786 $a->outNL;
23787 $a->ql('bb');
23788 $a->out;
23789 ok Assemble eq => <<END, avx512=>0;
23790 aa
23791 aabb
23792 END
23793  
23794 my $a = CreateArea;
23795 $a->q('ab');
23796 my $b = CreateArea;
23797 $b->append($a);
23798 $b->append($a);
23799 $a->append($b);
23800 $b->append($a);
23801 $a->append($b);
23802 $b->append($a);
23803 $b->append($a);
23804 $b->append($a);
23805 $b->append($a);
23806  
23807  
23808 $a->out; PrintOutNL;
23809 $b->outNL;
23810 my $sa = $a->used; $sa->outNL;
23811 my $sb = $b->used; $sb->outNL;
23812 $a->clear;
23813 my $sA = $a->used; $sA->outNL;
23814 my $sB = $b->used; $sB->outNL;
23815  
23816 ok Assemble eq => <<END, avx512=>0;
23817 abababababababab
23818 ababababababababababababababababababababababababababababababababababababab
23819 area used up: .... .... .... ..10
23820 area used up: .... .... .... ..4A
23821 area used up: .... .... .... ...0
23822 area used up: .... .... .... ..4A
23823 END
23824  
23825  
23826 =head3 Nasm::X86::Area::printOut($area, $Offset, $Length)
23827  
23828 Print part of the specified area on sysout.
23829  
23830 Parameter Description
23831 1 $area Area descriptor
23832 2 $Offset Offset
23833 3 $Length Length
23834  
23835 B<Example:>
23836  
23837  
23838 if (1)
23839 {LoadZmm 0, 61..61+63;
23840  
23841 my $a = CreateArea;
23842 $a->appendZmm(0);
23843 $a->printOut(0x44, 2);
23844 $a->dump("AA");
23845 $a->write(my $f = "aaa.txt");
23846  
23847 my $A = ReadArea $f;
23848 $A->dump("BB");
23849 ok Assemble eq => <<END;
23850 AB
23851 AA
23852 Area Size: 4096 Used: 128
23853 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23854 .... .... .... ..40 | 3D3E 3F40 4142 4344 4546 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 5758 595A 5B5C 5D5E 5F60 6162 6364 6566 6768 696A 6B6C 6D6E 6F70 7172 7374 7576 7778 797A 7B7C
23855 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23856 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23857 BB
23858 Area Size: 4096 Used: 128
23859 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23860 .... .... .... ..40 | 3D3E 3F40 4142 4344 4546 4748 494A 4B4C 4D4E 4F50 5152 5354 5556 5758 595A 5B5C 5D5E 5F60 6162 6364 6566 6768 696A 6B6C 6D6E 6F70 7172 7374 7576 7778 797A 7B7C
23861 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23862 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23863 END
23864 }
23865  
23866  
23867 =head3 Nasm::X86::Area::dump($area, $title, $depth)
23868  
23869 Dump details of an area.
23870  
23871 Parameter Description
23872 1 $area Area descriptor
23873 2 $title Title string
23874 3 $depth Optional variable number of 64 byte blocks to dump
23875  
23876 B<Example:>
23877  
23878  
23879 my $a = CreateArea;
23880  
23881 my $m = $a->allocZmmBlock;
23882 K(K => Rd(1..16))->loadZmm(31);
23883  
23884 $a->putZmmBlock ($m, 31);
23885 $a->dump("A");
23886  
23887 $a->getZmmBlock ($m, 30);
23888 $a->clearZmmBlock($m);
23889 $a->getZmmBlock ($m, 29);
23890  
23891 $a->clearZmmBlock($m);
23892 PrintOutRegisterInHex 31, 30, 29;
23893  
23894 ok Assemble eq => <<END, avx512=>1;
23895 A
23896 Area Size: 4096 Used: 128
23897 .... .... .... ...0 | __10 ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23898 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
23899 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23900 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23901 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23902 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23903 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
23904 END
23905  
23906 my $a = CreateArea;
23907  
23908 K(loop => 3)->for(sub
23909 {my ($i, $start, $next, $end) = @_;
23910 $i->outNL;
23911 my $m1 = $a->allocZmmBlock;
23912 my $m2 = $a->allocZmmBlock;
23913  
23914 K(K => Rd(1..16))->loadZmm(31);
23915 K(K => Rd(17..32))->loadZmm(30);
23916 PrintOutRegisterInHex 31, 30;
23917  
23918 $a->putZmmBlock($m1, 31);
23919 $a->putZmmBlock($m2, 30);
23920 $a->dump("A");
23921  
23922 $a->getZmmBlock($m1, 30);
23923 $a->getZmmBlock($m2, 31);
23924 PrintOutRegisterInHex 31, 30;
23925  
23926 $a->clearZmmBlock($m1);
23927 $a->freeZmmBlock($m1);
23928 $a->dump("B");
23929  
23930 $a->freeZmmBlock($m2);
23931 $a->dump("C");
23932 });
23933  
23934 ok Assemble eq => <<END, avx512=>1;
23935 index: .... .... .... ...0
23936 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23937 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23938 A
23939 Area Size: 4096 Used: 192
23940 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23941 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
23942 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23943 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23944 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23945 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23946 B
23947 Area Size: 4096 Used: 192
23948 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23949 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23950 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23951 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23952 C
23953 Area Size: 4096 Used: 192
23954 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23955 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23956 .... .... .... ..80 | 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23957 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23958 index: .... .... .... ...1
23959 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23960 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23961 A
23962 Area Size: 4096 Used: 192
23963 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23964 .... .... .... ..40 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23965 .... .... .... ..80 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
23966 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23967 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23968 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23969 B
23970 Area Size: 4096 Used: 192
23971 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23972 .... .... .... ..40 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23973 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23974 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23975 C
23976 Area Size: 4096 Used: 192
23977 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23978 .... .... .... ..40 | 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23979 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23980 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23981 index: .... .... .... ...2
23982 zmm31: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23983 zmm30: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23984 A
23985 Area Size: 4096 Used: 192
23986 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23987 .... .... .... ..40 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ .5__ ____ .6__ ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ .B__ ____ .C__ ____ .D__ ____ .E__ ____ .F__ ____ 10__ ____
23988 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23989 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23990 zmm31: .... ..20 .... ..1F .... ..1E .... ..1D - .... ..1C .... ..1B .... ..1A .... ..19 + .... ..18 .... ..17 .... ..16 .... ..15 - .... ..14 .... ..13 .... ..12 .... ..11
23991 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
23992 B
23993 Area Size: 4096 Used: 192
23994 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23995 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23996 .... .... .... ..80 | 11__ ____ 12__ ____ 13__ ____ 14__ ____ 15__ ____ 16__ ____ 17__ ____ 18__ ____ 19__ ____ 1A__ ____ 1B__ ____ 1C__ ____ 1D__ ____ 1E__ ____ 1F__ ____ 20__ ____
23997 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
23998 C
23999 Area Size: 4096 Used: 192
24000 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ 80__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24001 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24002 .... .... .... ..80 | 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24003 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24004 END
24005  
24006  
24007 =head2 Areas as Stacks
24008  
24009 Use an area as a stack. If the area is simultaneouls used for other operations confusion will ensue.
24010  
24011 =head3 Nasm::X86::Area::push($area, $var)
24012  
24013 Push the contents of a variable into an area
24014  
24015 Parameter Description
24016 1 $area Area descriptor
24017 2 $var Variable
24018  
24019 B<Example:>
24020  
24021  
24022 my $a = CreateArea(stack=>1);
24023  
24024 $a->stackVariableSize->outNL;
24025 $a->dump("AA");
24026 $a->push(K key => 0x11111111);
24027 $a->stackVariableSize->outNL;
24028 $a->dump("AA");
24029  
24030 $a->push(K key => 0x22222222); # 12
24031 $a->stackVariableSize->outNL;
24032 $a->dump("AA");
24033  
24034 PrintOutStringNL "Peek";
24035 $a->peek(1)->outNL;
24036 $a->stackVariableSize->outNL;
24037 $a->peek(2)->outNL;
24038 $a->stackVariableSize->outNL;
24039 $a->stackSize->outNL;
24040  
24041 PrintOutStringNL "stackVariable";
24042 $a->stackVariable(K key => 0)->outNL;
24043 $a->stackVariable(K key => 1)->outNL;
24044  
24045 PrintOutStringNL "Pop";
24046 my $s1 = $a->pop; # 9
24047 $s1->outNL;
24048 $a->stackVariableSize->outNL;
24049 my $s2 = $a->pop;
24050 $s2->outNL;
24051 $a->stackVariableSize->outNL;
24052 $a->dump("pop1");
24053 $a->dump("pop2");
24054  
24055 ClearRegisters zmm1, zmm2;
24056  
24057 K(key => 0x22222222)->qIntoZ(1, 16);
24058 K(key => 0x33333333)->qIntoZ(1, 32);
24059 K(key => 0x44444444)->qIntoZ(1, 48);
24060  
24061 K(key => 0x55555555)->qIntoZ(2, 16);
24062 K(key => 0x66666666)->qIntoZ(2, 32);
24063 K(key => 0x77777777)->qIntoZ(2, 48);
24064  
24065 PrintOutStringNL "Push";
24066 $a->pushZmm(1)->outNL;
24067 $a->pushZmm(2)->outNL;
24068  
24069 $a->dump("zmm 1, 2");
24070 $a->peekZmm(1, 1)->outNL;
24071 $a->peekZmm(2, 2)->outNL;
24072 PrintOutStringNL "Peek";
24073 PrintOutRegisterInHex zmm1, zmm2;
24074  
24075 $a->popZmm(3);
24076 $a->popZmm(4);
24077 PrintOutStringNL "Pop";
24078 PrintOutRegisterInHex zmm3, zmm4;
24079  
24080 ok Assemble eq => <<END, clocks=>391;
24081 size: .... .... .... ...0
24082 AA
24083 Area Size: 4096 Used: 64
24084 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24085 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24086 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24087 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24088 size: .... .... .... ...1
24089 AA
24090 Area Size: 4096 Used: 72
24091 .... .... .... ...0 | __10 ____ ____ ____ 48__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24092 .... .... .... ..40 | 1111 1111 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24093 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24094 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24095 size: .... .... .... ...2
24096 AA
24097 Area Size: 4096 Used: 80
24098 .... .... .... ...0 | __10 ____ ____ ____ 50__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24099 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24100 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24101 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24102 Peek
24103 pop: .... .... 2222 2222
24104 size: .... .... .... ...2
24105 pop: .... .... 1111 1111
24106 size: .... .... .... ...2
24107 stackSize: .... .... .... ..10
24108 stackVariable
24109 pop: .... .... 1111 1111
24110 pop: .... .... 2222 2222
24111 Pop
24112 pop: .... .... 2222 2222
24113 size: .... .... .... ...1
24114 pop: .... .... 1111 1111
24115 size: .... .... .... ...0
24116 pop1
24117 Area Size: 4096 Used: 64
24118 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24119 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24120 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24121 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24122 pop2
24123 Area Size: 4096 Used: 64
24124 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24125 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24126 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24127 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24128 Push
24129 zmmStackOffset: .... .... .... ..40
24130 zmmStackOffset: .... .... .... ..80
24131 zmm 1, 2
24132 Area Size: 4096 Used: 192
24133 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24134 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ 3333 3333 ____ ____ ____ ____ ____ ____ 4444 4444 ____ ____ ____ ____ ____ ____
24135 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ 5555 5555 ____ ____ ____ ____ ____ ____ 6666 6666 ____ ____ ____ ____ ____ ____ 7777 7777 ____ ____ ____ ____ ____ ____
24136 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24137 offset: .... .... .... ..80
24138 offset: .... .... .... ..40
24139 Peek
24140 zmm1: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24141 zmm2: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24142 Pop
24143 zmm3: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24144 zmm4: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24145 END
24146  
24147  
24148 =head3 Nasm::X86::Area::stackSize($area)
24149  
24150 Size of the stack in an area being used as a stack
24151  
24152 Parameter Description
24153 1 $area Area descriptor
24154  
24155 B<Example:>
24156  
24157  
24158 my $a = CreateArea(stack=>1);
24159  
24160 $a->stackVariableSize->outNL;
24161 $a->dump("AA");
24162 $a->push(K key => 0x11111111);
24163 $a->stackVariableSize->outNL;
24164 $a->dump("AA");
24165  
24166 $a->push(K key => 0x22222222); # 12
24167 $a->stackVariableSize->outNL;
24168 $a->dump("AA");
24169  
24170 PrintOutStringNL "Peek";
24171 $a->peek(1)->outNL;
24172 $a->stackVariableSize->outNL;
24173 $a->peek(2)->outNL;
24174 $a->stackVariableSize->outNL;
24175 $a->stackSize->outNL;
24176  
24177 PrintOutStringNL "stackVariable";
24178 $a->stackVariable(K key => 0)->outNL;
24179 $a->stackVariable(K key => 1)->outNL;
24180  
24181 PrintOutStringNL "Pop";
24182 my $s1 = $a->pop; # 9
24183 $s1->outNL;
24184 $a->stackVariableSize->outNL;
24185 my $s2 = $a->pop;
24186 $s2->outNL;
24187 $a->stackVariableSize->outNL;
24188 $a->dump("pop1");
24189 $a->dump("pop2");
24190  
24191 ClearRegisters zmm1, zmm2;
24192  
24193 K(key => 0x22222222)->qIntoZ(1, 16);
24194 K(key => 0x33333333)->qIntoZ(1, 32);
24195 K(key => 0x44444444)->qIntoZ(1, 48);
24196  
24197 K(key => 0x55555555)->qIntoZ(2, 16);
24198 K(key => 0x66666666)->qIntoZ(2, 32);
24199 K(key => 0x77777777)->qIntoZ(2, 48);
24200  
24201 PrintOutStringNL "Push";
24202 $a->pushZmm(1)->outNL;
24203 $a->pushZmm(2)->outNL;
24204  
24205 $a->dump("zmm 1, 2");
24206 $a->peekZmm(1, 1)->outNL;
24207 $a->peekZmm(2, 2)->outNL;
24208 PrintOutStringNL "Peek";
24209 PrintOutRegisterInHex zmm1, zmm2;
24210  
24211 $a->popZmm(3);
24212 $a->popZmm(4);
24213 PrintOutStringNL "Pop";
24214 PrintOutRegisterInHex zmm3, zmm4;
24215  
24216 ok Assemble eq => <<END, clocks=>391;
24217 size: .... .... .... ...0
24218 AA
24219 Area Size: 4096 Used: 64
24220 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24221 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24222 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24223 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24224 size: .... .... .... ...1
24225 AA
24226 Area Size: 4096 Used: 72
24227 .... .... .... ...0 | __10 ____ ____ ____ 48__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24228 .... .... .... ..40 | 1111 1111 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24229 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24230 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24231 size: .... .... .... ...2
24232 AA
24233 Area Size: 4096 Used: 80
24234 .... .... .... ...0 | __10 ____ ____ ____ 50__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24235 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24236 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24237 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24238 Peek
24239 pop: .... .... 2222 2222
24240 size: .... .... .... ...2
24241 pop: .... .... 1111 1111
24242 size: .... .... .... ...2
24243 stackSize: .... .... .... ..10
24244 stackVariable
24245 pop: .... .... 1111 1111
24246 pop: .... .... 2222 2222
24247 Pop
24248 pop: .... .... 2222 2222
24249 size: .... .... .... ...1
24250 pop: .... .... 1111 1111
24251 size: .... .... .... ...0
24252 pop1
24253 Area Size: 4096 Used: 64
24254 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24255 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24256 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24257 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24258 pop2
24259 Area Size: 4096 Used: 64
24260 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24261 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24262 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24263 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24264 Push
24265 zmmStackOffset: .... .... .... ..40
24266 zmmStackOffset: .... .... .... ..80
24267 zmm 1, 2
24268 Area Size: 4096 Used: 192
24269 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24270 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ 3333 3333 ____ ____ ____ ____ ____ ____ 4444 4444 ____ ____ ____ ____ ____ ____
24271 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ 5555 5555 ____ ____ ____ ____ ____ ____ 6666 6666 ____ ____ ____ ____ ____ ____ 7777 7777 ____ ____ ____ ____ ____ ____
24272 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24273 offset: .... .... .... ..80
24274 offset: .... .... .... ..40
24275 Peek
24276 zmm1: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24277 zmm2: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24278 Pop
24279 zmm3: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24280 zmm4: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24281 END
24282  
24283  
24284 =head3 Nasm::X86::Area::peek($area, $back)
24285  
24286 Peek at a variable on the stack
24287  
24288 Parameter Description
24289 1 $area Area descriptor
24290 2 $back How far back to look in the stack with the top most element being at one.
24291  
24292 B<Example:>
24293  
24294  
24295 my $a = CreateArea(stack=>1);
24296  
24297 $a->stackVariableSize->outNL;
24298 $a->dump("AA");
24299 $a->push(K key => 0x11111111);
24300 $a->stackVariableSize->outNL;
24301 $a->dump("AA");
24302  
24303 $a->push(K key => 0x22222222); # 12
24304 $a->stackVariableSize->outNL;
24305 $a->dump("AA");
24306  
24307 PrintOutStringNL "Peek";
24308 $a->peek(1)->outNL;
24309 $a->stackVariableSize->outNL;
24310 $a->peek(2)->outNL;
24311 $a->stackVariableSize->outNL;
24312 $a->stackSize->outNL;
24313  
24314 PrintOutStringNL "stackVariable";
24315 $a->stackVariable(K key => 0)->outNL;
24316 $a->stackVariable(K key => 1)->outNL;
24317  
24318 PrintOutStringNL "Pop";
24319 my $s1 = $a->pop; # 9
24320 $s1->outNL;
24321 $a->stackVariableSize->outNL;
24322 my $s2 = $a->pop;
24323 $s2->outNL;
24324 $a->stackVariableSize->outNL;
24325 $a->dump("pop1");
24326 $a->dump("pop2");
24327  
24328 ClearRegisters zmm1, zmm2;
24329  
24330 K(key => 0x22222222)->qIntoZ(1, 16);
24331 K(key => 0x33333333)->qIntoZ(1, 32);
24332 K(key => 0x44444444)->qIntoZ(1, 48);
24333  
24334 K(key => 0x55555555)->qIntoZ(2, 16);
24335 K(key => 0x66666666)->qIntoZ(2, 32);
24336 K(key => 0x77777777)->qIntoZ(2, 48);
24337  
24338 PrintOutStringNL "Push";
24339 $a->pushZmm(1)->outNL;
24340 $a->pushZmm(2)->outNL;
24341  
24342 $a->dump("zmm 1, 2");
24343 $a->peekZmm(1, 1)->outNL;
24344 $a->peekZmm(2, 2)->outNL;
24345 PrintOutStringNL "Peek";
24346 PrintOutRegisterInHex zmm1, zmm2;
24347  
24348 $a->popZmm(3);
24349 $a->popZmm(4);
24350 PrintOutStringNL "Pop";
24351 PrintOutRegisterInHex zmm3, zmm4;
24352  
24353 ok Assemble eq => <<END, clocks=>391;
24354 size: .... .... .... ...0
24355 AA
24356 Area Size: 4096 Used: 64
24357 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24358 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24359 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24360 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24361 size: .... .... .... ...1
24362 AA
24363 Area Size: 4096 Used: 72
24364 .... .... .... ...0 | __10 ____ ____ ____ 48__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24365 .... .... .... ..40 | 1111 1111 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24366 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24367 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24368 size: .... .... .... ...2
24369 AA
24370 Area Size: 4096 Used: 80
24371 .... .... .... ...0 | __10 ____ ____ ____ 50__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24372 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24373 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24374 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24375 Peek
24376 pop: .... .... 2222 2222
24377 size: .... .... .... ...2
24378 pop: .... .... 1111 1111
24379 size: .... .... .... ...2
24380 stackSize: .... .... .... ..10
24381 stackVariable
24382 pop: .... .... 1111 1111
24383 pop: .... .... 2222 2222
24384 Pop
24385 pop: .... .... 2222 2222
24386 size: .... .... .... ...1
24387 pop: .... .... 1111 1111
24388 size: .... .... .... ...0
24389 pop1
24390 Area Size: 4096 Used: 64
24391 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24392 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24393 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24394 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24395 pop2
24396 Area Size: 4096 Used: 64
24397 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24398 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24399 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24400 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24401 Push
24402 zmmStackOffset: .... .... .... ..40
24403 zmmStackOffset: .... .... .... ..80
24404 zmm 1, 2
24405 Area Size: 4096 Used: 192
24406 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24407 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ 3333 3333 ____ ____ ____ ____ ____ ____ 4444 4444 ____ ____ ____ ____ ____ ____
24408 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ 5555 5555 ____ ____ ____ ____ ____ ____ 6666 6666 ____ ____ ____ ____ ____ ____ 7777 7777 ____ ____ ____ ____ ____ ____
24409 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24410 offset: .... .... .... ..80
24411 offset: .... .... .... ..40
24412 Peek
24413 zmm1: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24414 zmm2: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24415 Pop
24416 zmm3: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24417 zmm4: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24418 END
24419  
24420  
24421 =head3 Nasm::X86::Area::stackVariable($area, $index)
24422  
24423 Peek at the variable indexed variable on the stack
24424  
24425 Parameter Description
24426 1 $area Area descriptor
24427 2 $index Index of element sought
24428  
24429 B<Example:>
24430  
24431  
24432 my $a = CreateArea(stack=>1);
24433  
24434 $a->stackVariableSize->outNL;
24435 $a->dump("AA");
24436 $a->push(K key => 0x11111111);
24437 $a->stackVariableSize->outNL;
24438 $a->dump("AA");
24439  
24440 $a->push(K key => 0x22222222); # 12
24441 $a->stackVariableSize->outNL;
24442 $a->dump("AA");
24443  
24444 PrintOutStringNL "Peek";
24445 $a->peek(1)->outNL;
24446 $a->stackVariableSize->outNL;
24447 $a->peek(2)->outNL;
24448 $a->stackVariableSize->outNL;
24449 $a->stackSize->outNL;
24450  
24451 PrintOutStringNL "stackVariable";
24452 $a->stackVariable(K key => 0)->outNL;
24453 $a->stackVariable(K key => 1)->outNL;
24454  
24455 PrintOutStringNL "Pop";
24456 my $s1 = $a->pop; # 9
24457 $s1->outNL;
24458 $a->stackVariableSize->outNL;
24459 my $s2 = $a->pop;
24460 $s2->outNL;
24461 $a->stackVariableSize->outNL;
24462 $a->dump("pop1");
24463 $a->dump("pop2");
24464  
24465 ClearRegisters zmm1, zmm2;
24466  
24467 K(key => 0x22222222)->qIntoZ(1, 16);
24468 K(key => 0x33333333)->qIntoZ(1, 32);
24469 K(key => 0x44444444)->qIntoZ(1, 48);
24470  
24471 K(key => 0x55555555)->qIntoZ(2, 16);
24472 K(key => 0x66666666)->qIntoZ(2, 32);
24473 K(key => 0x77777777)->qIntoZ(2, 48);
24474  
24475 PrintOutStringNL "Push";
24476 $a->pushZmm(1)->outNL;
24477 $a->pushZmm(2)->outNL;
24478  
24479 $a->dump("zmm 1, 2");
24480 $a->peekZmm(1, 1)->outNL;
24481 $a->peekZmm(2, 2)->outNL;
24482 PrintOutStringNL "Peek";
24483 PrintOutRegisterInHex zmm1, zmm2;
24484  
24485 $a->popZmm(3);
24486 $a->popZmm(4);
24487 PrintOutStringNL "Pop";
24488 PrintOutRegisterInHex zmm3, zmm4;
24489  
24490 ok Assemble eq => <<END, clocks=>391;
24491 size: .... .... .... ...0
24492 AA
24493 Area Size: 4096 Used: 64
24494 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24495 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24496 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24497 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24498 size: .... .... .... ...1
24499 AA
24500 Area Size: 4096 Used: 72
24501 .... .... .... ...0 | __10 ____ ____ ____ 48__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24502 .... .... .... ..40 | 1111 1111 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24503 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24504 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24505 size: .... .... .... ...2
24506 AA
24507 Area Size: 4096 Used: 80
24508 .... .... .... ...0 | __10 ____ ____ ____ 50__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24509 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24510 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24511 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24512 Peek
24513 pop: .... .... 2222 2222
24514 size: .... .... .... ...2
24515 pop: .... .... 1111 1111
24516 size: .... .... .... ...2
24517 stackSize: .... .... .... ..10
24518 stackVariable
24519 pop: .... .... 1111 1111
24520 pop: .... .... 2222 2222
24521 Pop
24522 pop: .... .... 2222 2222
24523 size: .... .... .... ...1
24524 pop: .... .... 1111 1111
24525 size: .... .... .... ...0
24526 pop1
24527 Area Size: 4096 Used: 64
24528 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24529 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24530 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24531 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24532 pop2
24533 Area Size: 4096 Used: 64
24534 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24535 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24536 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24537 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24538 Push
24539 zmmStackOffset: .... .... .... ..40
24540 zmmStackOffset: .... .... .... ..80
24541 zmm 1, 2
24542 Area Size: 4096 Used: 192
24543 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24544 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ 3333 3333 ____ ____ ____ ____ ____ ____ 4444 4444 ____ ____ ____ ____ ____ ____
24545 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ 5555 5555 ____ ____ ____ ____ ____ ____ 6666 6666 ____ ____ ____ ____ ____ ____ 7777 7777 ____ ____ ____ ____ ____ ____
24546 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24547 offset: .... .... .... ..80
24548 offset: .... .... .... ..40
24549 Peek
24550 zmm1: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24551 zmm2: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24552 Pop
24553 zmm3: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24554 zmm4: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24555 END
24556  
24557  
24558 =head3 Nasm::X86::Area::stackVariableSize($area)
24559  
24560 Size of a stack of variables in an area.
24561  
24562 Parameter Description
24563 1 $area Area descriptor
24564  
24565 B<Example:>
24566  
24567  
24568 my $a = CreateArea(stack=>1);
24569  
24570 $a->stackVariableSize->outNL;
24571 $a->dump("AA");
24572 $a->push(K key => 0x11111111);
24573 $a->stackVariableSize->outNL;
24574 $a->dump("AA");
24575  
24576 $a->push(K key => 0x22222222); # 12
24577 $a->stackVariableSize->outNL;
24578 $a->dump("AA");
24579  
24580 PrintOutStringNL "Peek";
24581 $a->peek(1)->outNL;
24582 $a->stackVariableSize->outNL;
24583 $a->peek(2)->outNL;
24584 $a->stackVariableSize->outNL;
24585 $a->stackSize->outNL;
24586  
24587 PrintOutStringNL "stackVariable";
24588 $a->stackVariable(K key => 0)->outNL;
24589 $a->stackVariable(K key => 1)->outNL;
24590  
24591 PrintOutStringNL "Pop";
24592 my $s1 = $a->pop; # 9
24593 $s1->outNL;
24594 $a->stackVariableSize->outNL;
24595 my $s2 = $a->pop;
24596 $s2->outNL;
24597 $a->stackVariableSize->outNL;
24598 $a->dump("pop1");
24599 $a->dump("pop2");
24600  
24601 ClearRegisters zmm1, zmm2;
24602  
24603 K(key => 0x22222222)->qIntoZ(1, 16);
24604 K(key => 0x33333333)->qIntoZ(1, 32);
24605 K(key => 0x44444444)->qIntoZ(1, 48);
24606  
24607 K(key => 0x55555555)->qIntoZ(2, 16);
24608 K(key => 0x66666666)->qIntoZ(2, 32);
24609 K(key => 0x77777777)->qIntoZ(2, 48);
24610  
24611 PrintOutStringNL "Push";
24612 $a->pushZmm(1)->outNL;
24613 $a->pushZmm(2)->outNL;
24614  
24615 $a->dump("zmm 1, 2");
24616 $a->peekZmm(1, 1)->outNL;
24617 $a->peekZmm(2, 2)->outNL;
24618 PrintOutStringNL "Peek";
24619 PrintOutRegisterInHex zmm1, zmm2;
24620  
24621 $a->popZmm(3);
24622 $a->popZmm(4);
24623 PrintOutStringNL "Pop";
24624 PrintOutRegisterInHex zmm3, zmm4;
24625  
24626 ok Assemble eq => <<END, clocks=>391;
24627 size: .... .... .... ...0
24628 AA
24629 Area Size: 4096 Used: 64
24630 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24631 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24632 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24633 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24634 size: .... .... .... ...1
24635 AA
24636 Area Size: 4096 Used: 72
24637 .... .... .... ...0 | __10 ____ ____ ____ 48__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24638 .... .... .... ..40 | 1111 1111 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24639 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24640 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24641 size: .... .... .... ...2
24642 AA
24643 Area Size: 4096 Used: 80
24644 .... .... .... ...0 | __10 ____ ____ ____ 50__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24645 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24646 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24647 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24648 Peek
24649 pop: .... .... 2222 2222
24650 size: .... .... .... ...2
24651 pop: .... .... 1111 1111
24652 size: .... .... .... ...2
24653 stackSize: .... .... .... ..10
24654 stackVariable
24655 pop: .... .... 1111 1111
24656 pop: .... .... 2222 2222
24657 Pop
24658 pop: .... .... 2222 2222
24659 size: .... .... .... ...1
24660 pop: .... .... 1111 1111
24661 size: .... .... .... ...0
24662 pop1
24663 Area Size: 4096 Used: 64
24664 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24665 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24666 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24667 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24668 pop2
24669 Area Size: 4096 Used: 64
24670 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24671 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24672 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24673 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24674 Push
24675 zmmStackOffset: .... .... .... ..40
24676 zmmStackOffset: .... .... .... ..80
24677 zmm 1, 2
24678 Area Size: 4096 Used: 192
24679 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24680 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ 3333 3333 ____ ____ ____ ____ ____ ____ 4444 4444 ____ ____ ____ ____ ____ ____
24681 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ 5555 5555 ____ ____ ____ ____ ____ ____ 6666 6666 ____ ____ ____ ____ ____ ____ 7777 7777 ____ ____ ____ ____ ____ ____
24682 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24683 offset: .... .... .... ..80
24684 offset: .... .... .... ..40
24685 Peek
24686 zmm1: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24687 zmm2: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24688 Pop
24689 zmm3: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24690 zmm4: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24691 END
24692  
24693  
24694 =head3 Nasm::X86::Area::pop($area)
24695  
24696 Pop a variable from the stack in an area being used as a stack
24697  
24698 Parameter Description
24699 1 $area Area descriptor
24700  
24701 B<Example:>
24702  
24703  
24704 my $a = CreateArea(stack=>1);
24705  
24706 $a->stackVariableSize->outNL;
24707 $a->dump("AA");
24708 $a->push(K key => 0x11111111);
24709 $a->stackVariableSize->outNL;
24710 $a->dump("AA");
24711  
24712 $a->push(K key => 0x22222222); # 12
24713 $a->stackVariableSize->outNL;
24714 $a->dump("AA");
24715  
24716 PrintOutStringNL "Peek";
24717 $a->peek(1)->outNL;
24718 $a->stackVariableSize->outNL;
24719 $a->peek(2)->outNL;
24720 $a->stackVariableSize->outNL;
24721 $a->stackSize->outNL;
24722  
24723 PrintOutStringNL "stackVariable";
24724 $a->stackVariable(K key => 0)->outNL;
24725 $a->stackVariable(K key => 1)->outNL;
24726  
24727 PrintOutStringNL "Pop";
24728 my $s1 = $a->pop; # 9
24729 $s1->outNL;
24730 $a->stackVariableSize->outNL;
24731 my $s2 = $a->pop;
24732 $s2->outNL;
24733 $a->stackVariableSize->outNL;
24734 $a->dump("pop1");
24735 $a->dump("pop2");
24736  
24737 ClearRegisters zmm1, zmm2;
24738  
24739 K(key => 0x22222222)->qIntoZ(1, 16);
24740 K(key => 0x33333333)->qIntoZ(1, 32);
24741 K(key => 0x44444444)->qIntoZ(1, 48);
24742  
24743 K(key => 0x55555555)->qIntoZ(2, 16);
24744 K(key => 0x66666666)->qIntoZ(2, 32);
24745 K(key => 0x77777777)->qIntoZ(2, 48);
24746  
24747 PrintOutStringNL "Push";
24748 $a->pushZmm(1)->outNL;
24749 $a->pushZmm(2)->outNL;
24750  
24751 $a->dump("zmm 1, 2");
24752 $a->peekZmm(1, 1)->outNL;
24753 $a->peekZmm(2, 2)->outNL;
24754 PrintOutStringNL "Peek";
24755 PrintOutRegisterInHex zmm1, zmm2;
24756  
24757 $a->popZmm(3);
24758 $a->popZmm(4);
24759 PrintOutStringNL "Pop";
24760 PrintOutRegisterInHex zmm3, zmm4;
24761  
24762 ok Assemble eq => <<END, clocks=>391;
24763 size: .... .... .... ...0
24764 AA
24765 Area Size: 4096 Used: 64
24766 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24767 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24768 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24769 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24770 size: .... .... .... ...1
24771 AA
24772 Area Size: 4096 Used: 72
24773 .... .... .... ...0 | __10 ____ ____ ____ 48__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24774 .... .... .... ..40 | 1111 1111 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24775 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24776 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24777 size: .... .... .... ...2
24778 AA
24779 Area Size: 4096 Used: 80
24780 .... .... .... ...0 | __10 ____ ____ ____ 50__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24781 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24782 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24783 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24784 Peek
24785 pop: .... .... 2222 2222
24786 size: .... .... .... ...2
24787 pop: .... .... 1111 1111
24788 size: .... .... .... ...2
24789 stackSize: .... .... .... ..10
24790 stackVariable
24791 pop: .... .... 1111 1111
24792 pop: .... .... 2222 2222
24793 Pop
24794 pop: .... .... 2222 2222
24795 size: .... .... .... ...1
24796 pop: .... .... 1111 1111
24797 size: .... .... .... ...0
24798 pop1
24799 Area Size: 4096 Used: 64
24800 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24801 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24802 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24803 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24804 pop2
24805 Area Size: 4096 Used: 64
24806 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24807 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24808 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24809 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24810 Push
24811 zmmStackOffset: .... .... .... ..40
24812 zmmStackOffset: .... .... .... ..80
24813 zmm 1, 2
24814 Area Size: 4096 Used: 192
24815 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24816 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ 3333 3333 ____ ____ ____ ____ ____ ____ 4444 4444 ____ ____ ____ ____ ____ ____
24817 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ 5555 5555 ____ ____ ____ ____ ____ ____ 6666 6666 ____ ____ ____ ____ ____ ____ 7777 7777 ____ ____ ____ ____ ____ ____
24818 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24819 offset: .... .... .... ..80
24820 offset: .... .... .... ..40
24821 Peek
24822 zmm1: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24823 zmm2: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24824 Pop
24825 zmm3: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24826 zmm4: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24827 END
24828  
24829  
24830 =head3 Nasm::X86::Area::pushZmm($area, $zmm)
24831  
24832 Push the contents of a zmm register into an area.
24833  
24834 Parameter Description
24835 1 $area Area descriptor
24836 2 $zmm Zmm number
24837  
24838 B<Example:>
24839  
24840  
24841 my $a = CreateArea(stack=>1);
24842  
24843 $a->stackVariableSize->outNL;
24844 $a->dump("AA");
24845 $a->push(K key => 0x11111111);
24846 $a->stackVariableSize->outNL;
24847 $a->dump("AA");
24848  
24849 $a->push(K key => 0x22222222); # 12
24850 $a->stackVariableSize->outNL;
24851 $a->dump("AA");
24852  
24853 PrintOutStringNL "Peek";
24854 $a->peek(1)->outNL;
24855 $a->stackVariableSize->outNL;
24856 $a->peek(2)->outNL;
24857 $a->stackVariableSize->outNL;
24858 $a->stackSize->outNL;
24859  
24860 PrintOutStringNL "stackVariable";
24861 $a->stackVariable(K key => 0)->outNL;
24862 $a->stackVariable(K key => 1)->outNL;
24863  
24864 PrintOutStringNL "Pop";
24865 my $s1 = $a->pop; # 9
24866 $s1->outNL;
24867 $a->stackVariableSize->outNL;
24868 my $s2 = $a->pop;
24869 $s2->outNL;
24870 $a->stackVariableSize->outNL;
24871 $a->dump("pop1");
24872 $a->dump("pop2");
24873  
24874 ClearRegisters zmm1, zmm2;
24875  
24876 K(key => 0x22222222)->qIntoZ(1, 16);
24877 K(key => 0x33333333)->qIntoZ(1, 32);
24878 K(key => 0x44444444)->qIntoZ(1, 48);
24879  
24880 K(key => 0x55555555)->qIntoZ(2, 16);
24881 K(key => 0x66666666)->qIntoZ(2, 32);
24882 K(key => 0x77777777)->qIntoZ(2, 48);
24883  
24884 PrintOutStringNL "Push";
24885 $a->pushZmm(1)->outNL;
24886 $a->pushZmm(2)->outNL;
24887  
24888 $a->dump("zmm 1, 2");
24889 $a->peekZmm(1, 1)->outNL;
24890 $a->peekZmm(2, 2)->outNL;
24891 PrintOutStringNL "Peek";
24892 PrintOutRegisterInHex zmm1, zmm2;
24893  
24894 $a->popZmm(3);
24895 $a->popZmm(4);
24896 PrintOutStringNL "Pop";
24897 PrintOutRegisterInHex zmm3, zmm4;
24898  
24899 ok Assemble eq => <<END, clocks=>391;
24900 size: .... .... .... ...0
24901 AA
24902 Area Size: 4096 Used: 64
24903 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24904 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24905 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24906 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24907 size: .... .... .... ...1
24908 AA
24909 Area Size: 4096 Used: 72
24910 .... .... .... ...0 | __10 ____ ____ ____ 48__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24911 .... .... .... ..40 | 1111 1111 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24912 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24913 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24914 size: .... .... .... ...2
24915 AA
24916 Area Size: 4096 Used: 80
24917 .... .... .... ...0 | __10 ____ ____ ____ 50__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24918 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24919 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24920 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24921 Peek
24922 pop: .... .... 2222 2222
24923 size: .... .... .... ...2
24924 pop: .... .... 1111 1111
24925 size: .... .... .... ...2
24926 stackSize: .... .... .... ..10
24927 stackVariable
24928 pop: .... .... 1111 1111
24929 pop: .... .... 2222 2222
24930 Pop
24931 pop: .... .... 2222 2222
24932 size: .... .... .... ...1
24933 pop: .... .... 1111 1111
24934 size: .... .... .... ...0
24935 pop1
24936 Area Size: 4096 Used: 64
24937 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24938 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24939 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24940 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24941 pop2
24942 Area Size: 4096 Used: 64
24943 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24944 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24945 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24946 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24947 Push
24948 zmmStackOffset: .... .... .... ..40
24949 zmmStackOffset: .... .... .... ..80
24950 zmm 1, 2
24951 Area Size: 4096 Used: 192
24952 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24953 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ 3333 3333 ____ ____ ____ ____ ____ ____ 4444 4444 ____ ____ ____ ____ ____ ____
24954 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ 5555 5555 ____ ____ ____ ____ ____ ____ 6666 6666 ____ ____ ____ ____ ____ ____ 7777 7777 ____ ____ ____ ____ ____ ____
24955 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
24956 offset: .... .... .... ..80
24957 offset: .... .... .... ..40
24958 Peek
24959 zmm1: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24960 zmm2: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24961 Pop
24962 zmm3: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
24963 zmm4: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
24964 END
24965  
24966  
24967 =head3 Nasm::X86::Area::peekZmm($area, $zmm, $back)
24968  
24969 Peek at a zmm register from the stack in an area being used as a stack and return a variable containing its offset in the area so we can update the pushed zmm if desired.
24970  
24971 Parameter Description
24972 1 $area Area descriptor
24973 2 $zmm Zmm number
24974 3 $back How far back to look in the stack with the top most element being at one.
24975  
24976 B<Example:>
24977  
24978  
24979 my $a = CreateArea(stack=>1);
24980  
24981 $a->stackVariableSize->outNL;
24982 $a->dump("AA");
24983 $a->push(K key => 0x11111111);
24984 $a->stackVariableSize->outNL;
24985 $a->dump("AA");
24986  
24987 $a->push(K key => 0x22222222); # 12
24988 $a->stackVariableSize->outNL;
24989 $a->dump("AA");
24990  
24991 PrintOutStringNL "Peek";
24992 $a->peek(1)->outNL;
24993 $a->stackVariableSize->outNL;
24994 $a->peek(2)->outNL;
24995 $a->stackVariableSize->outNL;
24996 $a->stackSize->outNL;
24997  
24998 PrintOutStringNL "stackVariable";
24999 $a->stackVariable(K key => 0)->outNL;
25000 $a->stackVariable(K key => 1)->outNL;
25001  
25002 PrintOutStringNL "Pop";
25003 my $s1 = $a->pop; # 9
25004 $s1->outNL;
25005 $a->stackVariableSize->outNL;
25006 my $s2 = $a->pop;
25007 $s2->outNL;
25008 $a->stackVariableSize->outNL;
25009 $a->dump("pop1");
25010 $a->dump("pop2");
25011  
25012 ClearRegisters zmm1, zmm2;
25013  
25014 K(key => 0x22222222)->qIntoZ(1, 16);
25015 K(key => 0x33333333)->qIntoZ(1, 32);
25016 K(key => 0x44444444)->qIntoZ(1, 48);
25017  
25018 K(key => 0x55555555)->qIntoZ(2, 16);
25019 K(key => 0x66666666)->qIntoZ(2, 32);
25020 K(key => 0x77777777)->qIntoZ(2, 48);
25021  
25022 PrintOutStringNL "Push";
25023 $a->pushZmm(1)->outNL;
25024 $a->pushZmm(2)->outNL;
25025  
25026 $a->dump("zmm 1, 2");
25027 $a->peekZmm(1, 1)->outNL;
25028 $a->peekZmm(2, 2)->outNL;
25029 PrintOutStringNL "Peek";
25030 PrintOutRegisterInHex zmm1, zmm2;
25031  
25032 $a->popZmm(3);
25033 $a->popZmm(4);
25034 PrintOutStringNL "Pop";
25035 PrintOutRegisterInHex zmm3, zmm4;
25036  
25037 ok Assemble eq => <<END, clocks=>391;
25038 size: .... .... .... ...0
25039 AA
25040 Area Size: 4096 Used: 64
25041 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25042 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25043 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25044 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25045 size: .... .... .... ...1
25046 AA
25047 Area Size: 4096 Used: 72
25048 .... .... .... ...0 | __10 ____ ____ ____ 48__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25049 .... .... .... ..40 | 1111 1111 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25050 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25051 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25052 size: .... .... .... ...2
25053 AA
25054 Area Size: 4096 Used: 80
25055 .... .... .... ...0 | __10 ____ ____ ____ 50__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25056 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25057 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25058 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25059 Peek
25060 pop: .... .... 2222 2222
25061 size: .... .... .... ...2
25062 pop: .... .... 1111 1111
25063 size: .... .... .... ...2
25064 stackSize: .... .... .... ..10
25065 stackVariable
25066 pop: .... .... 1111 1111
25067 pop: .... .... 2222 2222
25068 Pop
25069 pop: .... .... 2222 2222
25070 size: .... .... .... ...1
25071 pop: .... .... 1111 1111
25072 size: .... .... .... ...0
25073 pop1
25074 Area Size: 4096 Used: 64
25075 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25076 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25077 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25078 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25079 pop2
25080 Area Size: 4096 Used: 64
25081 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25082 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25083 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25084 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25085 Push
25086 zmmStackOffset: .... .... .... ..40
25087 zmmStackOffset: .... .... .... ..80
25088 zmm 1, 2
25089 Area Size: 4096 Used: 192
25090 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25091 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ 3333 3333 ____ ____ ____ ____ ____ ____ 4444 4444 ____ ____ ____ ____ ____ ____
25092 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ 5555 5555 ____ ____ ____ ____ ____ ____ 6666 6666 ____ ____ ____ ____ ____ ____ 7777 7777 ____ ____ ____ ____ ____ ____
25093 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25094 offset: .... .... .... ..80
25095 offset: .... .... .... ..40
25096 Peek
25097 zmm1: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
25098 zmm2: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
25099 Pop
25100 zmm3: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
25101 zmm4: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
25102 END
25103  
25104  
25105 =head3 Nasm::X86::Area::popZmm($area, $zmm)
25106  
25107 Pop a zmm register from the stack in an area being used as a stack
25108  
25109 Parameter Description
25110 1 $area Area descriptor
25111 2 $zmm Zmm number
25112  
25113 B<Example:>
25114  
25115  
25116 my $a = CreateArea(stack=>1);
25117  
25118 $a->stackVariableSize->outNL;
25119 $a->dump("AA");
25120 $a->push(K key => 0x11111111);
25121 $a->stackVariableSize->outNL;
25122 $a->dump("AA");
25123  
25124 $a->push(K key => 0x22222222); # 12
25125 $a->stackVariableSize->outNL;
25126 $a->dump("AA");
25127  
25128 PrintOutStringNL "Peek";
25129 $a->peek(1)->outNL;
25130 $a->stackVariableSize->outNL;
25131 $a->peek(2)->outNL;
25132 $a->stackVariableSize->outNL;
25133 $a->stackSize->outNL;
25134  
25135 PrintOutStringNL "stackVariable";
25136 $a->stackVariable(K key => 0)->outNL;
25137 $a->stackVariable(K key => 1)->outNL;
25138  
25139 PrintOutStringNL "Pop";
25140 my $s1 = $a->pop; # 9
25141 $s1->outNL;
25142 $a->stackVariableSize->outNL;
25143 my $s2 = $a->pop;
25144 $s2->outNL;
25145 $a->stackVariableSize->outNL;
25146 $a->dump("pop1");
25147 $a->dump("pop2");
25148  
25149 ClearRegisters zmm1, zmm2;
25150  
25151 K(key => 0x22222222)->qIntoZ(1, 16);
25152 K(key => 0x33333333)->qIntoZ(1, 32);
25153 K(key => 0x44444444)->qIntoZ(1, 48);
25154  
25155 K(key => 0x55555555)->qIntoZ(2, 16);
25156 K(key => 0x66666666)->qIntoZ(2, 32);
25157 K(key => 0x77777777)->qIntoZ(2, 48);
25158  
25159 PrintOutStringNL "Push";
25160 $a->pushZmm(1)->outNL;
25161 $a->pushZmm(2)->outNL;
25162  
25163 $a->dump("zmm 1, 2");
25164 $a->peekZmm(1, 1)->outNL;
25165 $a->peekZmm(2, 2)->outNL;
25166 PrintOutStringNL "Peek";
25167 PrintOutRegisterInHex zmm1, zmm2;
25168  
25169 $a->popZmm(3);
25170 $a->popZmm(4);
25171 PrintOutStringNL "Pop";
25172 PrintOutRegisterInHex zmm3, zmm4;
25173  
25174 ok Assemble eq => <<END, clocks=>391;
25175 size: .... .... .... ...0
25176 AA
25177 Area Size: 4096 Used: 64
25178 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25179 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25180 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25181 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25182 size: .... .... .... ...1
25183 AA
25184 Area Size: 4096 Used: 72
25185 .... .... .... ...0 | __10 ____ ____ ____ 48__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25186 .... .... .... ..40 | 1111 1111 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25187 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25188 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25189 size: .... .... .... ...2
25190 AA
25191 Area Size: 4096 Used: 80
25192 .... .... .... ...0 | __10 ____ ____ ____ 50__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25193 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25194 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25195 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25196 Peek
25197 pop: .... .... 2222 2222
25198 size: .... .... .... ...2
25199 pop: .... .... 1111 1111
25200 size: .... .... .... ...2
25201 stackSize: .... .... .... ..10
25202 stackVariable
25203 pop: .... .... 1111 1111
25204 pop: .... .... 2222 2222
25205 Pop
25206 pop: .... .... 2222 2222
25207 size: .... .... .... ...1
25208 pop: .... .... 1111 1111
25209 size: .... .... .... ...0
25210 pop1
25211 Area Size: 4096 Used: 64
25212 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25213 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25214 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25215 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25216 pop2
25217 Area Size: 4096 Used: 64
25218 .... .... .... ...0 | __10 ____ ____ ____ 40__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25219 .... .... .... ..40 | 1111 1111 ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25220 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25221 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25222 Push
25223 zmmStackOffset: .... .... .... ..40
25224 zmmStackOffset: .... .... .... ..80
25225 zmm 1, 2
25226 Area Size: 4096 Used: 192
25227 .... .... .... ...0 | __10 ____ ____ ____ C0__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25228 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ 2222 2222 ____ ____ ____ ____ ____ ____ 3333 3333 ____ ____ ____ ____ ____ ____ 4444 4444 ____ ____ ____ ____ ____ ____
25229 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ 5555 5555 ____ ____ ____ ____ ____ ____ 6666 6666 ____ ____ ____ ____ ____ ____ 7777 7777 ____ ____ ____ ____ ____ ____
25230 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
25231 offset: .... .... .... ..80
25232 offset: .... .... .... ..40
25233 Peek
25234 zmm1: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
25235 zmm2: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
25236 Pop
25237 zmm3: .... .... .... ...0 .... .... 7777 7777 - .... .... .... ...0 .... .... 6666 6666 + .... .... .... ...0 .... .... 5555 5555 - .... .... .... ...0 .... .... .... ...0
25238 zmm4: .... .... .... ...0 .... .... 4444 4444 - .... .... .... ...0 .... .... 3333 3333 + .... .... .... ...0 .... .... 2222 2222 - .... .... .... ...0 .... .... .... ...0
25239 END
25240  
25241  
25242 =head1 Tree
25243  
25244 Tree constructed as sets of blocks in an area.
25245  
25246 =head2 Constructors
25247  
25248 Construct a tree.
25249  
25250 =head3 Nasm::X86::Area::CreateTree($area, %options)
25251  
25252 Create a tree in an area.
25253  
25254 Parameter Description
25255 1 $area Area description
25256 2 %options Tree options
25257  
25258 B<Example:>
25259  
25260  
25261 my $a = CreateArea;
25262 my $t = $a->CreateTree;
25263 $t->put (K(key => 2), K(data => 0x22));
25264 $t->find(K key => 2);
25265 $t->found->outNL;
25266 $t->data ->outNL;
25267  
25268 ok Assemble eq => <<END, avx512=>1;
25269 found : .... .... .... ...1
25270 data : .... .... .... ..22
25271 END
25272  
25273  
25274 =head3 Nasm::X86::Tree::cloneDescriptor($tree)
25275  
25276 Clone the descriptor of a tree to make a new tree descriptor.
25277  
25278 Parameter Description
25279 1 $tree Tree descriptor
25280  
25281 B<Example:>
25282  
25283  
25284 my $a = CreateArea;
25285 my $t = $a->CreateTree;
25286 $t->push(ord 'a');
25287 my $T = $t->cloneDescriptor;
25288 $T->push(ord 'b');
25289 my $c = $a->CreateTree;
25290 $c->copyDescriptor($T);
25291 $T->push(ord 'c');
25292  
25293 $t->outAsUtf8NL;
25294 ok Assemble eq => <<END, avx512=>1;
25295 abc
25296 END
25297  
25298  
25299 =head3 Nasm::X86::Tree::copyDescriptor($target, $source)
25300  
25301 Copy the description of one tree into another.
25302  
25303 Parameter Description
25304 1 $target The target of the copy
25305 2 $source The source of the copy
25306  
25307 B<Example:>
25308  
25309  
25310 my $a = CreateArea;
25311 my $t = $a->CreateTree;
25312 $t->push(ord 'a');
25313 my $T = $t->cloneDescriptor;
25314 $T->push(ord 'b');
25315 my $c = $a->CreateTree;
25316 $c->copyDescriptor($T);
25317 $T->push(ord 'c');
25318  
25319 $t->outAsUtf8NL;
25320 ok Assemble eq => <<END, avx512=>1;
25321 abc
25322 END
25323  
25324  
25325 =head3 Nasm::X86::Tree::size($tree)
25326  
25327 Return in a variable the number of elements currently in the tree.
25328  
25329 Parameter Description
25330 1 $tree Tree descriptor
25331  
25332 B<Example:>
25333  
25334  
25335 my $a = CreateArea;
25336 my $t = $a->CreateTree;
25337  
25338 $t->put(K(key => 1), V(key => 1)); $t->size->outNL;
25339 $t->put(K(key => 2), K(key => 2)); $t->size->outNL;
25340 $t->put(V(key => 2), V(key => 2)); $t->size->outNL;
25341  
25342 $t->put(K(key => 3), K(key => 3)); $t->size->outNL;
25343 $t->put(V(key => 3), V(key => 3)); $t->size->outNL;
25344  
25345 $t->put(K(key => 4), K(key => 4)); $t->size->outNL;
25346 $t->put(K(key => 4), K(key => 4)); $t->size->outNL;
25347  
25348 $t->put(K(key => 5), K(key => 5)); $t->size->outNL;
25349 $t->put(V(key => 5), V(key => 5)); $t->size->outNL;
25350  
25351 $t->put(K(key => 6), K(key => 5)); $t->size->outNL;
25352 $t->put(V(key => 6), V(key => 5)); $t->size->outNL;
25353  
25354 $t->put(K(key => 7), K(key => 7)); $t->size->outNL;
25355 $t->put(V(key => 7), V(key => 7)); $t->size->outNL;
25356  
25357 $t->put(K(key => 8), K(key => 8)); $t->size->outNL;
25358 $t->put(V(key => 8), V(key => 8)); $t->size->outNL;
25359  
25360 $t->put(K(key => 9), K(key => 9)); $t->size->outNL;
25361 $t->put(V(key => 9), V(key => 9)); $t->size->outNL;
25362  
25363 $t->put(K(key => 10), K(key => 10)); $t->size->outNL;
25364 $t->put(V(key => 10), V(key => 10)); $t->size->outNL;
25365  
25366 $t->put(K(key => 11), K(key => 11)); $t->size->outNL;
25367 $t->put(V(key => 11), V(key => 11)); $t->size->outNL;
25368  
25369 $t->put(K(key => 12), K(key => 12)); $t->size->outNL;
25370 $t->put(V(key => 12), V(key => 12)); $t->size->outNL;
25371  
25372 $t->put(K(key => 13), K(key => 13)); $t->size->outNL;
25373 $t->put(V(key => 13), V(key => 13)); $t->size->outNL;
25374  
25375 $t->put(K(key => 14), K(key => 14)); $t->size->outNL;
25376 $t->put(V(key => 14), V(key => 14)); $t->size->outNL;
25377  
25378 $t->put(K(key => 15), K(key => 15)); $t->size->outNL;
25379 $t->put(V(key => 15), V(key => 15)); $t->size->outNL;
25380  
25381 $t->put(K(key => 4), K(key => 4));
25382  
25383 $t->dump8xx("AAA");
25384  
25385 ok Assemble debug => 0, eq => <<END, clocks=>18177;
25386 size of tree: .... .... .... ...1
25387 size of tree: .... .... .... ...2
25388 size of tree: .... .... .... ...2
25389 size of tree: .... .... .... ...3
25390 size of tree: .... .... .... ...3
25391 size of tree: .... .... .... ...4
25392 size of tree: .... .... .... ...4
25393 size of tree: .... .... .... ...5
25394 size of tree: .... .... .... ...5
25395 size of tree: .... .... .... ...6
25396 size of tree: .... .... .... ...6
25397 size of tree: .... .... .... ...7
25398 size of tree: .... .... .... ...7
25399 size of tree: .... .... .... ...8
25400 size of tree: .... .... .... ...8
25401 size of tree: .... .... .... ...9
25402 size of tree: .... .... .... ...9
25403 size of tree: .... .... .... ...A
25404 size of tree: .... .... .... ...A
25405 size of tree: .... .... .... ...B
25406 size of tree: .... .... .... ...B
25407 size of tree: .... .... .... ...C
25408 size of tree: .... .... .... ...C
25409 size of tree: .... .... .... ...D
25410 size of tree: .... .... .... ...D
25411 size of tree: .... .... .... ...E
25412 size of tree: .... .... .... ...E
25413 size of tree: .... .... .... ...F
25414 size of tree: .... .... .... ...F
25415 AAA
25416 Tree: .... .... .... ..40
25417 At: 200 length: 1, data: 240, nodes: 280, first: 40, root, parent
25418 Index: 0
25419 Keys : 7
25420 Data : 7
25421 Nodes: 80 140
25422 At: 80 length: 6, data: C0, nodes: 100, first: 40, up: 200, leaf
25423 Index: 0 1 2 3 4 5
25424 Keys : 1 2 3 4 5 6
25425 Data : 1 2 3 4 5 5
25426 end
25427 At: 140 length: 8, data: 180, nodes: 1C0, first: 40, up: 200, leaf
25428 Index: 0 1 2 3 4 5 6 7
25429 Keys : 8 9 A B C D E F
25430 Data : 8 9 A B C D E F
25431 end
25432 end
25433 END
25434  
25435  
25436 =head2 Insert
25437  
25438 Insert a key into the tree.
25439  
25440 =head3 Nasm::X86::Tree::put($tree, $key, $data)
25441  
25442 Put a variable key and data into a tree. The data could be a tree descriptor to place a sub tree into a tree at the indicated key.
25443  
25444 Parameter Description
25445 1 $tree Tree definition
25446 2 $key Variable key containing a number for a normal key or the offset in the area of a zmm block containing the key
25447 3 $data Data as a variable or a tree descriptor
25448  
25449 B<Example:>
25450  
25451  
25452 if (1)
25453 {my $a = CreateArea;
25454 my $t = $a->CreateTree;
25455 $t->put(1, 1);
25456 $t->find (1);
25457 $t->found->outNL;
25458 $t->data ->outNL;
25459  
25460 ok Assemble eq=><<END, avx512=>1;
25461 found : .... .... .... ...1
25462 data : .... .... .... ...1
25463 END
25464 }
25465  
25466 my $a = CreateArea;
25467 my $t = $a->CreateTree;
25468 my $N = K count => 128;
25469  
25470 $N->for(sub
25471 {my ($index, $start, $next, $end) = @_;
25472 my $l = $N-$index;
25473 $t->put($l, $l * 2);
25474 my $h = $N+$index;
25475 $t->put($h, $h * 2);
25476 });
25477 $t->put(K(zero=>0), K(zero=>0));
25478 $t->printInOrder("AAAA");
25479  
25480 PrintOutStringNL 'Indx Found Offset Double Found Offset Quad Found Offset Octo Found Offset *16 Found Offset *32 Found Offset *64 Found Offset *128 Found Offset *256 Found Offset *512';
25481 $N->for(sub
25482 {my ($index, $start, $next, $end) = @_;
25483 my $i = $index;
25484 my $j = $i * 2;
25485 my $k = $j * 2;
25486 my $l = $k * 2;
25487 my $m = $l * 2;
25488 my $n = $m * 2;
25489 my $o = $n * 2;
25490 my $p = $o * 2;
25491 my $q = $p * 2;
25492 $t->find($i); $i->outRightInDec(4); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25493 $t->find($j); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25494 $t->find($k); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25495 $t->find($l); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25496 $t->find($m); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25497 $t->find($n); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25498 $t->find($o); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25499 $t->find($p); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25500 $t->find($q); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDecNL(8);
25501 });
25502  
25503 ok Assemble eq => <<END, avx512=>1;
25504 AAAA 256: 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
25505 Indx Found Offset Double Found Offset Quad Found Offset Octo Found Offset *16 Found Offset *32 Found Offset *64 Found Offset *128 Found Offset *256 Found Offset *512
25506 0 1 80 0 1 80 0 1 80 0 1 80 0 1 80 0 1 80 0 1 80 0 1 80 0 1 80 0
25507 1 10 80 2 100 80 4 10000 80 800000000 80 16 10 200 32 10 1940 64 100000 11C0 128 10 C80 256 0 0
25508 2 100 80 4 10000 80 800000000 80 16 10 200 32 10 1940 64 100000 11C0 128 10 C80 256 0 0 0 0
25509 3 1000 80 6 1000000 80 12 100 1DC0 24 1 1AC0 48 1000 14C0 96 100 8C0 192 1 1100 384 0 0 0 0
25510 4 10000 80 800000000 80 16 10 200 32 10 1940 64 100000 11C0 128 10 C80 256 0 0 0 0 0 0
25511 5 100000 80 10 1 1DC0 20 1000 1C40 40 100 1640 80 1 D40 160 1000 800 320 0 0 0 0 0 0
25512 6 1000000 80 12 100 1DC0 24 1 1AC0 48 1000 14C0 96 100 8C0 192 1 1100 384 0 0 0 0 0 0
25513 710000000 80 14 10000 1DC0 28 10000 1AC0 56 10000 1340 112 10000 5C0 224 10000 17C0 448 0 0 0 0 0 0
25514 800000000 80 16 10 200 32 10 1940 64 100000 11C0 128 10 C80 256 0 0 0 0 0 0 0 0
25515 9 1 200 18 10 1C40 36 100000 1940 7200000000 200 144 10 500 288 0 0 0 0 0 0 0 0
25516 10 1 1DC0 20 1000 1C40 40 100 1640 80 1 D40 160 1000 800 320 0 0 0 0 0 0 0 0
25517 11 10 1DC0 22 100000 1C40 44 100000 200 88 10 A40 176 100000 B00 352 0 0 0 0 0 0 0 0
25518 12 100 1DC0 24 1 1AC0 48 1000 14C0 96 100 8C0 192 1 1100 384 0 0 0 0 0 0 0 0
25519 13 1000 1DC0 26 100 1AC0 52 1 1340 104 1000 740 208 100 1400 416 0 0 0 0 0 0 0 0
25520 14 10000 1DC0 28 10000 1AC0 56 10000 1340 112 10000 5C0 224 10000 17C0 448 0 0 0 0 0 0 0 0
25521 15 100000 1DC0 30 1000 200 60 10 11C0 120 100000 440 24000000000 1880 480 0 0 0 0 0 0 0 0
25522 16 10 200 32 10 1940 64 100000 11C0 128 10 C80 256 0 0 0 0 0 0 0 0 0 0
25523 17 1 1C40 34 1000 1940 68 100 1040 136 1 380 272 0 0 0 0 0 0 0 0 0 0
25524 18 10 1C40 36 100000 1940 7200000000 200 144 10 500 288 0 0 0 0 0 0 0 0 0 0
25525 19 100 1C40 38 1 1640 76 1000 EC0 152 100 680 304 0 0 0 0 0 0 0 0 0 0
25526 20 1000 1C40 40 100 1640 80 1 D40 160 1000 800 320 0 0 0 0 0 0 0 0 0 0
25527 21 10000 1C40 42 10000 1640 84 10000 D40 168 10000 980 336 0 0 0 0 0 0 0 0 0 0
25528 22 100000 1C40 44 100000 200 88 10 A40 176 100000 B00 352 0 0 0 0 0 0 0 0 0 0
25529 23 100 200 46 10 14C0 92 100000 A40 184 1 1880 368 0 0 0 0 0 0 0 0 0 0
25530 24 1 1AC0 48 1000 14C0 96 100 8C0 192 1 1100 384 0 0 0 0 0 0 0 0 0 0
25531 25 10 1AC0 50 100000 14C0 100 100 1700 200 10 1280 400 0 0 0 0 0 0 0 0 0 0
25532 26 100 1AC0 52 1 1340 104 1000 740 208 100 1400 416 0 0 0 0 0 0 0 0 0 0
25533 27 1000 1AC0 54 100 1340 108 1 5C0 216 1000 1580 432 0 0 0 0 0 0 0 0 0 0
25534 28 10000 1AC0 56 10000 1340 112 10000 5C0 224 10000 17C0 448 0 0 0 0 0 0 0 0 0 0
25535 29 100000 1AC0 5810000000 200 116 10 440 232 100000 1A00 464 0 0 0 0 0 0 0 0 0 0
25536 30 1000 200 60 10 11C0 120 100000 440 24000000000 1880 480 0 0 0 0 0 0 0 0 0 0
25537 31 1 1940 62 1000 11C0 124 100 2C0 248 1 1E80 496 0 0 0 0 0 0 0 0 0 0
25538 32 10 1940 64 100000 11C0 128 10 C80 256 0 0 0 0 0 0 0 0 0 0 0 0
25539 33 100 1940 66 1 1040 132 1000 140 264 0 0 0 0 0 0 0 0 0 0 0 0
25540 34 1000 1940 68 100 1040 136 1 380 272 0 0 0 0 0 0 0 0 0 0 0 0
25541 35 10000 1940 70 10000 1040 140 10000 380 280 0 0 0 0 0 0 0 0 0 0 0 0
25542 36 100000 1940 7200000000 200 144 10 500 288 0 0 0 0 0 0 0 0 0 0 0 0
25543 37 10000 200 74 10 EC0 148 100000 500 296 0 0 0 0 0 0 0 0 0 0 0 0
25544 38 1 1640 76 1000 EC0 152 100 680 304 0 0 0 0 0 0 0 0 0 0 0 0
25545 39 10 1640 78 100000 EC0 156 1000 BC0 312 0 0 0 0 0 0 0 0 0 0 0 0
25546 40 100 1640 80 1 D40 160 1000 800 320 0 0 0 0 0 0 0 0 0 0 0 0
25547 41 1000 1640 82 100 D40 164 1 980 328 0 0 0 0 0 0 0 0 0 0 0 0
25548 42 10000 1640 84 10000 D40 168 10000 980 336 0 0 0 0 0 0 0 0 0 0 0 0
25549 43 100000 1640 86 1 1700 172 10 B00 344 0 0 0 0 0 0 0 0 0 0 0 0
25550 44 100000 200 88 10 A40 176 100000 B00 352 0 0 0 0 0 0 0 0 0 0 0 0
25551 45 1 14C0 90 1000 A40 180 100 E00 360 0 0 0 0 0 0 0 0 0 0 0 0
25552 46 10 14C0 92 100000 A40 184 1 1880 368 0 0 0 0 0 0 0 0 0 0 0 0
25553 47 100 14C0 94 1 8C0 188 1000 F80 376 0 0 0 0 0 0 0 0 0 0 0 0
25554 48 1000 14C0 96 100 8C0 192 1 1100 384 0 0 0 0 0 0 0 0 0 0 0 0
25555 49 10000 14C0 98 10000 8C0 196 10000 1100 392 0 0 0 0 0 0 0 0 0 0 0 0
25556 50 100000 14C0 100 100 1700 200 10 1280 400 0 0 0 0 0 0 0 0 0 0 0 0
25557 51 1000000 200 102 10 740 204 100000 1280 408 0 0 0 0 0 0 0 0 0 0 0 0
25558 52 1 1340 104 1000 740 208 100 1400 416 0 0 0 0 0 0 0 0 0 0 0 0
25559 53 10 1340 106 100000 740 212 10000 1880 424 0 0 0 0 0 0 0 0 0 0 0 0
25560 54 100 1340 108 1 5C0 216 1000 1580 432 0 0 0 0 0 0 0 0 0 0 0 0
25561 55 1000 1340 110 100 5C0 220 1 17C0 440 0 0 0 0 0 0 0 0 0 0 0 0
25562 56 10000 1340 112 10000 5C0 224 10000 17C0 448 0 0 0 0 0 0 0 0 0 0 0 0
25563 57 100000 1340 114 10000 1700 228 10 1A00 456 0 0 0 0 0 0 0 0 0 0 0 0
25564 5810000000 200 116 10 440 232 100000 1A00 464 0 0 0 0 0 0 0 0 0 0 0 0
25565 59 1 11C0 118 1000 440 236 100 1B80 472 0 0 0 0 0 0 0 0 0 0 0 0
25566 60 10 11C0 120 100000 440 24000000000 1880 480 0 0 0 0 0 0 0 0 0 0 0 0
25567 61 100 11C0 122 1 2C0 244 1000 1D00 488 0 0 0 0 0 0 0 0 0 0 0 0
25568 62 1000 11C0 124 100 2C0 248 1 1E80 496 0 0 0 0 0 0 0 0 0 0 0 0
25569 63 10000 11C0 126 10000 2C0 252 10000 1E80 504 0 0 0 0 0 0 0 0 0 0 0 0
25570 64 100000 11C0 128 10 C80 256 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25571 6500000000 200 130 10 140 260 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25572 66 1 1040 132 1000 140 264 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25573 67 10 1040 134 100000 140 268 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25574 68 100 1040 136 1 380 272 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25575 69 1000 1040 138 100 380 276 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25576 70 10000 1040 140 10000 380 280 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25577 71 100000 1040 142 10 BC0 284 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25578 7200000000 200 144 10 500 288 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25579 73 1 EC0 146 1000 500 292 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25580 74 10 EC0 148 100000 500 296 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25581 75 100 EC0 150 1 680 300 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25582 76 1000 EC0 152 100 680 304 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25583 77 10000 EC0 154 10000 680 308 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25584 78 100000 EC0 156 1000 BC0 312 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25585 79 1 C80 158 10 800 316 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25586 80 1 D40 160 1000 800 320 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25587 81 10 D40 162 100000 800 324 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25588 82 100 D40 164 1 980 328 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25589 83 1000 D40 166 100 980 332 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25590 84 10000 D40 168 10000 980 336 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25591 85 100000 D40 170 100000 BC0 340 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25592 86 1 1700 172 10 B00 344 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25593 87 1 A40 174 1000 B00 348 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25594 88 10 A40 176 100000 B00 352 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25595 89 100 A40 178 1 E00 356 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25596 90 1000 A40 180 100 E00 360 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25597 91 10000 A40 182 10000 E00 364 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25598 92 100000 A40 184 1 1880 368 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25599 93 10 1700 186 10 F80 372 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25600 94 1 8C0 188 1000 F80 376 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25601 95 10 8C0 190 100000 F80 380 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25602 96 100 8C0 192 1 1100 384 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25603 97 1000 8C0 194 100 1100 388 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25604 98 10000 8C0 196 10000 1100 392 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25605 99 100000 8C0 198 100 1880 396 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25606 100 100 1700 200 10 1280 400 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25607 101 1 740 202 1000 1280 404 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25608 102 10 740 204 100000 1280 408 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25609 103 100 740 206 1 1400 412 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25610 104 1000 740 208 100 1400 416 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25611 105 10000 740 210 10000 1400 420 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25612 106 100000 740 212 10000 1880 424 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25613 107 1000 1700 214 10 1580 428 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25614 108 1 5C0 216 1000 1580 432 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25615 109 10 5C0 218 100000 1580 436 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25616 110 100 5C0 220 1 17C0 440 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25617 111 1000 5C0 222 100 17C0 444 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25618 112 10000 5C0 224 10000 17C0 448 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25619 113 100000 5C0 226 1000000 1880 452 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25620 114 10000 1700 228 10 1A00 456 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25621 115 1 440 230 1000 1A00 460 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25622 116 10 440 232 100000 1A00 464 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25623 117 100 440 234 1 1B80 468 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25624 118 1000 440 236 100 1B80 472 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25625 119 10000 440 238 10000 1B80 476 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25626 120 100000 440 24000000000 1880 480 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25627 121 100000 1700 242 10 1D00 484 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25628 122 1 2C0 244 1000 1D00 488 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25629 123 10 2C0 246 100000 1D00 492 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25630 124 100 2C0 248 1 1E80 496 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25631 125 1000 2C0 250 100 1E80 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25632 126 10000 2C0 252 10000 1E80 504 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25633 127 100000 2C0 254 1000000 1E80 508 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25634 END
25635  
25636 my $a = CreateArea;
25637 my $t = $a->CreateTree;
25638  
25639 $t->put(K(key => 1), V(key => 1)); $t->size->outNL;
25640 $t->put(K(key => 2), K(key => 2)); $t->size->outNL;
25641 $t->put(V(key => 2), V(key => 2)); $t->size->outNL;
25642  
25643 $t->put(K(key => 3), K(key => 3)); $t->size->outNL;
25644 $t->put(V(key => 3), V(key => 3)); $t->size->outNL;
25645  
25646 $t->put(K(key => 4), K(key => 4)); $t->size->outNL;
25647 $t->put(K(key => 4), K(key => 4)); $t->size->outNL;
25648  
25649 $t->put(K(key => 5), K(key => 5)); $t->size->outNL;
25650 $t->put(V(key => 5), V(key => 5)); $t->size->outNL;
25651  
25652 $t->put(K(key => 6), K(key => 5)); $t->size->outNL;
25653 $t->put(V(key => 6), V(key => 5)); $t->size->outNL;
25654  
25655 $t->put(K(key => 7), K(key => 7)); $t->size->outNL;
25656 $t->put(V(key => 7), V(key => 7)); $t->size->outNL;
25657  
25658 $t->put(K(key => 8), K(key => 8)); $t->size->outNL;
25659 $t->put(V(key => 8), V(key => 8)); $t->size->outNL;
25660  
25661 $t->put(K(key => 9), K(key => 9)); $t->size->outNL;
25662 $t->put(V(key => 9), V(key => 9)); $t->size->outNL;
25663  
25664 $t->put(K(key => 10), K(key => 10)); $t->size->outNL;
25665 $t->put(V(key => 10), V(key => 10)); $t->size->outNL;
25666  
25667 $t->put(K(key => 11), K(key => 11)); $t->size->outNL;
25668 $t->put(V(key => 11), V(key => 11)); $t->size->outNL;
25669  
25670 $t->put(K(key => 12), K(key => 12)); $t->size->outNL;
25671 $t->put(V(key => 12), V(key => 12)); $t->size->outNL;
25672  
25673 $t->put(K(key => 13), K(key => 13)); $t->size->outNL;
25674 $t->put(V(key => 13), V(key => 13)); $t->size->outNL;
25675  
25676 $t->put(K(key => 14), K(key => 14)); $t->size->outNL;
25677 $t->put(V(key => 14), V(key => 14)); $t->size->outNL;
25678  
25679 $t->put(K(key => 15), K(key => 15)); $t->size->outNL;
25680 $t->put(V(key => 15), V(key => 15)); $t->size->outNL;
25681  
25682 $t->put(K(key => 4), K(key => 4));
25683  
25684 $t->dump8xx("AAA");
25685  
25686 ok Assemble debug => 0, eq => <<END, clocks=>18177;
25687 size of tree: .... .... .... ...1
25688 size of tree: .... .... .... ...2
25689 size of tree: .... .... .... ...2
25690 size of tree: .... .... .... ...3
25691 size of tree: .... .... .... ...3
25692 size of tree: .... .... .... ...4
25693 size of tree: .... .... .... ...4
25694 size of tree: .... .... .... ...5
25695 size of tree: .... .... .... ...5
25696 size of tree: .... .... .... ...6
25697 size of tree: .... .... .... ...6
25698 size of tree: .... .... .... ...7
25699 size of tree: .... .... .... ...7
25700 size of tree: .... .... .... ...8
25701 size of tree: .... .... .... ...8
25702 size of tree: .... .... .... ...9
25703 size of tree: .... .... .... ...9
25704 size of tree: .... .... .... ...A
25705 size of tree: .... .... .... ...A
25706 size of tree: .... .... .... ...B
25707 size of tree: .... .... .... ...B
25708 size of tree: .... .... .... ...C
25709 size of tree: .... .... .... ...C
25710 size of tree: .... .... .... ...D
25711 size of tree: .... .... .... ...D
25712 size of tree: .... .... .... ...E
25713 size of tree: .... .... .... ...E
25714 size of tree: .... .... .... ...F
25715 size of tree: .... .... .... ...F
25716 AAA
25717 Tree: .... .... .... ..40
25718 At: 200 length: 1, data: 240, nodes: 280, first: 40, root, parent
25719 Index: 0
25720 Keys : 7
25721 Data : 7
25722 Nodes: 80 140
25723 At: 80 length: 6, data: C0, nodes: 100, first: 40, up: 200, leaf
25724 Index: 0 1 2 3 4 5
25725 Keys : 1 2 3 4 5 6
25726 Data : 1 2 3 4 5 5
25727 end
25728 At: 140 length: 8, data: 180, nodes: 1C0, first: 40, up: 200, leaf
25729 Index: 0 1 2 3 4 5 6 7
25730 Keys : 8 9 A B C D E F
25731 Data : 8 9 A B C D E F
25732 end
25733 end
25734 END
25735  
25736 my $a = CreateArea;
25737 my $t = $a->CreateTree;
25738  
25739 my $N = K(key => 999);
25740 $N->for(sub
25741 {my ($index, $start, $next, $end) = @_;
25742 $t->put($index, $index);
25743 });
25744  
25745 $N->for(sub
25746 {my ($index, $start, $next, $end) = @_;
25747 $t->find($index);
25748 });
25749  
25750 ok Assemble eq => <<END, clocks=>763430;
25751 END
25752  
25753  
25754 =head2 Find
25755  
25756 Find a key in the tree. Trees have dword integer keys and so can act as arrays as well.
25757  
25758 =head3 Nasm::X86::Tree::find($tree, $key)
25759  
25760 Find a key in a tree and tests whether the found data is a sub tree. The results are held in the variables "found", "data", "subTree" addressed by the tree descriptor. The key just searched for is held in the key field of the tree descriptor. The point at which it was found is held in B<found> which will be zero if the key was not found.
25761  
25762 Parameter Description
25763 1 $tree Tree descriptor
25764 2 $key Key field to search for which can either be a variable containing a double word for a normal tree or a zmm register containing the key to be sought for a string tree.
25765  
25766 B<Example:>
25767  
25768  
25769 if (1)
25770 {my $a = CreateArea;
25771 my $t = $a->CreateTree;
25772 $t->put(1, 1);
25773 $t->find (1);
25774 $t->found->outNL;
25775 $t->data ->outNL;
25776  
25777 ok Assemble eq=><<END, avx512=>1;
25778 found : .... .... .... ...1
25779 data : .... .... .... ...1
25780 END
25781 }
25782  
25783 my $a = CreateArea;
25784 my $t = $a->CreateTree;
25785 my $N = K count => 128;
25786  
25787 $N->for(sub
25788 {my ($index, $start, $next, $end) = @_;
25789 my $l = $N-$index;
25790 $t->put($l, $l * 2);
25791 my $h = $N+$index;
25792 $t->put($h, $h * 2);
25793 });
25794 $t->put(K(zero=>0), K(zero=>0));
25795 $t->printInOrder("AAAA");
25796  
25797 PrintOutStringNL 'Indx Found Offset Double Found Offset Quad Found Offset Octo Found Offset *16 Found Offset *32 Found Offset *64 Found Offset *128 Found Offset *256 Found Offset *512';
25798 $N->for(sub
25799 {my ($index, $start, $next, $end) = @_;
25800 my $i = $index;
25801 my $j = $i * 2;
25802 my $k = $j * 2;
25803 my $l = $k * 2;
25804 my $m = $l * 2;
25805 my $n = $m * 2;
25806 my $o = $n * 2;
25807 my $p = $o * 2;
25808 my $q = $p * 2;
25809 $t->find($i); $i->outRightInDec(4); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25810 $t->find($j); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25811 $t->find($k); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25812 $t->find($l); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25813 $t->find($m); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25814 $t->find($n); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25815 $t->find($o); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25816 $t->find($p); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDec (8);
25817 $t->find($q); $t->found->outRightInBin(8); $t->offset->outRightInHex(8); $t->data->outRightInDecNL(8);
25818 });
25819  
25820 ok Assemble eq => <<END, avx512=>1;
25821 AAAA 256: 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
25822 Indx Found Offset Double Found Offset Quad Found Offset Octo Found Offset *16 Found Offset *32 Found Offset *64 Found Offset *128 Found Offset *256 Found Offset *512
25823 0 1 80 0 1 80 0 1 80 0 1 80 0 1 80 0 1 80 0 1 80 0 1 80 0 1 80 0
25824 1 10 80 2 100 80 4 10000 80 800000000 80 16 10 200 32 10 1940 64 100000 11C0 128 10 C80 256 0 0
25825 2 100 80 4 10000 80 800000000 80 16 10 200 32 10 1940 64 100000 11C0 128 10 C80 256 0 0 0 0
25826 3 1000 80 6 1000000 80 12 100 1DC0 24 1 1AC0 48 1000 14C0 96 100 8C0 192 1 1100 384 0 0 0 0
25827 4 10000 80 800000000 80 16 10 200 32 10 1940 64 100000 11C0 128 10 C80 256 0 0 0 0 0 0
25828 5 100000 80 10 1 1DC0 20 1000 1C40 40 100 1640 80 1 D40 160 1000 800 320 0 0 0 0 0 0
25829 6 1000000 80 12 100 1DC0 24 1 1AC0 48 1000 14C0 96 100 8C0 192 1 1100 384 0 0 0 0 0 0
25830 710000000 80 14 10000 1DC0 28 10000 1AC0 56 10000 1340 112 10000 5C0 224 10000 17C0 448 0 0 0 0 0 0
25831 800000000 80 16 10 200 32 10 1940 64 100000 11C0 128 10 C80 256 0 0 0 0 0 0 0 0
25832 9 1 200 18 10 1C40 36 100000 1940 7200000000 200 144 10 500 288 0 0 0 0 0 0 0 0
25833 10 1 1DC0 20 1000 1C40 40 100 1640 80 1 D40 160 1000 800 320 0 0 0 0 0 0 0 0
25834 11 10 1DC0 22 100000 1C40 44 100000 200 88 10 A40 176 100000 B00 352 0 0 0 0 0 0 0 0
25835 12 100 1DC0 24 1 1AC0 48 1000 14C0 96 100 8C0 192 1 1100 384 0 0 0 0 0 0 0 0
25836 13 1000 1DC0 26 100 1AC0 52 1 1340 104 1000 740 208 100 1400 416 0 0 0 0 0 0 0 0
25837 14 10000 1DC0 28 10000 1AC0 56 10000 1340 112 10000 5C0 224 10000 17C0 448 0 0 0 0 0 0 0 0
25838 15 100000 1DC0 30 1000 200 60 10 11C0 120 100000 440 24000000000 1880 480 0 0 0 0 0 0 0 0
25839 16 10 200 32 10 1940 64 100000 11C0 128 10 C80 256 0 0 0 0 0 0 0 0 0 0
25840 17 1 1C40 34 1000 1940 68 100 1040 136 1 380 272 0 0 0 0 0 0 0 0 0 0
25841 18 10 1C40 36 100000 1940 7200000000 200 144 10 500 288 0 0 0 0 0 0 0 0 0 0
25842 19 100 1C40 38 1 1640 76 1000 EC0 152 100 680 304 0 0 0 0 0 0 0 0 0 0
25843 20 1000 1C40 40 100 1640 80 1 D40 160 1000 800 320 0 0 0 0 0 0 0 0 0 0
25844 21 10000 1C40 42 10000 1640 84 10000 D40 168 10000 980 336 0 0 0 0 0 0 0 0 0 0
25845 22 100000 1C40 44 100000 200 88 10 A40 176 100000 B00 352 0 0 0 0 0 0 0 0 0 0
25846 23 100 200 46 10 14C0 92 100000 A40 184 1 1880 368 0 0 0 0 0 0 0 0 0 0
25847 24 1 1AC0 48 1000 14C0 96 100 8C0 192 1 1100 384 0 0 0 0 0 0 0 0 0 0
25848 25 10 1AC0 50 100000 14C0 100 100 1700 200 10 1280 400 0 0 0 0 0 0 0 0 0 0
25849 26 100 1AC0 52 1 1340 104 1000 740 208 100 1400 416 0 0 0 0 0 0 0 0 0 0
25850 27 1000 1AC0 54 100 1340 108 1 5C0 216 1000 1580 432 0 0 0 0 0 0 0 0 0 0
25851 28 10000 1AC0 56 10000 1340 112 10000 5C0 224 10000 17C0 448 0 0 0 0 0 0 0 0 0 0
25852 29 100000 1AC0 5810000000 200 116 10 440 232 100000 1A00 464 0 0 0 0 0 0 0 0 0 0
25853 30 1000 200 60 10 11C0 120 100000 440 24000000000 1880 480 0 0 0 0 0 0 0 0 0 0
25854 31 1 1940 62 1000 11C0 124 100 2C0 248 1 1E80 496 0 0 0 0 0 0 0 0 0 0
25855 32 10 1940 64 100000 11C0 128 10 C80 256 0 0 0 0 0 0 0 0 0 0 0 0
25856 33 100 1940 66 1 1040 132 1000 140 264 0 0 0 0 0 0 0 0 0 0 0 0
25857 34 1000 1940 68 100 1040 136 1 380 272 0 0 0 0 0 0 0 0 0 0 0 0
25858 35 10000 1940 70 10000 1040 140 10000 380 280 0 0 0 0 0 0 0 0 0 0 0 0
25859 36 100000 1940 7200000000 200 144 10 500 288 0 0 0 0 0 0 0 0 0 0 0 0
25860 37 10000 200 74 10 EC0 148 100000 500 296 0 0 0 0 0 0 0 0 0 0 0 0
25861 38 1 1640 76 1000 EC0 152 100 680 304 0 0 0 0 0 0 0 0 0 0 0 0
25862 39 10 1640 78 100000 EC0 156 1000 BC0 312 0 0 0 0 0 0 0 0 0 0 0 0
25863 40 100 1640 80 1 D40 160 1000 800 320 0 0 0 0 0 0 0 0 0 0 0 0
25864 41 1000 1640 82 100 D40 164 1 980 328 0 0 0 0 0 0 0 0 0 0 0 0
25865 42 10000 1640 84 10000 D40 168 10000 980 336 0 0 0 0 0 0 0 0 0 0 0 0
25866 43 100000 1640 86 1 1700 172 10 B00 344 0 0 0 0 0 0 0 0 0 0 0 0
25867 44 100000 200 88 10 A40 176 100000 B00 352 0 0 0 0 0 0 0 0 0 0 0 0
25868 45 1 14C0 90 1000 A40 180 100 E00 360 0 0 0 0 0 0 0 0 0 0 0 0
25869 46 10 14C0 92 100000 A40 184 1 1880 368 0 0 0 0 0 0 0 0 0 0 0 0
25870 47 100 14C0 94 1 8C0 188 1000 F80 376 0 0 0 0 0 0 0 0 0 0 0 0
25871 48 1000 14C0 96 100 8C0 192 1 1100 384 0 0 0 0 0 0 0 0 0 0 0 0
25872 49 10000 14C0 98 10000 8C0 196 10000 1100 392 0 0 0 0 0 0 0 0 0 0 0 0
25873 50 100000 14C0 100 100 1700 200 10 1280 400 0 0 0 0 0 0 0 0 0 0 0 0
25874 51 1000000 200 102 10 740 204 100000 1280 408 0 0 0 0 0 0 0 0 0 0 0 0
25875 52 1 1340 104 1000 740 208 100 1400 416 0 0 0 0 0 0 0 0 0 0 0 0
25876 53 10 1340 106 100000 740 212 10000 1880 424 0 0 0 0 0 0 0 0 0 0 0 0
25877 54 100 1340 108 1 5C0 216 1000 1580 432 0 0 0 0 0 0 0 0 0 0 0 0
25878 55 1000 1340 110 100 5C0 220 1 17C0 440 0 0 0 0 0 0 0 0 0 0 0 0
25879 56 10000 1340 112 10000 5C0 224 10000 17C0 448 0 0 0 0 0 0 0 0 0 0 0 0
25880 57 100000 1340 114 10000 1700 228 10 1A00 456 0 0 0 0 0 0 0 0 0 0 0 0
25881 5810000000 200 116 10 440 232 100000 1A00 464 0 0 0 0 0 0 0 0 0 0 0 0
25882 59 1 11C0 118 1000 440 236 100 1B80 472 0 0 0 0 0 0 0 0 0 0 0 0
25883 60 10 11C0 120 100000 440 24000000000 1880 480 0 0 0 0 0 0 0 0 0 0 0 0
25884 61 100 11C0 122 1 2C0 244 1000 1D00 488 0 0 0 0 0 0 0 0 0 0 0 0
25885 62 1000 11C0 124 100 2C0 248 1 1E80 496 0 0 0 0 0 0 0 0 0 0 0 0
25886 63 10000 11C0 126 10000 2C0 252 10000 1E80 504 0 0 0 0 0 0 0 0 0 0 0 0
25887 64 100000 11C0 128 10 C80 256 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25888 6500000000 200 130 10 140 260 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25889 66 1 1040 132 1000 140 264 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25890 67 10 1040 134 100000 140 268 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25891 68 100 1040 136 1 380 272 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25892 69 1000 1040 138 100 380 276 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25893 70 10000 1040 140 10000 380 280 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25894 71 100000 1040 142 10 BC0 284 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25895 7200000000 200 144 10 500 288 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25896 73 1 EC0 146 1000 500 292 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25897 74 10 EC0 148 100000 500 296 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25898 75 100 EC0 150 1 680 300 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25899 76 1000 EC0 152 100 680 304 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25900 77 10000 EC0 154 10000 680 308 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25901 78 100000 EC0 156 1000 BC0 312 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25902 79 1 C80 158 10 800 316 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25903 80 1 D40 160 1000 800 320 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25904 81 10 D40 162 100000 800 324 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25905 82 100 D40 164 1 980 328 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25906 83 1000 D40 166 100 980 332 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25907 84 10000 D40 168 10000 980 336 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25908 85 100000 D40 170 100000 BC0 340 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25909 86 1 1700 172 10 B00 344 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25910 87 1 A40 174 1000 B00 348 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25911 88 10 A40 176 100000 B00 352 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25912 89 100 A40 178 1 E00 356 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25913 90 1000 A40 180 100 E00 360 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25914 91 10000 A40 182 10000 E00 364 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25915 92 100000 A40 184 1 1880 368 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25916 93 10 1700 186 10 F80 372 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25917 94 1 8C0 188 1000 F80 376 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25918 95 10 8C0 190 100000 F80 380 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25919 96 100 8C0 192 1 1100 384 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25920 97 1000 8C0 194 100 1100 388 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25921 98 10000 8C0 196 10000 1100 392 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25922 99 100000 8C0 198 100 1880 396 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25923 100 100 1700 200 10 1280 400 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25924 101 1 740 202 1000 1280 404 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25925 102 10 740 204 100000 1280 408 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25926 103 100 740 206 1 1400 412 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25927 104 1000 740 208 100 1400 416 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25928 105 10000 740 210 10000 1400 420 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25929 106 100000 740 212 10000 1880 424 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25930 107 1000 1700 214 10 1580 428 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25931 108 1 5C0 216 1000 1580 432 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25932 109 10 5C0 218 100000 1580 436 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25933 110 100 5C0 220 1 17C0 440 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25934 111 1000 5C0 222 100 17C0 444 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25935 112 10000 5C0 224 10000 17C0 448 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25936 113 100000 5C0 226 1000000 1880 452 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25937 114 10000 1700 228 10 1A00 456 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25938 115 1 440 230 1000 1A00 460 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25939 116 10 440 232 100000 1A00 464 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25940 117 100 440 234 1 1B80 468 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25941 118 1000 440 236 100 1B80 472 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25942 119 10000 440 238 10000 1B80 476 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25943 120 100000 440 24000000000 1880 480 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25944 121 100000 1700 242 10 1D00 484 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25945 122 1 2C0 244 1000 1D00 488 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25946 123 10 2C0 246 100000 1D00 492 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25947 124 100 2C0 248 1 1E80 496 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25948 125 1000 2C0 250 100 1E80 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25949 126 10000 2C0 252 10000 1E80 504 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25950 127 100000 2C0 254 1000000 1E80 508 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25951 END
25952  
25953 my $a = CreateArea;
25954 my $t = $a->CreateTree;
25955  
25956 my $N = K(key => 999);
25957 $N->for(sub
25958 {my ($index, $start, $next, $end) = @_;
25959 $t->put($index, $index);
25960 });
25961  
25962 $N->for(sub
25963 {my ($index, $start, $next, $end) = @_;
25964 $t->find($index);
25965 });
25966  
25967 ok Assemble eq => <<END, clocks=>763430;
25968 END
25969  
25970  
25971 =head3 Nasm::X86::Tree::findFirst($tree)
25972  
25973 Find the first element in a tree and set B<found>|B<key>|B<data>|B<subTree> to show the result.
25974  
25975 Parameter Description
25976 1 $tree Tree descriptor
25977  
25978 B<Example:>
25979  
25980  
25981 my $N = K(key => 32);
25982 my $a = CreateArea;
25983 my $t = $a->CreateTree;
25984  
25985 $N->for(sub
25986 {my ($i, $start, $next, $end) = @_;
25987 $t->put($i, $i);
25988 });
25989  
25990 $N->for(sub
25991 {my ($i, $start, $next, $end) = @_;
25992 $t->put($N + $i, $N + $i);
25993 $t->findFirst;
25994  
25995 If $t->key != $i,
25996 Then
25997 {PrintOutTraceBack "Reverse queue first failed at: "; $i->outNL;
25998 };
25999 $t->delete($i);
26000 If $t->size != $N,
26001 Then
26002 {PrintOutTraceBack "Reverse queue size failed at: "; $i->outNL;
26003 };
26004 $t->printInOrder("A");
26005 });
26006  
26007 ok Assemble eq => <<END, avx512=>1;
26008 A 32: 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
26009 A 32: 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21
26010 A 32: 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22
26011 A 32: 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23
26012 A 32: 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24
26013 A 32: 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25
26014 A 32: 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26
26015 A 32: 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
26016 A 32: 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28
26017 A 32: A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29
26018 A 32: B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A
26019 A 32: C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B
26020 A 32: D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C
26021 A 32: E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D
26022 A 32: F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E
26023 A 32: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
26024 A 32: 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30
26025 A 32: 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31
26026 A 32: 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32
26027 A 32: 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33
26028 A 32: 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34
26029 A 32: 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35
26030 A 32: 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36
26031 A 32: 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37
26032 A 32: 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38
26033 A 32: 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39
26034 A 32: 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A
26035 A 32: 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B
26036 A 32: 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C
26037 A 32: 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D
26038 A 32: 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E
26039 A 32: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
26040 END
26041  
26042  
26043 =head3 Nasm::X86::Tree::findLast($tree)
26044  
26045 Find the last key in a tree - crucial for stack like operations.
26046  
26047 Parameter Description
26048 1 $tree Tree descriptor
26049  
26050 B<Example:>
26051  
26052  
26053 my $N = K(key => 32);
26054 my $a = CreateArea;
26055 my $t = $a->CreateTree;
26056  
26057 $N->for(sub
26058 {my ($i, $start, $next, $end) = @_;
26059 $t->put($N + $i, $N + $i);
26060 });
26061  
26062 $N->for(sub
26063 {my ($i, $start, $next, $end) = @_;
26064 $t->put($N - $i, $N - $i);
26065 $t->findLast;
26066 $t->delete($t->key);
26067 If $t->size != $N - 1,
26068 Then
26069 {PrintOutTraceBack "Queued size failed at: "; $i->outNL;
26070 };
26071 $t->printInOrder("A");
26072 });
26073  
26074 ok Assemble eq => <<END, avx512=>1;
26075 A 31: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E
26076 A 31: 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D
26077 A 31: 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C
26078 A 31: 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B
26079 A 31: 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A
26080 A 31: 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39
26081 A 31: 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38
26082 A 31: 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37
26083 A 31: 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36
26084 A 31: 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35
26085 A 31: 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34
26086 A 31: 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33
26087 A 31: 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32
26088 A 31: 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31
26089 A 31: 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30
26090 A 31: 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
26091 A 31: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E
26092 A 31: F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D
26093 A 31: E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C
26094 A 31: D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B
26095 A 31: C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A
26096 A 31: B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29
26097 A 31: A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28
26098 A 31: 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
26099 A 31: 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26
26100 A 31: 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25
26101 A 31: 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24
26102 A 31: 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23
26103 A 31: 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22
26104 A 31: 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21
26105 A 31: 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
26106 A 31: 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
26107 END
26108  
26109  
26110 =head3 Nasm::X86::Tree::findNext($tree, $key)
26111  
26112 Find the next key greater than the one specified.
26113  
26114 Parameter Description
26115 1 $tree Tree descriptor
26116 2 $key Key
26117  
26118 B<Example:>
26119  
26120  
26121 my $a = CreateArea;
26122 my $t = $a->CreateTree;
26123 my $N = K loop => 8;
26124 $N->for(sub
26125 {my ($i) = @_;
26126 $t->put(2*$i, 2*$i);
26127 });
26128  
26129 (2*$N)->for(sub
26130 {my ($i) = @_;
26131 $i->outRightInDec(4); PrintOutString " -> ";
26132 $t->findNext($i);
26133 $t->found->out("f: ", " ");
26134 If $t->found > 0, Then {$t->key->out};
26135 PrintOutStringNL '.';
26136 });
26137  
26138 ok Assemble eq => <<END, avx512=>1;
26139 0 -> f: .... .... .... ...2 key : .... .... .... ...2.
26140 1 -> f: .... .... .... ...2 key : .... .... .... ...2.
26141 2 -> f: .... .... .... ...4 key : .... .... .... ...4.
26142 3 -> f: .... .... .... ...4 key : .... .... .... ...4.
26143 4 -> f: .... .... .... ...8 key : .... .... .... ...6.
26144 5 -> f: .... .... .... ...8 key : .... .... .... ...6.
26145 6 -> f: .... .... .... ..10 key : .... .... .... ...8.
26146 7 -> f: .... .... .... ..10 key : .... .... .... ...8.
26147 8 -> f: .... .... .... ..20 key : .... .... .... ...A.
26148 9 -> f: .... .... .... ..20 key : .... .... .... ...A.
26149 10 -> f: .... .... .... ..40 key : .... .... .... ...C.
26150 11 -> f: .... .... .... ..40 key : .... .... .... ...C.
26151 12 -> f: .... .... .... ..80 key : .... .... .... ...E.
26152 13 -> f: .... .... .... ..80 key : .... .... .... ...E.
26153 14 -> f: .... .... .... ...0 .
26154 15 -> f: .... .... .... ...0 .
26155 END
26156  
26157  
26158 =head3 Nasm::X86::Tree::findPrev($tree, $key)
26159  
26160 Find the previous key less than the one specified.
26161  
26162 Parameter Description
26163 1 $tree Tree descriptor
26164 2 $key Key
26165  
26166 B<Example:>
26167  
26168  
26169 my $a = CreateArea;
26170 my $t = $a->CreateTree;
26171 my $N = K loop => 8;
26172 $N->for(sub
26173 {my ($i) = @_;
26174 $t->put(2*$i, 2*$i);
26175 });
26176  
26177 (2*$N)->for(sub
26178 {my ($i) = @_;
26179 $i->outRightInDec(4); PrintOutString " -> ";
26180 $t->findPrev($i);
26181 $t->found->out("f: ", " ");
26182 If $t->found > 0, Then {$t->key->out};
26183 PrintOutStringNL '.';
26184 });
26185  
26186 ok Assemble eq => <<END, avx512=>1;
26187 0 -> f: .... .... .... ...0 .
26188 1 -> f: .... .... .... ...1 key : .... .... .... ...0.
26189 2 -> f: .... .... .... ...1 key : .... .... .... ...0.
26190 3 -> f: .... .... .... ...2 key : .... .... .... ...2.
26191 4 -> f: .... .... .... ...2 key : .... .... .... ...2.
26192 5 -> f: .... .... .... ...4 key : .... .... .... ...4.
26193 6 -> f: .... .... .... ...4 key : .... .... .... ...4.
26194 7 -> f: .... .... .... ...8 key : .... .... .... ...6.
26195 8 -> f: .... .... .... ...8 key : .... .... .... ...6.
26196 9 -> f: .... .... .... ..10 key : .... .... .... ...8.
26197 10 -> f: .... .... .... ..10 key : .... .... .... ...8.
26198 11 -> f: .... .... .... ..20 key : .... .... .... ...A.
26199 12 -> f: .... .... .... ..20 key : .... .... .... ...A.
26200 13 -> f: .... .... .... ..40 key : .... .... .... ...C.
26201 14 -> f: .... .... .... ..40 key : .... .... .... ...C.
26202 15 -> f: .... .... .... ..80 key : .... .... .... ...E.
26203 END
26204  
26205  
26206 =head3 Nasm::X86::Tree::findSubTree($tree, $key)
26207  
26208 Find a key in the specified tree and create a sub tree from the data field if possible.
26209  
26210 Parameter Description
26211 1 $tree Tree descriptor
26212 2 $key Key as a dword
26213  
26214 B<Example:>
26215  
26216  
26217 my $a = CreateArea;
26218 my $t = $a->CreateTree;
26219 my $T = $a->CreateTree;
26220  
26221 $t->put(1, $T);
26222 my $u = $t->findSubTree(1);
26223 $T->first->outNL;
26224 $u->first->outNL;
26225  
26226 ok Assemble eq => <<END, avx512=>1;
26227 first : .... .... .... ..80
26228 first : .... .... .... ..80
26229 END
26230  
26231  
26232 =head2 Sub trees
26233  
26234 Construct trees of trees - all private.
26235  
26236 =head2 Delete
26237  
26238 Delete a key from the tree
26239  
26240 =head3 Nasm::X86::Tree::delete($tree, $key)
26241  
26242 Find a key in a tree and delete it returning he value of the l=key deleted if found.
26243  
26244 Parameter Description
26245 1 $tree Tree descriptor
26246 2 $key Key field to delete
26247  
26248 B<Example:>
26249  
26250  
26251 my $a = CreateArea;
26252 my $t = $a->CreateTree;
26253  
26254 $t->put (K(key => 1), K(key => 0x11));
26255 $t->delete(K key => 1);
26256 $t->size->outNL;
26257  
26258 ok Assemble eq => <<END, avx512=>1;
26259 size of tree: .... .... .... ...0
26260 END
26261  
26262 my $a = CreateArea;
26263 my $t = $a->CreateTree;
26264 my $i2 = V k => 2; $t->put($i2, $i2);
26265 my $i3 = V k => 3; $t->put($i3, $i3);
26266 my $i4 = V k => 4; $t->put($i4, $i4);
26267 my $i1 = V k => 1; $t->put($i1, $i1);
26268 $t->size->outRightInDecNL(4); $t->dump("4"); $t->delete($i4);
26269 $t->size->outRightInDecNL(4); $t->dump("X"); $t->printInOrder("X");
26270  
26271 ok Assemble eq => <<END, avx512=>1;
26272 4
26273 4
26274 At: 80 length: 4, data: C0, nodes: 100, first: 40, root, leaf
26275 Index: 0 1 2 3
26276 Keys : 1 2 3 4
26277 Data : 1 2 3 4
26278 end
26279 3
26280 X
26281 At: 80 length: 3, data: C0, nodes: 100, first: 40, root, leaf
26282 Index: 0 1 2
26283 Keys : 1 2 3
26284 Data : 1 2 3
26285 end
26286 X 3: 1 2 3
26287 END
26288  
26289 my $a = CreateArea;
26290 my $t = $a->CreateTree;
26291 my $i20 = V k => 20; $t->put($i20, $i20);
26292 my $i30 = V k => 30; $t->put($i30, $i30);
26293 my $i40 = V k => 40; $t->put($i40, $i40);
26294 my $i10 = V k => 10; $t->put($i10, $i10);
26295 my $i31 = V k => 31; $t->put($i31, $i31);
26296 my $i32 = V k => 32; $t->put($i32, $i32);
26297 my $i33 = V k => 33; $t->put($i33, $i33);
26298 $t->size->outRightInDecNL(4); $t->dump("33"); $t->delete($i33);
26299 $t->size->outRightInDecNL(4); $t->dump("40"); $t->delete($i40);
26300 $t->size->outRightInDecNL(4); $t->dump("X"); $t->printInOrder("X");
26301  
26302 ok Assemble eq => <<END, avx512=>1;
26303 7
26304 33
26305 At: 80 length: 7, data: C0, nodes: 100, first: 40, root, leaf
26306 Index: 0 1 2 3 4 5 6
26307 Keys : A 14 1E 1F 20 21 28
26308 Data : 10 20 30 31 32 33 40
26309 end
26310 6
26311 40
26312 At: 80 length: 6, data: C0, nodes: 100, first: 40, root, leaf
26313 Index: 0 1 2 3 4 5
26314 Keys : A 14 1E 1F 20 28
26315 Data : 10 20 30 31 32 40
26316 end
26317 5
26318 X
26319 At: 80 length: 5, data: C0, nodes: 100, first: 40, root, leaf
26320 Index: 0 1 2 3 4
26321 Keys : A 14 1E 1F 20
26322 Data : 10 20 30 31 32
26323 end
26324 X 5: A 14 1E 1F 20
26325 END
26326  
26327 my $a = CreateArea;
26328 my $t = $a->CreateTree;
26329 my $i1 = V k => 0; $t->put($i1, $i1);
26330 my $i2 = V k => 11; $t->put($i2, $i2);
26331 my $i3 = V k => 13; $t->put($i3, $i3);
26332 my $i4 = V k => 15; $t->put($i4, $i4);
26333 $t->size->outRightInDecNL(4);
26334 $t->dump("1");
26335 $a->dump("AAA", K blocks => 12);
26336 $t->delete($i2);
26337 $t->size->outRightInDecNL(4); $t->dump("X"); $t->printInOrder("X");
26338  
26339 ok Assemble eq => <<END, avx512=>1;
26340 4
26341 1
26342 At: 80 length: 4, data: C0, nodes: 100, first: 40, root, leaf
26343 Index: 0 1 2 3
26344 Keys : 0 B D F
26345 Data : 0 11 13 15
26346 end
26347 AAA
26348 Area Size: 4096 Used: 320
26349 .... .... .... ...0 | __10 ____ ____ ____ 40.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26350 .... .... .... ..40 | 80__ ____ ____ ____ .4__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26351 .... .... .... ..80 | ____ ____ .B__ ____ .D__ ____ .F__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .4__ ____ C0__ ____
26352 .... .... .... ..C0 | ____ ____ .B__ ____ .D__ ____ .F__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __.1 ____
26353 .... .... .... .1.. | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ 40__ ____
26354 .... .... .... .140 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26355 .... .... .... .180 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26356 .... .... .... .1C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26357 .... .... .... .2.. | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26358 .... .... .... .240 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26359 .... .... .... .280 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26360 .... .... .... .2C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26361 3
26362 X
26363 At: 80 length: 3, data: C0, nodes: 100, first: 40, root, leaf
26364 Index: 0 1 2
26365 Keys : 0 D F
26366 Data : 0 13 15
26367 end
26368 X 3: 0 D F
26369 END
26370  
26371 my $a = CreateArea;
26372 my $t = $a->CreateTree;
26373 my $i1 = V k => 1; $t->put($i1, $i1);
26374 my $i2 = V k => 2; $t->put($i2, $i2);
26375 my $i3 = V k => 3; $t->put($i3, $i3);
26376 my $i4 = V k => 4; $t->put($i4, $i4);
26377 $t->size->outRightInDecNL(4); $t->dump("1"); $a->dump("AAA", K blocks => 12); $t->delete($i1);
26378 $t->size->outRightInDecNL(4); $t->dump("X"); $t->printInOrder("X");
26379  
26380 ok Assemble eq => <<END, avx512=>1;
26381 4
26382 1
26383 At: 80 length: 4, data: C0, nodes: 100, first: 40, root, leaf
26384 Index: 0 1 2 3
26385 Keys : 1 2 3 4
26386 Data : 1 2 3 4
26387 end
26388 AAA
26389 Area Size: 4096 Used: 320
26390 .... .... .... ...0 | __10 ____ ____ ____ 40.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26391 .... .... .... ..40 | 80__ ____ ____ ____ .4__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26392 .... .... .... ..80 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .4__ ____ C0__ ____
26393 .... .... .... ..C0 | .1__ ____ .2__ ____ .3__ ____ .4__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __.1 ____
26394 .... .... .... .1.. | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ 40__ ____
26395 .... .... .... .140 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26396 .... .... .... .180 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26397 .... .... .... .1C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26398 .... .... .... .2.. | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26399 .... .... .... .240 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26400 .... .... .... .280 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26401 .... .... .... .2C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
26402 3
26403 X
26404 At: 80 length: 3, data: C0, nodes: 100, first: 40, root, leaf
26405 Index: 0 1 2
26406 Keys : 2 3 4
26407 Data : 2 3 4
26408 end
26409 X 3: 2 3 4
26410 END
26411  
26412 my $a = CreateArea;
26413 my $t = $a->CreateTree;
26414 my $i1 = V k => 1; $t->put($i1, $i1);
26415 my $i2 = V k => 2; $t->put($i2, $i2);
26416 my $i3 = V k => 3; $t->put($i3, $i3);
26417 my $i4 = V k => 4; $t->put($i4, $i4);
26418 $t->size->outRightInDecNL(4); $t->dump("2"); $t->delete($i2);
26419 $t->size->outRightInDecNL(4); $t->dump("X"); $t->printInOrder("X");
26420  
26421 ok Assemble eq => <<END, avx512=>1;
26422 4
26423 2
26424 At: 80 length: 4, data: C0, nodes: 100, first: 40, root, leaf
26425 Index: 0 1 2 3
26426 Keys : 1 2 3 4
26427 Data : 1 2 3 4
26428 end
26429 3
26430 X
26431 At: 80 length: 3, data: C0, nodes: 100, first: 40, root, leaf
26432 Index: 0 1 2
26433 Keys : 1 3 4
26434 Data : 1 3 4
26435 end
26436 X 3: 1 3 4
26437 END
26438  
26439 my $a = CreateArea;
26440 my $t = $a->CreateTree;
26441 my $i1 = V k => 1; $t->put($i1, $i1);
26442 my $i2 = V k => 2; $t->put($i2, $i2);
26443 my $i3 = V k => 3; $t->put($i3, $i3);
26444 my $i4 = V k => 4; $t->put($i4, $i4);
26445 $t->size->outRightInDecNL(4); $t->dump("3"); $t->delete($i3);
26446 $t->size->outRightInDecNL(4); $t->dump("X"); $t->printInOrder("X");
26447  
26448 ok Assemble eq => <<END, avx512=>1;
26449 4
26450 3
26451 At: 80 length: 4, data: C0, nodes: 100, first: 40, root, leaf
26452 Index: 0 1 2 3
26453 Keys : 1 2 3 4
26454 Data : 1 2 3 4
26455 end
26456 3
26457 X
26458 At: 80 length: 3, data: C0, nodes: 100, first: 40, root, leaf
26459 Index: 0 1 2
26460 Keys : 1 2 4
26461 Data : 1 2 4
26462 end
26463 X 3: 1 2 4
26464 END
26465  
26466 my $a = CreateArea;
26467 my $t = $a->CreateTree;
26468 my $i1 = V k => 1; $t->put($i1, $i1);
26469 my $i2 = V k => 2; $t->put($i2, $i2);
26470 my $i3 = V k => 3; $t->put($i3, $i3);
26471 my $i4 = V k => 4; $t->put($i4, $i4);
26472 $t->size->outRightInDecNL(4); $t->dump("4"); $t->delete($i4);
26473 $t->size->outRightInDecNL(4); $t->dump("X"); $t->printInOrder("X");
26474  
26475 ok Assemble eq => <<END, avx512=>1;
26476 4
26477 4
26478 At: 80 length: 4, data: C0, nodes: 100, first: 40, root, leaf
26479 Index: 0 1 2 3
26480 Keys : 1 2 3 4
26481 Data : 1 2 3 4
26482 end
26483 3
26484 X
26485 At: 80 length: 3, data: C0, nodes: 100, first: 40, root, leaf
26486 Index: 0 1 2
26487 Keys : 1 2 3
26488 Data : 1 2 3
26489 end
26490 X 3: 1 2 3
26491 END
26492  
26493 my $a = CreateArea;
26494 my $t = $a->CreateTree;
26495 my $i2 = V k => 2; $t->put($i2, $i2);
26496 my $i1 = V k => 1; $t->put($i1, $i1);
26497 my $i3 = V k => 3; $t->put($i3, $i3);
26498 my $i4 = V k => 4; $t->put($i4, $i4);
26499 $t->size->outRightInDecNL(4); $t->dump("0"); $t->delete($i2);
26500 $t->size->outRightInDecNL(4); $t->dump("2"); $t->delete($i3);
26501 $t->size->outRightInDecNL(4); $t->dump("3"); $t->delete($i4);
26502 $t->size->outRightInDecNL(4); $t->dump("4"); $t->delete($i1);
26503 $t->size->outRightInDecNL(4); $t->dump("1");
26504  
26505 ok Assemble eq => <<END, avx512=>1;
26506 4
26507 0
26508 At: 80 length: 4, data: C0, nodes: 100, first: 40, root, leaf
26509 Index: 0 1 2 3
26510 Keys : 1 2 3 4
26511 Data : 1 2 3 4
26512 end
26513 3
26514 2
26515 At: 80 length: 3, data: C0, nodes: 100, first: 40, root, leaf
26516 Index: 0 1 2
26517 Keys : 1 3 4
26518 Data : 1 3 4
26519 end
26520 2
26521 3
26522 At: 80 length: 2, data: C0, nodes: 100, first: 40, root, leaf
26523 Index: 0 1
26524 Keys : 1 4
26525 Data : 1 4
26526 end
26527 1
26528 4
26529 At: 80 length: 1, data: C0, nodes: 100, first: 40, root, leaf
26530 Index: 0
26531 Keys : 1
26532 Data : 1
26533 end
26534 0
26535 1
26536 - empty
26537 END
26538  
26539 my $a = CreateArea;
26540 my $t = $a->CreateTree;
26541 $t->put( K(k=>1), K(d=>11));
26542 $t->put( K(k=>2), K(d=>22));
26543 $t->put( K(k=>3), K(d=>33));
26544 $t->delete(K k=>1); $t->dump("1");
26545 $t->delete(K k=>3); $t->dump("3");
26546 $t->delete(K k=>2); $t->dump("2");
26547 ok Assemble eq => <<END, label=>'t4';
26548 1
26549 At: 80 length: 2, data: C0, nodes: 100, first: 40, root, leaf
26550 Index: 0 1
26551 Keys : 2 3
26552 Data : 22 33
26553 end
26554 3
26555 At: 80 length: 1, data: C0, nodes: 100, first: 40, root, leaf
26556 Index: 0
26557 Keys : 2
26558 Data : 22
26559 end
26560 2
26561 - empty
26562 END
26563  
26564 my $a = CreateArea;
26565 my $t = $a->CreateTree;
26566 $t->put( K(k=>1), K(d=>11));
26567 $t->put( K(k=>2), K(d=>22));
26568 $t->put( K(k=>3), K(d=>33));
26569 $t->put( K(k=>4), K(d=>44));
26570 $t->dump("0");
26571 $t->delete(K k=>1);
26572 $t->dump("1");
26573 $t->delete(K k=>2);
26574 $t->dump("2");
26575 $t->delete(K k=>3);
26576 $t->dump("3");
26577 $t->delete(K k=>4);
26578 $t->dump("4");
26579 ok Assemble eq => <<END, avx512=>1;
26580 0
26581 At: 80 length: 4, data: C0, nodes: 100, first: 40, root, leaf
26582 Index: 0 1 2 3
26583 Keys : 1 2 3 4
26584 Data : 11 22 33 44
26585 end
26586 1
26587 At: 80 length: 3, data: C0, nodes: 100, first: 40, root, leaf
26588 Index: 0 1 2
26589 Keys : 2 3 4
26590 Data : 22 33 44
26591 end
26592 2
26593 At: 80 length: 2, data: C0, nodes: 100, first: 40, root, leaf
26594 Index: 0 1
26595 Keys : 3 4
26596 Data : 33 44
26597 end
26598 3
26599 At: 80 length: 1, data: C0, nodes: 100, first: 40, root, leaf
26600 Index: 0
26601 Keys : 4
26602 Data : 44
26603 end
26604 4
26605 - empty
26606 END
26607  
26608 my $a = CreateArea;
26609 my $t = $a->CreateTree;
26610 $t->put( K(k=>1), K(d=>11));
26611 $t->put( K(k=>2), K(d=>22));
26612 $t->put( K(k=>3), K(d=>33));
26613 $t->put( K(k=>4), K(d=>44));
26614 $t->dump("0");
26615 $t->delete(K k=>3);
26616 $t->dump("3");
26617 $t->delete(K k=>4);
26618 $t->dump("4");
26619 $t->delete(K k=>2);
26620 $t->dump("2");
26621 $t->delete(K k=>1);
26622 $t->dump("1");
26623 ok Assemble eq => <<END, avx512=>1;
26624 0
26625 At: 80 length: 4, data: C0, nodes: 100, first: 40, root, leaf
26626 Index: 0 1 2 3
26627 Keys : 1 2 3 4
26628 Data : 11 22 33 44
26629 end
26630 3
26631 At: 80 length: 3, data: C0, nodes: 100, first: 40, root, leaf
26632 Index: 0 1 2
26633 Keys : 1 2 4
26634 Data : 11 22 44
26635 end
26636 4
26637 At: 80 length: 2, data: C0, nodes: 100, first: 40, root, leaf
26638 Index: 0 1
26639 Keys : 1 2
26640 Data : 11 22
26641 end
26642 2
26643 At: 80 length: 1, data: C0, nodes: 100, first: 40, root, leaf
26644 Index: 0
26645 Keys : 1
26646 Data : 11
26647 end
26648 1
26649 - empty
26650 END
26651  
26652 my $a = CreateArea;
26653 my $t = $a->CreateTree;
26654 my $i1 = V k => 1; $t->put($i1, $i1);
26655 my $i2 = V k => 2; $t->put($i2, $i2);
26656 my $i3 = V k => 3; $t->put($i3, $i3);
26657 my $i4 = V k => 4; $t->put($i4, $i4);
26658 my $i5 = V k => 5; $t->put($i5, $i5);
26659 my $i6 = V k => 6; $t->put($i6, $i6);
26660 my $i7 = V k => 7; $t->put($i7, $i7);
26661 my $i8 = V k => 8; $t->put($i8, $i8);
26662 $t->size->outRightInDecNL(4); $t->dump("1"); $t->delete($i1);
26663 $t->size->outRightInDecNL(4); $t->dump("2"); $t->delete($i2);
26664 $t->size->outRightInDecNL(4); $t->dump("3"); $t->delete($i3);
26665 $t->size->outRightInDecNL(4); $t->dump("4"); $t->delete($i4);
26666 $t->size->outRightInDecNL(4); $t->dump("5"); $t->delete($i5);
26667 $t->size->outRightInDecNL(4); $t->dump("6"); $t->delete($i6);
26668 $t->size->outRightInDecNL(4); $t->dump("7"); $t->delete($i7);
26669 $t->size->outRightInDecNL(4); $t->dump("8"); $t->delete($i8);
26670 $t->size->outRightInDecNL(4);
26671 $t->dump("X");
26672  
26673 ok Assemble eq => <<END, avx512=>1;
26674 8
26675 1
26676 At: 80 length: 8, data: C0, nodes: 100, first: 40, root, leaf
26677 Index: 0 1 2 3 4 5 6 7
26678 Keys : 1 2 3 4 5 6 7 8
26679 Data : 1 2 3 4 5 6 7 8
26680 end
26681 7
26682 2
26683 At: 80 length: 7, data: C0, nodes: 100, first: 40, root, leaf
26684 Index: 0 1 2 3 4 5 6
26685 Keys : 2 3 4 5 6 7 8
26686 Data : 2 3 4 5 6 7 8
26687 end
26688 6
26689 3
26690 At: 80 length: 6, data: C0, nodes: 100, first: 40, root, leaf
26691 Index: 0 1 2 3 4 5
26692 Keys : 3 4 5 6 7 8
26693 Data : 3 4 5 6 7 8
26694 end
26695 5
26696 4
26697 At: 80 length: 5, data: C0, nodes: 100, first: 40, root, leaf
26698 Index: 0 1 2 3 4
26699 Keys : 4 5 6 7 8
26700 Data : 4 5 6 7 8
26701 end
26702 4
26703 5
26704 At: 80 length: 4, data: C0, nodes: 100, first: 40, root, leaf
26705 Index: 0 1 2 3
26706 Keys : 5 6 7 8
26707 Data : 5 6 7 8
26708 end
26709 3
26710 6
26711 At: 80 length: 3, data: C0, nodes: 100, first: 40, root, leaf
26712 Index: 0 1 2
26713 Keys : 6 7 8
26714 Data : 6 7 8
26715 end
26716 2
26717 7
26718 At: 80 length: 2, data: C0, nodes: 100, first: 40, root, leaf
26719 Index: 0 1
26720 Keys : 7 8
26721 Data : 7 8
26722 end
26723 1
26724 8
26725 At: 80 length: 1, data: C0, nodes: 100, first: 40, root, leaf
26726 Index: 0
26727 Keys : 8
26728 Data : 8
26729 end
26730 0
26731 X
26732 - empty
26733 END
26734  
26735 my $a = CreateArea;
26736 my $t = $a->CreateTree;
26737 my $N = K loop => 20;
26738 $N->for(sub # Load tree
26739 {my ($i) = @_;
26740 $t->put($i, $i);
26741 });
26742 $t->size->outNL; $t->printInOrder("AA");
26743 $t->delete(K k => 0); $t->printInOrder(" 0");
26744 $t->delete(K k => 9); $t->printInOrder(" 9");
26745 $t->delete(K k => 1); $t->printInOrder(" 1");
26746 $t->delete(K k => 8); $t->printInOrder(" 8");
26747 $t->delete(K k => 2); $t->printInOrder(" 2");
26748 $t->delete(K k => 7); $t->printInOrder(" 7");
26749 $t->delete(K k => 3); $t->printInOrder(" 3");
26750 $t->delete(K k => 6); $t->printInOrder(" 6");
26751 $t->delete(K k => 4); $t->printInOrder(" 4");
26752 $t->delete(K k => 5); $t->printInOrder(" 5");
26753 $t->delete(K k => 10); $t->printInOrder("10");
26754 $t->delete(K k => 19); $t->printInOrder("19");
26755 $t->delete(K k => 11); $t->printInOrder("11");
26756 $t->delete(K k => 18); $t->printInOrder("18");
26757 $t->delete(K k => 12); $t->printInOrder("12");
26758 $t->delete(K k => 17); $t->printInOrder("17");
26759 $t->delete(K k => 13); $t->printInOrder("13");
26760 $t->delete(K k => 16); $t->printInOrder("16");
26761 $t->delete(K k => 14); $t->printInOrder("14");
26762 $t->delete(K k => 15); $t->printInOrder("15");
26763  
26764 ok Assemble eq => <<END, avx512=>1;
26765 size of tree: .... .... .... ..14
26766 AA 20: 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13
26767 0 19: 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13
26768 9 18: 1 2 3 4 5 6 7 8 A B C D E F 10 11 12 13
26769 1 17: 2 3 4 5 6 7 8 A B C D E F 10 11 12 13
26770 8 16: 2 3 4 5 6 7 A B C D E F 10 11 12 13
26771 2 15: 3 4 5 6 7 A B C D E F 10 11 12 13
26772 7 14: 3 4 5 6 A B C D E F 10 11 12 13
26773 3 13: 4 5 6 A B C D E F 10 11 12 13
26774 6 12: 4 5 A B C D E F 10 11 12 13
26775 4 11: 5 A B C D E F 10 11 12 13
26776 5 10: A B C D E F 10 11 12 13
26777 10 9: B C D E F 10 11 12 13
26778 19 8: B C D E F 10 11 12
26779 11 7: C D E F 10 11 12
26780 18 6: C D E F 10 11
26781 12 5: D E F 10 11
26782 17 4: D E F 10
26783 13 3: E F 10
26784 16 2: E F
26785 14 1: F
26786 15- empty
26787 END
26788  
26789 my $a = CreateArea;
26790 my $t = $a->CreateTree;
26791 my $N = K loop => 16;
26792 $N->for(sub
26793 {my ($i) = @_;
26794 $t->put($i, $i);
26795 });
26796 $t->printInOrder(" 0"); $t->delete(K k => 0);
26797 $t->printInOrder(" 2"); $t->delete(K k => 2);
26798 $t->printInOrder(" 4"); $t->delete(K k => 4);
26799 $t->printInOrder(" 6"); $t->delete(K k => 6);
26800 $t->printInOrder(" 8"); $t->delete(K k => 8);
26801 $t->printInOrder("10"); $t->delete(K k => 10);
26802 $t->printInOrder("12"); $t->delete(K k => 12);
26803 $t->printInOrder("14"); $t->delete(K k => 14);
26804 $t->printInOrder(" 1"); $t->delete(K k => 1);
26805 $t->printInOrder(" 3"); $t->delete(K k => 3);
26806 $t->printInOrder(" 5"); $t->delete(K k => 5);
26807 $t->printInOrder(" 7"); $t->delete(K k => 7);
26808 $t->printInOrder(" 9"); $t->delete(K k => 9);
26809 $t->printInOrder("11"); $t->delete(K k => 11);
26810 $t->printInOrder("13"); $t->delete(K k => 13);
26811 $t->printInOrder("15"); $t->delete(K k => 15);
26812 $t->printInOrder("XX");
26813  
26814 ok Assemble eq => <<END, avx512=>1;
26815 0 16: 0 1 2 3 4 5 6 7 8 9 A B C D E F
26816 2 15: 1 2 3 4 5 6 7 8 9 A B C D E F
26817 4 14: 1 3 4 5 6 7 8 9 A B C D E F
26818 6 13: 1 3 5 6 7 8 9 A B C D E F
26819 8 12: 1 3 5 7 8 9 A B C D E F
26820 10 11: 1 3 5 7 9 A B C D E F
26821 12 10: 1 3 5 7 9 B C D E F
26822 14 9: 1 3 5 7 9 B D E F
26823 1 8: 1 3 5 7 9 B D F
26824 3 7: 3 5 7 9 B D F
26825 5 6: 5 7 9 B D F
26826 7 5: 7 9 B D F
26827 9 4: 9 B D F
26828 11 3: B D F
26829 13 2: D F
26830 15 1: F
26831 XX- empty
26832 END
26833  
26834 my $a = CreateArea;
26835 my $t = $a->CreateTree;
26836 my $N = K max => 8;
26837  
26838 $N->for(sub # Load tree
26839 {my ($i) = @_;
26840 $t->put( $i, 2 * $i);
26841 $t->put(2 * $N - $i - 1, 2 * ($N - $i));
26842 });
26843 # $t->printInOrder("Full");
26844  
26845 ($N-1)->for(sub # Delete elements
26846 {my ($i) = @_;
26847 my $n1 = ($N + $i)->clone("1111"); my $n2 = ($N - $i - 1)->clone("2222");
26848  
26849 $n1->outNL;
26850 $t->delete($n1);
26851 $t->printInOrder("1111");
26852  
26853 $n2->outNL;
26854 $t->delete($n2);
26855 $t->printInOrder("2222");
26856 });
26857 $t->dump("Two:");
26858 $t->size->outRightInDecNL(4);
26859  
26860 ok Assemble eq => <<END, avx512=>1;
26861 1111: .... .... .... ...8
26862 1111 15: 0 1 2 3 4 5 6 7 9 A B C D E F
26863 2222: .... .... .... ...7
26864 2222 14: 0 1 2 3 4 5 6 9 A B C D E F
26865 1111: .... .... .... ...9
26866 1111 13: 0 1 2 3 4 5 6 A B C D E F
26867 2222: .... .... .... ...6
26868 2222 12: 0 1 2 3 4 5 A B C D E F
26869 1111: .... .... .... ...A
26870 1111 11: 0 1 2 3 4 5 B C D E F
26871 2222: .... .... .... ...5
26872 2222 10: 0 1 2 3 4 B C D E F
26873 1111: .... .... .... ...B
26874 1111 9: 0 1 2 3 4 C D E F
26875 2222: .... .... .... ...4
26876 2222 8: 0 1 2 3 C D E F
26877 1111: .... .... .... ...C
26878 1111 7: 0 1 2 3 D E F
26879 2222: .... .... .... ...3
26880 2222 6: 0 1 2 D E F
26881 1111: .... .... .... ...D
26882 1111 5: 0 1 2 E F
26883 2222: .... .... .... ...2
26884 2222 4: 0 1 E F
26885 1111: .... .... .... ...E
26886 1111 3: 0 1 F
26887 2222: .... .... .... ...1
26888 2222 2: 0 F
26889 Two:
26890 At: 80 length: 2, data: C0, nodes: 100, first: 40, root, leaf
26891 Index: 0 1
26892 Keys : 0 F
26893 Data : 0 16
26894 end
26895 2
26896 END
26897  
26898 my $a = CreateArea;
26899 my $t = $a->CreateTree;
26900 my $N = K max => 100;
26901  
26902 $N->for(sub # Load tree
26903 {my ($index, $start, $next, $end) = @_;
26904 $t->put($index, 2 * $index);
26905 If $t->size != $index + 1,
26906 Then
26907 {PrintOutStringNL "SSSS"; $index->outNL; Exit(0);
26908 };
26909 });
26910  
26911 $N->for(sub # Check elements
26912 {my ($i) = @_;
26913 $t->find($i);
26914 If $t->found == 0,
26915 Then
26916 {PrintOutStringNL "AAAA"; $i->outNL; Exit(0);
26917 };
26918 });
26919  
26920 $N->for(sub # Delete elements
26921 {my ($i) = @_;
26922 $t->delete($i);
26923  
26924 If $t->size != $N - $i - 1,
26925 Then
26926 {PrintOutStringNL "TTTT"; $i->outNL; Exit(0);
26927 };
26928  
26929 $N->for(sub # Check elements
26930 {my ($j) = @_;
26931 $t->find($j);
26932 If $t->found == 0,
26933 Then
26934 {If $j > $i,
26935 Then
26936 {PrintOutStringNL "BBBBB"; $j->outNL; Exit(0); # Not deleted yet so it should be findable
26937 };
26938 },
26939 Else
26940 {If $j <= $i,
26941 Then
26942 {PrintOutStringNL "CCCCC"; $j->outNL; Exit(0); # Deleted so should not be findable
26943 };
26944 };
26945 });
26946 });
26947  
26948 ok Assemble eq => <<END, avx512=>1;
26949 END
26950  
26951 my $a = CreateArea;
26952 my $t = $a->CreateTree;
26953 my $N = K loop => 16;
26954 $N->for(sub
26955 {my ($i) = @_;
26956 $t->put($i, $i);
26957 });
26958 ($N/2)->for(sub
26959 {my ($i) = @_;
26960 $t->printInOrder("AAAA");
26961 $t->delete($i * 2);
26962 });
26963 ($N/2)->for(sub
26964 {my ($i) = @_;
26965 $t->printInOrder("BBBB");
26966 $t->delete($i * 2 + 1);
26967 });
26968 $t->printInOrder("CCCC");
26969  
26970 ok Assemble eq => <<END, avx512=>1;
26971 AAAA 16: 0 1 2 3 4 5 6 7 8 9 A B C D E F
26972 AAAA 15: 1 2 3 4 5 6 7 8 9 A B C D E F
26973 AAAA 14: 1 3 4 5 6 7 8 9 A B C D E F
26974 AAAA 13: 1 3 5 6 7 8 9 A B C D E F
26975 AAAA 12: 1 3 5 7 8 9 A B C D E F
26976 AAAA 11: 1 3 5 7 9 A B C D E F
26977 AAAA 10: 1 3 5 7 9 B C D E F
26978 AAAA 9: 1 3 5 7 9 B D E F
26979 BBBB 8: 1 3 5 7 9 B D F
26980 BBBB 7: 3 5 7 9 B D F
26981 BBBB 6: 5 7 9 B D F
26982 BBBB 5: 7 9 B D F
26983 BBBB 4: 9 B D F
26984 BBBB 3: B D F
26985 BBBB 2: D F
26986 BBBB 1: F
26987 CCCC- empty
26988 END
26989  
26990 my $a = CreateArea;
26991 my $t = $a->CreateTree;
26992 my $N = K loop => 36;
26993 $N->for(sub
26994 {my ($i) = @_;
26995 $t->put($i, $i);
26996 });
26997 $t->delete(K 1 => 0); $t->printInOrder(" 0");
26998 $t->delete(K 1 => 5); $t->printInOrder(" 5");
26999 $t->delete(K 1 => 10); $t->printInOrder("10");
27000 $t->delete(K 1 => 15); $t->printInOrder("15");
27001 $t->delete(K 1 => 20); $t->printInOrder("20");
27002 $t->delete(K 1 => 25); $t->printInOrder("25");
27003 $t->delete(K 1 => 30); $t->printInOrder("30");
27004 $t->delete(K 1 => 35); $t->printInOrder("35");
27005  
27006 $t->delete(K 1 => 1); $t->printInOrder(" 1");
27007 $t->delete(K 1 => 6); $t->printInOrder(" 6");
27008 $t->delete(K 1 => 11); $t->printInOrder("11");
27009 $t->delete(K 1 => 16); $t->printInOrder("16");
27010 $t->delete(K 1 => 21); $t->printInOrder("21");
27011 $t->delete(K 1 => 26); $t->printInOrder("26");
27012 $t->delete(K 1 => 31); $t->printInOrder("31");
27013  
27014 $t->delete(K 1 => 2); $t->printInOrder(" 2");
27015 $t->delete(K 1 => 7); $t->printInOrder(" 7");
27016 $t->delete(K 1 => 12); $t->printInOrder("12");
27017 $t->delete(K 1 => 17); $t->printInOrder("17");
27018 $t->delete(K 1 => 22); $t->printInOrder("22");
27019 $t->delete(K 1 => 27); $t->printInOrder("27");
27020 $t->delete(K 1 => 32); $t->printInOrder("32");
27021  
27022 $t->delete(K 1 => 3); $t->printInOrder(" 3");
27023 $t->delete(K 1 => 8); $t->printInOrder(" 8");
27024 $t->delete(K 1 => 13); $t->printInOrder("13");
27025 $t->delete(K 1 => 18); $t->printInOrder("18");
27026 $t->delete(K 1 => 23); $t->printInOrder("23");
27027 $t->delete(K 1 => 28); $t->printInOrder("28");
27028 $t->delete(K 1 => 33); $t->printInOrder("33");
27029  
27030 $t->delete(K 1 => 4); $t->printInOrder(" 4");
27031 $t->delete(K 1 => 9); $t->printInOrder(" 9");
27032 $t->delete(K 1 => 14); $t->printInOrder("14");
27033 $t->delete(K 1 => 19); $t->printInOrder("19");
27034 $t->delete(K 1 => 24); $t->printInOrder("24");
27035 $t->delete(K 1 => 29); $t->printInOrder("29");
27036 $t->delete(K 1 => 34); $t->printInOrder("34");
27037  
27038 ok Assemble eq => <<END, avx512=>1;
27039 0 35: 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23
27040 5 34: 1 2 3 4 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23
27041 10 33: 1 2 3 4 6 7 8 9 B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23
27042 15 32: 1 2 3 4 6 7 8 9 B C D E 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23
27043 20 31: 1 2 3 4 6 7 8 9 B C D E 10 11 12 13 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23
27044 25 30: 1 2 3 4 6 7 8 9 B C D E 10 11 12 13 15 16 17 18 1A 1B 1C 1D 1E 1F 20 21 22 23
27045 30 29: 1 2 3 4 6 7 8 9 B C D E 10 11 12 13 15 16 17 18 1A 1B 1C 1D 1F 20 21 22 23
27046 35 28: 1 2 3 4 6 7 8 9 B C D E 10 11 12 13 15 16 17 18 1A 1B 1C 1D 1F 20 21 22
27047 1 27: 2 3 4 6 7 8 9 B C D E 10 11 12 13 15 16 17 18 1A 1B 1C 1D 1F 20 21 22
27048 6 26: 2 3 4 7 8 9 B C D E 10 11 12 13 15 16 17 18 1A 1B 1C 1D 1F 20 21 22
27049 11 25: 2 3 4 7 8 9 C D E 10 11 12 13 15 16 17 18 1A 1B 1C 1D 1F 20 21 22
27050 16 24: 2 3 4 7 8 9 C D E 11 12 13 15 16 17 18 1A 1B 1C 1D 1F 20 21 22
27051 21 23: 2 3 4 7 8 9 C D E 11 12 13 16 17 18 1A 1B 1C 1D 1F 20 21 22
27052 26 22: 2 3 4 7 8 9 C D E 11 12 13 16 17 18 1B 1C 1D 1F 20 21 22
27053 31 21: 2 3 4 7 8 9 C D E 11 12 13 16 17 18 1B 1C 1D 20 21 22
27054 2 20: 3 4 7 8 9 C D E 11 12 13 16 17 18 1B 1C 1D 20 21 22
27055 7 19: 3 4 8 9 C D E 11 12 13 16 17 18 1B 1C 1D 20 21 22
27056 12 18: 3 4 8 9 D E 11 12 13 16 17 18 1B 1C 1D 20 21 22
27057 17 17: 3 4 8 9 D E 12 13 16 17 18 1B 1C 1D 20 21 22
27058 22 16: 3 4 8 9 D E 12 13 17 18 1B 1C 1D 20 21 22
27059 27 15: 3 4 8 9 D E 12 13 17 18 1C 1D 20 21 22
27060 32 14: 3 4 8 9 D E 12 13 17 18 1C 1D 21 22
27061 3 13: 4 8 9 D E 12 13 17 18 1C 1D 21 22
27062 8 12: 4 9 D E 12 13 17 18 1C 1D 21 22
27063 13 11: 4 9 E 12 13 17 18 1C 1D 21 22
27064 18 10: 4 9 E 13 17 18 1C 1D 21 22
27065 23 9: 4 9 E 13 18 1C 1D 21 22
27066 28 8: 4 9 E 13 18 1D 21 22
27067 33 7: 4 9 E 13 18 1D 22
27068 4 6: 9 E 13 18 1D 22
27069 9 5: E 13 18 1D 22
27070 14 4: 13 18 1D 22
27071 19 3: 18 1D 22
27072 24 2: 1D 22
27073 29 1: 22
27074 34- empty
27075 END
27076  
27077  
27078 =head3 Nasm::X86::Tree::clear($tree)
27079  
27080 Delete everything in the tree except the first block recording any memory liberated on the free chain.
27081  
27082 Parameter Description
27083 1 $tree Tree
27084  
27085 B<Example:>
27086  
27087  
27088 my $a = CreateArea;
27089 my $t = $a->CreateTree;
27090 my $N = K loop => 16;
27091  
27092 $N->for(sub {my ($i) = @_; $t->push($i+1)});
27093 $t->size->out("t: ", " ");
27094 $a->used->out("u: ", " ");
27095 $a->freeChainSpace->out("f: ", " ");
27096 $a->size->outNL;
27097 $t->clear;
27098 $t->size->out("t: ", " ");
27099 $a->used->out("u: ", " ");
27100 $a->freeChainSpace->out("f: ", " ");
27101 $a->size->outNL;
27102  
27103 $N->for(sub {my ($i) = @_; $t->push($i+1)});
27104 $t->size->out("t: ", " ");
27105 $a->used->out("u: ", " ");
27106 $a->freeChainSpace->out("f: ", " ");
27107 $a->size->outNL;
27108 $t->clear;
27109 $t->size->out("t: ", " ");
27110 $a->used->out("u: ", " ");
27111 $a->freeChainSpace->out("f: ", " ");
27112 $a->size->outNL;
27113  
27114 $N->for(sub {my ($i) = @_; $t->push($i+1)});
27115 $t->free;
27116 $a->used->out("Clear tree: u: ");
27117 $a->freeChainSpace->out(" f: ", " ");
27118 $a->size->outNL;
27119  
27120 $a->clear;
27121 $a->used->out("Clear area: u: ");
27122 $a->freeChainSpace->out(" f: ", " ");
27123 $a->size->outNL;
27124  
27125 ok Assemble eq => <<END, label=>'t5';
27126 t: .... .... .... ..10 u: .... .... .... .280 f: .... .... .... ...0 size of area: .... .... .... 10..
27127 t: .... .... .... ...0 u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
27128 t: .... .... .... ..10 u: .... .... .... .280 f: .... .... .... ...0 size of area: .... .... .... 10..
27129 t: .... .... .... ...0 u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
27130 Clear tree: u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
27131 Clear area: u: .... .... .... ...0 f: .... .... .... ...0 size of area: .... .... .... 10..
27132 END
27133  
27134  
27135 =head3 Nasm::X86::Tree::free($tree)
27136  
27137 Free all the memory used by a tree.
27138  
27139 Parameter Description
27140 1 $tree Tree
27141  
27142 B<Example:>
27143  
27144  
27145 my $a = CreateArea;
27146 my $t = $a->CreateTree;
27147 my $N = K loop => 16;
27148  
27149 $N->for(sub {my ($i) = @_; $t->push($i+1)});
27150 $t->size->out("t: ", " ");
27151 $a->used->out("u: ", " ");
27152 $a->freeChainSpace->out("f: ", " ");
27153 $a->size->outNL;
27154 $t->clear;
27155 $t->size->out("t: ", " ");
27156 $a->used->out("u: ", " ");
27157 $a->freeChainSpace->out("f: ", " ");
27158 $a->size->outNL;
27159  
27160 $N->for(sub {my ($i) = @_; $t->push($i+1)});
27161 $t->size->out("t: ", " ");
27162 $a->used->out("u: ", " ");
27163 $a->freeChainSpace->out("f: ", " ");
27164 $a->size->outNL;
27165 $t->clear;
27166 $t->size->out("t: ", " ");
27167 $a->used->out("u: ", " ");
27168 $a->freeChainSpace->out("f: ", " ");
27169 $a->size->outNL;
27170  
27171 $N->for(sub {my ($i) = @_; $t->push($i+1)});
27172 $t->free;
27173 $a->used->out("Clear tree: u: ");
27174 $a->freeChainSpace->out(" f: ", " ");
27175 $a->size->outNL;
27176  
27177 $a->clear;
27178 $a->used->out("Clear area: u: ");
27179 $a->freeChainSpace->out(" f: ", " ");
27180 $a->size->outNL;
27181  
27182 ok Assemble eq => <<END, label=>'t5';
27183 t: .... .... .... ..10 u: .... .... .... .280 f: .... .... .... ...0 size of area: .... .... .... 10..
27184 t: .... .... .... ...0 u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
27185 t: .... .... .... ..10 u: .... .... .... .280 f: .... .... .... ...0 size of area: .... .... .... 10..
27186 t: .... .... .... ...0 u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
27187 Clear tree: u: .... .... .... .280 f: .... .... .... .240 size of area: .... .... .... 10..
27188 Clear area: u: .... .... .... ...0 f: .... .... .... ...0 size of area: .... .... .... 10..
27189 END
27190  
27191  
27192 =head2 Iteration
27193  
27194 Iterate through a tree non recursively
27195  
27196 =head3 Nasm::X86::Tree::by($tree, $block)
27197  
27198 Call the specified block with each element of the specified tree in ascending order.
27199  
27200 Parameter Description
27201 1 $tree Tree descriptor
27202 2 $block Block to execute
27203  
27204 B<Example:>
27205  
27206  
27207 my $a = CreateArea;
27208 my $t = $a->CreateTree;
27209 my $N = K loop => 16;
27210 $N->for(sub
27211 {my ($i) = @_;
27212 $t->put($i, 2 * $i);
27213 });
27214  
27215 $t->by(sub
27216 {my ($tree, $start, $next, $end) = @_;
27217 $tree->key->out(""); $tree->data->outNL(" ");
27218 });
27219  
27220 ok Assemble eq => <<END, avx512=>1;
27221 .... .... .... ...0 .... .... .... ...0
27222 .... .... .... ...1 .... .... .... ...2
27223 .... .... .... ...2 .... .... .... ...4
27224 .... .... .... ...3 .... .... .... ...6
27225 .... .... .... ...4 .... .... .... ...8
27226 .... .... .... ...5 .... .... .... ...A
27227 .... .... .... ...6 .... .... .... ...C
27228 .... .... .... ...7 .... .... .... ...E
27229 .... .... .... ...8 .... .... .... ..10
27230 .... .... .... ...9 .... .... .... ..12
27231 .... .... .... ...A .... .... .... ..14
27232 .... .... .... ...B .... .... .... ..16
27233 .... .... .... ...C .... .... .... ..18
27234 .... .... .... ...D .... .... .... ..1A
27235 .... .... .... ...E .... .... .... ..1C
27236 .... .... .... ...F .... .... .... ..1E
27237 END
27238  
27239  
27240 =head3 Nasm::X86::Tree::yb($tree, $block)
27241  
27242 Call the specified block with each element of the specified tree in descending order.
27243  
27244 Parameter Description
27245 1 $tree Tree descriptor
27246 2 $block Block to execute
27247  
27248 B<Example:>
27249  
27250  
27251 my $a = CreateArea;
27252 my $t = $a->CreateTree;
27253 my $N = K loop => 16;
27254 $N->for(sub
27255 {my ($i) = @_;
27256 $t->put($i, 2* $i);
27257 });
27258  
27259 $t->yb(sub
27260 {my ($tree, $start, $prev, $end) = @_;
27261 $tree->key->out(""); $tree->data->outNL(" ");
27262 });
27263  
27264 ok Assemble eq => <<END, avx512=>1;
27265 .... .... .... ...F .... .... .... ..1E
27266 .... .... .... ...E .... .... .... ..1C
27267 .... .... .... ...D .... .... .... ..1A
27268 .... .... .... ...C .... .... .... ..18
27269 .... .... .... ...B .... .... .... ..16
27270 .... .... .... ...A .... .... .... ..14
27271 .... .... .... ...9 .... .... .... ..12
27272 .... .... .... ...8 .... .... .... ..10
27273 .... .... .... ...7 .... .... .... ...E
27274 .... .... .... ...6 .... .... .... ...C
27275 .... .... .... ...5 .... .... .... ...A
27276 .... .... .... ...4 .... .... .... ...8
27277 .... .... .... ...3 .... .... .... ...6
27278 .... .... .... ...2 .... .... .... ...4
27279 .... .... .... ...1 .... .... .... ...2
27280 .... .... .... ...0 .... .... .... ...0
27281 END
27282  
27283  
27284 =head2 Push and Pop
27285  
27286 Use a tree as a stack: Push elements on to a tree with the next available key; Pop the last element in a tree.
27287  
27288 =head3 Nasm::X86::Tree::peek($tree, $Back)
27289  
27290 Peek at the element the specified distance back from the top of the stack and return its B<value> in data and found status in B<found> in the tree descriptor.
27291  
27292 Parameter Description
27293 1 $tree Tree descriptor
27294 2 $Back How far back to go with 1 being the top
27295  
27296 B<Example:>
27297  
27298  
27299 my $a = CreateArea;
27300 my $t = $a->CreateTree;
27301 my $N = K loop => 16;
27302 $N->for(sub
27303 {my ($i) = @_;
27304 $t->push($i);
27305 });
27306  
27307 $t->peek(1)->data ->outNL;
27308 $t->peek(2)->data ->outNL;
27309 $t->peek(3)->found->outNL;
27310 $t->peek(2 * $N )->found->outNL;
27311  
27312 $t->size->outNL;
27313 $t->get(8); $t->found->out("f: ", " "); $t->key->out("i: ", " "); $t->data->outNL;
27314  
27315 $N->for(sub
27316 {my ($i) = @_;
27317 $t->pop; $t->found->out("f: ", " "); $t->key->out("i: ", " "); $t->data->outNL;
27318 });
27319 # $t->pop; $t->found->outNL("f: ");
27320  
27321 ok Assemble eq => <<END, clocks => 29_852;
27322 data : .... .... .... ...F
27323 data : .... .... .... ...E
27324 found : .... .... .... ..40
27325 found : .... .... .... ...0
27326 size of tree: .... .... .... ..10
27327 f: .... .... .... ...2 i: .... .... .... ...8 data : .... .... .... ...8
27328 f: .... .... .... ...1 i: .... .... .... ...F data : .... .... .... ...F
27329 f: .... .... .... ...1 i: .... .... .... ...E data : .... .... .... ...E
27330 f: .... .... .... ...1 i: .... .... .... ...D data : .... .... .... ...D
27331 f: .... .... .... ...1 i: .... .... .... ...C data : .... .... .... ...C
27332 f: .... .... .... ...1 i: .... .... .... ...B data : .... .... .... ...B
27333 f: .... .... .... ...1 i: .... .... .... ...A data : .... .... .... ...A
27334 f: .... .... .... ...1 i: .... .... .... ...9 data : .... .... .... ...9
27335 f: .... .... .... ...1 i: .... .... .... ...8 data : .... .... .... ...8
27336 f: .... .... .... ...1 i: .... .... .... ...7 data : .... .... .... ...7
27337 f: .... .... .... ...1 i: .... .... .... ...6 data : .... .... .... ...6
27338 f: .... .... .... ...1 i: .... .... .... ...5 data : .... .... .... ...5
27339 f: .... .... .... ...1 i: .... .... .... ...4 data : .... .... .... ...4
27340 f: .... .... .... ...1 i: .... .... .... ...3 data : .... .... .... ...3
27341 f: .... .... .... ...1 i: .... .... .... ...2 data : .... .... .... ...2
27342 f: .... .... .... ...1 i: .... .... .... ...1 data : .... .... .... ...1
27343 f: .... .... .... ...1 i: .... .... .... ...0 data : .... .... .... ...0
27344 END
27345  
27346  
27347 =head3 Nasm::X86::Tree::peekSubTree($tree, $Back)
27348  
27349 Pop the last value out of a tree and return a tree descriptor positioned on it with the first/found fields set.
27350  
27351 Parameter Description
27352 1 $tree Tree descriptor
27353 2 $Back How far back to go with 1 being the top
27354  
27355 B<Example:>
27356  
27357  
27358 my $a = CreateArea;
27359 my $t = $a->CreateTree;
27360 my $T = $a->CreateTree;
27361  
27362 $T->push(0x22);
27363 $t->push($T);
27364 my $u = $t->peekSubTree(1);
27365 $u->peek(1);
27366 $u->found->outNL;
27367 $u->data->outNL;
27368 ok Assemble eq => <<END, avx512=>1;
27369 found : .... .... .... ...1
27370 data : .... .... .... ..22
27371 END
27372  
27373  
27374 =head3 Nasm::X86::Tree::pop($tree)
27375  
27376 Pop the last value out of a tree and return the key/data/subTree in the tree descriptor.
27377  
27378 Parameter Description
27379 1 $tree Tree descriptor
27380  
27381 B<Example:>
27382  
27383  
27384 my $a = CreateArea;
27385 my $t = $a->CreateTree;
27386 my $N = K loop => 16;
27387 $N->for(sub
27388 {my ($i) = @_;
27389 $t->push($i);
27390 });
27391  
27392 $t->peek(1)->data ->outNL;
27393 $t->peek(2)->data ->outNL;
27394 $t->peek(3)->found->outNL;
27395 $t->peek(2 * $N )->found->outNL;
27396  
27397 $t->size->outNL;
27398 $t->get(8); $t->found->out("f: ", " "); $t->key->out("i: ", " "); $t->data->outNL;
27399  
27400 $N->for(sub
27401 {my ($i) = @_;
27402 $t->pop; $t->found->out("f: ", " "); $t->key->out("i: ", " "); $t->data->outNL;
27403 });
27404 # $t->pop; $t->found->outNL("f: ");
27405  
27406 ok Assemble eq => <<END, clocks => 29_852;
27407 data : .... .... .... ...F
27408 data : .... .... .... ...E
27409 found : .... .... .... ..40
27410 found : .... .... .... ...0
27411 size of tree: .... .... .... ..10
27412 f: .... .... .... ...2 i: .... .... .... ...8 data : .... .... .... ...8
27413 f: .... .... .... ...1 i: .... .... .... ...F data : .... .... .... ...F
27414 f: .... .... .... ...1 i: .... .... .... ...E data : .... .... .... ...E
27415 f: .... .... .... ...1 i: .... .... .... ...D data : .... .... .... ...D
27416 f: .... .... .... ...1 i: .... .... .... ...C data : .... .... .... ...C
27417 f: .... .... .... ...1 i: .... .... .... ...B data : .... .... .... ...B
27418 f: .... .... .... ...1 i: .... .... .... ...A data : .... .... .... ...A
27419 f: .... .... .... ...1 i: .... .... .... ...9 data : .... .... .... ...9
27420 f: .... .... .... ...1 i: .... .... .... ...8 data : .... .... .... ...8
27421 f: .... .... .... ...1 i: .... .... .... ...7 data : .... .... .... ...7
27422 f: .... .... .... ...1 i: .... .... .... ...6 data : .... .... .... ...6
27423 f: .... .... .... ...1 i: .... .... .... ...5 data : .... .... .... ...5
27424 f: .... .... .... ...1 i: .... .... .... ...4 data : .... .... .... ...4
27425 f: .... .... .... ...1 i: .... .... .... ...3 data : .... .... .... ...3
27426 f: .... .... .... ...1 i: .... .... .... ...2 data : .... .... .... ...2
27427 f: .... .... .... ...1 i: .... .... .... ...1 data : .... .... .... ...1
27428 f: .... .... .... ...1 i: .... .... .... ...0 data : .... .... .... ...0
27429 END
27430  
27431  
27432 =head3 Nasm::X86::Tree::popSubTree($tree, %options)
27433  
27434 Pop the last value out of a tree and return a tree descriptor positioned on it with the first/found fields set.
27435  
27436 Parameter Description
27437 1 $tree Tree descriptor
27438 2 %options Options describing the sub tree
27439  
27440 B<Example:>
27441  
27442  
27443 my $a = CreateArea;
27444 my $t = $a->CreateTree;
27445 my $T = $a->CreateTree;
27446 $T->push(K key => 0x333);
27447  
27448 $t->push($T);
27449 $t->push(K key => 0x22);
27450  
27451 $t->pop;
27452 $t->found->outNL;
27453 $t->data->outNL;
27454 $t->subTree->outNL;
27455  
27456 my $P = $t->popSubTree;
27457 $t->found->outNL;
27458 $t->data->outNL;
27459 $t->subTree->outNL;
27460 PrintOutStringNL "PPPPP";
27461 $P->find(K key => 0);
27462 $P->found->outNL;
27463 $P->data->outNL;
27464  
27465 ok Assemble eq => <<END, avx512=>1;
27466 found : .... .... .... ...1
27467 data : .... .... .... ..22
27468 subTree: .... .... .... ...0
27469 found : .... .... .... ...1
27470 data : .... .... .... ..80
27471 subTree: .... .... .... ...1
27472 PPPPP
27473 found : .... .... .... ...1
27474 data : .... .... .... .333
27475 END
27476  
27477  
27478 =head3 Nasm::X86::Tree::get($tree, $Key)
27479  
27480 Retrieves the element at the specified zero based index in the stack.
27481  
27482 Parameter Description
27483 1 $tree Tree descriptor
27484 2 $Key Zero based index
27485  
27486 B<Example:>
27487  
27488  
27489 my $a = CreateArea;
27490 my $t = $a->CreateTree;
27491 my $N = K loop => 16;
27492 $N->for(sub
27493 {my ($i) = @_;
27494 $t->push($i);
27495 });
27496  
27497 $t->peek(1)->data ->outNL;
27498 $t->peek(2)->data ->outNL;
27499 $t->peek(3)->found->outNL;
27500 $t->peek(2 * $N )->found->outNL;
27501  
27502 $t->size->outNL;
27503 $t->get(8); $t->found->out("f: ", " "); $t->key->out("i: ", " "); $t->data->outNL;
27504  
27505 $N->for(sub
27506 {my ($i) = @_;
27507 $t->pop; $t->found->out("f: ", " "); $t->key->out("i: ", " "); $t->data->outNL;
27508 });
27509 # $t->pop; $t->found->outNL("f: ");
27510  
27511 ok Assemble eq => <<END, clocks => 29_852;
27512 data : .... .... .... ...F
27513 data : .... .... .... ...E
27514 found : .... .... .... ..40
27515 found : .... .... .... ...0
27516 size of tree: .... .... .... ..10
27517 f: .... .... .... ...2 i: .... .... .... ...8 data : .... .... .... ...8
27518 f: .... .... .... ...1 i: .... .... .... ...F data : .... .... .... ...F
27519 f: .... .... .... ...1 i: .... .... .... ...E data : .... .... .... ...E
27520 f: .... .... .... ...1 i: .... .... .... ...D data : .... .... .... ...D
27521 f: .... .... .... ...1 i: .... .... .... ...C data : .... .... .... ...C
27522 f: .... .... .... ...1 i: .... .... .... ...B data : .... .... .... ...B
27523 f: .... .... .... ...1 i: .... .... .... ...A data : .... .... .... ...A
27524 f: .... .... .... ...1 i: .... .... .... ...9 data : .... .... .... ...9
27525 f: .... .... .... ...1 i: .... .... .... ...8 data : .... .... .... ...8
27526 f: .... .... .... ...1 i: .... .... .... ...7 data : .... .... .... ...7
27527 f: .... .... .... ...1 i: .... .... .... ...6 data : .... .... .... ...6
27528 f: .... .... .... ...1 i: .... .... .... ...5 data : .... .... .... ...5
27529 f: .... .... .... ...1 i: .... .... .... ...4 data : .... .... .... ...4
27530 f: .... .... .... ...1 i: .... .... .... ...3 data : .... .... .... ...3
27531 f: .... .... .... ...1 i: .... .... .... ...2 data : .... .... .... ...2
27532 f: .... .... .... ...1 i: .... .... .... ...1 data : .... .... .... ...1
27533 f: .... .... .... ...1 i: .... .... .... ...0 data : .... .... .... ...0
27534 END
27535  
27536  
27537 =head2 Trees as Strings
27538  
27539 Use trees as strings of dwords. The size of the tree is the length of the string. Each dword is consider as an indivisible unit. This arrangement allows the normal string operations of concatenation and substring to be performed easily.
27540  
27541 =head3 Nasm::X86::Tree::appendAscii($string, $address, $size)
27542  
27543 Append ascii bytes in memory to a tree acting as a string. The address and size of the source memory are specified via variables. Each byte should represent a valid ascii byte so that it can be considered, when left extended with 24 zero bits, as utf32.
27544  
27545 Parameter Description
27546 1 $string Tree descriptor of string to append to
27547 2 $address Variable address of memory to append from
27548 3 $size Variable size of memory
27549  
27550 B<Example:>
27551  
27552  
27553 my $a = CreateArea;
27554 my $t = $a->CreateTree;
27555 my $b = Rb(0x41..0x51);
27556 $t->appendAscii(K(address=> $b), K(size => 1));
27557 $t->outAsUtf8NL;
27558 my $T = $a->CreateTree;
27559 $T->append($t);
27560 $T->append($t);
27561 $T->outAsUtf8NL;
27562 $T->appendAscii(K(address=> $b) + 1, K(size => 1));
27563 my $c = $T->clone;
27564 $c->outAsUtf8NL;
27565 my $d = $c->substring(1, 3);
27566 $d->outAsUtf8NL;
27567 ok Assemble eq => <<END, avx512=>1;
27568 A
27569 AA
27570 AAB
27571 AB
27572 END
27573  
27574  
27575 =head3 Nasm::X86::Tree::append($string, $append)
27576  
27577 Append the second source string to the first target string renumbering the keys of the source string to follow on from those of the target string. A string can safely be appended to itself.
27578  
27579 Parameter Description
27580 1 $string Tree descriptor of string to append to
27581 2 $append Tree descriptor of string to append from
27582  
27583 B<Example:>
27584  
27585  
27586 my $a = CreateArea;
27587 my $t = $a->CreateTree;
27588  
27589 $t->push(K alpha => 0x03b1);
27590 $t->push(K beta => 0x03b2);
27591 $t->push(K gamma => 0x03b3);
27592 $t->push(K delta => 0x03b4);
27593  
27594 $t->outAsUtf8NL;
27595  
27596 $t->append($t);
27597 $t->outAsUtf8NL;
27598  
27599 $t->append($t);
27600 $t->outAsUtf8NL;
27601  
27602 my $T = $t->substring(K(key => 4), K(key => 8));
27603 $T->outAsUtf8NL;
27604  
27605 my $r = $T->reverse;
27606 $r->outAsUtf8NL;
27607  
27608 ok Assemble eq => <<END, avx512=>1;
27609 αβγδ
27610 αβγδαβγδ
27611 αβγδαβγδαβγδαβγδ
27612 αβγδ
27613 δγβα
27614 END
27615  
27616 my $a = CreateArea;
27617 my $t = $a->CreateTree;
27618 my $b = Rb(0x41..0x51);
27619 $t->appendAscii(K(address=> $b), K(size => 1));
27620 $t->outAsUtf8NL;
27621 my $T = $a->CreateTree;
27622 $T->append($t);
27623 $T->append($t);
27624 $T->outAsUtf8NL;
27625 $T->appendAscii(K(address=> $b) + 1, K(size => 1));
27626 my $c = $T->clone;
27627 $c->outAsUtf8NL;
27628 my $d = $c->substring(1, 3);
27629 $d->outAsUtf8NL;
27630 ok Assemble eq => <<END, avx512=>1;
27631 A
27632 AA
27633 AAB
27634 AB
27635 END
27636  
27637 my $f = "zzzOperators.lib"; # Methods to be called against each syntactic item
27638  
27639 my $library = Subroutine # This subroutine and all of the subroutines it contains will be saved in an area and that area will be written to a file from where it can be included via L<incBin> in subsequent assemblies.
27640 {my ($p, $s, $sub) = @_;
27641  
27642 Subroutine # A contained routine that we wish to export to a file
27643 {my ($p, $s, $sub) = @_;
27644 PrintOutString "Ascii: ";
27645  
27646 my $parse = $$s{parse}; # Parse
27647 my $source = $parse->source; # Source
27648  
27649 $parse->area->getZmmBlock($$p{offset}, 1); # Load current parse tree node
27650  
27651 my $w = dSize;
27652 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of ascii
27653 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in source
27654  
27655 ($source+$position)->printOutMemoryNL($length); # Print the ascii string
27656  
27657 } name => "Ascii",
27658 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
27659 parameters => [qw(offset)];
27660  
27661 Subroutine # Another subroutine that will be exported because it is within the subroutine that is being exported as a library
27662 {my ($p, $s, $sub) = @_;
27663 PrintOutStringNL "Add";
27664 } name => "+",
27665 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
27666 parameters => [qw(offset)];
27667  
27668 Subroutine
27669 {my ($p, $s, $sub) = @_;
27670 PrintOutStringNL "Times";
27671 } name => "✕",
27672 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
27673 parameters => [qw(offset)];
27674  
27675 Subroutine
27676 {my ($p, $s, $sub) = @_;
27677 PrintOutStringNL "And";
27678 } name => "𝕒𝕟𝕕",
27679 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
27680 parameters => [qw(offset)];
27681  
27682  
27683 Subroutine
27684 {my ($p, $s, $sub) = @_;
27685 PrintOutString "Variable: ";
27686  
27687 my $parse = $$s{parse}; # Parse
27688 my $source = $parse->source; # Source
27689  
27690 $parse->area->getZmmBlock($$p{offset}, 1); # Load current parse tree node
27691  
27692 my $w = dSize;
27693 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of ascii
27694 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in source
27695  
27696 ($source+$position)->printOutMemoryNL($length); # Print the ascii string
27697  
27698 } name => "Variable",
27699 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
27700 parameters => [qw(offset)];
27701  
27702 } name => "operators", parameters=>[qw(a b c)], export => $f;
27703  
27704 ok Assemble eq => <<END, avx512=>1;
27705 END
27706  
27707 my $l = ReadArea $f; # Area containing subroutine library
27708  
27709 my ($A, $N) = constantString qq(1+𝗔✕𝗕+𝗖𝕒𝕟𝕕2✕𝗔+𝗕+𝗖); # Utf8 string to parse
27710  
27711 my $p = ParseUnisyn($A, $N); # 10_445 Parse utf8 string 5_340 after single character lexical items, 4_950 after jump table
27712  
27713 $p->dumpParseResult;
27714  
27715 $p->traverseApplyingLibraryOperators($l); # Traverse a parse tree applying a library of operators where they intersect with lexical items in the parse tree
27716  
27717 # ✕ 2715
27718 # + ff0b
27719  
27720 ok Assemble eq => <<END, clocks=>20_921;
27721 parseChar : .... .... ...1 D5D6
27722 parseFail : .... .... .... ...0
27723 position : .... .... .... ..38
27724 parseMatch : .... .... .... ...0
27725 parseReason: .... .... .... ...0
27726 𝕒𝕟𝕕
27727 ._+
27728 ._._✕
27729 ._._._+
27730 ._._._._1
27731 ._._._._𝗔
27732 ._._._𝗕
27733 ._._𝗖
27734 ._+
27735 ._._+
27736 ._._._✕
27737 ._._._._2
27738 ._._._._𝗔
27739 ._._._𝗕
27740 ._._𝗖
27741 Ascii: 1
27742 Variable: 𝗔
27743 Add
27744 Variable: 𝗕
27745 Times
27746 Variable: 𝗖
27747 Add
27748 Ascii: 2
27749 Variable: 𝗔
27750 Times
27751 Variable: 𝗕
27752 Add
27753 Variable: 𝗖
27754 Add
27755 And
27756 END
27757 unlink $f;
27758  
27759  
27760 =head3 Nasm::X86::Tree::clone($string)
27761  
27762 Clone a string.
27763  
27764 Parameter Description
27765 1 $string Tree descriptor
27766  
27767 B<Example:>
27768  
27769  
27770 my $a = CreateArea;
27771 my $t = $a->CreateTree;
27772 my $b = Rb(0x41..0x51);
27773 $t->appendAscii(K(address=> $b), K(size => 1));
27774 $t->outAsUtf8NL;
27775 my $T = $a->CreateTree;
27776 $T->append($t);
27777 $T->append($t);
27778 $T->outAsUtf8NL;
27779 $T->appendAscii(K(address=> $b) + 1, K(size => 1));
27780 my $c = $T->clone;
27781 $c->outAsUtf8NL;
27782 my $d = $c->substring(1, 3);
27783 $d->outAsUtf8NL;
27784 ok Assemble eq => <<END, avx512=>1;
27785 A
27786 AA
27787 AAB
27788 AB
27789 END
27790  
27791  
27792 =head3 Nasm::X86::Tree::substring($string, $Start, $Finish)
27793  
27794 Create the substring of the specified string between the specified start and end keys.
27795  
27796 Parameter Description
27797 1 $string Tree descriptor of string to extract from
27798 2 $Start Start key
27799 3 $Finish End key
27800  
27801 B<Example:>
27802  
27803  
27804 my $a = CreateArea;
27805 my $t = $a->CreateTree;
27806  
27807 $t->push(K alpha => 0x03b1);
27808 $t->push(K beta => 0x03b2);
27809 $t->push(K gamma => 0x03b3);
27810 $t->push(K delta => 0x03b4);
27811  
27812 $t->outAsUtf8NL;
27813  
27814 $t->append($t);
27815 $t->outAsUtf8NL;
27816  
27817 $t->append($t);
27818 $t->outAsUtf8NL;
27819  
27820 my $T = $t->substring(K(key => 4), K(key => 8));
27821 $T->outAsUtf8NL;
27822  
27823 my $r = $T->reverse;
27824 $r->outAsUtf8NL;
27825  
27826 ok Assemble eq => <<END, avx512=>1;
27827 αβγδ
27828 αβγδαβγδ
27829 αβγδαβγδαβγδαβγδ
27830 αβγδ
27831 δγβα
27832 END
27833  
27834  
27835 =head3 Nasm::X86::Tree::reverse($string)
27836  
27837 Create a clone of the string in reverse order.
27838  
27839 Parameter Description
27840 1 $string Tree descriptor of string
27841  
27842 B<Example:>
27843  
27844  
27845 my $a = CreateArea;
27846 my $t = $a->CreateTree;
27847  
27848 $t->push(K alpha => 0x03b1);
27849 $t->push(K beta => 0x03b2);
27850 $t->push(K gamma => 0x03b3);
27851 $t->push(K delta => 0x03b4);
27852  
27853 $t->outAsUtf8NL;
27854  
27855 $t->append($t);
27856 $t->outAsUtf8NL;
27857  
27858 $t->append($t);
27859 $t->outAsUtf8NL;
27860  
27861 my $T = $t->substring(K(key => 4), K(key => 8));
27862 $T->outAsUtf8NL;
27863  
27864 my $r = $T->reverse;
27865 $r->outAsUtf8NL;
27866  
27867 ok Assemble eq => <<END, avx512=>1;
27868 αβγδ
27869 αβγδαβγδ
27870 αβγδαβγδαβγδαβγδ
27871 αβγδ
27872 δγβα
27873 END
27874  
27875  
27876 =head2 Trees as sets
27877  
27878 Trees of trees as sets
27879  
27880 =head3 Nasm::X86::Tree::union($tree)
27881  
27882 Given a tree of trees consider each sub tree as a set and form the union of all these sets as a new tree.
27883  
27884 Parameter Description
27885 1 $tree Tree descriptor for a tree of trees
27886  
27887 B<Example:>
27888  
27889  
27890 my $a = CreateArea;
27891 my $r = $a->CreateTree;
27892 my $s = $a->CreateTree;
27893 my $t = $a->CreateTree;
27894  
27895 $r->put(K(key => 1), K(data => 1));
27896 $r->put(K(key => 2), K(data => 2));
27897  
27898 $s->put(K(key => 1), K(data => 1));
27899 $s->put(K(key => 3), K(data => 3));
27900  
27901 $t->push($r);
27902 $t->push($s);
27903  
27904 my $u = $t->union;
27905 $t->dump('input 1 2 1 3');
27906 $u->dump('union 1 2 3');
27907  
27908 my $i = $t->intersection;
27909 $i->dump('intersection 1');
27910  
27911 ok Assemble eq => <<END, avx512=>1;
27912 input 1 2 1 3
27913 At: 280 length: 2, data: 2C0, nodes: 300, first: C0, root, leaf, trees: 11
27914 Index: 0 1
27915 Keys : 0 1
27916 Data : 10* 1C*
27917 At: 100 length: 2, data: 140, nodes: 180, first: 40, root, leaf
27918 Index: 0 1
27919 Keys : 1 2
27920 Data : 1 2
27921 end
27922 At: 1C0 length: 2, data: 200, nodes: 240, first: 80, root, leaf
27923 Index: 0 1
27924 Keys : 1 3
27925 Data : 1 3
27926 end
27927 end
27928 union 1 2 3
27929 At: 380 length: 3, data: 3C0, nodes: 400, first: 340, root, leaf
27930 Index: 0 1 2
27931 Keys : 1 2 3
27932 Data : 1 2 3
27933 end
27934 intersection 1
27935 At: 480 length: 1, data: 4C0, nodes: 500, first: 440, root, leaf
27936 Index: 0
27937 Keys : 1
27938 Data : 1
27939 end
27940 END
27941  
27942  
27943 =head3 Nasm::X86::Tree::intersection($tree)
27944  
27945 Given a tree of trees consider each sub tree as a set and form the intersection of all these sets as a new tree.
27946  
27947 Parameter Description
27948 1 $tree Tree descriptor for a tree of trees
27949  
27950 B<Example:>
27951  
27952  
27953 my $a = CreateArea;
27954 my $r = $a->CreateTree;
27955 my $s = $a->CreateTree;
27956 my $t = $a->CreateTree;
27957  
27958 $r->put(K(key => 1), K(data => 1));
27959 $r->put(K(key => 2), K(data => 2));
27960  
27961 $s->put(K(key => 1), K(data => 1));
27962 $s->put(K(key => 3), K(data => 3));
27963  
27964 $t->push($r);
27965 $t->push($s);
27966  
27967 my $u = $t->union;
27968 $t->dump('input 1 2 1 3');
27969 $u->dump('union 1 2 3');
27970  
27971 my $i = $t->intersection;
27972 $i->dump('intersection 1');
27973  
27974 ok Assemble eq => <<END, avx512=>1;
27975 input 1 2 1 3
27976 At: 280 length: 2, data: 2C0, nodes: 300, first: C0, root, leaf, trees: 11
27977 Index: 0 1
27978 Keys : 0 1
27979 Data : 10* 1C*
27980 At: 100 length: 2, data: 140, nodes: 180, first: 40, root, leaf
27981 Index: 0 1
27982 Keys : 1 2
27983 Data : 1 2
27984 end
27985 At: 1C0 length: 2, data: 200, nodes: 240, first: 80, root, leaf
27986 Index: 0 1
27987 Keys : 1 3
27988 Data : 1 3
27989 end
27990 end
27991 union 1 2 3
27992 At: 380 length: 3, data: 3C0, nodes: 400, first: 340, root, leaf
27993 Index: 0 1 2
27994 Keys : 1 2 3
27995 Data : 1 2 3
27996 end
27997 intersection 1
27998 At: 480 length: 1, data: 4C0, nodes: 500, first: 440, root, leaf
27999 Index: 0
28000 Keys : 1
28001 Data : 1
28002 end
28003 END
28004  
28005  
28006 =head2 Key String Trees
28007  
28008 A key string tree has strings for keys.
28009  
28010 =head3 Nasm::X86::Tree::getKeyString($tree, $address, $size)
28011  
28012 Find a string in a string tree and return the associated data and find status in the data and found fields of the tree.
28013  
28014 Parameter Description
28015 1 $tree Tree descriptor
28016 2 $address Address of key
28017 3 $size Length of key
28018  
28019 B<Example:>
28020  
28021  
28022 my $t = CreateArea->CreateTree(stringTree=>1);
28023  
28024 K(loop => 3)->for(sub
28025 {my $a = $t->uniqueKeyString(constantString("aaaa")); $a->outNL;
28026 my $b = $t->uniqueKeyString(constantString("bbbb")); $b->outNL;
28027 });
28028  
28029 for my $k(qw(aaaa bbbb ccccc))
28030 {PrintOutStringNL $k;
28031 $t->getKeyString(constantString $k); $t->found->outNL; $t->data->outNL;
28032 }
28033  
28034 ok Assemble eq => <<END, clocks=>4374;
28035 count: .... .... .... ...0
28036 count: .... .... .... ...1
28037 count: .... .... .... ...0
28038 count: .... .... .... ...1
28039 count: .... .... .... ...0
28040 count: .... .... .... ...1
28041 aaaa
28042 found : .... .... .... ...1
28043 data : .... .... .... ...0
28044 bbbb
28045 found : .... .... .... ...2
28046 data : .... .... .... ...1
28047 ccccc
28048 found : .... .... .... ...0
28049 data : .... .... .... ...0
28050 END
28051  
28052 my $a = CreateArea;
28053 my $t = $a->CreateTree(stringTree=>1);
28054 $t->putKeyString(constantString("dddd444"), K(data => 8));
28055 $t->putKeyString(constantString("dddd4444"), K(data => 9));
28056 $t->putKeyString(constantString("eeee5555"), K(data =>10));
28057 $t->putKeyString(constantString("bbbb2222"), K(data => 2));
28058 $t->putKeyString(constantString("cccc3333"), K(data => 7));
28059 $t->putKeyString(constantString("aaaa1111"), K(data => 1));
28060 $t->putKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44443"), K data => 6);
28061 $t->putKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44442"), K data => 5);
28062 $t->putKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44441"), K data => 4);
28063 $t->putKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44440"), K data => 3);
28064 $a->dump("AA", K(depth => 20));
28065 $t->dump("TT");
28066  
28067 $t->getKeyString(constantString("aaaa1111")); $t->data->outNL;
28068 $t->getKeyString(constantString("bbbb2222")); $t->data->outNL;
28069 $t->getKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44440")); $t->data->outNL;
28070 $t->getKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44441")); $t->data->outNL;
28071 $t->getKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44442")); $t->data->outNL;
28072 $t->getKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44443")); $t->data->outNL;
28073 $t->getKeyString(constantString("cccc3333")); $t->data->outNL;
28074 $t->getKeyString(constantString("dddd444")); $t->data->outNL;
28075 $t->getKeyString(constantString("dddd4444")); $t->data->outNL;
28076 $t->getKeyString(constantString("eeee5555")); $t->data->outNL;
28077  
28078 ok Assemble eq => <<END, avx512=>1;
28079 AA
28080 Area Size: 4096 Used: 1280
28081 .... .... .... ...0 | __10 ____ ____ ____ __.5 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28082 .... .... .... ..40 | C0__ ____ .1__ ____ .7__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28083 .... .... .... ..80 | 6464 6464 3434 34__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28084 .... .... .... ..C0 | 80.2 ____ __.2 ____ C0.2 ____ 40.2 ____ 80__ ____ 80.1 ____ C0.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .7__ .4__ __.1 ____
28085 .... .... .... .1.. | .1__ ____ .2__ ____ __.3 ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ 40.1 ____
28086 .... .... .... .140 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ 40__ ____
28087 .... .... .... .180 | 6464 6464 3434 3434 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28088 .... .... .... .1C0 | 6565 6565 3535 3535 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28089 .... .... .... .2.. | 6262 6262 3232 3232 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28090 .... .... .... .240 | 6363 6363 3333 3333 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28091 .... .... .... .280 | 6161 6161 3131 3131 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28092 .... .... .... .2C0 | 6363 6363 3131 3131 6363 6363 3232 3232 6363 6363 3333 3333 6363 6363 3434 3434 6363 6363 3131 3131 6363 6363 3232 3232 6363 6363 3333 3333 6363 6363 3434 3434
28093 .... .... .... .3.. | 80.3 ____ .1__ ____ .4__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28094 .... .... .... .340 | 33__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28095 .... .... .... .380 | C0.4 ____ 80.4 ____ 40.4 ____ 40.3 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .4__ ____ C0.3 ____
28096 .... .... .... .3C0 | .3__ ____ .4__ ____ .5__ ____ .6__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __.4 ____
28097 .... .... .... .4.. | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __.3 ____
28098 .... .... .... .440 | 32__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28099 .... .... .... .480 | 31__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28100 .... .... .... .4C0 | 30__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28101 TT
28102 At: C0 length: 7, data: 100, nodes: 140, first: 40, root, leaf, trees: 100
28103 Index: 0 1 2 3 4 5 6
28104 Keys : 280 200 2C0 240 80 180 1C0
28105 Data : 1 2 38* 7 8 9 10
28106 At: 380 length: 4, data: 3C0, nodes: 400, first: 300, root, leaf
28107 Index: 0 1 2 3
28108 Keys : 4C0 480 440 340
28109 Data : 3 4 5 6
28110 end
28111 end
28112 data : .... .... .... ...1
28113 data : .... .... .... ...2
28114 data : .... .... .... ...3
28115 data : .... .... .... ...4
28116 data : .... .... .... ...5
28117 data : .... .... .... ...6
28118 data : .... .... .... ...7
28119 data : .... .... .... ...8
28120 data : .... .... .... ...9
28121 data : .... .... .... ...A
28122 END
28123  
28124  
28125 =head3 Nasm::X86::Tree::putKeyString($tree, $address, $size, $data)
28126  
28127 Associate a string of any length with a double word.
28128  
28129 Parameter Description
28130 1 $tree Tree descriptor
28131 2 $address Address of key
28132 3 $size Length of key
28133 4 $data Data associated with key
28134  
28135 B<Example:>
28136  
28137  
28138 my $a = CreateArea;
28139 my $t = $a->CreateTree(stringTree=>1);
28140 $t->putKeyString(constantString("dddd444"), K(data => 8));
28141 $t->putKeyString(constantString("dddd4444"), K(data => 9));
28142 $t->putKeyString(constantString("eeee5555"), K(data =>10));
28143 $t->putKeyString(constantString("bbbb2222"), K(data => 2));
28144 $t->putKeyString(constantString("cccc3333"), K(data => 7));
28145 $t->putKeyString(constantString("aaaa1111"), K(data => 1));
28146 $t->putKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44443"), K data => 6);
28147 $t->putKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44442"), K data => 5);
28148 $t->putKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44441"), K data => 4);
28149 $t->putKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44440"), K data => 3);
28150 $a->dump("AA", K(depth => 20));
28151 $t->dump("TT");
28152  
28153 $t->getKeyString(constantString("aaaa1111")); $t->data->outNL;
28154 $t->getKeyString(constantString("bbbb2222")); $t->data->outNL;
28155 $t->getKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44440")); $t->data->outNL;
28156 $t->getKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44441")); $t->data->outNL;
28157 $t->getKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44442")); $t->data->outNL;
28158 $t->getKeyString(constantString("cccc1111cccc2222cccc3333cccc4444cccc1111cccc2222cccc3333cccc44443")); $t->data->outNL;
28159 $t->getKeyString(constantString("cccc3333")); $t->data->outNL;
28160 $t->getKeyString(constantString("dddd444")); $t->data->outNL;
28161 $t->getKeyString(constantString("dddd4444")); $t->data->outNL;
28162 $t->getKeyString(constantString("eeee5555")); $t->data->outNL;
28163  
28164 ok Assemble eq => <<END, avx512=>1;
28165 AA
28166 Area Size: 4096 Used: 1280
28167 .... .... .... ...0 | __10 ____ ____ ____ __.5 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28168 .... .... .... ..40 | C0__ ____ .1__ ____ .7__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28169 .... .... .... ..80 | 6464 6464 3434 34__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28170 .... .... .... ..C0 | 80.2 ____ __.2 ____ C0.2 ____ 40.2 ____ 80__ ____ 80.1 ____ C0.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .7__ .4__ __.1 ____
28171 .... .... .... .1.. | .1__ ____ .2__ ____ __.3 ____ .7__ ____ .8__ ____ .9__ ____ .A__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ 40.1 ____
28172 .... .... .... .140 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ 40__ ____
28173 .... .... .... .180 | 6464 6464 3434 3434 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28174 .... .... .... .1C0 | 6565 6565 3535 3535 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28175 .... .... .... .2.. | 6262 6262 3232 3232 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28176 .... .... .... .240 | 6363 6363 3333 3333 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28177 .... .... .... .280 | 6161 6161 3131 3131 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28178 .... .... .... .2C0 | 6363 6363 3131 3131 6363 6363 3232 3232 6363 6363 3333 3333 6363 6363 3434 3434 6363 6363 3131 3131 6363 6363 3232 3232 6363 6363 3333 3333 6363 6363 3434 3434
28179 .... .... .... .3.. | 80.3 ____ .1__ ____ .4__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28180 .... .... .... .340 | 33__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28181 .... .... .... .380 | C0.4 ____ 80.4 ____ 40.4 ____ 40.3 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .4__ ____ C0.3 ____
28182 .... .... .... .3C0 | .3__ ____ .4__ ____ .5__ ____ .6__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __.4 ____
28183 .... .... .... .4.. | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __.3 ____
28184 .... .... .... .440 | 32__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28185 .... .... .... .480 | 31__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28186 .... .... .... .4C0 | 30__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
28187 TT
28188 At: C0 length: 7, data: 100, nodes: 140, first: 40, root, leaf, trees: 100
28189 Index: 0 1 2 3 4 5 6
28190 Keys : 280 200 2C0 240 80 180 1C0
28191 Data : 1 2 38* 7 8 9 10
28192 At: 380 length: 4, data: 3C0, nodes: 400, first: 300, root, leaf
28193 Index: 0 1 2 3
28194 Keys : 4C0 480 440 340
28195 Data : 3 4 5 6
28196 end
28197 end
28198 data : .... .... .... ...1
28199 data : .... .... .... ...2
28200 data : .... .... .... ...3
28201 data : .... .... .... ...4
28202 data : .... .... .... ...5
28203 data : .... .... .... ...6
28204 data : .... .... .... ...7
28205 data : .... .... .... ...8
28206 data : .... .... .... ...9
28207 data : .... .... .... ...A
28208 END
28209  
28210  
28211 =head3 Nasm::X86::Tree::uniqueKeyString($tree, $address, $size)
28212  
28213 Add a key string to a string tree if the key is not already present and return a unique number identifying the string (although currently there is no way to fast way to recover the string from the number). If the key string is already present in the string tree return the number associated with the original key string rather than creating a new entry.
28214  
28215 Parameter Description
28216 1 $tree Tree descriptor
28217 2 $address Address of key
28218 3 $size Length of key
28219  
28220 B<Example:>
28221  
28222  
28223 my $t = CreateArea->CreateTree(stringTree=>1);
28224  
28225 K(loop => 3)->for(sub
28226 {my $a = $t->uniqueKeyString(constantString("aaaa")); $a->outNL;
28227 my $b = $t->uniqueKeyString(constantString("bbbb")); $b->outNL;
28228 });
28229  
28230 for my $k(qw(aaaa bbbb ccccc))
28231 {PrintOutStringNL $k;
28232 $t->getKeyString(constantString $k); $t->found->outNL; $t->data->outNL;
28233 }
28234  
28235 ok Assemble eq => <<END, clocks=>4374;
28236 count: .... .... .... ...0
28237 count: .... .... .... ...1
28238 count: .... .... .... ...0
28239 count: .... .... .... ...1
28240 count: .... .... .... ...0
28241 count: .... .... .... ...1
28242 aaaa
28243 found : .... .... .... ...1
28244 data : .... .... .... ...0
28245 bbbb
28246 found : .... .... .... ...2
28247 data : .... .... .... ...1
28248 ccccc
28249 found : .... .... .... ...0
28250 data : .... .... .... ...0
28251 END
28252  
28253  
28254 =head2 Print
28255  
28256 Print a tree
28257  
28258 =head3 Nasm::X86::Tree::printInOrder($tree, $title)
28259  
28260 Print a tree in order.
28261  
28262 Parameter Description
28263 1 $tree Tree
28264 2 $title Title
28265  
28266 B<Example:>
28267  
28268  
28269 my $a = CreateArea;
28270 my $t = $a->CreateTree;
28271 my $N = K count => 128;
28272  
28273 $N->for(sub
28274 {my ($index, $start, $next, $end) = @_;
28275 my $l0 = ($N-$index) / 2;
28276 my $l1 = ($N+$index) / 2;
28277 my $h0 = $N-$index;
28278 my $h1 = $N+$index;
28279 $t->put($l0, $l0 * 2);
28280 $t->put($h1, $h1 * 2);
28281 $t->put($l1, $l1 * 2);
28282 $t->put($h0, $h0 * 2);
28283 });
28284  
28285 $t->printInOrder("AAAA");
28286  
28287 ok Assemble eq => <<END, label=>'t3';
28288 AAAA 256: 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
28289 END
28290  
28291 my $a = CreateArea;
28292 my $t = $a->CreateTree;
28293 my $N = K count => 128;
28294  
28295 $N->for(sub
28296 {my ($index, $start, $next, $end) = @_;
28297 my $l0 = ($N-$index) / 2;
28298 my $l1 = ($N+$index) / 2;
28299 my $h0 = $N-$index;
28300 my $h1 = $N+$index;
28301 $t->put($l0, $l0 * 2);
28302 $t->put($h1, $h1 * 2);
28303 $t->put($l1, $l1 * 2);
28304 $t->put($h0, $h0 * 2);
28305 });
28306 $t->printInOrder("AAAA");
28307  
28308 ok Assemble eq => <<END, avx512=>1;
28309 AAAA 256: 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
28310 END
28311  
28312  
28313 =head3 Nasm::X86::Tree::outAsUtf8($string)
28314  
28315 Print the data values of the specified string on stdout assuming each data value is a utf32 character and that the output device supports utf8.
28316  
28317 Parameter Description
28318 1 $string Tree descriptor of string
28319  
28320 B<Example:>
28321  
28322  
28323 my $a = CreateArea;
28324 my $t = $a->CreateTree;
28325  
28326 $t->push(K alpha => 0x03b1);
28327 $t->push(K beta => 0x03b2);
28328 $t->push(K gamma => 0x03b3);
28329 $t->push(K delta => 0x03b4);
28330  
28331 $t->outAsUtf8NL;
28332  
28333 $t->append($t);
28334 $t->outAsUtf8NL;
28335  
28336 $t->append($t);
28337 $t->outAsUtf8NL;
28338  
28339 my $T = $t->substring(K(key => 4), K(key => 8));
28340 $T->outAsUtf8NL;
28341  
28342 my $r = $T->reverse;
28343 $r->outAsUtf8NL;
28344  
28345 ok Assemble eq => <<END, avx512=>1;
28346 αβγδ
28347 αβγδαβγδ
28348 αβγδαβγδαβγδαβγδ
28349 αβγδ
28350 δγβα
28351 END
28352  
28353 my $f = "zzzOperators.lib"; # Methods to be called against each syntactic item
28354  
28355 my $library = Subroutine # This subroutine and all of the subroutines it contains will be saved in an area and that area will be written to a file from where it can be included via L<incBin> in subsequent assemblies.
28356 {my ($p, $s, $sub) = @_;
28357  
28358 Subroutine # A contained routine that we wish to export to a file
28359 {my ($p, $s, $sub) = @_;
28360 PrintOutString "Ascii: ";
28361  
28362 my $parse = $$s{parse}; # Parse
28363 my $source = $parse->source; # Source
28364  
28365 $parse->area->getZmmBlock($$p{offset}, 1); # Load current parse tree node
28366  
28367 my $w = dSize;
28368 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of ascii
28369 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in source
28370  
28371 ($source+$position)->printOutMemoryNL($length); # Print the ascii string
28372  
28373 } name => "Ascii",
28374 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28375 parameters => [qw(offset)];
28376  
28377 Subroutine # Another subroutine that will be exported because it is within the subroutine that is being exported as a library
28378 {my ($p, $s, $sub) = @_;
28379 PrintOutStringNL "Add";
28380 } name => "+",
28381 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28382 parameters => [qw(offset)];
28383  
28384 Subroutine
28385 {my ($p, $s, $sub) = @_;
28386 PrintOutStringNL "Times";
28387 } name => "✕",
28388 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28389 parameters => [qw(offset)];
28390  
28391 Subroutine
28392 {my ($p, $s, $sub) = @_;
28393 PrintOutStringNL "And";
28394 } name => "𝕒𝕟𝕕",
28395 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28396 parameters => [qw(offset)];
28397  
28398  
28399 Subroutine
28400 {my ($p, $s, $sub) = @_;
28401 PrintOutString "Variable: ";
28402  
28403 my $parse = $$s{parse}; # Parse
28404 my $source = $parse->source; # Source
28405  
28406 $parse->area->getZmmBlock($$p{offset}, 1); # Load current parse tree node
28407  
28408 my $w = dSize;
28409 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of ascii
28410 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in source
28411  
28412 ($source+$position)->printOutMemoryNL($length); # Print the ascii string
28413  
28414 } name => "Variable",
28415 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28416 parameters => [qw(offset)];
28417  
28418 } name => "operators", parameters=>[qw(a b c)], export => $f;
28419  
28420 ok Assemble eq => <<END, avx512=>1;
28421 END
28422  
28423 my $l = ReadArea $f; # Area containing subroutine library
28424  
28425 my ($A, $N) = constantString qq(1+𝗔✕𝗕+𝗖𝕒𝕟𝕕2✕𝗔+𝗕+𝗖); # Utf8 string to parse
28426  
28427 my $p = ParseUnisyn($A, $N); # 10_445 Parse utf8 string 5_340 after single character lexical items, 4_950 after jump table
28428  
28429 $p->dumpParseResult;
28430  
28431 $p->traverseApplyingLibraryOperators($l); # Traverse a parse tree applying a library of operators where they intersect with lexical items in the parse tree
28432  
28433 # ✕ 2715
28434 # + ff0b
28435  
28436 ok Assemble eq => <<END, clocks=>20_921;
28437 parseChar : .... .... ...1 D5D6
28438 parseFail : .... .... .... ...0
28439 position : .... .... .... ..38
28440 parseMatch : .... .... .... ...0
28441 parseReason: .... .... .... ...0
28442 𝕒𝕟𝕕
28443 ._+
28444 ._._✕
28445 ._._._+
28446 ._._._._1
28447 ._._._._𝗔
28448 ._._._𝗕
28449 ._._𝗖
28450 ._+
28451 ._._+
28452 ._._._✕
28453 ._._._._2
28454 ._._._._𝗔
28455 ._._._𝗕
28456 ._._𝗖
28457 Ascii: 1
28458 Variable: 𝗔
28459 Add
28460 Variable: 𝗕
28461 Times
28462 Variable: 𝗖
28463 Add
28464 Ascii: 2
28465 Variable: 𝗔
28466 Times
28467 Variable: 𝗕
28468 Add
28469 Variable: 𝗖
28470 Add
28471 And
28472 END
28473 unlink $f;
28474  
28475  
28476 =head3 Nasm::X86::Tree::outAsUtf8NL($string)
28477  
28478 Print the data values of the specified string on stdout assuming each data value is a utf32 character and that the output device supports utf8. Follow the print with a new line character.
28479  
28480 Parameter Description
28481 1 $string Tree descriptor of string
28482  
28483 B<Example:>
28484  
28485  
28486 my $a = CreateArea;
28487 my $t = $a->CreateTree;
28488 my $b = Rb(0x41..0x51);
28489 $t->appendAscii(K(address=> $b), K(size => 1));
28490 $t->outAsUtf8NL;
28491 my $T = $a->CreateTree;
28492 $T->append($t);
28493 $T->append($t);
28494 $T->outAsUtf8NL;
28495 $T->appendAscii(K(address=> $b) + 1, K(size => 1));
28496 my $c = $T->clone;
28497 $c->outAsUtf8NL;
28498 my $d = $c->substring(1, 3);
28499 $d->outAsUtf8NL;
28500 ok Assemble eq => <<END, avx512=>1;
28501 A
28502 AA
28503 AAB
28504 AB
28505 END
28506  
28507  
28508 =head1 Unisyn
28509  
28510 Parse Unisyn language statements.
28511  
28512 =head2 Lex
28513  
28514 Lexical Analysis
28515  
28516 =head3 Nasm::X86::Unisyn::Lex::composeUnisyn($words)
28517  
28518 Compose phrases of Unisyn and return them as a string
28519  
28520 Parameter Description
28521 1 $words String of words
28522  
28523 B<Example:>
28524  
28525  
28526 if (1)
28527  
28528 {my $t = Nasm::X86::Unisyn::Lex::composeUnisyn "va w m+ w vb"; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
28529  
28530 is_deeply $t, "𝗮 + 𝗯";
28531 my $p = &ParseUnisyn(constantString $t);
28532 $p->dumpPostOrder;
28533 ok Assemble eq => <<END;
28534 ._𝗮 
28535 ._𝗯
28536 + 
28537 END
28538 }
28539  
28540  
28541 =head3 Nasm::X86::Unisyn::Lex::PermissibleTransitionsArray()
28542  
28543 Create and load the table of lexical transitions.
28544  
28545  
28546 B<Example:>
28547  
28548  
28549 my $a = Nasm::X86::Unisyn::Lex::Number::a; # Assign-2 - right to left
28550 my $b = Nasm::X86::Unisyn::Lex::Number::b; # Open
28551  
28552  
28553 my ($N, $A) = Nasm::X86::Unisyn::Lex::PermissibleTransitionsArray; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
28554  
28555 Mov rax, $A;
28556 Add rax, ($a << Nasm::X86::Unisyn::Lex::PermissibleTransitionsArrayBits) + $a;
28557 Mov al, "[rax]";
28558 And rax, 0xff;
28559 PrintOutRegisterInHex rax;
28560  
28561 Mov rax, $A;
28562 Add rax, ($b << Nasm::X86::Unisyn::Lex::PermissibleTransitionsArrayBits) + $b;
28563 Mov al, "[rax]";
28564 And rax, 0xff;
28565 PrintOutRegisterInHex rax;
28566 ok Assemble eq => <<END, avx512=>1;
28567 rax: .... .... .... ..FF
28568 rax: .... .... .... ...1
28569 END
28570  
28571 if (1) # Place parser tables into an area
28572 {my $a = CreateArea;
28573 my ($alphabetN, $alphabetA) = Nasm::X86::Unisyn::Lex::AlphabetsArray;
28574  
28575 my ($transitionsN, $transitionsA) = Nasm::X86::Unisyn::Lex::PermissibleTransitionsArray; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
28576  
28577  
28578 $a->appendVar(V address => "[$transitionsN]");
28579 $a->appendVar(V address => "[$alphabetN]"); # Save sizes at start if area where they can be easily found
28580  
28581 $a->appendMemory(V(address => $transitionsA), V size => "[$transitionsN]"); # Save transitions
28582 $a->appendMemory(V(address => $alphabetA), V size => "[$alphabetN]"); # Save alphabets classification
28583  
28584 $a->write("z123.txt"); # Save the area to the named file
28585 ok Assemble eq => <<END;
28586 END
28587 }
28588  
28589  
28590 =head3 Nasm::X86::Unisyn::Lex::AlphabetsArray()
28591  
28592 Create an array of utf32 to alphabet number.
28593  
28594  
28595 B<Example:>
28596  
28597  
28598  
28599 my ($N, $A) = Nasm::X86::Unisyn::Lex::AlphabetsArray; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
28600  
28601 Mov rax, "[$N]";
28602 PrintOutRegisterInHex rax;
28603 Mov rax, $A;
28604 Add rax, ord('𝝰');
28605 Mov al, "[rax]";
28606 And rax, 0xff;
28607 PrintOutRegisterInHex rax;
28608  
28609 Mov rax, $A;
28610 Add rax, ord('𝔸');
28611 Mov al, "[rax]";
28612 And rax, 0xff;
28613 PrintOutRegisterInHex rax;
28614  
28615 my sub expect($)
28616 {my ($n) = @_; # Parameters
28617 $n >= 0x10 ? sprintf("%2X", $n) : sprintf(".%1X", $n)
28618 }
28619  
28620 my $a = expect Nasm::X86::Unisyn::Lex::Number::v;
28621 my $b = expect Nasm::X86::Unisyn::Lex::Number::d;
28622 ok Assemble eq => <<END, avx512=>1;
28623 rax: .... .... ...1 EEF2
28624 rax: .... .... .... ..$a
28625 rax: .... .... .... ..$b
28626 END
28627  
28628 if (1) # Place parser tables into an area
28629 {my $a = CreateArea;
28630  
28631 my ($alphabetN, $alphabetA) = Nasm::X86::Unisyn::Lex::AlphabetsArray; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
28632  
28633 my ($transitionsN, $transitionsA) = Nasm::X86::Unisyn::Lex::PermissibleTransitionsArray;
28634  
28635 $a->appendVar(V address => "[$transitionsN]");
28636 $a->appendVar(V address => "[$alphabetN]"); # Save sizes at start if area where they can be easily found
28637  
28638 $a->appendMemory(V(address => $transitionsA), V size => "[$transitionsN]"); # Save transitions
28639 $a->appendMemory(V(address => $alphabetA), V size => "[$alphabetN]"); # Save alphabets classification
28640  
28641 $a->write("z123.txt"); # Save the area to the named file
28642 ok Assemble eq => <<END;
28643 END
28644 }
28645  
28646  
28647 =head3 Nasm::X86::Unisyn::Lex::letterToNumber()
28648  
28649 Map each letter in the union of the alphabets to a sequential number
28650  
28651  
28652 B<Example:>
28653  
28654  
28655 if (1)
28656  
28657 {my ($n, $l) = Nasm::X86::Unisyn::Lex::letterToNumber; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
28658  
28659 my ($N, $L) = Nasm::X86::Unisyn::Lex::numberToLetter;
28660  
28661 If $N > $n,
28662 Then
28663 {PrintErrTraceBack "Numbers to letters cannot be greater than letters to numbers";
28664 };
28665  
28666 $l->setReg(rax);
28667 $L->setReg(rbx);
28668  
28669 $n->for(sub
28670 {my ($i, $start, $next, $end) = @_;
28671 $i->setReg(rsi); # The character we want to test as utf32
28672  
28673 Mov edx, "[rax+4*rsi]"; # The unisyn number of a letter
28674 Cmp edx, -1;
28675 Je $next; # Not a unisyn chaarcter
28676  
28677 Mov r15d, "[rbx+4*rdx]"; # r15 contains the utf32 representation of a unisyn letter
28678  
28679 Cmp r15, rsi; # Check that we retirved th chaarcter westarted with
28680 IfNe
28681 Then
28682 {$i->outNL("Mismatch: ");
28683 PrintOutRegisterInHex rsi, r15;
28684 }
28685 });
28686  
28687 ok Assemble eq => <<END;
28688 END
28689 }
28690  
28691  
28692 =head3 Nasm::X86::Unisyn::Lex::numberToLetter()
28693  
28694 Recover a letter from its unique number
28695  
28696  
28697 B<Example:>
28698  
28699  
28700 if (1)
28701 {my ($n, $l) = Nasm::X86::Unisyn::Lex::letterToNumber;
28702  
28703 my ($N, $L) = Nasm::X86::Unisyn::Lex::numberToLetter; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
28704  
28705  
28706 If $N > $n,
28707 Then
28708 {PrintErrTraceBack "Numbers to letters cannot be greater than letters to numbers";
28709 };
28710  
28711 $l->setReg(rax);
28712 $L->setReg(rbx);
28713  
28714 $n->for(sub
28715 {my ($i, $start, $next, $end) = @_;
28716 $i->setReg(rsi); # The character we want to test as utf32
28717  
28718 Mov edx, "[rax+4*rsi]"; # The unisyn number of a letter
28719 Cmp edx, -1;
28720 Je $next; # Not a unisyn chaarcter
28721  
28722 Mov r15d, "[rbx+4*rdx]"; # r15 contains the utf32 representation of a unisyn letter
28723  
28724 Cmp r15, rsi; # Check that we retirved th chaarcter westarted with
28725 IfNe
28726 Then
28727 {$i->outNL("Mismatch: ");
28728 PrintOutRegisterInHex rsi, r15;
28729 }
28730 });
28731  
28732 ok Assemble eq => <<END;
28733 END
28734 }
28735  
28736  
28737 =head2 Parse
28738  
28739 Parse Unisyn language statements.
28740  
28741 =head3 ParseUnisyn($a8, $s8)
28742  
28743 Parse a string of utf8 characters.
28744  
28745 Parameter Description
28746 1 $a8 Address of utf8 source string
28747 2 $s8 Size of utf8 source string in bytes
28748  
28749 B<Example:>
28750  
28751  
28752 my $f = "zzzOperators.lib"; # Methods to be called against each syntactic item
28753  
28754 my $library = Subroutine # This subroutine and all of the subroutines it contains will be saved in an area and that area will be written to a file from where it can be included via L<incBin> in subsequent assemblies.
28755 {my ($p, $s, $sub) = @_;
28756  
28757 Subroutine # A contained routine that we wish to export to a file
28758 {my ($p, $s, $sub) = @_;
28759 PrintOutString "Ascii: ";
28760  
28761 my $parse = $$s{parse}; # Parse
28762 my $source = $parse->source; # Source
28763  
28764 $parse->area->getZmmBlock($$p{offset}, 1); # Load current parse tree node
28765  
28766 my $w = dSize;
28767 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of ascii
28768 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in source
28769  
28770 ($source+$position)->printOutMemoryNL($length); # Print the ascii string
28771  
28772 } name => "Ascii",
28773 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28774 parameters => [qw(offset)];
28775  
28776 Subroutine # Another subroutine that will be exported because it is within the subroutine that is being exported as a library
28777 {my ($p, $s, $sub) = @_;
28778 PrintOutStringNL "Add";
28779 } name => "+",
28780 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28781 parameters => [qw(offset)];
28782  
28783 Subroutine
28784 {my ($p, $s, $sub) = @_;
28785 PrintOutStringNL "Times";
28786 } name => "✕",
28787 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28788 parameters => [qw(offset)];
28789  
28790 Subroutine
28791 {my ($p, $s, $sub) = @_;
28792 PrintOutStringNL "And";
28793 } name => "𝕒𝕟𝕕",
28794 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28795 parameters => [qw(offset)];
28796  
28797  
28798 Subroutine
28799 {my ($p, $s, $sub) = @_;
28800 PrintOutString "Variable: ";
28801  
28802 my $parse = $$s{parse}; # Parse
28803 my $source = $parse->source; # Source
28804  
28805 $parse->area->getZmmBlock($$p{offset}, 1); # Load current parse tree node
28806  
28807 my $w = dSize;
28808 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of ascii
28809 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in source
28810  
28811 ($source+$position)->printOutMemoryNL($length); # Print the ascii string
28812  
28813 } name => "Variable",
28814 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28815 parameters => [qw(offset)];
28816  
28817 } name => "operators", parameters=>[qw(a b c)], export => $f;
28818  
28819 ok Assemble eq => <<END, avx512=>1;
28820 END
28821  
28822 my $l = ReadArea $f; # Area containing subroutine library
28823  
28824 my ($A, $N) = constantString qq(1+𝗔✕𝗕+𝗖𝕒𝕟𝕕2✕𝗔+𝗕+𝗖); # Utf8 string to parse
28825  
28826  
28827 my $p = ParseUnisyn($A, $N); # 10_445 Parse utf8 string 5_340 after single character lexical items, 4_950 after jump table # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
28828  
28829  
28830 $p->dumpParseResult;
28831  
28832 $p->traverseApplyingLibraryOperators($l); # Traverse a parse tree applying a library of operators where they intersect with lexical items in the parse tree
28833  
28834 # ✕ 2715
28835 # + ff0b
28836  
28837 ok Assemble eq => <<END, clocks=>20_921;
28838 parseChar : .... .... ...1 D5D6
28839 parseFail : .... .... .... ...0
28840 position : .... .... .... ..38
28841 parseMatch : .... .... .... ...0
28842 parseReason: .... .... .... ...0
28843 𝕒𝕟𝕕
28844 ._+
28845 ._._✕
28846 ._._._+
28847 ._._._._1
28848 ._._._._𝗔
28849 ._._._𝗕
28850 ._._𝗖
28851 ._+
28852 ._._+
28853 ._._._✕
28854 ._._._._2
28855 ._._._._𝗔
28856 ._._._𝗕
28857 ._._𝗖
28858 Ascii: 1
28859 Variable: 𝗔
28860 Add
28861 Variable: 𝗕
28862 Times
28863 Variable: 𝗖
28864 Add
28865 Ascii: 2
28866 Variable: 𝗔
28867 Times
28868 Variable: 𝗕
28869 Add
28870 Variable: 𝗖
28871 Add
28872 And
28873 END
28874 unlink $f;
28875  
28876  
28877 =head3 Nasm::X86::Unisyn::Parse::dumpParseResult($parse)
28878  
28879 Dump the result of a parse
28880  
28881 Parameter Description
28882 1 $parse Parse
28883  
28884 B<Example:>
28885  
28886  
28887 my $f = "zzzOperators.lib"; # Methods to be called against each syntactic item
28888  
28889 my $library = Subroutine # This subroutine and all of the subroutines it contains will be saved in an area and that area will be written to a file from where it can be included via L<incBin> in subsequent assemblies.
28890 {my ($p, $s, $sub) = @_;
28891  
28892 Subroutine # A contained routine that we wish to export to a file
28893 {my ($p, $s, $sub) = @_;
28894 PrintOutString "Ascii: ";
28895  
28896 my $parse = $$s{parse}; # Parse
28897 my $source = $parse->source; # Source
28898  
28899 $parse->area->getZmmBlock($$p{offset}, 1); # Load current parse tree node
28900  
28901 my $w = dSize;
28902 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of ascii
28903 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in source
28904  
28905 ($source+$position)->printOutMemoryNL($length); # Print the ascii string
28906  
28907 } name => "Ascii",
28908 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28909 parameters => [qw(offset)];
28910  
28911 Subroutine # Another subroutine that will be exported because it is within the subroutine that is being exported as a library
28912 {my ($p, $s, $sub) = @_;
28913 PrintOutStringNL "Add";
28914 } name => "+",
28915 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28916 parameters => [qw(offset)];
28917  
28918 Subroutine
28919 {my ($p, $s, $sub) = @_;
28920 PrintOutStringNL "Times";
28921 } name => "✕",
28922 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28923 parameters => [qw(offset)];
28924  
28925 Subroutine
28926 {my ($p, $s, $sub) = @_;
28927 PrintOutStringNL "And";
28928 } name => "𝕒𝕟𝕕",
28929 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28930 parameters => [qw(offset)];
28931  
28932  
28933 Subroutine
28934 {my ($p, $s, $sub) = @_;
28935 PrintOutString "Variable: ";
28936  
28937 my $parse = $$s{parse}; # Parse
28938 my $source = $parse->source; # Source
28939  
28940 $parse->area->getZmmBlock($$p{offset}, 1); # Load current parse tree node
28941  
28942 my $w = dSize;
28943 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of ascii
28944 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in source
28945  
28946 ($source+$position)->printOutMemoryNL($length); # Print the ascii string
28947  
28948 } name => "Variable",
28949 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
28950 parameters => [qw(offset)];
28951  
28952 } name => "operators", parameters=>[qw(a b c)], export => $f;
28953  
28954 ok Assemble eq => <<END, avx512=>1;
28955 END
28956  
28957 my $l = ReadArea $f; # Area containing subroutine library
28958  
28959 my ($A, $N) = constantString qq(1+𝗔✕𝗕+𝗖𝕒𝕟𝕕2✕𝗔+𝗕+𝗖); # Utf8 string to parse
28960  
28961 my $p = ParseUnisyn($A, $N); # 10_445 Parse utf8 string 5_340 after single character lexical items, 4_950 after jump table
28962  
28963 $p->dumpParseResult;
28964  
28965 $p->traverseApplyingLibraryOperators($l); # Traverse a parse tree applying a library of operators where they intersect with lexical items in the parse tree
28966  
28967 # ✕ 2715
28968 # + ff0b
28969  
28970 ok Assemble eq => <<END, clocks=>20_921;
28971 parseChar : .... .... ...1 D5D6
28972 parseFail : .... .... .... ...0
28973 position : .... .... .... ..38
28974 parseMatch : .... .... .... ...0
28975 parseReason: .... .... .... ...0
28976 𝕒𝕟𝕕
28977 ._+
28978 ._._✕
28979 ._._._+
28980 ._._._._1
28981 ._._._._𝗔
28982 ._._._𝗕
28983 ._._𝗖
28984 ._+
28985 ._._+
28986 ._._._✕
28987 ._._._._2
28988 ._._._._𝗔
28989 ._._._𝗕
28990 ._._𝗖
28991 Ascii: 1
28992 Variable: 𝗔
28993 Add
28994 Variable: 𝗕
28995 Times
28996 Variable: 𝗖
28997 Add
28998 Ascii: 2
28999 Variable: 𝗔
29000 Times
29001 Variable: 𝗕
29002 Add
29003 Variable: 𝗖
29004 Add
29005 And
29006 END
29007 unlink $f;
29008  
29009  
29010 =head3 Nasm::X86::Unisyn::Parse::dumpPostOrder($parse)
29011  
29012 Dump a parse tree in post order.
29013  
29014 Parameter Description
29015 1 $parse Parse
29016  
29017 B<Example:>
29018  
29019  
29020 my $u = Nasm::X86::Unisyn::Lex::composeUnisyn("va w m+ vb");
29021 my $t = '𝗮 +𝗯';
29022 is_deeply $u, $t;
29023  
29024 my $p = &ParseUnisyn(constantString $t); # Parse the utf8 string minus the final new line
29025  
29026 $p->dumpPostOrder;
29027 ok Assemble eq <<END;
29028 ._𝗮 
29029 ._𝗯
29030 +
29031 END
29032  
29033 if (1)
29034 {my $t = Nasm::X86::Unisyn::Lex::composeUnisyn "va w m+ w vb";
29035 is_deeply $t, "𝗮 + 𝗯";
29036 my $p = &ParseUnisyn(constantString $t);
29037 $p->dumpPostOrder;
29038 ok Assemble eq => <<END;
29039 ._𝗮 
29040 ._𝗯
29041 + 
29042 END
29043 }
29044  
29045  
29046 =head3 Nasm::X86::Unisyn::Parse::traverseApplyingLibraryOperators($parse, $library)
29047  
29048 Traverse a parse tree, in post order, applying a library of operators.
29049  
29050 Parameter Description
29051 1 $parse Parse tree
29052 2 $library Area containing a library
29053  
29054 B<Example:>
29055  
29056  
29057 my $f = "zzzOperators.lib"; # Methods to be called against each syntactic item
29058  
29059 my $library = Subroutine # This subroutine and all of the subroutines it contains will be saved in an area and that area will be written to a file from where it can be included via L<incBin> in subsequent assemblies.
29060 {my ($p, $s, $sub) = @_;
29061  
29062 Subroutine # A contained routine that we wish to export to a file
29063 {my ($p, $s, $sub) = @_;
29064 PrintOutString "Ascii: ";
29065  
29066 my $parse = $$s{parse}; # Parse
29067 my $source = $parse->source; # Source
29068  
29069 $parse->area->getZmmBlock($$p{offset}, 1); # Load current parse tree node
29070  
29071 my $w = dSize;
29072 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of ascii
29073 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in source
29074  
29075 ($source+$position)->printOutMemoryNL($length); # Print the ascii string
29076  
29077 } name => "Ascii",
29078 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
29079 parameters => [qw(offset)];
29080  
29081 Subroutine # Another subroutine that will be exported because it is within the subroutine that is being exported as a library
29082 {my ($p, $s, $sub) = @_;
29083 PrintOutStringNL "Add";
29084 } name => "+",
29085 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
29086 parameters => [qw(offset)];
29087  
29088 Subroutine
29089 {my ($p, $s, $sub) = @_;
29090 PrintOutStringNL "Times";
29091 } name => "✕",
29092 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
29093 parameters => [qw(offset)];
29094  
29095 Subroutine
29096 {my ($p, $s, $sub) = @_;
29097 PrintOutStringNL "And";
29098 } name => "𝕒𝕟𝕕",
29099 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
29100 parameters => [qw(offset)];
29101  
29102  
29103 Subroutine
29104 {my ($p, $s, $sub) = @_;
29105 PrintOutString "Variable: ";
29106  
29107 my $parse = $$s{parse}; # Parse
29108 my $source = $parse->source; # Source
29109  
29110 $parse->area->getZmmBlock($$p{offset}, 1); # Load current parse tree node
29111  
29112 my $w = dSize;
29113 my $length = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::length); # Length of ascii
29114 my $position = dFromZ(1, $w * Nasm::X86::Unisyn::Lex::position); # Position in source
29115  
29116 ($source+$position)->printOutMemoryNL($length); # Print the ascii string
29117  
29118 } name => "Variable",
29119 structures => {parse => Nasm::X86::Unisyn::DescribeParse},
29120 parameters => [qw(offset)];
29121  
29122 } name => "operators", parameters=>[qw(a b c)], export => $f;
29123  
29124 ok Assemble eq => <<END, avx512=>1;
29125 END
29126  
29127 my $l = ReadArea $f; # Area containing subroutine library
29128  
29129 my ($A, $N) = constantString qq(1+𝗔✕𝗕+𝗖𝕒𝕟𝕕2✕𝗔+𝗕+𝗖); # Utf8 string to parse
29130  
29131 my $p = ParseUnisyn($A, $N); # 10_445 Parse utf8 string 5_340 after single character lexical items, 4_950 after jump table
29132  
29133 $p->dumpParseResult;
29134  
29135 $p->traverseApplyingLibraryOperators($l); # Traverse a parse tree applying a library of operators where they intersect with lexical items in the parse tree
29136  
29137 # ✕ 2715
29138 # + ff0b
29139  
29140 ok Assemble eq => <<END, clocks=>20_921;
29141 parseChar : .... .... ...1 D5D6
29142 parseFail : .... .... .... ...0
29143 position : .... .... .... ..38
29144 parseMatch : .... .... .... ...0
29145 parseReason: .... .... .... ...0
29146 𝕒𝕟𝕕
29147 ._+
29148 ._._✕
29149 ._._._+
29150 ._._._._1
29151 ._._._._𝗔
29152 ._._._𝗕
29153 ._._𝗖
29154 ._+
29155 ._._+
29156 ._._._✕
29157 ._._._._2
29158 ._._._._𝗔
29159 ._._._𝗕
29160 ._._𝗖
29161 Ascii: 1
29162 Variable: 𝗔
29163 Add
29164 Variable: 𝗕
29165 Times
29166 Variable: 𝗖
29167 Add
29168 Ascii: 2
29169 Variable: 𝗔
29170 Times
29171 Variable: 𝗕
29172 Add
29173 Variable: 𝗖
29174 Add
29175 And
29176 END
29177 unlink $f;
29178  
29179  
29180 =head1 Assemble
29181  
29182 Assemble generated code
29183  
29184 =head2 CallC($sub, @parameters)
29185  
29186 Call a C subroutine.
29187  
29188 Parameter Description
29189 1 $sub Name of the sub to call
29190 2 @parameters Parameters
29191  
29192 B<Example:>
29193  
29194  
29195 my $format = Rs "Hello %s
29196 ";
29197 my $data = Rs "World";
29198  
29199 Extern qw(printf exit malloc strcpy); Link 'c';
29200  
29201  
29202 CallC 'malloc', length($format)+1; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29203  
29204 Mov r15, rax;
29205  
29206 CallC 'strcpy', r15, $format; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29207  
29208  
29209 CallC 'printf', r15, $data; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29210  
29211  
29212 CallC 'exit', 0; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29213  
29214  
29215 ok Assemble avx512=>0, eq => <<END;
29216 Hello World
29217 END
29218  
29219  
29220 =head2 Extern(@externalReferences)
29221  
29222 Name external references.
29223  
29224 Parameter Description
29225 1 @externalReferences External references
29226  
29227 B<Example:>
29228  
29229  
29230 my $format = Rs "Hello %s
29231 ";
29232 my $data = Rs "World";
29233  
29234  
29235 Extern qw(printf exit malloc strcpy); Link 'c'; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29236  
29237  
29238 CallC 'malloc', length($format)+1;
29239 Mov r15, rax;
29240 CallC 'strcpy', r15, $format;
29241 CallC 'printf', r15, $data;
29242 CallC 'exit', 0;
29243  
29244 ok Assemble avx512=>0, eq => <<END;
29245 Hello World
29246 END
29247  
29248  
29249 =head2 Link(@libraries)
29250  
29251 Libraries to link with.
29252  
29253 Parameter Description
29254 1 @libraries Link library names which will be looked for on "LIBPATH"
29255  
29256 B<Example:>
29257  
29258  
29259 my $format = Rs "Hello %s
29260 ";
29261 my $data = Rs "World";
29262  
29263  
29264 Extern qw(printf exit malloc strcpy); Link 'c'; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29265  
29266  
29267 CallC 'malloc', length($format)+1;
29268 Mov r15, rax;
29269 CallC 'strcpy', r15, $format;
29270 CallC 'printf', r15, $data;
29271 CallC 'exit', 0;
29272  
29273 ok Assemble avx512=>0, eq => <<END;
29274 Hello World
29275 END
29276  
29277  
29278 =head2 Start()
29279  
29280 Initialize the assembler.
29281  
29282  
29283 B<Example:>
29284  
29285  
29286  
29287 Start; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29288  
29289 Exit(0);
29290 ok Assemble eq => <<END;
29291 END
29292  
29293  
29294 =head2 Exit($c)
29295  
29296 Exit with the specified return code or zero if no return code supplied. Assemble() automatically adds a call to Exit(0) if the last operation in the program is not a call to Exit.
29297  
29298 Parameter Description
29299 1 $c Return code
29300  
29301 B<Example:>
29302  
29303  
29304 Start;
29305  
29306 Exit(0); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29307  
29308 ok Assemble eq => <<END;
29309 END
29310  
29311 Comment "Print a string from memory";
29312 my $s = "Hello World";
29313 Mov rax, Rs($s);
29314 Mov rdi, length $s;
29315 PrintOutMemory;
29316  
29317 Exit(0); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29318  
29319  
29320 ok Assemble(avx512=>0) =~ m(Hello World);
29321  
29322  
29323 =head2 Assemble(%options)
29324  
29325 Assemble the generated code.
29326  
29327 Parameter Description
29328 1 %options Options
29329  
29330 B<Example:>
29331  
29332  
29333 PrintOutStringNL "Hello World";
29334 PrintOutStringNL "Hello
29335 World";
29336 PrintErrStringNL "Hello World";
29337  
29338  
29339 ok Assemble eq => <<END, avx512=>0, label=>'t1'; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29340  
29341 Hello World
29342 Hello
29343 World
29344 END
29345  
29346  
29347 ok Assemble eq => <<END, mix=>1; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29348  
29349 END
29350  
29351  
29352 =head1 Awaiting Classification
29353  
29354 Routines that have not yet been classified.
29355  
29356  
29357 =head1 Hash Definitions
29358  
29359  
29360  
29361  
29362 =head2 Nasm::X86 Definition
29363  
29364  
29365 Tree
29366  
29367  
29368  
29369  
29370 =head3 Output fields
29371  
29372  
29373 =head4 B
29374  
29375 Log2 of size of initial allocation
29376  
29377 =head4 N
29378  
29379 Initial allocation
29380  
29381 =head4 address
29382  
29383 Variable that addresses the memory containing the area
29384  
29385 =head4 area
29386  
29387 Area definition.
29388  
29389 =head4 block
29390  
29391 Block used to generate this subroutine
29392  
29393 =head4 constant
29394  
29395 Constant if true
29396  
29397 =head4 data
29398  
29399 Variable containing the current data
29400  
29401 =head4 dataOffset
29402  
29403 The start of the data
29404  
29405 =head4 end
29406  
29407 End label for this subroutine
29408  
29409 =head4 export
29410  
29411 File this subroutine was exported to if any
29412  
29413 =head4 expr
29414  
29415 Expression that initializes the variable
29416  
29417 =head4 fcArray
29418  
29419 Offset of cached array in first block
29420  
29421 =head4 fcControl
29422  
29423 Offset of the tree bits and present bits in the first cache of low key values for this tree.
29424  
29425 =head4 fcDWidth
29426  
29427 Number of dwords available in the first cache. The first cache supplies an alternate area to store the values of keys less than this value to fill the otherwise unused space in a way that improves the performance of trees when used to represent small arrays, stacks or structures.
29428  
29429 =head4 fcPresent
29430  
29431 Offset of the present bits in the control dword
29432  
29433 =head4 fcPresentOff
29434  
29435 Byte offset of word containing present bits
29436  
29437 =head4 fcTreeBits
29438  
29439 Offset of the tree bits in bits in the control dword
29440  
29441 =head4 fcTreeBitsOff
29442  
29443 Byte offset of word containing tree bits
29444  
29445 =head4 first
29446  
29447 Variable addressing offset to first block of the tree which is the header block
29448  
29449 =head4 found
29450  
29451 Variable indicating whether the last find was successful or not
29452  
29453 =head4 freeOffset
29454  
29455 Free chain offset
29456  
29457 =head4 key
29458  
29459 Variable containing the current key
29460  
29461 =head4 keyDataMask
29462  
29463 Key data mask
29464  
29465 =head4 label
29466  
29467 Address in memory
29468  
29469 =head4 length
29470  
29471 Number of keys in a maximal block
29472  
29473 =head4 lengthLeft
29474  
29475 Left minimal number of keys
29476  
29477 =head4 lengthMiddle
29478  
29479 Number of splitting key counting from 1
29480  
29481 =head4 lengthMin
29482  
29483 The smallest number of keys we are allowed in any node other than a root node.
29484  
29485 =head4 lengthOffset
29486  
29487 Offset of length in keys block. The length field is a word - see: "MultiWayTree.svg"
29488  
29489 =head4 lengthRight
29490  
29491 Right minimal number of keys
29492  
29493 =head4 loop
29494  
29495 Offset of keys, data, node loop.
29496  
29497 =head4 maxKeys
29498  
29499 Maximum number of keys allowed in this tree which might well ne less than the maximum we can store in a zmm.
29500  
29501 =head4 maxKeysZ
29502  
29503 The maximum possible number of keys in a zmm register
29504  
29505 =head4 maxNodesZ
29506  
29507 The maximum possible number of nodes in a zmm register
29508  
29509 =head4 middleOffset
29510  
29511 Offset of the middle slot in bytes
29512  
29513 =head4 name
29514  
29515 Optional name
29516  
29517 =head4 nextOffset
29518  
29519 Position of next offset on free chain
29520  
29521 =head4 nodeMask
29522  
29523 Node mask
29524  
29525 =head4 offset
29526  
29527 Variable containing the offset of the block containing the current key
29528  
29529 =head4 options
29530  
29531 Options used by the author of the subroutine
29532  
29533 =head4 optionsOffset
29534  
29535 Offset of the options double word in the first block
29536  
29537 =head4 parameters
29538  
29539 Parameters definitions supplied by the author of the subroutine which get mapped in to parameter variables.
29540  
29541 =head4 position
29542  
29543 Position in stack frame
29544  
29545 =head4 reference
29546  
29547 Reference to another variable
29548  
29549 =head4 rightOffset
29550  
29551 Offset of the first right slot in bytes
29552  
29553 =head4 rootOffset
29554  
29555 Offset of the root field in the first block - the root field contains the offset of the block containing the keys of the root of the tree
29556  
29557 =head4 sizeOffset
29558  
29559 Offset of the size field in the first block - tells us the number of keys in the tree
29560  
29561 =head4 splittingKey
29562  
29563 Offset at which to split a full block
29564  
29565 =head4 stack
29566  
29567 MArk the area as being used as a stack
29568  
29569 =head4 start
29570  
29571 Start label for this subroutine which includes the enter instruction used to create a new stack frame
29572  
29573 =head4 stringTree
29574  
29575 String tree - now obsolete
29576  
29577 =head4 stringTreeBit
29578  
29579 Bit indicating string key tree
29580  
29581 =head4 stringTreeCountOff
29582  
29583 This field is used to count the total number of keys in a string tree so that we can assign unique numbers when pushing.
29584  
29585 =head4 structureCopies
29586  
29587 Copies of the structures passed to this subroutine with their variables replaced with references
29588  
29589 =head4 structureVariables
29590  
29591 Map structure variables to references at known positions in the sub
29592  
29593 =head4 subTree
29594  
29595 Variable indicating whether the last find found a sub tree
29596  
29597 =head4 treeBits
29598  
29599 Offset of tree bits in keys block. The tree bits field is a word, each bit of which tells us whether the corresponding data element is the offset (or not) to a sub tree of this tree .
29600  
29601 =head4 treeBitsMask
29602  
29603 Total of 14 tree bits
29604  
29605 =head4 treeOffset
29606  
29607 Yggdrasil - a tree of global variables in this area
29608  
29609 =head4 up
29610  
29611 Offset of up in data block.
29612  
29613 =head4 usedOffset
29614  
29615 Used field offset
29616  
29617 =head4 variables
29618  
29619 Map parameters to references at known positions in the sub
29620  
29621 =head4 vars
29622  
29623 Number of variables in subroutine
29624  
29625 =head4 width
29626  
29627 Width of a key or data slot.
29628  
29629 =head4 zWidth
29630  
29631 Width of a zmm register
29632  
29633 =head4 zWidthD
29634  
29635 Width of a zmm in double words being the element size
29636  
29637 =head4 zmmBlock
29638  
29639 Size of a zmm block - 64 bytes
29640  
29641  
29642  
29643 =head1 Attributes
29644  
29645  
29646 The following is a list of all the attributes in this package. A method coded
29647 with the same name in your package will over ride the method of the same name
29648 in this package and thus provide your value for the attribute in place of the
29649 default value supplied for this attribute by this package.
29650  
29651 =head2 Replaceable Attribute List
29652  
29653  
29654 Pi32 Pi64 bSize dSize qSize wSize
29655  
29656  
29657 =head2 Pi32
29658  
29659 Pi as a 32 bit float.
29660  
29661  
29662 =head2 Pi64
29663  
29664 Pi as a 64 bit float.
29665  
29666  
29667 =head2 bSize
29668  
29669 Size of a byte in bytes
29670  
29671  
29672 =head2 dSize
29673  
29674 Size of a double word in bytes
29675  
29676  
29677 =head2 qSize
29678  
29679 Size of a quad word in bytes
29680  
29681  
29682 =head2 wSize
29683  
29684 Size of a word in bytes
29685  
29686  
29687  
29688  
29689 =head1 Private Methods
29690  
29691 =head2 Dbwdq($s, @d)
29692  
29693 Layout data.
29694  
29695 Parameter Description
29696 1 $s Element size
29697 2 @d Data to be laid out
29698  
29699 =head2 Rbwdq($s, @d)
29700  
29701 Layout data.
29702  
29703 Parameter Description
29704 1 $s Element size
29705 2 @d Data to be laid out
29706  
29707 =head2 PushRR(@r)
29708  
29709 Push registers onto the stack without tracking.
29710  
29711 Parameter Description
29712 1 @r Register
29713  
29714 =head2 PopRR(@r)
29715  
29716 Pop registers from the stack without tracking.
29717  
29718 Parameter Description
29719 1 @r Register
29720  
29721 =head2 registerNameFromNumber($r)
29722  
29723 Register name from number where possible.
29724  
29725 Parameter Description
29726 1 $r Register number
29727  
29728 =head2 ChooseRegisters($number, @registers)
29729  
29730 Choose the specified numbers of registers excluding those on the specified list.
29731  
29732 Parameter Description
29733 1 $number Number of registers needed
29734 2 @registers Registers not to choose
29735  
29736 =head2 checkZmmRegister($z)
29737  
29738 Check that a register is a zmm register.
29739  
29740 Parameter Description
29741 1 $z Parameters
29742  
29743 =head2 LoadRegFromMm($mm, $offset, $reg)
29744  
29745 Load the specified register from the numbered zmm at the quad offset specified as a constant number.
29746  
29747 Parameter Description
29748 1 $mm Mm register
29749 2 $offset Offset in quads
29750 3 $reg General purpose register to load
29751  
29752 B<Example:>
29753  
29754  
29755 Mov rax, 1; SaveRegIntoMm(zmm0, 0, rax);
29756 Mov rax, 2; SaveRegIntoMm(zmm0, 1, rax);
29757 Mov rax, 3; SaveRegIntoMm(zmm0, 2, rax);
29758 Mov rax, 4; SaveRegIntoMm(zmm0, 3, rax);
29759  
29760  
29761 LoadRegFromMm(zmm0, 0, r15); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29762  
29763  
29764 LoadRegFromMm(zmm0, 1, r14); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29765  
29766  
29767 LoadRegFromMm(zmm0, 2, r13); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29768  
29769  
29770 LoadRegFromMm(zmm0, 3, r12); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29771  
29772  
29773 PrintOutRegisterInHex ymm0, r15, r14, r13, r12;
29774 ok Assemble(debug => 0, eq => <<END, avx512=>1);
29775 ymm0: .... .... .... ...4 .... .... .... ...3 - .... .... .... ...2 .... .... .... ...1
29776 r15: .... .... .... ...1
29777 r14: .... .... .... ...2
29778 r13: .... .... .... ...3
29779 r12: .... .... .... ...4
29780 END
29781  
29782  
29783 =head2 extractRegisterNumberFromMM($mm)
29784  
29785 Extract the register number from an *mm register.
29786  
29787 Parameter Description
29788 1 $mm Mmm register
29789  
29790 =head2 getBwdqFromMm($xyz, $size, $mm, $offset, %options)
29791  
29792 Get the numbered byte|word|double word|quad word from the numbered zmm register and return it in a variable.
29793  
29794 Parameter Description
29795 1 $xyz Size of mm
29796 2 $size Size of get
29797 3 $mm Mm register
29798 4 $offset Offset in bytes either as a constant or as a variable
29799 5 %options Options
29800  
29801 =head2 LoadConstantIntoMaskRegister($mask, $value)
29802  
29803 Set a mask register equal to a constant.
29804  
29805 Parameter Description
29806 1 $mask Number of mask register to load
29807 2 $value Constant to load
29808  
29809 =head2 createBitNumberFromAlternatingPattern($prefix, @values)
29810  
29811 Create a number from a bit pattern.
29812  
29813 Parameter Description
29814 1 $prefix Prefix bits
29815 2 @values +n 1 bits -n 0 bits
29816  
29817 =head2 opposingJump($j)
29818  
29819 Return the opposite of a jump.
29820  
29821 Parameter Description
29822 1 $j Jump
29823  
29824 B<Example:>
29825  
29826  
29827  
29828 is_deeply opposingJump(q(Jl)), q(Jge); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29829  
29830  
29831 is_deeply opposingJump(q(Jg)), q(Jle); # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
29832  
29833  
29834  
29835 =head2 IfS($then, $else)
29836  
29837 If signed greater than or equal execute the then block else the else block.
29838  
29839 Parameter Description
29840 1 $then Then - required
29841 2 $else Else - optional
29842  
29843 =head2 IfNs($then, $else)
29844  
29845 If signed less than execute the then block else the else block.
29846  
29847 Parameter Description
29848 1 $then Then - required
29849 2 $else Else - optional
29850  
29851 =head2 SubroutineStartStack()
29852  
29853 Initialize a new stack frame. The first quad of each frame has the address of the name of the sub in the low dword, and the parameter count in the upper byte of the quad. This field is all zeroes in the initial frame.
29854  
29855  
29856 =head2 copyStructureMinusVariables($s)
29857  
29858 Copy a non recursive structure ignoring variables.
29859  
29860 Parameter Description
29861 1 $s Structure to copy
29862  
29863 =head2 Nasm::X86::Subroutine::writeLibraryToArea($s, $subs)
29864  
29865 Write a subroutine library to an area then save the area in a file so that the subroutine can be reloaded at a later date either as separate file or via incorporation into a thing. A thing was originally an assembly of people as in "The Allthing" or the "Stort Thing".
29866  
29867 Parameter Description
29868 1 $s Sub definition of containing subroutine
29869 2 $subs Definitions of contained subroutines
29870  
29871 =head2 Nasm::X86::Area::readLibraryHeader($area, $uniqueStrings, $singleLetterArray)
29872  
29873 Create a tree mapping the numbers assigned to subroutine names to the offsets of the corresponding routines in a library returning the intersection so formed mapping the lexical item numbers (not names) encountered during parsing with the matching routines in the library. Optionally a subroutine (like Nasm::X86::Unisyn::Lex::letterToNumber) can be provided that returns details of an array that maps a single utf32 character to a smaller number which will be assumed to be the number of the routine with that single letter as its name.
29874  
29875 Parameter Description
29876 1 $area Area containing subroutine library
29877 2 $uniqueStrings Unique strings from parse
29878 3 $singleLetterArray Subroutine returning details of a single character mapping array
29879  
29880 B<Example:>
29881  
29882  
29883 my $a = CreateArea;
29884  
29885 my $u = $a->CreateTree(stringTree=>1);
29886 $u->putKeyString(constantString("ab"), K key => 1);
29887 $u->putKeyString(constantString("ac"), K key => 3);
29888 $u->putKeyString(constantString("𝕒𝕒"), K key => 4);
29889  
29890 my %s = (ab => 2, 𝕒𝕒 =>8, 𝗮𝗮𝗮=>12, 𝝰𝝰𝝰𝝰=>16); # Subroutine names and offsets
29891  
29892 $a->writeLibraryHeader({%s});
29893 my ($inter, $subroutines) = $a->readLibraryHeader($u);
29894  
29895 $inter->dump("TT");
29896  
29897 ok Assemble eq => <<END, clocks=>4374;
29898 TT
29899 At: 1C0 length: 2, data: 200, nodes: 240, first: 40, root, leaf
29900 Index: 0 1
29901 Keys : 1 4
29902 Data : 2 8
29903 end
29904 END
29905  
29906 my $a = CreateArea;
29907 my $t = $a->CreateTree;
29908  
29909 K(loop => 16)->for(sub
29910 {my ($i, $start, $next, $end) = @_;
29911 my $T = $a->CreateTree;
29912 $t->put($i, $T);
29913 $t->size->outNL;
29914 });
29915  
29916 K(loop => 16)->for(sub
29917 {my ($i, $start, $next, $end) = @_;
29918 $t->popSubTree;
29919 $t->size->outNL;
29920 });
29921  
29922 ok Assemble eq => <<END, avx512=>1;
29923 size of tree: .... .... .... ...1
29924 size of tree: .... .... .... ...2
29925 size of tree: .... .... .... ...3
29926 size of tree: .... .... .... ...4
29927 size of tree: .... .... .... ...5
29928 size of tree: .... .... .... ...6
29929 size of tree: .... .... .... ...7
29930 size of tree: .... .... .... ...8
29931 size of tree: .... .... .... ...9
29932 size of tree: .... .... .... ...A
29933 size of tree: .... .... .... ...B
29934 size of tree: .... .... .... ...C
29935 size of tree: .... .... .... ...D
29936 size of tree: .... .... .... ...E
29937 size of tree: .... .... .... ...F
29938 size of tree: .... .... .... ..10
29939 size of tree: .... .... .... ...F
29940 size of tree: .... .... .... ...E
29941 size of tree: .... .... .... ...D
29942 size of tree: .... .... .... ...C
29943 size of tree: .... .... .... ...B
29944 size of tree: .... .... .... ...A
29945 size of tree: .... .... .... ...9
29946 size of tree: .... .... .... ...8
29947 size of tree: .... .... .... ...7
29948 size of tree: .... .... .... ...6
29949 size of tree: .... .... .... ...5
29950 size of tree: .... .... .... ...4
29951 size of tree: .... .... .... ...3
29952 size of tree: .... .... .... ...2
29953 size of tree: .... .... .... ...1
29954 size of tree: .... .... .... ...0
29955 END
29956  
29957 my $a = CreateArea;
29958 my $t = $a->CreateTree;
29959 my $T = $a->CreateTree;
29960 $t->push($T);
29961 $a->dump("AA");
29962 $t->popSubTree;
29963 $a->dump("BB");
29964  
29965 ok Assemble eq => <<END, avx512=>1;
29966 AA
29967 Area Size: 4096 Used: 384
29968 .... .... .... ...0 | __10 ____ ____ ____ 80.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
29969 .... .... .... ..40 | C0__ ____ ____ ____ .1__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
29970 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
29971 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .1__ .1__ __.1 ____
29972 BB
29973 Area Size: 4096 Used: 384
29974 .... .... .... ...0 | __10 ____ ____ ____ 80.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
29975 .... .... .... ..40 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
29976 .... .... .... ..80 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
29977 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .1__ .1__ __.1 ____
29978 END
29979  
29980  
29981 =head2 Nasm::X86::Subroutine::subroutineDefinition($area, $file, $name)
29982  
29983 Get the definition of a subroutine from an area.
29984  
29985 Parameter Description
29986 1 $area Area - but only to get easy access to this routine
29987 2 $file File containing area
29988 3 $name Name of subroutine whose details we want
29989  
29990 =head2 Nasm::X86::Subroutine::mapStructureVariables($sub, $S, @P)
29991  
29992 Find the paths to variables in the copies of the structures passed as parameters and replace those variables with references so that in the subroutine we can refer to these variables regardless of where they are actually defined.
29993  
29994 Parameter Description
29995 1 $sub Sub definition
29996 2 $S Copies of source structures
29997 3 @P Path through copies of source structures to a variable that becomes a reference
29998  
29999 =head2 Nasm::X86::Subroutine::uploadStructureVariablesToNewStackFrame($sub, $sv, $S, @P)
30000  
30001 Create references to variables in parameter structures from variables in the stack frame of the subroutine.
30002  
30003 Parameter Description
30004 1 $sub Sub definition
30005 2 $sv Structure variables
30006 3 $S Source tree of input structures
30007 4 @P Path through source structures tree
30008  
30009 =head2 Nasm::X86::Subroutine::uploadToNewStackFrame($sub, $sv, $source, $target)
30010  
30011 Map a variable in the current stack into a reference in the next stack frame being the one that will be used by this sub.
30012  
30013 Parameter Description
30014 1 $sub Subroutine descriptor
30015 2 $sv Structure variables
30016 3 $source Source variable in the current stack frame
30017 4 $target The reference in the new stack frame
30018  
30019 =head2 Nasm::X86::Subroutine::validateParameters($sub, %options)
30020  
30021 Check that the parameters and structures presented in a call to a subroutine math those defined for the subroutine.
30022  
30023 Parameter Description
30024 1 $sub Subroutine descriptor
30025 2 %options Options
30026  
30027 =head2 PrintTraceBack($channel)
30028  
30029 Trace the call stack.
30030  
30031 Parameter Description
30032 1 $channel Channel to write on
30033  
30034 =head2 PrintErrTraceBack($message)
30035  
30036 Print sub routine track back on stderr and then exit with a message.
30037  
30038 Parameter Description
30039 1 $message Reason why we are printing the trace back and then stopping
30040  
30041 =head2 PrintNL($channel)
30042  
30043 Print a new line to stdout or stderr.
30044  
30045 Parameter Description
30046 1 $channel Channel to write on
30047  
30048 =head2 PrintErrNL()
30049  
30050 Print a new line to stderr.
30051  
30052  
30053 =head2 PrintString($channel, @string)
30054  
30055 Print a constant string to the specified channel.
30056  
30057 Parameter Description
30058 1 $channel Channel
30059 2 @string Strings
30060  
30061 =head2 PrintStringNL($channel, @string)
30062  
30063 Print a constant string to the specified channel followed by a new line.
30064  
30065 Parameter Description
30066 1 $channel Channel
30067 2 @string Strings
30068  
30069 =head2 PrintErrString(@string)
30070  
30071 Print a constant string to stderr.
30072  
30073 Parameter Description
30074 1 @string String
30075  
30076 =head2 PrintErrStringNL(@string)
30077  
30078 Print a constant string to stderr followed by a new line.
30079  
30080 Parameter Description
30081 1 @string String
30082  
30083 B<Example:>
30084  
30085  
30086 PrintOutStringNL "Hello World";
30087 PrintOutStringNL "Hello
30088 World";
30089  
30090 PrintErrStringNL "Hello World"; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
30091  
30092  
30093 ok Assemble eq => <<END, avx512=>0, label=>'t1';
30094 Hello World
30095 Hello
30096 World
30097 END
30098  
30099  
30100 =head2 PrintCString($channel, $string)
30101  
30102 Print a zero terminated C style string addressed by a variable on the specified channel.
30103  
30104 Parameter Description
30105 1 $channel Channel
30106 2 $string String
30107  
30108 =head2 PrintCStringNL($channel, $string)
30109  
30110 Print a zero terminated C style string addressed by a variable on the specified channel followed by a new line.
30111  
30112 Parameter Description
30113 1 $channel Channel
30114 2 $string Strings
30115  
30116 =head2 PrintSpace($channel, $spaces)
30117  
30118 Print a constant number of spaces to the specified channel.
30119  
30120 Parameter Description
30121 1 $channel Channel
30122 2 $spaces Number of spaces if not one.
30123  
30124 =head2 PrintErrSpace($spaces)
30125  
30126 Print a constant number of spaces to stderr.
30127  
30128 Parameter Description
30129 1 $spaces Number of spaces if not one.
30130  
30131 =head2 hexTranslateTable()
30132  
30133 Create/address a hex translate table and return its label.
30134  
30135  
30136 =head2 PrintRaxInHex($channel, $end)
30137  
30138 Write the content of register rax in hexadecimal in big endian notation to the specified channel.
30139  
30140 Parameter Description
30141 1 $channel Channel
30142 2 $end Optional end byte
30143  
30144 =head2 PrintErrRaxInHex()
30145  
30146 Write the content of register rax in hexadecimal in big endian notation to stderr.
30147  
30148  
30149 =head2 PrintErrRaxInHexNL()
30150  
30151 Write the content of register rax in hexadecimal in big endian notation to stderr followed by a new line.
30152  
30153  
30154 =head2 PrintRax_InHex($channel, $end)
30155  
30156 Write the content of register rax in hexadecimal in big endian notation to the specified channel replacing zero bytes with __.
30157  
30158 Parameter Description
30159 1 $channel Channel
30160 2 $end Optional end byte
30161  
30162 =head2 PrintErrRax_InHex()
30163  
30164 Write the content of register rax in hexadecimal in big endian notation to stderr.
30165  
30166  
30167 =head2 PrintErrRax_InHexNL()
30168  
30169 Write the content of register rax in hexadecimal in big endian notation to stderr followed by a new line.
30170  
30171  
30172 =head2 PrintOneRegisterInHex($channel, $r)
30173  
30174 Print the named register as a hex string.
30175  
30176 Parameter Description
30177 1 $channel Channel to print on
30178 2 $r Register to print
30179  
30180 =head2 PrintErrOneRegisterInHex($r)
30181  
30182 Print the named register as a hex string on stderr.
30183  
30184 Parameter Description
30185 1 $r Register to print
30186  
30187 =head2 PrintErrOneRegisterInHexNL($r)
30188  
30189 Print the named register as a hex string on stderr followed by new line.
30190  
30191 Parameter Description
30192 1 $r Register to print
30193  
30194 =head2 PrintRegisterInHex($channel, @r)
30195  
30196 Print the named registers as hex strings.
30197  
30198 Parameter Description
30199 1 $channel Channel to print on
30200 2 @r Names of the registers to print
30201  
30202 =head2 PrintErrRegisterInHex(@r)
30203  
30204 Print the named registers as hex strings on stderr.
30205  
30206 Parameter Description
30207 1 @r Names of the registers to print
30208  
30209 =head2 PrintOutRipInHex()
30210  
30211 Print the instruction pointer in hex.
30212  
30213  
30214 =head2 PrintOutRflagsInHex()
30215  
30216 Print the flags register in hex.
30217  
30218  
30219 =head2 PrintErrZF()
30220  
30221 Print the zero flag without disturbing it on stderr.
30222  
30223  
30224 =head2 PrintRightInHex($channel, $number, $width)
30225  
30226 Print out a number in hex right justified in a field of specified width on the specified channel.
30227  
30228 Parameter Description
30229 1 $channel Channel
30230 2 $number Number as a variable or register
30231 3 $width Width of output field as a constant
30232  
30233 =head2 PrintErrRightInHex($number, $width)
30234  
30235 Write the specified variable in hexadecimal right justified in a field of specified width on stderr.
30236  
30237 Parameter Description
30238 1 $number Number as a variable
30239 2 $width Width of output field as a variable
30240  
30241 =head2 PrintErrRightInHexNL($number, $width)
30242  
30243 Write the specified variable in hexadecimal right justified in a field of specified width on stderr followed by a new line.
30244  
30245 Parameter Description
30246 1 $number Number as a variable
30247 2 $width Width of output field as a variable
30248  
30249 =head2 PrintRightInBin($channel, $Number, $Width)
30250  
30251 Print out a number in binary right justified in a field of specified width on the specified channel.
30252  
30253 Parameter Description
30254 1 $channel Channel
30255 2 $Number Number as a variable or register
30256 3 $Width Width of output field as a variable or constant
30257  
30258 =head2 PrintErrRightInBin($number, $width)
30259  
30260 Write the specified variable in binary right justified in a field of specified width on stderr.
30261  
30262 Parameter Description
30263 1 $number Number as a variable
30264 2 $width Width of output field as a variable
30265  
30266 =head2 PrintErrRightInBinNL($number, $width)
30267  
30268 Write the specified variable in binary right justified in a field of specified width on stderr followed by a new line.
30269  
30270 Parameter Description
30271 1 $number Number as a variable
30272 2 $width Width of output field as a variable
30273  
30274 =head2 PrintRaxInDec($channel)
30275  
30276 Print rax in decimal on the specified channel.
30277  
30278 Parameter Description
30279 1 $channel Channel to write on
30280  
30281 =head2 PrintErrRaxInDec()
30282  
30283 Print rax in decimal on stderr.
30284  
30285  
30286 =head2 PrintErrRaxInDecNL()
30287  
30288 Print rax in decimal on stderr followed by a new line.
30289  
30290  
30291 =head2 PrintRaxRightInDec($Width, $channel)
30292  
30293 Print rax in decimal right justified in a field of the specified width on the specified channel.
30294  
30295 Parameter Description
30296 1 $Width Width as a variable or a constant
30297 2 $channel Channel
30298  
30299 =head2 PrintRightInDec($channel, $Number, $width)
30300  
30301 Print out a number in decimal right justified in a field of specified width on the specified channel.
30302  
30303 Parameter Description
30304 1 $channel Channel
30305 2 $Number Number as a variable or register
30306 3 $width Width of output field as a variable or constant
30307  
30308 =head2 PrintErrRightInDec($number, $width)
30309  
30310 Print a variable or register in decimal right justified in a field of the specified width on stderr.
30311  
30312 Parameter Description
30313 1 $number Number as a variable or a register
30314 2 $width Width as a variable or constant
30315  
30316 =head2 PrintErrRightInDecNL($number, $width)
30317  
30318 Print a variable or register in decimal right justified in a field of the specified width on stderr followed by a new line.
30319  
30320 Parameter Description
30321 1 $number Number as a variable or a register
30322 2 $width Width as a variable or constant
30323  
30324 =head2 PrintRaxAsText($channel)
30325  
30326 Print the string in rax on the specified channel.
30327  
30328 Parameter Description
30329 1 $channel Channel to write on
30330  
30331 =head2 PrintErrRaxAsText()
30332  
30333 Print rax as text on stderr.
30334  
30335  
30336 =head2 PrintErrRaxAsTextNL()
30337  
30338 Print rax as text on stderr followed by a new line.
30339  
30340  
30341 =head2 PrintRaxAsChar($channel)
30342  
30343 Print the ascii character in rax on the specified channel.
30344  
30345 Parameter Description
30346 1 $channel Channel to write on
30347  
30348 =head2 PrintErrRaxAsChar()
30349  
30350 Print the character in rax on stderr.
30351  
30352  
30353 =head2 PrintErrRaxAsCharNL()
30354  
30355 Print the character in rax on stderr followed by a new line.
30356  
30357  
30358 =head2 Variable($name, $expr, %options)
30359  
30360 Create a new variable with the specified name initialized via an optional expression.
30361  
30362 Parameter Description
30363 1 $name Name of variable
30364 2 $expr Optional expression initializing variable
30365 3 %options Options
30366  
30367 =head2 R($name)
30368  
30369 Define a reference variable.
30370  
30371 Parameter Description
30372 1 $name Name of variable
30373  
30374 =head2 Nasm::X86::Variable::dump($left, $channel, $newLine, $title1, $title2)
30375  
30376 Dump the value of a variable to the specified channel adding an optional title and new line if requested.
30377  
30378 Parameter Description
30379 1 $left Left variable
30380 2 $channel Channel
30381 3 $newLine New line required
30382 4 $title1 Optional leading title
30383 5 $title2 Optional trailing title
30384  
30385 B<Example:>
30386  
30387  
30388 PrintCString ($stdout, V(str => Rs("abc\0def")));
30389 PrintCStringNL($stdout, V(str => Rs("ABC\0DEF")));
30390 ok Assemble eq => <<END;
30391 abcABC
30392 END
30393  
30394 my $a = V(a => 3); $a->outNL;
30395 my $b = K(b => 2); $b->outNL;
30396 my $c = $a + $b; $c->outNL;
30397 my $d = $c - $a; $d->outNL;
30398 my $g = $a * $b; $g->outNL;
30399 my $h = $g / $b; $h->outNL;
30400 my $i = $a % $b; $i->outNL;
30401  
30402 If ($a == 3,
30403 Then
30404 {PrintOutStringNL "a == 3"
30405 },
30406 Else
30407 {PrintOutStringNL "a != 3"
30408 });
30409  
30410 ++$a; $a->outNL;
30411 --$a; $a->outNL;
30412  
30413 ok Assemble eq => <<END, avx512=>0;
30414 a: .... .... .... ...3
30415 b: .... .... .... ...2
30416 (a add b): .... .... .... ...5
30417 ((a add b) sub a): .... .... .... ...2
30418 (a times b): .... .... .... ...6
30419 ((a times b) / b): .... .... .... ...3
30420 (a % b): .... .... .... ...1
30421 a == 3
30422 a: .... .... .... ...4
30423 a: .... .... .... ...3
30424 END
30425  
30426  
30427 =head2 Nasm::X86::Variable::err($left, $title1, $title2)
30428  
30429 Dump the value of a variable on stderr.
30430  
30431 Parameter Description
30432 1 $left Left variable
30433 2 $title1 Optional leading title
30434 3 $title2 Optional trailing title
30435  
30436 =head2 Nasm::X86::Variable::errNL($left, $title1, $title2)
30437  
30438 Dump the value of a variable on stderr and append a new line.
30439  
30440 Parameter Description
30441 1 $left Left variable
30442 2 $title1 Optional leading title
30443 3 $title2 Optional trailing title
30444  
30445 =head2 Nasm::X86::Variable::d($left, $title1, $title2)
30446  
30447 Dump the value of a variable on stderr and append the source file calling line in a format that Geany understands.
30448  
30449 Parameter Description
30450 1 $left Left variable
30451 2 $title1 Optional leading title
30452 3 $title2 Optional trailing title
30453  
30454 =head2 Nasm::X86::Variable::errInDec($number, $title1, $title2)
30455  
30456 Dump the value of a variable on stderr in decimal.
30457  
30458 Parameter Description
30459 1 $number Number as variable
30460 2 $title1 Optional leading title
30461 3 $title2 Optional trailing title
30462  
30463 =head2 Nasm::X86::Variable::errInDecNL($number, $title1, $title2)
30464  
30465 Dump the value of a variable on stderr in decimal followed by a new line.
30466  
30467 Parameter Description
30468 1 $number Number as variable
30469 2 $title1 Optional leading title
30470 3 $title2 Optional trailing title
30471  
30472 =head2 Nasm::X86::Variable::rightInDec($number, $channel, $width)
30473  
30474 Dump the value of a variable on the specified channel as a decimal number right adjusted in a field of specified width.
30475  
30476 Parameter Description
30477 1 $number Number as variable
30478 2 $channel Channel
30479 3 $width Width
30480  
30481 =head2 Nasm::X86::Variable::errRightInDec($number, $width)
30482  
30483 Dump the value of a variable on stderr as a decimal number right adjusted in a field of specified width.
30484  
30485 Parameter Description
30486 1 $number Number
30487 2 $width Width
30488  
30489 =head2 Nasm::X86::Variable::errRightInDecNL($number, $width)
30490  
30491 Dump the value of a variable on stderr as a decimal number right adjusted in a field of specified width followed by a new line.
30492  
30493 Parameter Description
30494 1 $number Number
30495 2 $width Width
30496  
30497 =head2 Nasm::X86::Variable::rightInHex($number, $channel, $width)
30498  
30499 Write the specified variable number in hexadecimal right justified in a field of specified width to the specified channel.
30500  
30501 Parameter Description
30502 1 $number Number to print as a variable
30503 2 $channel Channel to print on
30504 3 $width Width of output field
30505  
30506 =head2 Nasm::X86::Variable::errRightInHex($number, $width)
30507  
30508 Write the specified variable number in hexadecimal right justified in a field of specified width to stderr.
30509  
30510 Parameter Description
30511 1 $number Number to print as a variable
30512 2 $width Width of output field
30513  
30514 =head2 Nasm::X86::Variable::errRightInHexNL($number, $width)
30515  
30516 Write the specified variable number in hexadecimal right justified in a field of specified width to stderr followed by a new line.
30517  
30518 Parameter Description
30519 1 $number Number to print as a variable
30520 2 $width Width of output field
30521  
30522 =head2 Nasm::X86::Variable::rightInBin($number, $channel, $width)
30523  
30524 Write the specified variable number in binary right justified in a field of specified width to the specified channel.
30525  
30526 Parameter Description
30527 1 $number Number to print as a variable
30528 2 $channel Channel to print on
30529 3 $width Width of output field
30530  
30531 =head2 Nasm::X86::Variable::errRightInBin($number, $width)
30532  
30533 Write the specified variable number in binary right justified in a field of specified width to stderr.
30534  
30535 Parameter Description
30536 1 $number Number to print as a variable
30537 2 $width Width of output field
30538  
30539 =head2 Nasm::X86::Variable::errRightInBinNL($number, $width)
30540  
30541 Write the specified variable number in binary right justified in a field of specified width to stderr followed by a new line.
30542  
30543 Parameter Description
30544 1 $number Number to print as a variable
30545 2 $width Width of output field
30546  
30547 =head2 Nasm::X86::Variable::errSpaces($count)
30548  
30549 Print the specified number of spaces to stderr.
30550  
30551 Parameter Description
30552 1 $count Number of spaces
30553  
30554 =head2 Nasm::X86::Variable::errCString($string)
30555  
30556 Print a zero terminated C style string addressed by a variable on stderr.
30557  
30558 Parameter Description
30559 1 $string String
30560  
30561 =head2 Nasm::X86::Variable::errCStringNL($string)
30562  
30563 Print a zero terminated C style string addressed by a variable on stderr followed by a new line.
30564  
30565 Parameter Description
30566 1 $string String
30567  
30568 =head2 Nasm::X86::Variable::equals($op, $left, $right)
30569  
30570 Equals operator.
30571  
30572 Parameter Description
30573 1 $op Operator
30574 2 $left Left variable
30575 3 $right Right variable
30576  
30577 =head2 Nasm::X86::Variable::assign($left, $op, $right)
30578  
30579 Assign to the left hand side the value of the right hand side.
30580  
30581 Parameter Description
30582 1 $left Left variable
30583 2 $op Operator
30584 3 $right Right variable
30585  
30586 =head2 Nasm::X86::Variable::plusAssign($left, $right)
30587  
30588 Implement plus and assign.
30589  
30590 Parameter Description
30591 1 $left Left variable
30592 2 $right Right variable
30593  
30594 =head2 Nasm::X86::Variable::minusAssign($left, $right)
30595  
30596 Implement minus and assign.
30597  
30598 Parameter Description
30599 1 $left Left variable
30600 2 $right Right variable
30601  
30602 =head2 Nasm::X86::Variable::arithmetic($op, $name, $left, $right)
30603  
30604 Return a variable containing the result of an arithmetic operation on the left hand and right hand side variables.
30605  
30606 Parameter Description
30607 1 $op Operator
30608 2 $name Operator name
30609 3 $left Left variable
30610 4 $right Right variable
30611  
30612 =head2 Nasm::X86::Variable::add($left, $right)
30613  
30614 Add the right hand variable to the left hand variable and return the result as a new variable.
30615  
30616 Parameter Description
30617 1 $left Left variable
30618 2 $right Right variable
30619  
30620 =head2 Nasm::X86::Variable::sub($left, $right)
30621  
30622 Subtract the right hand variable from the left hand variable and return the result as a new variable.
30623  
30624 Parameter Description
30625 1 $left Left variable
30626 2 $right Right variable
30627  
30628 =head2 Nasm::X86::Variable::times($left, $right)
30629  
30630 Multiply the left hand variable by the right hand variable and return the result as a new variable.
30631  
30632 Parameter Description
30633 1 $left Left variable
30634 2 $right Right variable
30635  
30636 =head2 Nasm::X86::Variable::division($op, $left, $right)
30637  
30638 Return a variable containing the result or the remainder that occurs when the left hand side is divided by the right hand side.
30639  
30640 Parameter Description
30641 1 $op Operator
30642 2 $left Left variable
30643 3 $right Right variable
30644  
30645 =head2 Nasm::X86::Variable::divide($left, $right)
30646  
30647 Divide the left hand variable by the right hand variable and return the result as a new variable.
30648  
30649 Parameter Description
30650 1 $left Left variable
30651 2 $right Right variable
30652  
30653 =head2 Nasm::X86::Variable::mod($left, $right)
30654  
30655 Divide the left hand variable by the right hand variable and return the remainder as a new variable.
30656  
30657 Parameter Description
30658 1 $left Left variable
30659 2 $right Right variable
30660  
30661 =head2 Nasm::X86::Variable::shiftLeft($left, $right)
30662  
30663 Shift the left hand variable left by the number of bits specified in the right hand variable and return the result as a new variable.
30664  
30665 Parameter Description
30666 1 $left Left variable
30667 2 $right Right variable
30668  
30669 B<Example:>
30670  
30671  
30672 K(loop=>16)->for(sub
30673 {my ($index, $start, $next, $end) = @_;
30674 (K(one => 1) << $index)->outRightInBinNL(16);
30675 (K(one => 1<<15) >> $index)->outRightInBinNL(16);
30676 });
30677  
30678 ok Assemble eq => <<END, avx512=>1;
30679 1
30680 1000000000000000
30681 10
30682 100000000000000
30683 100
30684 10000000000000
30685 1000
30686 1000000000000
30687 10000
30688 100000000000
30689 100000
30690 10000000000
30691 1000000
30692 1000000000
30693 10000000
30694 100000000
30695 100000000
30696 10000000
30697 1000000000
30698 1000000
30699 10000000000
30700 100000
30701 100000000000
30702 10000
30703 1000000000000
30704 1000
30705 10000000000000
30706 100
30707 100000000000000
30708 10
30709 1000000000000000
30710 1
30711 END
30712  
30713  
30714 =head2 Nasm::X86::Variable::shiftRight($left, $right)
30715  
30716 Shift the left hand variable right by the number of bits specified in the right hand variable and return the result as a new variable.
30717  
30718 Parameter Description
30719 1 $left Left variable
30720 2 $right Right variable
30721  
30722 B<Example:>
30723  
30724  
30725 K(loop=>16)->for(sub
30726 {my ($index, $start, $next, $end) = @_;
30727 (K(one => 1) << $index)->outRightInBinNL(16);
30728 (K(one => 1<<15) >> $index)->outRightInBinNL(16);
30729 });
30730  
30731 ok Assemble eq => <<END, avx512=>1;
30732 1
30733 1000000000000000
30734 10
30735 100000000000000
30736 100
30737 10000000000000
30738 1000
30739 1000000000000
30740 10000
30741 100000000000
30742 100000
30743 10000000000
30744 1000000
30745 1000000000
30746 10000000
30747 100000000
30748 100000000
30749 10000000
30750 1000000000
30751 1000000
30752 10000000000
30753 100000
30754 100000000000
30755 10000
30756 1000000000000
30757 1000
30758 10000000000000
30759 100
30760 100000000000000
30761 10
30762 1000000000000000
30763 1
30764 END
30765  
30766  
30767 =head2 Nasm::X86::Variable::not($left)
30768  
30769 Form two complement of left hand side and return it as a variable.
30770  
30771 Parameter Description
30772 1 $left Left variable
30773  
30774 =head2 Nasm::X86::Variable::booleanZF($sub, $op, $left, $right)
30775  
30776 Combine the left hand variable with the right hand variable via a boolean operator and indicate the result by setting the zero flag if the result is true.
30777  
30778 Parameter Description
30779 1 $sub Operator
30780 2 $op Operator name
30781 3 $left Left variable
30782 4 $right Right variable
30783  
30784 =head2 Nasm::X86::Variable::eq($left, $right)
30785  
30786 Check whether the left hand variable is equal to the right hand variable.
30787  
30788 Parameter Description
30789 1 $left Left variable
30790 2 $right Right variable
30791  
30792 =head2 Nasm::X86::Variable::ne($left, $right)
30793  
30794 Check whether the left hand variable is not equal to the right hand variable.
30795  
30796 Parameter Description
30797 1 $left Left variable
30798 2 $right Right variable
30799  
30800 =head2 Nasm::X86::Variable::ge($left, $right)
30801  
30802 Check whether the left hand variable is greater than or equal to the right hand variable.
30803  
30804 Parameter Description
30805 1 $left Left variable
30806 2 $right Right variable
30807  
30808 =head2 Nasm::X86::Variable::gt($left, $right)
30809  
30810 Check whether the left hand variable is greater than the right hand variable.
30811  
30812 Parameter Description
30813 1 $left Left variable
30814 2 $right Right variable
30815  
30816 =head2 Nasm::X86::Variable::le($left, $right)
30817  
30818 Check whether the left hand variable is less than or equal to the right hand variable.
30819  
30820 Parameter Description
30821 1 $left Left variable
30822 2 $right Right variable
30823  
30824 =head2 Nasm::X86::Variable::lt($left, $right)
30825  
30826 Check whether the left hand variable is less than the right hand variable.
30827  
30828 Parameter Description
30829 1 $left Left variable
30830 2 $right Right variable
30831  
30832 =head2 Nasm::X86::Variable::incDec($left, $op)
30833  
30834 Increment or decrement a variable.
30835  
30836 Parameter Description
30837 1 $left Left variable operator
30838 2 $op Address of operator to perform inc or dec
30839  
30840 =head2 Nasm::X86::Variable::inc($left)
30841  
30842 Increment a variable.
30843  
30844 Parameter Description
30845 1 $left Variable
30846  
30847 =head2 Nasm::X86::Variable::dec($left)
30848  
30849 Decrement a variable.
30850  
30851 Parameter Description
30852 1 $left Variable
30853  
30854 =head2 Nasm::X86::Variable::str($left)
30855  
30856 The name of the variable.
30857  
30858 Parameter Description
30859 1 $left Variable
30860  
30861 B<Example:>
30862  
30863  
30864 if (1)
30865 {my $a = V(key => 0x123);
30866 is_deeply $a->at, "[rbp-8*(2)]";
30867 is_deeply $a->addressExpr, "[rbp-8*(2)]";
30868  
30869 ok !$a->isRef;
30870  
30871 Mov rax, -1;
30872 Kmovq k1, rax;
30873 PrintOutRegisterInHex k1;
30874  
30875 K(key => 2)->clearBit(rax);
30876 PrintOutRegisterInHex rax;
30877  
30878 K(key => 2)->setBit(rax);
30879 PrintOutRegisterInHex rax;
30880  
30881 K(key => 3)->clearMaskBit(k1);
30882 PrintOutRegisterInHex k1;
30883  
30884 K(key => 3)->setMaskBit(k1);
30885 PrintOutRegisterInHex k1;
30886  
30887 K(key => 0)->clearMaskBit(k1);
30888 PrintOutRegisterInHex k1;
30889  
30890 ClearRegisters k1;
30891 K(key => 7)->setMaskFirst(k1);
30892 PrintOutRegisterInHex k1;
30893  
30894 K(key => 3)->spaces($stdout);
30895 PrintOutRegisterInHex k1;
30896  
30897 my $N = K size => 4096;
30898 my $A = $N->allocateMemory;
30899 $A->clearMemory($N);
30900 ClearMemory($A, $N);
30901  
30902 $A->setReg(rax);
30903 Mov "dword[rax]", 0x61626364;
30904 Mov "dword[rax+4]", 0x65666768;
30905  
30906 ($A+8)->copyMemory($A, K key => 8);
30907  
30908 $A->printOutMemory (K(key => 16));
30909 $A->printOutMemoryNL(K(key => 16));
30910  
30911 K(K => Rd(0..63))->loadZmm(1);
30912 PrintOutRegisterInHex zmm1;
30913  
30914 ok Assemble eq => <<END;
30915 k1: .... .... .... ..-1
30916 rax: FFFF FFFF FFFF FFFB
30917 rax: .... .... .... ..-1
30918 k1: FFFF FFFF FFFF FFF7
30919 k1: .... .... .... ..-1
30920 k1: FFFF FFFF FFFF FFFE
30921 k1: .... .... .... ..7F
30922 k1: .... .... .... ..7F
30923 dcbahgfedcbahgfedcbahgfedcbahgfe
30924 zmm1: .... ...F .... ...E .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
30925 END
30926 }
30927  
30928  
30929 =head2 Nasm::X86::Variable::and($left, $right)
30930  
30931 And two variables.
30932  
30933 Parameter Description
30934 1 $left Left variable
30935 2 $right Right variable
30936  
30937 =head2 Nasm::X86::Variable::or($left, $right)
30938  
30939 Or two variables.
30940  
30941 Parameter Description
30942 1 $left Left variable
30943 2 $right Right variable
30944  
30945 =head2 Nasm::X86::Variable::putBwdqIntoMm($content, $size, $mm, $offset)
30946  
30947 Place the value of the content variable at the byte|word|double word|quad word in the numbered zmm register.
30948  
30949 Parameter Description
30950 1 $content Variable with content
30951 2 $size Size of put
30952 3 $mm Numbered zmm
30953 4 $offset Offset in bytes
30954  
30955 =head2 dFromPointInZ($point, $zmm, %options)
30956  
30957 Get the double word from the numbered zmm register at a point specified by the variable or register and return it in a variable.
30958  
30959 Parameter Description
30960 1 $point Point
30961 2 $zmm Numbered zmm
30962 3 %options Options
30963  
30964 B<Example:>
30965  
30966  
30967 Mov r15, 0x12345678;
30968 bRegIntoZmm(r15, 1, 0);
30969 bRegIntoZmm(r15, 1, 1);
30970 dRegIntoZmm(r15, 1, 4);
30971 dRegIntoZmm(r15, 1, 8);
30972 dRegIntoZmm(r15, 1, 12);
30973 PrintOutRegisterInHex xmm(1);
30974 PrintOutRegisterInHex zmm(1);
30975  
30976 bRegFromZmm(r15, 1, 1);
30977 PrintOutRegisterInHex r15;
30978  
30979 bFromX(1, 0)->outNL;
30980 bFromZ(1, 0)->outNL;
30981  
30982 dRegFromZmm(r14, 1, 3);
30983 PrintOutRegisterInHex r14;
30984  
30985 wRegFromZmm(r14, 1, 3);
30986 PrintOutRegisterInHex r14;
30987  
30988 bFromX(1, 0)->outNL;
30989 bFromZ(1, 1)->outNL;
30990 bFromZ(1, 2)->outNL;
30991  
30992 wFromX(1, 0)->outNL;
30993 wFromZ(1, 1)->outNL;
30994 wFromZ(1, 2)->outNL;
30995  
30996 dFromX(1, 0)->outNL;
30997 dFromZ(1, 1)->outNL;
30998 dFromZ(1, 2)->outNL;
30999  
31000 qFromX(1, 0)->outNL;
31001 qFromZ(1, 1)->outNL;
31002 dFromZ(1, 2)->outNL;
31003  
31004  
31005 K( offset => 1 << 5)->dFromPointInZ(zmm(1))->outNL; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
31006  
31007  
31008 Mov r15, 2;
31009 Kmovq k7, r15;
31010 LoadZmm 2, map {0xff} 1..64;
31011 PrintOutRegisterInHex zmm2;
31012 Vmovdqu8 zmmM (2, 7), zmm(1);
31013 Vmovdqu8 zmmMZ(3, 7), zmm(1);
31014 PrintOutRegisterInHex zmm1, zmm2, zmm3;
31015  
31016 ok Assemble eq => <<END;
31017 xmm1: 1234 5678 1234 5678 1234 5678 .... 7878
31018 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
31019 r15: .... .... 1234 5678
31020 b at offset 0 in xmm1: .... .... .... ..78
31021 b at offset 0 in zmm1: .... .... .... ..78
31022 r14: .... .... 3456 78..
31023 r14: .... .... 3456 78..
31024 b at offset 0 in xmm1: .... .... .... ..78
31025 b at offset 1 in zmm1: .... .... .... ..78
31026 b at offset 2 in zmm1: .... .... .... ...0
31027 w at offset 0 in xmm1: .... .... .... 7878
31028 w at offset 1 in zmm1: .... .... .... ..78
31029 w at offset 2 in zmm1: .... .... .... ...0
31030 d at offset 0 in xmm1: .... .... .... 7878
31031 d at offset 1 in zmm1: .... .... 78.. ..78
31032 d at offset 2 in zmm1: .... .... 5678 ....
31033 q at offset 0 in xmm1: 1234 5678 .... 7878
31034 q at offset 1 in zmm1: 7812 3456 78.. ..78
31035 d at offset 2 in zmm1: .... .... 5678 ....
31036 d: .... .... .... ...0
31037 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1
31038 zmm1: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - 1234 5678 1234 5678 1234 5678 .... 7878
31039 zmm2: .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 .... .... .... ..-1 + .... .... .... ..-1 .... .... .... ..-1 - .... .... .... ..-1 FFFF FFFF FFFF 78FF
31040 zmm3: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... 78..
31041 END
31042  
31043  
31044 =head2 Nasm::X86::Variable::printMemory($address, $channel, $size)
31045  
31046 Print the specified number of bytes from the memory addressed by the variable on the specified channel.
31047  
31048 Parameter Description
31049 1 $address Address of memory
31050 2 $channel Channel to print on as a constant
31051 3 $size Number of bytes to print
31052  
31053 =head2 Nasm::X86::Variable::printErrMemory($address, $size)
31054  
31055 Print the specified number of bytes of the memory addressed by the variable on stdout.
31056  
31057 Parameter Description
31058 1 $address Address of memory
31059 2 $size Number of bytes to print
31060  
31061 =head2 Nasm::X86::Variable::printErrMemoryNL($address, $size)
31062  
31063 Print the specified number of bytes of the memory addressed by the variable on stdout followed by a new line.
31064  
31065 Parameter Description
31066 1 $address Address of memory
31067 2 $size Number of bytes to print
31068  
31069 =head2 Nasm::X86::Variable::printMemoryInHexNL($address, $channel, $size)
31070  
31071 Write, in hexadecimal, the memory addressed by a variable to stdout or stderr.
31072  
31073 Parameter Description
31074 1 $address Address of memory
31075 2 $channel Channel to print on
31076 3 $size Number of bytes to print
31077  
31078 =head2 Nasm::X86::Variable::printErrMemoryInHexNL($address, $size)
31079  
31080 Write the memory addressed by a variable to stderr.
31081  
31082 Parameter Description
31083 1 $address Address of memory
31084 2 $size Number of bytes to print
31085  
31086 =head2 PrintMemoryInHex($channel)
31087  
31088 Dump memory from the address in rax for the length in rdi on the specified channel. As this method prints in blocks of 8 up to 7 bytes will be missing from the end unless the length is a multiple of 8 .
31089  
31090 Parameter Description
31091 1 $channel Channel
31092  
31093 =head2 PrintErrMemoryInHex()
31094  
31095 Dump memory from the address in rax for the length in rdi on stderr.
31096  
31097  
31098 =head2 PrintErrMemoryInHexNL()
31099  
31100 Dump memory from the address in rax for the length in rdi and then print a new line.
31101  
31102  
31103 =head2 PrintMemory_InHex($channel)
31104  
31105 Dump memory from the address in rax for the length in rdi on the specified channel. As this method prints in blocks of 8 up to 7 bytes will be missing from the end unless the length is a multiple of 8 .
31106  
31107 Parameter Description
31108 1 $channel Channel
31109  
31110 =head2 PrintErrMemory_InHex()
31111  
31112 Dump memory from the address in rax for the length in rdi on stderr.
31113  
31114  
31115 =head2 PrintErrMemory_InHexNL()
31116  
31117 Dump memory from the address in rax for the length in rdi and then print a new line.
31118  
31119  
31120 =head2 PrintMemory($channel)
31121  
31122 Print the memory addressed by rax for a length of rdi on the specified channel where channel can be a constant number or a register expression using a bound register.
31123  
31124 Parameter Description
31125 1 $channel Channel
31126  
31127 B<Example:>
31128  
31129  
31130 if (1)
31131 {my $s = "zzzCreated.data";
31132 my $f = Rs $s;
31133 Mov rax, $f;
31134 OpenWrite;
31135 Mov r15, rax;
31136 Mov rax, $f;
31137 Mov rdi, length $s;
31138  
31139 PrintMemory r15; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
31140  
31141 CloseFile;
31142 ok Assemble eq=><<END, avx512=>1;
31143 END
31144 ok -e $s;
31145 unlink $s;
31146 }
31147  
31148 if (!!onGitHub) {
31149  
31150  
31151 =head2 PrintMemoryNL()
31152  
31153 Print the memory addressed by rax for a length of rdi on the specified channel followed by a new line.
31154  
31155  
31156 =head2 PrintErrMemory()
31157  
31158 Print the memory addressed by rax for a length of rdi on stderr.
31159  
31160  
31161 =head2 PrintErrMemoryNL()
31162  
31163 Print the memory addressed by rax for a length of rdi followed by a new line on stderr.
31164  
31165  
31166 =head2 CopyMemory4K($source, $target, $size)
31167  
31168 Copy memory in 4K byte blocks.
31169  
31170 Parameter Description
31171 1 $source Source address variable
31172 2 $target Target address variable
31173 3 $size Number of 4K byte blocks to move
31174  
31175 =head2 convert_rax_from_utf32_to_utf8()
31176  
31177 Convert a utf32 character held in rax to a utf8 character held in rax.
31178  
31179  
31180 B<Example:>
31181  
31182  
31183 # $ U+0024 010 0100 00100100 24
31184 # £ U+00A3 000 1010 0011 11000010 10100011 C2 A3
31185 # ह U+0939 0000 1001 0011 1001 11100000 10100100 10111001 E0 A4 B9
31186 # € U+20AC 0010 0000 1010 1100 11100010 10000010 10101100 E2 82 AC
31187 # 한 U+D55C 1101 0101 0101 1100 11101101 10010101 10011100 ED 95 9C
31188 # 𐍈 U+10348 0 0001 0000 0011 0100 1000 11110000 10010000 10001101 10001000 F0 90 8D 88
31189 Mov rax, 0x40; # 0x40
31190  
31191 convert_rax_from_utf32_to_utf8; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
31192  
31193 PrintOutRegisterInHex rax;
31194  
31195 Mov rax, 0x03b1; # 0xCE 0xB1
31196  
31197 convert_rax_from_utf32_to_utf8; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
31198  
31199 PrintOutRegisterInHex rax;
31200  
31201 Mov rax, 0x20ac; # 0xE2 0x82 0xAC;
31202  
31203 convert_rax_from_utf32_to_utf8; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
31204  
31205 PrintOutRegisterInHex rax;
31206  
31207 Mov rax, 0x10348; # 0xf0 0x90 0x8d 0x88
31208  
31209 convert_rax_from_utf32_to_utf8; # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
31210  
31211 PrintOutRegisterInHex rax;
31212  
31213 ok Assemble eq => <<END, avx512=>1;
31214 rax: .... .... .... ..40
31215 rax: .... .... .... B1CE
31216 rax: .... .... ..AC 82E2
31217 rax: .... .... 888D 90F0
31218 END
31219  
31220  
31221 =head2 Cstrlen()
31222  
31223 Length of the C style string addressed by rax returning the length in r15.
31224  
31225  
31226 =head2 DescribeArea(%options)
31227  
31228 Describe a relocatable area. By describing an areas, we allocate space with which to describe it in the current stack frame but we do not allocate memory for the area itself in the heap.
31229  
31230 Parameter Description
31231 1 %options Optional variable addressing the start of the area
31232  
31233 =head2 Nasm::X86::Area::copyDescriptor($target, $source)
31234  
31235 Copy the description of one area into another
31236  
31237 Parameter Description
31238 1 $target Target area
31239 2 $source Source area
31240  
31241 =head2 Nasm::X86::Area::updateSpace($area, $size)
31242  
31243 Make sure that a variable addressed area has enough space to accommodate content of a variable size.
31244  
31245 Parameter Description
31246 1 $area Area descriptor
31247 2 $size Variable size needed
31248  
31249 =head2 Nasm::X86::Area::allocZmmBlock3($area)
31250  
31251 Allocate three zmm blocks in one go and return their offsets.
31252  
31253 Parameter Description
31254 1 $area Area
31255  
31256 =head2 Nasm::X86::Yggdrasil::UniqueStrings {K key => 0}(sub Nasm::X86::Yggdrasil::SubroutineOffsets {K key => 1})
31257  
31258 A tree of strings that assigns unique numbers to strings.
31259  
31260 Parameter Description
31261 1 sub Nasm::X86::Yggdrasil::SubroutineOffsets {K key => 1} P Translates a string number into the offset of a subroutine in an area.
31262  
31263 =head2 Nasm::X86::Yggdrasil::SubroutineOffsets {K key => 1}(sub Nasm::X86::Yggdrasil::SubroutineDefinitions{K key => 2})
31264  
31265 Translates a string number into the offset of a subroutine in an area.
31266  
31267 Parameter Description
31268 1 sub Nasm::X86::Yggdrasil::SubroutineDefinitions{K key => 2} P Maps the unique string number for a subroutine name to the offset in the are that contains the length (as a dword) followed by the string content of the Perl data structure describing the subroutine in question.
31269  
31270 =head2 Nasm::X86::Yggdrasil::SubroutineDefinitions{K key => 2}(sub Nasm::X86::Yggdrasil::Unisyn::Alphabets {K key => 3})
31271  
31272 Maps the unique string number for a subroutine name to the offset in the are that contains the length (as a dword) followed by the string content of the Perl data structure describing the subroutine in question.
31273  
31274 Parameter Description
31275 1 sub Nasm::X86::Yggdrasil::Unisyn::Alphabets {K key => 3} P Unisyn alphabets.
31276  
31277 =head2 Nasm::X86::Yggdrasil::Unisyn::Alphabets {K key => 3}(sub Nasm::X86::Yggdrasil::Unisyn::Open {K key => 4})
31278  
31279 Unisyn alphabets.
31280  
31281 Parameter Description
31282 1 sub Nasm::X86::Yggdrasil::Unisyn::Open {K key => 4} P Open bracket to close bracket
31283  
31284 =head2 Nasm::X86::Yggdrasil::Unisyn::Open {K key => 4}(sub Nasm::X86::Yggdrasil::Unisyn::Close {K key => 5})
31285  
31286 Open bracket to close bracket
31287  
31288 Parameter Description
31289 1 sub Nasm::X86::Yggdrasil::Unisyn::Close {K key => 5} P Close bracket to open bracket
31290  
31291 =head2 Nasm::X86::Yggdrasil::Unisyn::Close {K key => 5}(sub Nasm::X86::Yggdrasil::Unisyn::Transitions {K key => 6})
31292  
31293 Close bracket to open bracket
31294  
31295 Parameter Description
31296 1 sub Nasm::X86::Yggdrasil::Unisyn::Transitions {K key => 6} P Permissible transitions from alphabet to alphabet
31297  
31298 =head2 Nasm::X86::Yggdrasil::Unisyn::Transitions {K key => 6}()
31299  
31300 Permissible transitions from alphabet to alphabet
31301  
31302  
31303 =head2 Nasm::X86::Area::checkYggdrasilCreated($area)
31304  
31305 Return a tree descriptor for the Yggdrasil world tree for an area. If Yggdrasil has not been created the found field of the returned descriptor will have zero in it else one.
31306  
31307 Parameter Description
31308 1 $area Area descriptor
31309  
31310 B<Example:>
31311  
31312  
31313 my $A = CreateArea;
31314 my $t = $A->checkYggdrasilCreated;
31315 $t->found->outNL;
31316 my $y = $A->yggdrasil;
31317 my $T = $A->checkYggdrasilCreated;
31318 $T->found->outNL;
31319 ok Assemble debug => 0, eq => <<END, avx512=>1;
31320 found : .... .... .... ...0
31321 found : .... .... .... ...1
31322 END
31323  
31324  
31325 =head2 Nasm::X86::Area::zero($area)
31326  
31327 Append a trailing zero to the area addressed by rax.
31328  
31329 Parameter Description
31330 1 $area Area descriptor
31331  
31332 =head2 DescribeTree(%options)
31333  
31334 Return a descriptor for a tree with the specified options. The options from one tree get inherited by any sub trees they contain
31335  
31336 Parameter Description
31337 1 %options Tree description options
31338  
31339 =head2 Nasm::X86::Area::DescribeTree($area, %options)
31340  
31341 Return a descriptor for a tree in the specified area with the specified options.
31342  
31343 Parameter Description
31344 1 $area Area descriptor
31345 2 %options Options for tree
31346  
31347 =head2 Nasm::X86::Tree::DescribeTree($tree, %options)
31348  
31349 Create a description of a tree.
31350  
31351 Parameter Description
31352 1 $tree Tree descriptor
31353 2 %options {first=>first node of tree if not the existing first node; area=>area used by tree if not the existing area}
31354  
31355 =head2 Nasm::X86::Tree::position($tree, $first)
31356  
31357 Create a new tree description for a tree positioned at the specified location.
31358  
31359 Parameter Description
31360 1 $tree Tree descriptor
31361 2 $first Offset of tree
31362  
31363 =head2 Nasm::X86::Tree::firstFromMemory($tree, $zmm)
31364  
31365 Load the first block for a tree into the numbered zmm.
31366  
31367 Parameter Description
31368 1 $tree Tree descriptor
31369 2 $zmm Number of zmm to contain first block
31370  
31371 =head2 Nasm::X86::Tree::firstIntoMemory($tree, $zmm)
31372  
31373 Save the first block of a tree in the numbered zmm back into memory.
31374  
31375 Parameter Description
31376 1 $tree Tree descriptor
31377 2 $zmm Number of zmm containing first block
31378  
31379 =head2 Nasm::X86::Tree::rootIntoFirst($tree, $zmm, $value)
31380  
31381 Put the contents of a variable into the root field of the first block of a tree when held in a zmm register.
31382  
31383 Parameter Description
31384 1 $tree Tree descriptor
31385 2 $zmm Number of zmm containing first block
31386 3 $value Variable containing value to put
31387  
31388 =head2 Nasm::X86::Tree::rootFromFirst($tree, $zmm, %options)
31389  
31390 Return a variable containing the offset of the root block of a tree from the first block when held in a zmm register.
31391  
31392 Parameter Description
31393 1 $tree Tree descriptor
31394 2 $zmm Number of zmm containing first block
31395 3 %options Options
31396  
31397 =head2 Nasm::X86::Tree::root($t, $F, $offset)
31398  
31399 Check whether the specified offset refers to the root of a tree when the first block is held in a zmm register. The result is returned by setting the zero flag to one if the offset is the root, else to zero.
31400  
31401 Parameter Description
31402 1 $t Tree descriptor
31403 2 $F Zmm register holding first block
31404 3 $offset Offset of block as a variable
31405  
31406 B<Example:>
31407  
31408  
31409 my $a = CreateArea;
31410 my $t = $a->CreateTree;
31411 my $b = $t->allocBlock(31, 30, 29);
31412 K(data => 0x33)->dIntoZ(31, 4);
31413 $t->lengthIntoKeys(31, K length =>0x9);
31414 $t->putBlock($b, 31, 30, 29);
31415 $t->getBlock($b, 25, 24, 23);
31416 PrintOutRegisterInHex 25;
31417 $t->lengthFromKeys(25)->outNL;
31418  
31419  
31420 $t->firstFromMemory(28);
31421 $t->incSizeInFirst (28);
31422 $t->rootIntoFirst (28, K value => 0x2222);
31423 $t->root (28, K value => 0x2222); PrintOutZF;
31424 $t->root (28, K value => 0x2221); PrintOutZF;
31425 $t->root (28, K value => 0x2222); PrintOutZF;
31426 $t->firstIntoMemory(28);
31427  
31428 $t->first->outNL;
31429 $b->outNL;
31430 $a->dump("1111");
31431 PrintOutRegisterInHex 31, 30, 29, 28;
31432  
31433 If $t->leafFromNodes(29) > 0, Then {PrintOutStringNL "29 Leaf"}, Else {PrintOutStringNL "29 Branch"};
31434 If $t->leafFromNodes(28) > 0, Then {PrintOutStringNL "28 Leaf"}, Else {PrintOutStringNL "28 Branch"};
31435  
31436  
31437 ok Assemble eq => <<END, avx512=>1;
31438 zmm25: .... ..C0 .... ...9 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... ..33 .... ....
31439 b at offset 56 in zmm25: .... .... .... ...9
31440 ZF=1
31441 ZF=0
31442 ZF=1
31443 first : .... .... .... ..40
31444 address: .... .... .... ..80
31445 1111
31446 Area Size: 4096 Used: 320
31447 .... .... .... ...0 | __10 ____ ____ ____ 40.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
31448 .... .... .... ..40 | 2222 ____ ____ ____ .1__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
31449 .... .... .... ..80 | ____ ____ 33__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .9__ ____ C0__ ____
31450 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __.1 ____
31451 zmm31: .... ..C0 .... ...9 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... ..33 .... ....
31452 zmm30: .... .1.. .... .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
31453 zmm29: .... ..40 .... .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
31454 zmm28: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...1 .... .... .... 2222
31455 29 Leaf
31456 28 Branch
31457 END
31458  
31459  
31460 =head2 Nasm::X86::Tree::optionsFromFirst($tree, $zmm, %options)
31461  
31462 Return a variable containing the options double word from the first block zmm register.
31463  
31464 Parameter Description
31465 1 $tree Tree descriptor
31466 2 $zmm Number of zmm containing first block
31467 3 %options Options
31468  
31469 =head2 Nasm::X86::Tree::optionsIntoFirst($tree, $zmm, $value, %options)
31470  
31471 Put the contents of a variable into the options field of the first block of a tree when the first block is held in a zmm register.
31472  
31473 Parameter Description
31474 1 $tree Tree descriptor
31475 2 $zmm Number of zmm containing first block
31476 3 $value Variable containing options to put
31477 4 %options Options
31478  
31479 =head2 Nasm::X86::Tree::sizeFromFirst($tree, $zmm)
31480  
31481 Return a variable containing the number of keys in the specified tree when the first block is held in a zmm register..
31482  
31483 Parameter Description
31484 1 $tree Tree descriptor
31485 2 $zmm Number of zmm containing first block
31486  
31487 =head2 Nasm::X86::Tree::sizeIntoFirst($tree, $zmm, $value)
31488  
31489 Put the contents of a variable into the size field of the first block of a tree when the first block is held in a zmm register.
31490  
31491 Parameter Description
31492 1 $tree Tree descriptor
31493 2 $zmm Number of zmm containing first block
31494 3 $value Variable containing value to put
31495  
31496 =head2 Nasm::X86::Tree::incSizeInFirst($tree, $zmm)
31497  
31498 Increment the size field in the first block of a tree when the first block is held in a zmm register.
31499  
31500 Parameter Description
31501 1 $tree Tree descriptor
31502 2 $zmm Number of zmm containing first block
31503  
31504 B<Example:>
31505  
31506  
31507 my $t = DescribeTree();
31508  
31509 my $F = 31;
31510 K(key => 0xff)->dIntoZ($F, 60);
31511 K(key => 0xee)->dIntoZ($F, 56);
31512 PrintOutRegisterInHex $F;
31513 $t->incSizeInFirst($F); PrintOutRegisterInHex $F;
31514 $t->incSizeInFirst($F); PrintOutRegisterInHex $F;
31515 $t->incSizeInFirst($F); PrintOutRegisterInHex $F;
31516 $t->decSizeInFirst($F); PrintOutRegisterInHex $F;
31517 $t->decSizeInFirst($F); PrintOutRegisterInHex $F;
31518 $t->decSizeInFirst($F); PrintOutRegisterInHex $F;
31519  
31520 ok Assemble eq => <<END, avx512=>1; # Once we know the insertion point we can add the key/data/subTree triple, increase the length and update the tree bits
31521 zmm31: .... ..FF .... ..EE .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
31522 zmm31: .... ..FF .... ..EE .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...1 .... .... .... ...0
31523 zmm31: .... ..FF .... ..EE .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...2 .... .... .... ...0
31524 zmm31: .... ..FF .... ..EE .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...3 .... .... .... ...0
31525 zmm31: .... ..FF .... ..EE .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...2 .... .... .... ...0
31526 zmm31: .... ..FF .... ..EE .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...1 .... .... .... ...0
31527 zmm31: .... ..FF .... ..EE .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
31528 END
31529  
31530  
31531 =head2 Nasm::X86::Tree::decSizeInFirst($tree, $zmm)
31532  
31533 Decrement the size field in the first block of a tree when the first block is held in a zmm register.
31534  
31535 Parameter Description
31536 1 $tree Tree descriptor
31537 2 $zmm Number of zmm containing first block
31538  
31539 =head2 Nasm::X86::Tree::incSize($tree)
31540  
31541 Increment the size of a tree.
31542  
31543 Parameter Description
31544 1 $tree Tree descriptor
31545  
31546 =head2 Nasm::X86::Tree::decSize($tree)
31547  
31548 Decrement the size of a tree.
31549  
31550 Parameter Description
31551 1 $tree Tree descriptor
31552  
31553 =head2 Nasm::X86::Tree::allocBlock($tree, $K, $D, $N)
31554  
31555 Allocate a keys/data/node block and place it in the numbered zmm registers.
31556  
31557 Parameter Description
31558 1 $tree Tree descriptor
31559 2 $K Numbered zmm for keys
31560 3 $D Numbered zmm for data
31561 4 $N Numbered zmm for children
31562  
31563 B<Example:>
31564  
31565  
31566 my $a = CreateArea;
31567 my $t = $a->CreateTree;
31568 my $b = $t->allocBlock(31, 30, 29);
31569 K(data => 0x33)->dIntoZ(31, 4);
31570 $t->lengthIntoKeys(31, K length =>0x9);
31571 $t->putBlock($b, 31, 30, 29);
31572 $t->getBlock($b, 25, 24, 23);
31573 PrintOutRegisterInHex 25;
31574 $t->lengthFromKeys(25)->outNL;
31575  
31576  
31577 $t->firstFromMemory(28);
31578 $t->incSizeInFirst (28);
31579 $t->rootIntoFirst (28, K value => 0x2222);
31580 $t->root (28, K value => 0x2222); PrintOutZF;
31581 $t->root (28, K value => 0x2221); PrintOutZF;
31582 $t->root (28, K value => 0x2222); PrintOutZF;
31583 $t->firstIntoMemory(28);
31584  
31585 $t->first->outNL;
31586 $b->outNL;
31587 $a->dump("1111");
31588 PrintOutRegisterInHex 31, 30, 29, 28;
31589  
31590 If $t->leafFromNodes(29) > 0, Then {PrintOutStringNL "29 Leaf"}, Else {PrintOutStringNL "29 Branch"};
31591 If $t->leafFromNodes(28) > 0, Then {PrintOutStringNL "28 Leaf"}, Else {PrintOutStringNL "28 Branch"};
31592  
31593  
31594 ok Assemble eq => <<END, avx512=>1;
31595 zmm25: .... ..C0 .... ...9 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... ..33 .... ....
31596 b at offset 56 in zmm25: .... .... .... ...9
31597 ZF=1
31598 ZF=0
31599 ZF=1
31600 first : .... .... .... ..40
31601 address: .... .... .... ..80
31602 1111
31603 Area Size: 4096 Used: 320
31604 .... .... .... ...0 | __10 ____ ____ ____ 40.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
31605 .... .... .... ..40 | 2222 ____ ____ ____ .1__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
31606 .... .... .... ..80 | ____ ____ 33__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .9__ ____ C0__ ____
31607 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __.1 ____
31608 zmm31: .... ..C0 .... ...9 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... ..33 .... ....
31609 zmm30: .... .1.. .... .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
31610 zmm29: .... ..40 .... .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
31611 zmm28: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...1 .... .... .... 2222
31612 29 Leaf
31613 28 Branch
31614 END
31615  
31616  
31617 =head2 Nasm::X86::Tree::freeBlock($tree, $k, $K, $D, $N)
31618  
31619 Free a keys/data/node block whose keys block entry is located at the specified offset.
31620  
31621 Parameter Description
31622 1 $tree Tree descriptor
31623 2 $k Offset of keys block
31624 3 $K Numbered zmm for keys
31625 4 $D Numbered zmm for data
31626 5 $N Numbered zmm for children
31627  
31628 =head2 Nasm::X86::Tree::upFromData($tree, $zmm, %options)
31629  
31630 Up from the data zmm in a block in a tree.
31631  
31632 Parameter Description
31633 1 $tree Tree descriptor
31634 2 $zmm Number of zmm containing data block
31635 3 %options Options
31636  
31637 =head2 Nasm::X86::Tree::upIntoData($tree, $value, $zmm)
31638  
31639 Up into the data zmm in a block in a tree.
31640  
31641 Parameter Description
31642 1 $tree Tree descriptor
31643 2 $value Variable containing value to put
31644 3 $zmm Number of zmm containing first block
31645  
31646 =head2 Nasm::X86::Tree::lengthFromKeys($t, $zmm, %options)
31647  
31648 Get the length of the keys block in the numbered zmm and return it as a variable.
31649  
31650 Parameter Description
31651 1 $t Tree descriptor
31652 2 $zmm Zmm number
31653 3 %options Options
31654  
31655 =head2 Nasm::X86::Tree::lengthIntoKeys($t, $zmm, $length)
31656  
31657 Get the length of the block in the numbered zmm from the specified variable.
31658  
31659 Parameter Description
31660 1 $t Tree
31661 2 $zmm Zmm number
31662 3 $length Length variable
31663  
31664 =head2 Nasm::X86::Tree::incLengthInKeys($t, $K)
31665  
31666 Increment the number of keys in a keys block or complain if such is not possible.
31667  
31668 Parameter Description
31669 1 $t Tree
31670 2 $K Zmm number
31671  
31672 =head2 Nasm::X86::Tree::decLengthInKeys($t, $K)
31673  
31674 Decrement the number of keys in a keys block or complain if such is not possible.
31675  
31676 Parameter Description
31677 1 $t Tree
31678 2 $K Zmm number
31679  
31680 =head2 Nasm::X86::Tree::leafFromNodes($tree, $zmm, %options)
31681  
31682 Return a variable containing true if we are on a leaf. We determine whether we are on a leaf by checking the offset of the first sub node. If it is zero we are on a leaf otherwise not.
31683  
31684 Parameter Description
31685 1 $tree Tree descriptor
31686 2 $zmm Number of zmm containing node block
31687 3 %options Options
31688  
31689 =head2 Nasm::X86::Tree::getLoop($t, $zmm, %options)
31690  
31691 Return the value of the loop field as a variable.
31692  
31693 Parameter Description
31694 1 $t Tree descriptor
31695 2 $zmm Numbered zmm
31696 3 %options Options
31697  
31698 =head2 Nasm::X86::Tree::putLoop($t, $value, $zmm)
31699  
31700 Set the value of the loop field from a variable.
31701  
31702 Parameter Description
31703 1 $t Tree descriptor
31704 2 $value Variable containing offset of next loop entry
31705 3 $zmm Numbered zmm
31706  
31707 =head2 Nasm::X86::Tree::maskForFullKeyArea()
31708  
31709 Place a mask for the full key area in the numbered mask register.
31710  
31711  
31712 =head2 Nasm::X86::Tree::maskForFullNodesArea()
31713  
31714 Place a mask for the full nodes area in the numbered mask register.
31715  
31716  
31717 =head2 Nasm::X86::Tree::getBlock($tree, $offset, $K, $D, $N)
31718  
31719 Get the keys, data and child nodes for a tree node from the specified offset in the area for the tree.
31720  
31721 Parameter Description
31722 1 $tree Tree descriptor
31723 2 $offset Offset of block as a variable
31724 3 $K Numbered zmm for keys
31725 4 $D Numbered data for keys
31726 5 $N Numbered zmm for nodes
31727  
31728 B<Example:>
31729  
31730  
31731 my $a = CreateArea;
31732 my $t = $a->CreateTree;
31733 my $b = $t->allocBlock(31, 30, 29);
31734 K(data => 0x33)->dIntoZ(31, 4);
31735 $t->lengthIntoKeys(31, K length =>0x9);
31736 $t->putBlock($b, 31, 30, 29);
31737 $t->getBlock($b, 25, 24, 23);
31738 PrintOutRegisterInHex 25;
31739 $t->lengthFromKeys(25)->outNL;
31740  
31741  
31742 $t->firstFromMemory(28);
31743 $t->incSizeInFirst (28);
31744 $t->rootIntoFirst (28, K value => 0x2222);
31745 $t->root (28, K value => 0x2222); PrintOutZF;
31746 $t->root (28, K value => 0x2221); PrintOutZF;
31747 $t->root (28, K value => 0x2222); PrintOutZF;
31748 $t->firstIntoMemory(28);
31749  
31750 $t->first->outNL;
31751 $b->outNL;
31752 $a->dump("1111");
31753 PrintOutRegisterInHex 31, 30, 29, 28;
31754  
31755 If $t->leafFromNodes(29) > 0, Then {PrintOutStringNL "29 Leaf"}, Else {PrintOutStringNL "29 Branch"};
31756 If $t->leafFromNodes(28) > 0, Then {PrintOutStringNL "28 Leaf"}, Else {PrintOutStringNL "28 Branch"};
31757  
31758  
31759 ok Assemble eq => <<END, avx512=>1;
31760 zmm25: .... ..C0 .... ...9 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... ..33 .... ....
31761 b at offset 56 in zmm25: .... .... .... ...9
31762 ZF=1
31763 ZF=0
31764 ZF=1
31765 first : .... .... .... ..40
31766 address: .... .... .... ..80
31767 1111
31768 Area Size: 4096 Used: 320
31769 .... .... .... ...0 | __10 ____ ____ ____ 40.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
31770 .... .... .... ..40 | 2222 ____ ____ ____ .1__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
31771 .... .... .... ..80 | ____ ____ 33__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .9__ ____ C0__ ____
31772 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __.1 ____
31773 zmm31: .... ..C0 .... ...9 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... ..33 .... ....
31774 zmm30: .... .1.. .... .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
31775 zmm29: .... ..40 .... .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
31776 zmm28: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...1 .... .... .... 2222
31777 29 Leaf
31778 28 Branch
31779 END
31780  
31781  
31782 =head2 Nasm::X86::Tree::putBlock($t, $offset, $K, $D, $N)
31783  
31784 Put a tree block held in three zmm registers back into the area holding the tree at the specified offset.
31785  
31786 Parameter Description
31787 1 $t Tree descriptor
31788 2 $offset Offset of block as a variable
31789 3 $K Numbered zmm for keys
31790 4 $D Numbered data for keys
31791 5 $N Numbered zmm for nodes
31792  
31793 B<Example:>
31794  
31795  
31796 my $a = CreateArea;
31797 my $t = $a->CreateTree;
31798 my $b = $t->allocBlock(31, 30, 29);
31799 K(data => 0x33)->dIntoZ(31, 4);
31800 $t->lengthIntoKeys(31, K length =>0x9);
31801 $t->putBlock($b, 31, 30, 29);
31802 $t->getBlock($b, 25, 24, 23);
31803 PrintOutRegisterInHex 25;
31804 $t->lengthFromKeys(25)->outNL;
31805  
31806  
31807 $t->firstFromMemory(28);
31808 $t->incSizeInFirst (28);
31809 $t->rootIntoFirst (28, K value => 0x2222);
31810 $t->root (28, K value => 0x2222); PrintOutZF;
31811 $t->root (28, K value => 0x2221); PrintOutZF;
31812 $t->root (28, K value => 0x2222); PrintOutZF;
31813 $t->firstIntoMemory(28);
31814  
31815 $t->first->outNL;
31816 $b->outNL;
31817 $a->dump("1111");
31818 PrintOutRegisterInHex 31, 30, 29, 28;
31819  
31820 If $t->leafFromNodes(29) > 0, Then {PrintOutStringNL "29 Leaf"}, Else {PrintOutStringNL "29 Branch"};
31821 If $t->leafFromNodes(28) > 0, Then {PrintOutStringNL "28 Leaf"}, Else {PrintOutStringNL "28 Branch"};
31822  
31823  
31824 ok Assemble eq => <<END, avx512=>1;
31825 zmm25: .... ..C0 .... ...9 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... ..33 .... ....
31826 b at offset 56 in zmm25: .... .... .... ...9
31827 ZF=1
31828 ZF=0
31829 ZF=1
31830 first : .... .... .... ..40
31831 address: .... .... .... ..80
31832 1111
31833 Area Size: 4096 Used: 320
31834 .... .... .... ...0 | __10 ____ ____ ____ 40.1 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
31835 .... .... .... ..40 | 2222 ____ ____ ____ .1__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
31836 .... .... .... ..80 | ____ ____ 33__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ .9__ ____ C0__ ____
31837 .... .... .... ..C0 | ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __.1 ____
31838 zmm31: .... ..C0 .... ...9 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... ..33 .... ....
31839 zmm30: .... .1.. .... .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
31840 zmm29: .... ..40 .... .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
31841 zmm28: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...1 .... .... .... 2222
31842 29 Leaf
31843 28 Branch
31844 END
31845  
31846  
31847 =head2 Nasm::X86::Tree::firstNode($tree, $K, $D, $N)
31848  
31849 Return as a variable the last node block in the specified tree node held in a zmm.
31850  
31851 Parameter Description
31852 1 $tree Tree definition
31853 2 $K Key zmm
31854 3 $D Data zmm
31855 4 $N Node zmm for a node block
31856  
31857 B<Example:>
31858  
31859  
31860 my $a = CreateArea;
31861 my $t = $a->CreateTree;
31862  
31863 my ($K, $D, $N) = (31, 30, 29);
31864  
31865 K(K => Rd( 1..16))->loadZmm($K);
31866 K(K => Rd( 1..16))->loadZmm($N);
31867  
31868 $t->lengthIntoKeys($K, K length => $t->length);
31869  
31870 PrintOutRegisterInHex 31, 29;
31871 my $f = $t->firstNode($K, $D, $N);
31872 my $l = $t-> lastNode($K, $D, $N);
31873 $f->outNL;
31874 $l->outNL;
31875  
31876 ok Assemble eq => <<END, avx512=>1;
31877 zmm31: .... ..10 .... ...D .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
31878 zmm29: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
31879 d at offset 0 in zmm29: .... .... .... ...1
31880 d at offset (b at offset 56 in zmm31 times 4) in zmm29: .... .... .... ...E
31881 END
31882  
31883 my $a = CreateArea;
31884 my $t = $a->CreateTree;
31885  
31886 my ($K, $D, $N) = (31, 30, 29);
31887  
31888 K(K => Rd( 1..16))->loadZmm($K);
31889 K(K => Rd( 1..16))->loadZmm($N);
31890  
31891 $t->lengthIntoKeys($K, K length => $t->length);
31892  
31893 PrintOutRegisterInHex 31, 29;
31894 my $f = $t->firstNode($K, $D, $N);
31895 my $l = $t-> lastNode($K, $D, $N);
31896 $f->outNL;
31897 $l->outNL;
31898  
31899 ok Assemble eq => <<END, avx512=>1;
31900 zmm31: .... ..10 .... ...D .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
31901 zmm29: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
31902 d at offset 0 in zmm29: .... .... .... ...1
31903 d at offset (b at offset 56 in zmm31 times 4) in zmm29: .... .... .... ...E
31904 END
31905  
31906  
31907 =head2 Nasm::X86::Tree::lastNode($tree, $K, $D, $N)
31908  
31909 Return as a variable the last node block in the specified tree node held in a zmm.
31910  
31911 Parameter Description
31912 1 $tree Tree definition
31913 2 $K Key zmm
31914 3 $D Data zmm
31915 4 $N Node zmm for a node block
31916  
31917 B<Example:>
31918  
31919  
31920 my $a = CreateArea;
31921 my $t = $a->CreateTree;
31922  
31923 my ($K, $D, $N) = (31, 30, 29);
31924  
31925 K(K => Rd( 1..16))->loadZmm($K);
31926 K(K => Rd( 1..16))->loadZmm($N);
31927  
31928 $t->lengthIntoKeys($K, K length => $t->length);
31929  
31930 PrintOutRegisterInHex 31, 29;
31931 my $f = $t->firstNode($K, $D, $N);
31932 my $l = $t-> lastNode($K, $D, $N);
31933 $f->outNL;
31934 $l->outNL;
31935  
31936 ok Assemble eq => <<END, avx512=>1;
31937 zmm31: .... ..10 .... ...D .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
31938 zmm29: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
31939 d at offset 0 in zmm29: .... .... .... ...1
31940 d at offset (b at offset 56 in zmm31 times 4) in zmm29: .... .... .... ...E
31941 END
31942  
31943 my $a = CreateArea;
31944 my $t = $a->CreateTree;
31945  
31946 my ($K, $D, $N) = (31, 30, 29);
31947  
31948 K(K => Rd( 1..16))->loadZmm($K);
31949 K(K => Rd( 1..16))->loadZmm($N);
31950  
31951 $t->lengthIntoKeys($K, K length => $t->length);
31952  
31953 PrintOutRegisterInHex 31, 29;
31954 my $f = $t->firstNode($K, $D, $N);
31955 my $l = $t-> lastNode($K, $D, $N);
31956 $f->outNL;
31957 $l->outNL;
31958  
31959 ok Assemble eq => <<END, avx512=>1;
31960 zmm31: .... ..10 .... ...D .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
31961 zmm29: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
31962 d at offset 0 in zmm29: .... .... .... ...1
31963 d at offset (b at offset 56 in zmm31 times 4) in zmm29: .... .... .... ...E
31964 END
31965  
31966  
31967 =head2 Nasm::X86::Tree::relativeNode($tree, $offset, $relative, $K, $N)
31968  
31969 Return as a variable a node offset relative (specified as ac constant) to another offset in the same node in the specified zmm.
31970  
31971 Parameter Description
31972 1 $tree Tree definition
31973 2 $offset Offset
31974 3 $relative Relative location
31975 4 $K Key zmm
31976 5 $N Node zmm
31977  
31978 =head2 Nasm::X86::Tree::nextNode($tree, $offset, $K, $N)
31979  
31980 Return as a variable the next node block offset after the specified one in the specified zmm.
31981  
31982 Parameter Description
31983 1 $tree Tree definition
31984 2 $offset Offset
31985 3 $K Key zmm
31986 4 $N Node zmm
31987  
31988 B<Example:>
31989  
31990  
31991 my $a = CreateArea;
31992 my $t = $a->CreateTree;
31993  
31994 K(loop => 66)->for(sub
31995 {my ($index, $start, $next, $end) = @_;
31996 $t->put($index, 2 * $index);
31997 });
31998 $t->getBlock(K(offset=>0x200), 31, 30, 29);
31999 $t->nextNode(K(offset=>0x440), 31, 29)->outRightInHexNL(K width => 3);
32000 $t->prevNode(K(offset=>0x440), 31, 29)->outRightInHexNL(K width => 3);
32001  
32002 ok Assemble eq => <<END, avx512=>1;
32003 500
32004 380
32005 END
32006  
32007  
32008 =head2 Nasm::X86::Tree::prevNode($tree, $offset, $K, $N)
32009  
32010 Return as a variable the previous node block offset after the specified one in the specified zmm.
32011  
32012 Parameter Description
32013 1 $tree Tree definition
32014 2 $offset Offset
32015 3 $K Key zmm
32016 4 $N Node zmm
32017  
32018 B<Example:>
32019  
32020  
32021 my $a = CreateArea;
32022 my $t = $a->CreateTree;
32023  
32024 K(loop => 66)->for(sub
32025 {my ($index, $start, $next, $end) = @_;
32026 $t->put($index, 2 * $index);
32027 });
32028 $t->getBlock(K(offset=>0x200), 31, 30, 29);
32029 $t->nextNode(K(offset=>0x440), 31, 29)->outRightInHexNL(K width => 3);
32030 $t->prevNode(K(offset=>0x440), 31, 29)->outRightInHexNL(K width => 3);
32031  
32032 ok Assemble eq => <<END, avx512=>1;
32033 500
32034 380
32035 END
32036  
32037  
32038 =head2 Nasm::X86::Tree::indexNode($tree, $offset, $K, $N)
32039  
32040 Return, as a variable, the point mask obtained by testing the nodes in a block for specified offset. We have to supply the keys as well so that we can find the number of nodes. We need the number of nodes so that we only search the valid area not all possible node positions in the zmm.
32041  
32042 Parameter Description
32043 1 $tree Tree definition
32044 2 $offset Key as a variable
32045 3 $K Zmm containing keys
32046 4 $N Comparison from B<Vpcmp>
32047  
32048 =head2 Nasm::X86::Tree::expand($tree, $offset)
32049  
32050 Expand the node at the specified offset in the specified tree if it needs to be expanded and is not the root node (which cannot be expanded because it has no siblings to take substance from whereas as all other nodes do). Set tree.found to the offset of the left sibling if the node at the specified offset was merged into it and freed else set tree.found to zero.
32051  
32052 Parameter Description
32053 1 $tree Tree descriptor
32054 2 $offset Offset of node block to expand
32055  
32056 =head2 Nasm::X86::Tree::replace($tree, $point, $K, $D)
32057  
32058 Replace the key/data/subTree at the specified point in the specified zmm with the values found in the tree key/data/sub tree fields.
32059  
32060 Parameter Description
32061 1 $tree Tree descriptor
32062 2 $point Point at which to extract
32063 3 $K Keys zmm
32064 4 $D Data zmm
32065  
32066 B<Example:>
32067  
32068  
32069 my ($K, $D) = (31, 30);
32070  
32071 K(K => Rd(reverse 1..16))->loadZmm($K);
32072 K(K => Rd(reverse 1..16))->loadZmm($D);
32073 PrintOutStringNL "Start";
32074 PrintOutRegisterInHex $K, $D;
32075  
32076 my $a = CreateArea;
32077 my $t = $a->CreateTree;
32078  
32079 K(loop => 14)->for(sub
32080 {my ($index, $start, $next, $end) = @_;
32081  
32082 $t->key ->copy($index);
32083 $t->data ->copy($index * 2);
32084 $t->subTree->copy($index % 2);
32085  
32086 $t->replace(K(one=>1)<<$index, $K, $D);
32087  
32088 $index->outNL;
32089 PrintOutRegisterInHex $K, $D;
32090 });
32091  
32092 ok Assemble eq => <<END, avx512=>1;
32093 Start
32094 zmm31: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...C - .... ...D .... ...E .... ...F .... ..10
32095 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...C - .... ...D .... ...E .... ...F .... ..10
32096 index: .... .... .... ...0
32097 zmm31: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...C - .... ...D .... ...E .... ...F .... ....
32098 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...C - .... ...D .... ...E .... ...F .... ....
32099 index: .... .... .... ...1
32100 zmm31: .... ...1 ...2 ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...C - .... ...D .... ...E .... ...1 .... ....
32101 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...C - .... ...D .... ...E .... ...2 .... ....
32102 index: .... .... .... ...2
32103 zmm31: .... ...1 ...2 ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...C - .... ...D .... ...2 .... ...1 .... ....
32104 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...C - .... ...D .... ...4 .... ...2 .... ....
32105 index: .... .... .... ...3
32106 zmm31: .... ...1 ...A ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...C - .... ...3 .... ...2 .... ...1 .... ....
32107 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...C - .... ...6 .... ...4 .... ...2 .... ....
32108 index: .... .... .... ...4
32109 zmm31: .... ...1 ...A ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
32110 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...B .... ...8 - .... ...6 .... ...4 .... ...2 .... ....
32111 index: .... .... .... ...5
32112 zmm31: .... ...1 ..2A ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
32113 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...A .... ...A .... ...8 - .... ...6 .... ...4 .... ...2 .... ....
32114 index: .... .... .... ...6
32115 zmm31: .... ...1 ..2A ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
32116 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...9 .... ...C .... ...A .... ...8 - .... ...6 .... ...4 .... ...2 .... ....
32117 index: .... .... .... ...7
32118 zmm31: .... ...1 ..AA ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
32119 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...E .... ...C .... ...A .... ...8 - .... ...6 .... ...4 .... ...2 .... ....
32120 index: .... .... .... ...8
32121 zmm31: .... ...1 ..AA ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
32122 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...7 .... ..10 + .... ...E .... ...C .... ...A .... ...8 - .... ...6 .... ...4 .... ...2 .... ....
32123 index: .... .... .... ...9
32124 zmm31: .... ...1 .2AA ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
32125 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ...6 .... ..12 .... ..10 + .... ...E .... ...C .... ...A .... ...8 - .... ...6 .... ...4 .... ...2 .... ....
32126 index: .... .... .... ...A
32127 zmm31: .... ...1 .2AA ...2 .... ...3 .... ...4 - .... ...5 .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
32128 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ...5 .... ..14 .... ..12 .... ..10 + .... ...E .... ...C .... ...A .... ...8 - .... ...6 .... ...4 .... ...2 .... ....
32129 index: .... .... .... ...B
32130 zmm31: .... ...1 .AAA ...2 .... ...3 .... ...4 - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
32131 zmm30: .... ...1 .... ...2 .... ...3 .... ...4 - .... ..16 .... ..14 .... ..12 .... ..10 + .... ...E .... ...C .... ...A .... ...8 - .... ...6 .... ...4 .... ...2 .... ....
32132 index: .... .... .... ...C
32133 zmm31: .... ...1 .AAA ...2 .... ...3 .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
32134 zmm30: .... ...1 .... ...2 .... ...3 .... ..18 - .... ..16 .... ..14 .... ..12 .... ..10 + .... ...E .... ...C .... ...A .... ...8 - .... ...6 .... ...4 .... ...2 .... ....
32135 index: .... .... .... ...D
32136 zmm31: .... ...1 2AAA ...2 .... ...D .... ...C - .... ...B .... ...A .... ...9 .... ...8 + .... ...7 .... ...6 .... ...5 .... ...4 - .... ...3 .... ...2 .... ...1 .... ....
32137 zmm30: .... ...1 .... ...2 .... ..1A .... ..18 - .... ..16 .... ..14 .... ..12 .... ..10 + .... ...E .... ...C .... ...A .... ...8 - .... ...6 .... ...4 .... ...2 .... ....
32138 END
32139  
32140  
32141 =head2 Nasm::X86::Tree::overWriteKeyDataTreeInLeaf($tree, $point, $K, $D, $IK, $ID, $subTree)
32142  
32143 Over write an existing key/data/sub tree triple in a set of zmm registers and set the tree bit as indicated.
32144  
32145 Parameter Description
32146 1 $tree Tree descriptor
32147 2 $point Register point at which to overwrite formatted as a one in a sea of zeros
32148 3 $K Key
32149 4 $D Data
32150 5 $IK Insert key
32151 6 $ID Insert data
32152 7 $subTree Sub tree if tree.
32153  
32154 =head2 Nasm::X86::Tree::indexXX($tree, $key, $K, $cmp, $inc, %options)
32155  
32156 Return, as a variable, the mask obtained by performing a specified comparison on the key area of a node against a specified key.
32157  
32158 Parameter Description
32159 1 $tree Tree definition
32160 2 $key Key to search for as a variable or a zmm containing a copy of the key to be searched for in each slot
32161 3 $K Zmm containing keys
32162 4 $cmp Comparison from B<Vpcmp>
32163 5 $inc Whether to increment the result by one
32164 6 %options Options
32165  
32166 =head2 Nasm::X86::Tree::indexEq($tree, $key, $K, %options)
32167  
32168 Return the position of a key in a zmm equal to the specified key as a point in a variable.
32169  
32170 Parameter Description
32171 1 $tree Tree definition
32172 2 $key Key as a variable
32173 3 $K Zmm containing keys
32174 4 %options Options
32175  
32176 B<Example:>
32177  
32178  
32179 my $tree = DescribeTree;
32180  
32181 my $K = 31;
32182  
32183 K(K => Rd(0..15))->loadZmm($K);
32184 $tree->lengthIntoKeys($K, K length => 13);
32185  
32186 K(loop => 16)->for(sub
32187 {my ($index, $start, $next, $end) = @_;
32188 my $f = $tree->indexEq ($index, $K);
32189 $index->outRightInDec( 2);
32190 $f ->outRightInBin(14);
32191 PrintOutStringNL " |"
32192 });
32193  
32194 ok Assemble eq => <<END, avx512=>1;
32195 0 1 |
32196 1 10 |
32197 2 100 |
32198 3 1000 |
32199 4 10000 |
32200 5 100000 |
32201 6 1000000 |
32202 7 10000000 |
32203 8 100000000 |
32204 9 1000000000 |
32205 10 10000000000 |
32206 11 100000000000 |
32207 12 1000000000000 |
32208 13 |
32209 14 |
32210 15 |
32211 END
32212  
32213 my $tree = DescribeTree();
32214 $tree->maskForFullKeyArea(7); # Mask for full key area
32215 PrintOutRegisterInHex k7;
32216 $tree->maskForFullNodesArea(7); # Mask for full nodes area
32217 PrintOutRegisterInHex k7;
32218 ok Assemble eq => <<END, avx512=>1;
32219 k7: .... .... .... 3FFF
32220 k7: .... .... .... 7FFF
32221 END
32222  
32223  
32224 =head2 Nasm::X86::Tree::insertionPoint($tree, $key, $K, %options)
32225  
32226 Return the position at which a key should be inserted into a zmm as a point in a variable.
32227  
32228 Parameter Description
32229 1 $tree Tree definition
32230 2 $key Key as a variable
32231 3 $K Zmm containing keys
32232 4 %options Options
32233  
32234 B<Example:>
32235  
32236  
32237 my $tree = DescribeTree(length => 7);
32238  
32239 my $K = 31;
32240  
32241 K(K => Rd(map {2*$_} 1..16))->loadZmm($K);
32242 $tree->lengthIntoKeys($K, K length => 13);
32243  
32244 K(loop => 32)->for(sub
32245 {my ($index, $start, $next, $end) = @_;
32246 my $f = $tree->insertionPoint($index, $K);
32247 $index->outRightInDec( 2);
32248 $f ->outRightInBin(16);
32249 PrintOutStringNL " |"
32250 });
32251  
32252 ok Assemble eq => <<END, avx512=>1;
32253 0 1 |
32254 1 1 |
32255 2 10 |
32256 3 10 |
32257 4 100 |
32258 5 100 |
32259 6 1000 |
32260 7 1000 |
32261 8 10000 |
32262 9 10000 |
32263 10 100000 |
32264 11 100000 |
32265 12 1000000 |
32266 13 1000000 |
32267 14 10000000 |
32268 15 10000000 |
32269 16 100000000 |
32270 17 100000000 |
32271 18 1000000000 |
32272 19 1000000000 |
32273 20 10000000000 |
32274 21 10000000000 |
32275 22 100000000000 |
32276 23 100000000000 |
32277 24 1000000000000 |
32278 25 1000000000000 |
32279 26 10000000000000 |
32280 27 10000000000000 |
32281 28 10000000000000 |
32282 29 10000000000000 |
32283 30 10000000000000 |
32284 31 10000000000000 |
32285 END
32286  
32287  
32288 =head2 Nasm::X86::Tree::indexEqLt($tree, $key, $K, $setEq, $setLt)
32289  
32290 Set the specified registers with the equals point and the insertion point for the specified key in the specified zmm.
32291  
32292 Parameter Description
32293 1 $tree Tree definition
32294 2 $key Zmm containing a copy of the key to be searched for in each slot
32295 3 $K Zmm to check
32296 4 $setEq Bound register to set with equals point
32297 5 $setLt Bound register to set with insertion point.
32298  
32299 B<Example:>
32300  
32301  
32302 my $tree = DescribeTree;
32303  
32304 my $K = 31, my $key = 30;
32305  
32306 K(K => Rd(0..15))->loadZmm($K);
32307 $tree->lengthIntoKeys($K, K length => 13);
32308  
32309 K(loop => 16)->for(sub
32310 {my ($index, $start, $next, $end) = @_;
32311 $index->setReg(rdi);
32312 Vpbroadcastd zmm($key), edi;
32313  
32314 $tree->indexEqLt ($key, $K, r15, r14);
32315 Pushfq;
32316 my $f = V key => r15;
32317 $index->outRightInDec( 2);
32318 $f ->outRightInBin(14);
32319 PrintOutString " ";
32320 Popfq;
32321 PrintOutZF;
32322 });
32323  
32324 ok Assemble eq => <<END, avx512=>1;
32325 0 1 ZF=0
32326 1 10 ZF=0
32327 2 100 ZF=0
32328 3 1000 ZF=0
32329 4 10000 ZF=0
32330 5 100000 ZF=0
32331 6 1000000 ZF=0
32332 7 10000000 ZF=0
32333 8 100000000 ZF=0
32334 9 1000000000 ZF=0
32335 10 10000000000 ZF=0
32336 11 100000000000 ZF=0
32337 12 1000000000000 ZF=0
32338 13 ZF=1
32339 14 ZF=1
32340 15 ZF=1
32341 END
32342  
32343  
32344 =head2 Nasm::X86::Tree::insertKeyDataTreeIntoLeaf($tree, $point, $F, $K, $D, $IK, $ID, $subTree)
32345  
32346 Insert a new key/data/sub tree triple into a set of zmm registers if there is room, increment the length of the node and set the tree bit as indicated and increment the number of elements in the tree.
32347  
32348 Parameter Description
32349 1 $tree Tree descriptor
32350 2 $point Register point at which to insert formatted as a one in a sea of zeros
32351 3 $F First
32352 4 $K Key
32353 5 $D Data
32354 6 $IK Insert key
32355 7 $ID Insert data
32356 8 $subTree Sub tree if tree.
32357  
32358 =head2 Nasm::X86::Tree::splitNode($tree, $offset)
32359  
32360 Split a node if it it is full returning a variable that indicates whether a split occurred or not.
32361  
32362 Parameter Description
32363 1 $tree Tree descriptor
32364 2 $offset Offset of block in area of tree as a variable
32365  
32366 =head2 Nasm::X86::Tree::splitNotRoot($tree, $newRight, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN)
32367  
32368 Split a non root left node pushing its excess right and up.
32369  
32370 Parameter Description
32371 1 $tree Tree definition
32372 2 $newRight Variable offset in area of right node block
32373 3 $PK Parent keys zmm
32374 4 $PD Data zmm
32375 5 $PN Nodes zmm
32376 6 $LK Left keys zmm
32377 7 $LD Data zmm
32378 8 $LN Nodes zmm
32379 9 $RK Right keys
32380 10 $RD Data
32381 11 $RN Node zmm
32382  
32383 =head2 Nasm::X86::Tree::splitRoot($tree, $nLeft, $nRight, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN)
32384  
32385 Split a non root node into left and right nodes with the left half left in the left node and splitting key/data pushed into the parent node with the remainder pushed into the new right node.
32386  
32387 Parameter Description
32388 1 $tree Tree definition
32389 2 $nLeft Variable offset in area of new left node block
32390 3 $nRight Variable offset in area of new right node block
32391 4 $PK Parent keys zmm
32392 5 $PD Data zmm
32393 6 $PN Nodes zmm
32394 7 $LK Left keys zmm
32395 8 $LD Data zmm
32396 9 $LN Nodes zmm
32397 10 $RK Right keys
32398 11 $RD Data
32399 12 $RN Nodes zmm
32400  
32401 =head2 Nasm::X86::Tree::zero($tree)
32402  
32403 Zero the return fields of a tree descriptor.
32404  
32405 Parameter Description
32406 1 $tree Tree descriptor
32407  
32408 =head2 Nasm::X86::Tree::findAndReload($t, $key)
32409  
32410 Find a key in the specified tree and clone it is it is a sub tree.
32411  
32412 Parameter Description
32413 1 $t Tree descriptor
32414 2 $key Key as a dword
32415  
32416 =head2 Nasm::X86::Tree::leftOrRightMost($tree, $dir, $node, $offset)
32417  
32418 Return the offset of the left most or right most node.
32419  
32420 Parameter Description
32421 1 $tree Tree descriptor
32422 2 $dir Direction: left = 0 or right = 1
32423 3 $node Start node
32424 4 $offset Offset of located node
32425  
32426 =head2 Nasm::X86::Tree::leftMost($t, $node, $offset)
32427  
32428 Return the offset of the left most node from the specified node.
32429  
32430 Parameter Description
32431 1 $t Tree descriptor
32432 2 $node Start node
32433 3 $offset Returned offset
32434  
32435 =head2 Nasm::X86::Tree::rightMost($t, $node, $offset)
32436  
32437 Return the offset of the left most node from the specified node.
32438  
32439 Parameter Description
32440 1 $t Tree descriptor
32441 2 $node Start node
32442 3 $offset Returned offset
32443  
32444 =head2 Nasm::X86::Tree::depth($tree, $node)
32445  
32446 Return the depth of a node within a tree.
32447  
32448 Parameter Description
32449 1 $tree Tree descriptor
32450 2 $node Node
32451  
32452 =head2 Nasm::X86::Tree::isTree($t, $zmm, $point)
32453  
32454 Set the Zero Flag to oppose the tree bit in the numbered zmm register holding the keys of a node to indicate whether the data element indicated by the specified register is an offset to a sub tree in the containing area or not.
32455  
32456 Parameter Description
32457 1 $t Tree descriptor
32458 2 $zmm Numbered zmm register holding the keys for a node in the tree
32459 3 $point Register showing point to test
32460  
32461 B<Example:>
32462  
32463  
32464  
32465 my $t = DescribeTree;
32466 Mov r8, 0b100; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32467 Mov r8, 0b010; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32468 Mov r8, 0b001; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32469 Mov r8, 0b010; $t->clearTreeBit(31, r8); PrintOutRegisterInHex 31;
32470  
32471 $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32472 Mov r8, 0b010; $t->insertZeroIntoTreeBits(31, r8); $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32473 Mov r8, 0b010; $t->insertOneIntoTreeBits (31, r8); $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32474  
32475 $t->getTreeBits(31, r8);
32476 V(TreeBits => r8)->outRightInHexNL(4);
32477 PrintOutRegisterInHex 31;
32478  
32479 Mov r8, 1; $t->isTree(31, r8); PrintOutZF;
32480 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32481 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32482 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32483  
32484 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32485 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32486 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32487 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32488  
32489 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32490 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32491 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32492 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32493  
32494 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32495 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32496 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32497 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32498  
32499 Not r8; $t->setTreeBits(31, r8); PrintOutRegisterInHex 31;
32500  
32501 ok Assemble eq => <<END, avx512=>1;
32502 zmm31: .... .... ...4 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32503 zmm31: .... .... ...6 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32504 zmm31: .... .... ...7 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32505 zmm31: .... .... ...5 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32506 101
32507 1001
32508 10011
32509 13
32510 zmm31: .... .... ..13 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32511 ZF=0
32512 ZF=0
32513 ZF=1
32514 ZF=1
32515 ZF=0
32516 ZF=1
32517 ZF=1
32518 ZF=1
32519 ZF=1
32520 ZF=1
32521 ZF=1
32522 ZF=1
32523 ZF=1
32524 ZF=1
32525 ZF=1
32526 ZF=1
32527 zmm31: .... .... 3FFF .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32528 END
32529  
32530  
32531 =head2 Nasm::X86::Tree::getTreeBit($t, $zmm, $point, %options)
32532  
32533 Get the tree bit from the numbered zmm at the specified point and return it in a variable as a one or a zero.
32534  
32535 Parameter Description
32536 1 $t Tree descriptor
32537 2 $zmm Register showing point to test
32538 3 $point Numbered zmm register holding the keys for a node in the tree
32539 4 %options Options
32540  
32541 =head2 Nasm::X86::Tree::setOrClearTreeBit($t, $set, $point, $zmm)
32542  
32543 Set or clear the tree bit selected by the specified point in the numbered zmm register holding the keys of a node to indicate that the data element indicated by the specified register is an offset to a sub tree in the containing area.
32544  
32545 Parameter Description
32546 1 $t Tree descriptor
32547 2 $set Set if true else clear
32548 3 $point Register holding point to set
32549 4 $zmm Numbered zmm register holding the keys for a node in the tree
32550  
32551 =head2 Nasm::X86::Tree::setTreeBit($t, $zmm, $point)
32552  
32553 Set the tree bit in the numbered zmm register holding the keys of a node to indicate that the data element indexed by the specified register is an offset to a sub tree in the containing area.
32554  
32555 Parameter Description
32556 1 $t Tree descriptor
32557 2 $zmm Numbered zmm register holding the keys for a node in the tree
32558 3 $point Register holding the point to clear
32559  
32560 =head2 Nasm::X86::Tree::clearTreeBit($t, $zmm, $point)
32561  
32562 Clear the tree bit in the numbered zmm register holding the keys of a node to indicate that the data element indexed by the specified register is an offset to a sub tree in the containing area.
32563  
32564 Parameter Description
32565 1 $t Tree descriptor
32566 2 $zmm Numbered zmm register holding the keys for a node in the tree
32567 3 $point Register holding register holding the point to set
32568  
32569 =head2 Nasm::X86::Tree::setOrClearTreeBitToMatchContent($t, $zmm, $point, $content)
32570  
32571 Set or clear the tree bit pointed to by the specified register depending on the content of the specified variable.
32572  
32573 Parameter Description
32574 1 $t Tree descriptor
32575 2 $zmm Numbered keys zmm
32576 3 $point Register indicating point
32577 4 $content Content indicating zero or one
32578  
32579 =head2 Nasm::X86::Tree::getTreeBits($t, $zmm, $register)
32580  
32581 Load the tree bits from the numbered zmm into the specified register.
32582  
32583 Parameter Description
32584 1 $t Tree descriptor
32585 2 $zmm Numbered zmm
32586 3 $register Target register
32587  
32588 B<Example:>
32589  
32590  
32591  
32592 my $t = DescribeTree;
32593 Mov r8, 0b100; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32594 Mov r8, 0b010; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32595 Mov r8, 0b001; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32596 Mov r8, 0b010; $t->clearTreeBit(31, r8); PrintOutRegisterInHex 31;
32597  
32598 $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32599 Mov r8, 0b010; $t->insertZeroIntoTreeBits(31, r8); $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32600 Mov r8, 0b010; $t->insertOneIntoTreeBits (31, r8); $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32601  
32602 $t->getTreeBits(31, r8);
32603 V(TreeBits => r8)->outRightInHexNL(4);
32604 PrintOutRegisterInHex 31;
32605  
32606 Mov r8, 1; $t->isTree(31, r8); PrintOutZF;
32607 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32608 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32609 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32610  
32611 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32612 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32613 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32614 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32615  
32616 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32617 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32618 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32619 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32620  
32621 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32622 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32623 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32624 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32625  
32626 Not r8; $t->setTreeBits(31, r8); PrintOutRegisterInHex 31;
32627  
32628 ok Assemble eq => <<END, avx512=>1;
32629 zmm31: .... .... ...4 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32630 zmm31: .... .... ...6 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32631 zmm31: .... .... ...7 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32632 zmm31: .... .... ...5 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32633 101
32634 1001
32635 10011
32636 13
32637 zmm31: .... .... ..13 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32638 ZF=0
32639 ZF=0
32640 ZF=1
32641 ZF=1
32642 ZF=0
32643 ZF=1
32644 ZF=1
32645 ZF=1
32646 ZF=1
32647 ZF=1
32648 ZF=1
32649 ZF=1
32650 ZF=1
32651 ZF=1
32652 ZF=1
32653 ZF=1
32654 zmm31: .... .... 3FFF .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32655 END
32656  
32657  
32658 =head2 Nasm::X86::Tree::setTreeBits($t, $zmm, $register)
32659  
32660 Put the tree bits in the specified register into the numbered zmm.
32661  
32662 Parameter Description
32663 1 $t Tree descriptor
32664 2 $zmm Numbered zmm
32665 3 $register Target register
32666  
32667 B<Example:>
32668  
32669  
32670  
32671 my $t = DescribeTree;
32672 Mov r8, 0b100; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32673 Mov r8, 0b010; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32674 Mov r8, 0b001; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32675 Mov r8, 0b010; $t->clearTreeBit(31, r8); PrintOutRegisterInHex 31;
32676  
32677 $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32678 Mov r8, 0b010; $t->insertZeroIntoTreeBits(31, r8); $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32679 Mov r8, 0b010; $t->insertOneIntoTreeBits (31, r8); $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32680  
32681 $t->getTreeBits(31, r8);
32682 V(TreeBits => r8)->outRightInHexNL(4);
32683 PrintOutRegisterInHex 31;
32684  
32685 Mov r8, 1; $t->isTree(31, r8); PrintOutZF;
32686 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32687 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32688 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32689  
32690 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32691 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32692 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32693 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32694  
32695 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32696 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32697 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32698 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32699  
32700 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32701 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32702 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32703 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32704  
32705 Not r8; $t->setTreeBits(31, r8); PrintOutRegisterInHex 31;
32706  
32707 ok Assemble eq => <<END, avx512=>1;
32708 zmm31: .... .... ...4 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32709 zmm31: .... .... ...6 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32710 zmm31: .... .... ...7 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32711 zmm31: .... .... ...5 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32712 101
32713 1001
32714 10011
32715 13
32716 zmm31: .... .... ..13 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32717 ZF=0
32718 ZF=0
32719 ZF=1
32720 ZF=1
32721 ZF=0
32722 ZF=1
32723 ZF=1
32724 ZF=1
32725 ZF=1
32726 ZF=1
32727 ZF=1
32728 ZF=1
32729 ZF=1
32730 ZF=1
32731 ZF=1
32732 ZF=1
32733 zmm31: .... .... 3FFF .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32734 END
32735  
32736  
32737 =head2 Nasm::X86::Tree::insertTreeBit($t, $onz, $zmm, $point)
32738  
32739 Insert a zero or one into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
32740  
32741 Parameter Description
32742 1 $t Tree descriptor
32743 2 $onz 0 - zero or 1 - one
32744 3 $zmm Numbered zmm
32745 4 $point Register indicating point
32746  
32747 =head2 Nasm::X86::Tree::insertZeroIntoTreeBits($t, $zmm, $point)
32748  
32749 Insert a zero into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
32750  
32751 Parameter Description
32752 1 $t Tree descriptor
32753 2 $zmm Numbered zmm
32754 3 $point Register indicating point
32755  
32756 B<Example:>
32757  
32758  
32759  
32760 my $t = DescribeTree;
32761 Mov r8, 0b100; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32762 Mov r8, 0b010; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32763 Mov r8, 0b001; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32764 Mov r8, 0b010; $t->clearTreeBit(31, r8); PrintOutRegisterInHex 31;
32765  
32766 $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32767 Mov r8, 0b010; $t->insertZeroIntoTreeBits(31, r8); $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32768 Mov r8, 0b010; $t->insertOneIntoTreeBits (31, r8); $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32769  
32770 $t->getTreeBits(31, r8);
32771 V(TreeBits => r8)->outRightInHexNL(4);
32772 PrintOutRegisterInHex 31;
32773  
32774 Mov r8, 1; $t->isTree(31, r8); PrintOutZF;
32775 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32776 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32777 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32778  
32779 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32780 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32781 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32782 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32783  
32784 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32785 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32786 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32787 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32788  
32789 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32790 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32791 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32792 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32793  
32794 Not r8; $t->setTreeBits(31, r8); PrintOutRegisterInHex 31;
32795  
32796 ok Assemble eq => <<END, avx512=>1;
32797 zmm31: .... .... ...4 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32798 zmm31: .... .... ...6 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32799 zmm31: .... .... ...7 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32800 zmm31: .... .... ...5 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32801 101
32802 1001
32803 10011
32804 13
32805 zmm31: .... .... ..13 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32806 ZF=0
32807 ZF=0
32808 ZF=1
32809 ZF=1
32810 ZF=0
32811 ZF=1
32812 ZF=1
32813 ZF=1
32814 ZF=1
32815 ZF=1
32816 ZF=1
32817 ZF=1
32818 ZF=1
32819 ZF=1
32820 ZF=1
32821 ZF=1
32822 zmm31: .... .... 3FFF .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32823 END
32824  
32825  
32826 =head2 Nasm::X86::Tree::insertOneIntoTreeBits($t, $zmm, $point)
32827  
32828 Insert a one into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
32829  
32830 Parameter Description
32831 1 $t Tree descriptor
32832 2 $zmm Numbered zmm
32833 3 $point Register indicating point
32834  
32835 B<Example:>
32836  
32837  
32838  
32839 my $t = DescribeTree;
32840 Mov r8, 0b100; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32841 Mov r8, 0b010; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32842 Mov r8, 0b001; $t->setTreeBit(31, r8); PrintOutRegisterInHex 31;
32843 Mov r8, 0b010; $t->clearTreeBit(31, r8); PrintOutRegisterInHex 31;
32844  
32845 $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32846 Mov r8, 0b010; $t->insertZeroIntoTreeBits(31, r8); $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32847 Mov r8, 0b010; $t->insertOneIntoTreeBits (31, r8); $t->getTreeBits(31, r8); V(TreeBits => r8)->outRightInBinNL(16);
32848  
32849 $t->getTreeBits(31, r8);
32850 V(TreeBits => r8)->outRightInHexNL(4);
32851 PrintOutRegisterInHex 31;
32852  
32853 Mov r8, 1; $t->isTree(31, r8); PrintOutZF;
32854 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32855 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32856 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32857  
32858 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32859 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32860 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32861 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32862  
32863 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32864 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32865 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32866 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32867  
32868 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32869 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32870 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32871 Shl r8, 1; $t->isTree(31, r8); PrintOutZF;
32872  
32873 Not r8; $t->setTreeBits(31, r8); PrintOutRegisterInHex 31;
32874  
32875 ok Assemble eq => <<END, avx512=>1;
32876 zmm31: .... .... ...4 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32877 zmm31: .... .... ...6 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32878 zmm31: .... .... ...7 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32879 zmm31: .... .... ...5 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32880 101
32881 1001
32882 10011
32883 13
32884 zmm31: .... .... ..13 .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32885 ZF=0
32886 ZF=0
32887 ZF=1
32888 ZF=1
32889 ZF=0
32890 ZF=1
32891 ZF=1
32892 ZF=1
32893 ZF=1
32894 ZF=1
32895 ZF=1
32896 ZF=1
32897 ZF=1
32898 ZF=1
32899 ZF=1
32900 ZF=1
32901 zmm31: .... .... 3FFF .... .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32902 END
32903  
32904  
32905 =head2 Nasm::X86::Tree::insertIntoTreeBits($t, $zmm, $point, $content)
32906  
32907 Insert a one into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
32908  
32909 Parameter Description
32910 1 $t Tree descriptor
32911 2 $zmm Numbered zmm
32912 3 $point Register indicating point
32913 4 $content Bit to insert
32914  
32915 =head2 Nasm::X86::Tree::extract($tree, $point, $K, $D, $N)
32916  
32917 Extract the key/data/node and tree bit at the specified point from the block held in the specified zmm registers.
32918  
32919 Parameter Description
32920 1 $tree Tree descriptor
32921 2 $point Point at which to extract
32922 3 $K Keys zmm
32923 4 $D Data zmm
32924 5 $N Node zmm
32925  
32926 B<Example:>
32927  
32928  
32929 my ($K, $D, $N) = (31, 30, 29);
32930  
32931 K(K => Rd( 1..16))->loadZmm($K);
32932 K(K => Rd( 1..16))->loadZmm($D);
32933 K(K => Rd(map {0} 1..16))->loadZmm($N);
32934  
32935 my $a = CreateArea;
32936 my $t = $a->CreateTree;
32937  
32938 my $p = K(one => 1) << K three => 3;
32939 Mov r15, 0xAAAA;
32940 $t->setTreeBits($K, r15);
32941  
32942 PrintOutStringNL "Start";
32943 PrintOutRegisterInHex 31, 30, 29;
32944  
32945 $t->extract($p, $K, $D, $N);
32946  
32947 PrintOutStringNL "Finish";
32948 PrintOutRegisterInHex 31, 30, 29;
32949  
32950 ok Assemble eq => <<END, avx512=>1;
32951 Start
32952 zmm31: .... ..10 2AAA ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
32953 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
32954 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32955 Finish
32956 zmm31: .... ..10 2AAA ...E .... ...E .... ...E - .... ...D .... ...C .... ...B .... ...A + .... ...9 .... ...8 .... ...7 .... ...6 - .... ...5 .... ...3 .... ...2 .... ...1
32957 zmm30: .... ..10 .... ...F .... ...E .... ...E - .... ...D .... ...C .... ...B .... ...A + .... ...9 .... ...8 .... ...7 .... ...6 - .... ...5 .... ...3 .... ...2 .... ...1
32958 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
32959 END
32960  
32961  
32962 =head2 Nasm::X86::Tree::extractFirst($tree, $K, $D, $N)
32963  
32964 Extract the first key/data and tree bit at the specified point from the block held in the specified zmm registers and place the extracted data/bit in tree data/subTree.
32965  
32966 Parameter Description
32967 1 $tree Tree descriptor
32968 2 $K Keys zmm
32969 3 $D Data zmm
32970 4 $N Node zmm
32971  
32972 B<Example:>
32973  
32974  
32975 my ($K, $D, $N) = (31, 30, 29);
32976  
32977 K(K => Rd( 1..16)) ->loadZmm($K);
32978 K(K => Rd( 1..16)) ->loadZmm($D);
32979 K(K => Rd(map {0} 1..16))->loadZmm($N);
32980  
32981 my $a = CreateArea;
32982 my $t = $a->CreateTree;
32983  
32984 my $p = K(one => 1) << K three => 3;
32985 Mov r15, 0xAAAA;
32986 $t->setTreeBits($K, r15);
32987  
32988 PrintOutStringNL "Start";
32989 PrintOutRegisterInHex 31, 30, 29;
32990  
32991 K(n=>4)->for(sub
32992 {my ($index, $start, $next, $end) = @_;
32993  
32994 $t->extractFirst($K, $D, $N);
32995  
32996 PrintOutStringNL "-------------";
32997 $index->outNL;
32998 PrintOutRegisterInHex 31, 30, 29;
32999  
33000 $t->data->outNL;
33001 $t->subTree->outNL;
33002 $t->lengthFromKeys($K)->outNL;
33003 });
33004  
33005 ok Assemble eq => <<END, avx512=>1;
33006 Start
33007 zmm31: .... ..10 2AAA ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
33008 zmm30: .... ..10 .... ...F .... ...E .... ...D - .... ...C .... ...B .... ...A .... ...9 + .... ...8 .... ...7 .... ...6 .... ...5 - .... ...4 .... ...3 .... ...2 .... ...1
33009 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
33010 -------------
33011 index: .... .... .... ...0
33012 zmm31: .... ..10 1555 ...E .... ...E .... ...E - .... ...D .... ...C .... ...B .... ...A + .... ...9 .... ...8 .... ...7 .... ...6 - .... ...5 .... ...4 .... ...3 .... ...2
33013 zmm30: .... ..10 .... ...F .... ...E .... ...E - .... ...D .... ...C .... ...B .... ...A + .... ...9 .... ...8 .... ...7 .... ...6 - .... ...5 .... ...4 .... ...3 .... ...2
33014 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
33015 data : .... .... .... ...1
33016 subTree: .... .... .... ...0
33017 b at offset 56 in zmm31: .... .... .... ...E
33018 -------------
33019 index: .... .... .... ...1
33020 zmm31: .... ..10 .AAA ...D .... ...E .... ...E - .... ...E .... ...D .... ...C .... ...B + .... ...A .... ...9 .... ...8 .... ...7 - .... ...6 .... ...5 .... ...4 .... ...3
33021 zmm30: .... ..10 .... ...F .... ...E .... ...E - .... ...E .... ...D .... ...C .... ...B + .... ...A .... ...9 .... ...8 .... ...7 - .... ...6 .... ...5 .... ...4 .... ...3
33022 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
33023 data : .... .... .... ...2
33024 subTree: .... .... .... ...1
33025 b at offset 56 in zmm31: .... .... .... ...D
33026 -------------
33027 index: .... .... .... ...2
33028 zmm31: .... ..10 .555 ...C .... ...E .... ...E - .... ...E .... ...E .... ...D .... ...C + .... ...B .... ...A .... ...9 .... ...8 - .... ...7 .... ...6 .... ...5 .... ...4
33029 zmm30: .... ..10 .... ...F .... ...E .... ...E - .... ...E .... ...E .... ...D .... ...C + .... ...B .... ...A .... ...9 .... ...8 - .... ...7 .... ...6 .... ...5 .... ...4
33030 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
33031 data : .... .... .... ...3
33032 subTree: .... .... .... ...0
33033 b at offset 56 in zmm31: .... .... .... ...C
33034 -------------
33035 index: .... .... .... ...3
33036 zmm31: .... ..10 .2AA ...B .... ...E .... ...E - .... ...E .... ...E .... ...E .... ...D + .... ...C .... ...B .... ...A .... ...9 - .... ...8 .... ...7 .... ...6 .... ...5
33037 zmm30: .... ..10 .... ...F .... ...E .... ...E - .... ...E .... ...E .... ...E .... ...D + .... ...C .... ...B .... ...A .... ...9 - .... ...8 .... ...7 .... ...6 .... ...5
33038 zmm29: .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0 + .... .... .... ...0 .... .... .... ...0 - .... .... .... ...0 .... .... .... ...0
33039 data : .... .... .... ...4
33040 subTree: .... .... .... ...1
33041 b at offset 56 in zmm31: .... .... .... ...B
33042 END
33043  
33044  
33045 =head2 Nasm::X86::Tree::mergeOrSteal($tree, $offset)
33046  
33047 Merge the block at the specified offset with its right sibling or steal from it. If there is no right sibling then do the same thing but with the left sibling. The supplied block must not be the root. The key we are looking for must be in the tree key field.
33048  
33049 Parameter Description
33050 1 $tree Tree descriptor
33051 2 $offset Offset of non root block that might need to merge or steal
33052  
33053 =head2 Nasm::X86::Tree::stealFromRight($tree, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN)
33054  
33055 Steal one key from the node on the right where the current left node,parent node and right node are held in zmm registers and return one if the steal was performed, else zero.
33056  
33057 Parameter Description
33058 1 $tree Tree definition
33059 2 $PK Parent keys zmm
33060 3 $PD Data zmm
33061 4 $PN Nodes zmm
33062 5 $LK Left keys zmm
33063 6 $LD Data zmm
33064 7 $LN Nodes zmm
33065 8 $RK Right keys
33066 9 $RD Data
33067 10 $RN Nodes zmm.
33068  
33069 =head2 Nasm::X86::Tree::stealFromLeft($tree, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN)
33070  
33071 Steal one key from the node on the left where the current left node,parent node and right node are held in zmm registers and return one if the steal was performed, else zero.
33072  
33073 Parameter Description
33074 1 $tree Tree definition
33075 2 $PK Parent keys zmm
33076 3 $PD Data zmm
33077 4 $PN Nodes zmm
33078 5 $LK Left keys zmm
33079 6 $LD Data zmm
33080 7 $LN Nodes zmm
33081 8 $RK Right keys
33082 9 $RD Data
33083 10 $RN Nodes zmm.
33084  
33085 =head2 Nasm::X86::Tree::merge($tree, $PK, $PD, $PN, $LK, $LD, $LN, $RK, $RD, $RN)
33086  
33087 Merge a left and right node if they are at minimum size.
33088  
33089 Parameter Description
33090 1 $tree Tree definition
33091 2 $PK Parent keys zmm
33092 3 $PD Data zmm
33093 4 $PN Nodes zmm
33094 5 $LK Left keys zmm
33095 6 $LD Data zmm
33096 7 $LN Nodes zmm
33097 8 $RK Right keys
33098 9 $RD Data
33099 10 $RN Nodes zmm.
33100  
33101 =head2 Nasm::X86::Tree::deleteFirstKeyAndData($tree, $K, $D)
33102  
33103 Delete the first element of a leaf mode returning its characteristics in the calling tree descriptor.
33104  
33105 Parameter Description
33106 1 $tree Tree definition
33107 2 $K Keys zmm
33108 3 $D Data zmm
33109  
33110 =head2 Nasm::X86::Tree::push($tree, $data)
33111  
33112 Push a data value onto a tree. If the data is a reference to a tree then the offset of the first block of the tree is pushed.
33113  
33114 Parameter Description
33115 1 $tree Tree descriptor
33116 2 $data Variable data
33117  
33118 B<Example:>
33119  
33120  
33121 my $a = CreateArea;
33122 my $t = $a->CreateTree;
33123 my $N = K loop => 16;
33124 $N->for(sub
33125 {my ($i) = @_;
33126 $t->push($i);
33127 });
33128  
33129 $t->peek(1)->data ->outNL;
33130 $t->peek(2)->data ->outNL;
33131 $t->peek(3)->found->outNL;
33132 $t->peek(2 * $N )->found->outNL;
33133  
33134 $t->size->outNL;
33135 $t->get(8); $t->found->out("f: ", " "); $t->key->out("i: ", " "); $t->data->outNL;
33136  
33137 $N->for(sub
33138 {my ($i) = @_;
33139 $t->pop; $t->found->out("f: ", " "); $t->key->out("i: ", " "); $t->data->outNL;
33140 });
33141 # $t->pop; $t->found->outNL("f: ");
33142  
33143 ok Assemble eq => <<END, clocks => 29_852;
33144 data : .... .... .... ...F
33145 data : .... .... .... ...E
33146 found : .... .... .... ..40
33147 found : .... .... .... ...0
33148 size of tree: .... .... .... ..10
33149 f: .... .... .... ...2 i: .... .... .... ...8 data : .... .... .... ...8
33150 f: .... .... .... ...1 i: .... .... .... ...F data : .... .... .... ...F
33151 f: .... .... .... ...1 i: .... .... .... ...E data : .... .... .... ...E
33152 f: .... .... .... ...1 i: .... .... .... ...D data : .... .... .... ...D
33153 f: .... .... .... ...1 i: .... .... .... ...C data : .... .... .... ...C
33154 f: .... .... .... ...1 i: .... .... .... ...B data : .... .... .... ...B
33155 f: .... .... .... ...1 i: .... .... .... ...A data : .... .... .... ...A
33156 f: .... .... .... ...1 i: .... .... .... ...9 data : .... .... .... ...9
33157 f: .... .... .... ...1 i: .... .... .... ...8 data : .... .... .... ...8
33158 f: .... .... .... ...1 i: .... .... .... ...7 data : .... .... .... ...7
33159 f: .... .... .... ...1 i: .... .... .... ...6 data : .... .... .... ...6
33160 f: .... .... .... ...1 i: .... .... .... ...5 data : .... .... .... ...5
33161 f: .... .... .... ...1 i: .... .... .... ...4 data : .... .... .... ...4
33162 f: .... .... .... ...1 i: .... .... .... ...3 data : .... .... .... ...3
33163 f: .... .... .... ...1 i: .... .... .... ...2 data : .... .... .... ...2
33164 f: .... .... .... ...1 i: .... .... .... ...1 data : .... .... .... ...1
33165 f: .... .... .... ...1 i: .... .... .... ...0 data : .... .... .... ...0
33166 END
33167  
33168 my $b = Rb(0x41..0x51);
33169 my $a = CreateArea;
33170 my $T;
33171 for my $i(1..8)
33172 {my $t = $a->CreateTree;
33173 $t->appendAscii(K(address=> $b), K(size => 1));
33174 $t->push($T) if $T;
33175 $T = $t;
33176 }
33177  
33178 $T->dump8xx("T");
33179 ok Assemble eq => <<END, trace=>0;
33180 T
33181 Tree: .... .... .... .740
33182 At: 780 length: 2, data: 7C0, nodes: 800, first: 740, root, leaf, trees: 10
33183 Index: 0 1
33184 Keys : 0 1
33185 Data : 41 64*
33186 Tree: 640
33187 At: 680 length: 2, data: 6C0, nodes: 700, first: 640, root, leaf, trees: 10
33188 Index: 0 1
33189 Keys : 0 1
33190 Data : 41 54*
33191 Tree: 540
33192 At: 580 length: 2, data: 5C0, nodes: 600, first: 540, root, leaf, trees: 10
33193 Index: 0 1
33194 Keys : 0 1
33195 Data : 41 44*
33196 Tree: 440
33197 At: 480 length: 2, data: 4C0, nodes: 500, first: 440, root, leaf, trees: 10
33198 Index: 0 1
33199 Keys : 0 1
33200 Data : 41 34*
33201 Tree: 340
33202 At: 380 length: 2, data: 3C0, nodes: 400, first: 340, root, leaf, trees: 10
33203 Index: 0 1
33204 Keys : 0 1
33205 Data : 41 24*
33206 Tree: 240
33207 At: 280 length: 2, data: 2C0, nodes: 300, first: 240, root, leaf, trees: 10
33208 Index: 0 1
33209 Keys : 0 1
33210 Data : 41 14*
33211 Tree: 140
33212 At: 180 length: 2, data: 1C0, nodes: 200, first: 140, root, leaf, trees: 10
33213 Index: 0 1
33214 Keys : 0 1
33215 Data : 41 4*
33216 Tree: 40
33217 At: 80 length: 1, data: C0, nodes: 100, first: 40, root, leaf
33218 Index: 0
33219 Keys : 0
33220 Data : 41
33221 end
33222 end
33223 end
33224 end
33225 end
33226 end
33227 end
33228 end
33229 END
33230  
33231  
33232 =head2 Nasm::X86::Tree::dumpWithWidth($tree, $title, $width, $margin, $first, $keyX, $dataX)
33233  
33234 Dump a tree and all its sub trees.
33235  
33236 Parameter Description
33237 1 $tree Tree
33238 2 $title Title
33239 3 $width Width of offset field
33240 4 $margin The maximum width of the indented area
33241 5 $first Whether to print the offset of the tree
33242 6 $keyX Whether to print the key field in hex or decimal
33243 7 $dataX Whether to print the data field in hex or decimal
33244  
33245 =head2 Nasm::X86::Tree::dump($tree, $title)
33246  
33247 Dump a tree and all its sub trees.
33248  
33249 Parameter Description
33250 1 $tree Tree
33251 2 $title Title
33252  
33253 =head2 Nasm::X86::Tree::dump8($tree, $title)
33254  
33255 Dump a tree and all its sub trees using 8 character fields for numbers.
33256  
33257 Parameter Description
33258 1 $tree Tree
33259 2 $title Title
33260  
33261 =head2 Nasm::X86::Tree::dump8xx($tree, $title)
33262  
33263 Dump a tree and all its sub trees using 8 character fields for numbers printing the keys and data in hexadecimal.
33264  
33265 Parameter Description
33266 1 $tree Tree
33267 2 $title Title
33268  
33269 B<Example:>
33270  
33271  
33272 my $a = CreateArea;
33273 my $t = $a->CreateTree;
33274 my $T = $a->CreateTree;
33275  
33276 $T->push(K key => 1);
33277 $t->push($T);
33278 $t->dump8xx('AA');
33279 my $s = $t->popSubTree;
33280 $t->dump8xx('BB');
33281 $s->dump8xx('CC');
33282 ok Assemble eq => <<END, avx512=>1;
33283 AA
33284 Tree: .... .... .... ..40
33285 At: 180 length: 1, data: 1C0, nodes: 200, first: 40, root, leaf, trees: 1
33286 Index: 0
33287 Keys : 0
33288 Data : 8*
33289 Tree: 80
33290 At: C0 length: 1, data: 100, nodes: 140, first: 80, root, leaf
33291 Index: 0
33292 Keys : 0
33293 Data : 1
33294 end
33295 end
33296 BB
33297 - empty
33298 CC
33299 Tree: .... .... .... ..80
33300 At: C0 length: 1, data: 100, nodes: 140, first: 80, root, leaf
33301 Index: 0
33302 Keys : 0
33303 Data : 1
33304 end
33305 END
33306  
33307  
33308 =head2 compactRangeIntoHex(@P)
33309  
33310 Compact a range of numbers into hexadecimal.
33311  
33312 Parameter Description
33313 1 @P Numbers to compact
33314  
33315 B<Example:>
33316  
33317  
33318  
33319 ok compactRangeIntoHex(qw(0x1 0x2 0x3 0x5 0x7 0x8 0x9 0xb)) eq # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲
33320  
33321  
33322  
33323 =head2 Nasm::X86::Unisyn::Lex::Number::S {0}(sub Nasm::X86::Unisyn::Lex::Number::F {1})
33324  
33325 Start symbol.
33326  
33327 Parameter Description
33328 1 sub Nasm::X86::Unisyn::Lex::Number::F {1} P End symbol.
33329  
33330 =head2 Nasm::X86::Unisyn::Lex::Number::F {1}()
33331  
33332 End symbol.
33333  
33334  
33335 =head2 Nasm::X86::Unisyn::Lex::Number::A {2}(sub Nasm::X86::Unisyn::Lex::Letter::A {(0x0..0x7f, 0x24b6..0x24e9)})
33336  
33337 ASCII characters extended with circled characters to act as escape sequences.
33338  
33339 Parameter Description
33340 1 sub Nasm::X86::Unisyn::Lex::Letter::A {(0x0..0x7f P
33341 2 0x24b6..0x24e9)}
33342  
33343 =head2 Nasm::X86::Unisyn::Lex::Number::p {3}(sub Nasm::X86::Unisyn::Lex::Letter::p {(0x1d468...0x1d49b, 0x1d71c..0x1d755, map {ord} qw(₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₀))})
33344  
33345 Prefix operator - applies only to the following variable or bracketed term.
33346  
33347 Parameter Description
33348 1 sub Nasm::X86::Unisyn::Lex::Letter::p {(0x1d468...0x1d49b P
33349 2 0x1d71c..0x1d755
33350 3 map {ord} qw(₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₀))}
33351  
33352 =head2 Nasm::X86::Unisyn::Lex::Number::v {4}(sub Nasm::X86::Unisyn::Lex::Letter::v {(0x1d5d4...0x1d607, 0x1d756..0x1d78f)})
33353  
33354 Variable names.
33355  
33356 Parameter Description
33357 1 sub Nasm::X86::Unisyn::Lex::Letter::v {(0x1d5d4...0x1d607 P
33358 2 0x1d756..0x1d78f)}
33359  
33360 =head2 Nasm::X86::Unisyn::Lex::Number::q {5}()
33361  
33362 Suffix operator - applies only to the preceding variable or bracketed term.
33363  
33364  
33365 =head2 Nasm::X86::Unisyn::Lex::Number::s {6}()
33366  
33367 Infix operator with left to right binding at priority 1.
33368  
33369  
33370 =head2 Nasm::X86::Unisyn::Lex::Number::b {7}(sub Nasm::X86::Unisyn::Lex::Letter::b)
33371  
33372 Open.
33373  
33374 Parameter Description
33375 1 sub Nasm::X86::Unisyn::Lex::Letter::b P
33376  
33377 =head2 Nasm::X86::Unisyn::Lex::Number::B {8}(sub Nasm::X86::Unisyn::Lex::Letter::B)
33378  
33379 Close.
33380  
33381 Parameter Description
33382 1 sub Nasm::X86::Unisyn::Lex::Letter::B P
33383  
33384 =head2 Nasm::X86::Unisyn::Lex::Letter::d()
33385  
33386 Dyad 2 - Double struck
33387  
33388  
33389 =head2 Nasm::X86::Unisyn::Lex::Letter::e()
33390  
33391 Dyad 3 - Mono
33392  
33393  
33394 =head2 Nasm::X86::Unisyn::Lex::Number::a {11}(sub Nasm::X86::Unisyn::Lex::Letter::a)
33395  
33396 Assign infix operator with right to left binding at priority 4.
33397  
33398 Parameter Description
33399 1 sub Nasm::X86::Unisyn::Lex::Letter::a P
33400  
33401 =head2 Nasm::X86::Unisyn::Lex::Letter::f()
33402  
33403 Dyad 5 - Sans-serif Normal
33404  
33405  
33406 =head2 Nasm::X86::Unisyn::Lex::Letter::g()
33407  
33408 Dyad 6 - Sans-serif Bold
33409  
33410  
33411 =head2 Nasm::X86::Unisyn::Lex::Letter::h()
33412  
33413 Dyad 7 - Calligraphy - normal
33414  
33415  
33416 =head2 Nasm::X86::Unisyn::Lex::Letter::i()
33417  
33418 Dyad 8 - Calligraphy - bold
33419  
33420  
33421 =head2 Nasm::X86::Unisyn::Lex::Letter::j()
33422  
33423 Dyad 9 - Fraktur - Normal
33424  
33425  
33426 =head2 Nasm::X86::Unisyn::Lex::Letter::k()
33427  
33428 Dyad 10 - Fraktur - bold
33429  
33430  
33431 =head2 Nasm::X86::Unisyn::Lex::Number::l {18}()
33432  
33433 Dyad 11
33434  
33435  
33436 =head2 Nasm::X86::Unisyn::Lex::Number::m {19}(sub Nasm::X86::Unisyn::Lex::Letter::m)
33437  
33438 Dyad 12
33439  
33440 Parameter Description
33441 1 sub Nasm::X86::Unisyn::Lex::Letter::m P
33442  
33443 =head2 Nasm::X86::Unisyn::Lex::Number::w {20}(sub Nasm::X86::Unisyn::Lex::Letter::w)
33444  
33445 White space
33446  
33447 Parameter Description
33448 1 sub Nasm::X86::Unisyn::Lex::Letter::w P
33449  
33450 =head2 Nasm::X86::Unisyn::Lex::PermissibleTransitionsArrayBits {5}()
33451  
33452 The number of bits needed to express a transition
33453  
33454  
33455 =head2 Nasm::X86::Unisyn::Lex::Reason::Success {0};(sub Nasm::X86::Unisyn::Lex::Reason::BadUtf8 {1};)
33456  
33457 Successful parse.
33458  
33459 Parameter Description
33460 1 sub Nasm::X86::Unisyn::Lex::Reason::BadUtf8 {1}; P Bad utf8 character encountered.
33461  
33462 =head2 Nasm::X86::Unisyn::Lex::Reason::BadUtf8 {1};(sub Nasm::X86::Unisyn::Lex::Reason::InvalidChar {2};)
33463  
33464 Bad utf8 character encountered.
33465  
33466 Parameter Description
33467 1 sub Nasm::X86::Unisyn::Lex::Reason::InvalidChar {2}; P Character not part of Earl Zero.
33468  
33469 =head2 Nasm::X86::Unisyn::Lex::Reason::InvalidChar {2};(sub Nasm::X86::Unisyn::Lex::Reason::InvalidTransition {3};)
33470  
33471 Character not part of Earl Zero.
33472  
33473 Parameter Description
33474 1 sub Nasm::X86::Unisyn::Lex::Reason::InvalidTransition {3}; P Transition from one lexical item to another not allowed.
33475  
33476 =head2 Nasm::X86::Unisyn::Lex::Reason::InvalidTransition {3};(sub Nasm::X86::Unisyn::Lex::Reason::TrailingClose {4};)
33477  
33478 Transition from one lexical item to another not allowed.
33479  
33480 Parameter Description
33481 1 sub Nasm::X86::Unisyn::Lex::Reason::TrailingClose {4}; P Trailing closing bracket discovered.
33482  
33483 =head2 Nasm::X86::Unisyn::Lex::Reason::TrailingClose {4};(sub Nasm::X86::Unisyn::Lex::Reason::Mismatch {5};)
33484  
33485 Trailing closing bracket discovered.
33486  
33487 Parameter Description
33488 1 sub Nasm::X86::Unisyn::Lex::Reason::Mismatch {5}; P Mismatched bracket.
33489  
33490 =head2 Nasm::X86::Unisyn::Lex::Reason::Mismatch {5};(sub Nasm::X86::Unisyn::Lex::Reason::NotFinal {6};)
33491  
33492 Mismatched bracket.
33493  
33494 Parameter Description
33495 1 sub Nasm::X86::Unisyn::Lex::Reason::NotFinal {6}; P Expected something after final character.
33496  
33497 =head2 Nasm::X86::Unisyn::Lex::Reason::NotFinal {6};(sub Nasm::X86::Unisyn::Lex::Reason::BracketsNotClosed {7};)
33498  
33499 Expected something after final character.
33500  
33501 Parameter Description
33502 1 sub Nasm::X86::Unisyn::Lex::Reason::BracketsNotClosed {7}; P Open brackets not closed at end of.
33503  
33504 =head2 Nasm::X86::Unisyn::Lex::Reason::BracketsNotClosed {7};()
33505  
33506 Open brackets not closed at end of.
33507  
33508  
33509 =head2 Nasm::X86::Unisyn::Lex::position {0};(sub Nasm::X86::Unisyn::Lex::length {1};)
33510  
33511 Position of the parsed item in the input text.
33512  
33513 Parameter Description
33514 1 sub Nasm::X86::Unisyn::Lex::length {1}; P Length of the lexical item in bytes.
33515  
33516 =head2 Nasm::X86::Unisyn::Lex::length {1};(sub Nasm::X86::Unisyn::Lex::type {2};)
33517  
33518 Length of the lexical item in bytes.
33519  
33520 Parameter Description
33521 1 sub Nasm::X86::Unisyn::Lex::type {2}; P Type of the lexical item.
33522  
33523 =head2 Nasm::X86::Unisyn::Lex::type {2};(sub Nasm::X86::Unisyn::Lex::left {3};)
33524  
33525 Type of the lexical item.
33526  
33527 Parameter Description
33528 1 sub Nasm::X86::Unisyn::Lex::left {3}; P Left operand.
33529  
33530 =head2 Nasm::X86::Unisyn::Lex::left {3};(sub Nasm::X86::Unisyn::Lex::right {4};)
33531  
33532 Left operand.
33533  
33534 Parameter Description
33535 1 sub Nasm::X86::Unisyn::Lex::right {4}; P Right operand.
33536  
33537 =head2 Nasm::X86::Unisyn::Lex::right {4};(sub Nasm::X86::Unisyn::Lex::symbol {5};)
33538  
33539 Right operand.
33540  
33541 Parameter Description
33542 1 sub Nasm::X86::Unisyn::Lex::symbol {5}; P Symbol.
33543  
33544 =head2 Nasm::X86::Unisyn::Lex::symbol {5};()
33545  
33546 Symbol.
33547  
33548  
33549 =head2 Nasm::X86::Unisyn::DescribeParse()
33550  
33551 Describe a parse - create a description on the stack to receive the results of a parse
33552  
33553  
33554 =head2 sortHashKeysByIntegerValues($h)
33555  
33556 Sort the keys of a hash whose values are integers by those values returning the keys so sorted as an array.
33557  
33558 Parameter Description
33559 1 $h Hash
33560  
33561 =head2 Nasm::X86::Unisyn::Parse($pd)
33562  
33563 Parse a string of utf8 characters.
33564  
33565 Parameter Description
33566 1 $pd Parse descriptor
33567  
33568 =head2 Nasm::X86::Unisyn::Parse::dump($parse)
33569  
33570 Dump a parse tree in order.
33571  
33572 Parameter Description
33573 1 $parse Parse
33574  
33575 =head2 LocateIntelEmulator()
33576  
33577 Locate the Intel Software Development Emulator.
33578  
33579  
33580 =head2 getInstructionCount()
33581  
33582 Get the number of instructions executed from the emulator mix file.
33583  
33584  
33585 =head2 OptimizePopPush(%options)
33586  
33587 Perform code optimizations.
33588  
33589 Parameter Description
33590 1 %options Options
33591  
33592 =head2 OptimizeReload(%options)
33593  
33594 Reload: a = b; b = a; remove second - as redundant.
33595  
33596 Parameter Description
33597 1 %options Options
33598  
33599 =head2 hasAvx512()
33600  
33601 Check whether the current device has avx512 instructions or not.
33602  
33603  
33604 =head2 lineNumbersToSubNamesFromSource()
33605  
33606 Create a hash mapping line numbers to subroutine definitions.
33607  
33608  
33609 =head2 locateRunTimeErrorInDebugTraceOutput($trace)
33610  
33611 Locate the traceback of the last known good position in the trace file before the error occurred.
33612  
33613 Parameter Description
33614 1 $trace Trace mode
33615  
33616 =head2 fixMixOutput()
33617  
33618 Fix mix output so we know where the code comes from in the source file.
33619  
33620  
33621 =head2 countComments($count)
33622  
33623 Count the number of comments in the text of the program so we can see what code is being generated too often.
33624  
33625 Parameter Description
33626 1 $count Comment count
33627  
33628 =head2 numberWithUnderScores($n)
33629  
33630 Place underscores in the string representation of a number.
33631  
33632 Parameter Description
33633 1 $n Number to add commas to
33634  
33635 =head2 onGitHub()
33636  
33637 Whether we are on GitHub or not.
33638  
33639  
33640 =head2 totalBytesAssembled()
33641  
33642 Total size in bytes of all files assembled during testing.
33643  
33644  
33645 =head2 testParseUnisyn($compose, $text, $parse)
33646  
33647 Test the parse of a unisyn expression.
33648  
33649 Parameter Description
33650 1 $compose The composing expression used to create a unisyn expression
33651 2 $text The expected composed expression
33652 3 $parse The expected parse tree
33653  
33654 =head2 BinarySearchD(%options)
33655  
33656 Search for an ordered array of double words addressed by r15, of length held in r14 for a double word held in r13 and call the $then routine with the index in rax if found else call the $else routine.
33657  
33658 Parameter Description
33659 1 %options Options
33660  
33661  
33662 =head1 Index
33663  
33664  
33665 1 L<AllocateMemory|/AllocateMemory> - Allocate the variable specified amount of memory via mmap and return its address as a variable.
33666  
33667 2 L<AndBlock|/AndBlock> - Short circuit B<and>: execute a block of code to test conditions which, if all of them pass, allows the first block to continue successfully else if one of the conditions fails we execute the optional fail block.
33668  
33669 3 L<Assemble|/Assemble> - Assemble the generated code.
33670  
33671 4 L<bFromX|/bFromX> - Get the byte from the numbered xmm register and return it in a variable.
33672  
33673 5 L<bFromZ|/bFromZ> - Get the byte from the numbered zmm register and return it in a variable.
33674  
33675 6 L<BinarySearchD|/BinarySearchD> - Search for an ordered array of double words addressed by r15, of length held in r14 for a double word held in r13 and call the $then routine with the index in rax if found else call the $else routine.
33676  
33677 7 L<Block|/Block> - Execute a block of code with labels supplied for the start and end of this code.
33678  
33679 8 L<bRegFromZmm|/bRegFromZmm> - Load the specified register from the byte at the specified offset located in the numbered zmm.
33680  
33681 9 L<bRegIntoZmm|/bRegIntoZmm> - Put the byte content of the specified register into the byte in the numbered zmm at the specified offset in the zmm.
33682  
33683 10 L<CallC|/CallC> - Call a C subroutine.
33684  
33685 11 L<checkZmmRegister|/checkZmmRegister> - Check that a register is a zmm register.
33686  
33687 12 L<ChooseRegisters|/ChooseRegisters> - Choose the specified numbers of registers excluding those on the specified list.
33688  
33689 13 L<ClearMemory|/ClearMemory> - Clear memory with a variable address and variable length.
33690  
33691 14 L<ClearRegisters|/ClearRegisters> - Clear registers by setting them to zero.
33692  
33693 15 L<ClearZF|/ClearZF> - Clear the zero flag.
33694  
33695 16 L<CloseFile|/CloseFile> - Close the file whose descriptor is in rax.
33696  
33697 17 L<Comment|/Comment> - Insert a comment into the assembly code.
33698  
33699 18 L<compactRangeIntoHex|/compactRangeIntoHex> - Compact a range of numbers into hexadecimal.
33700  
33701 19 L<constantString|/constantString> - Return the address and length of a constant string as two variables.
33702  
33703 20 L<convert_rax_from_utf32_to_utf8|/convert_rax_from_utf32_to_utf8> - Convert a utf32 character held in rax to a utf8 character held in rax.
33704  
33705 21 L<ConvertUtf8ToUtf32|/ConvertUtf8ToUtf32> - Convert an allocated string of utf8 to an allocated string of utf32 and return its address and length.
33706  
33707 22 L<CopyMemory|/CopyMemory> - Copy memory.
33708  
33709 23 L<CopyMemory4K|/CopyMemory4K> - Copy memory in 4K byte blocks.
33710  
33711 24 L<CopyMemory64|/CopyMemory64> - Copy memory in 64 byte blocks.
33712  
33713 25 L<copyStructureMinusVariables|/copyStructureMinusVariables> - Copy a non recursive structure ignoring variables.
33714  
33715 26 L<countComments|/countComments> - Count the number of comments in the text of the program so we can see what code is being generated too often.
33716  
33717 27 L<CreateArea|/CreateArea> - Create an relocatable area and returns its address in rax.
33718  
33719 28 L<createBitNumberFromAlternatingPattern|/createBitNumberFromAlternatingPattern> - Create a number from a bit pattern.
33720  
33721 29 L<Cstrlen|/Cstrlen> - Length of the C style string addressed by rax returning the length in r15.
33722  
33723 30 L<Db|/Db> - Layout bytes in the data segment and return their label.
33724  
33725 31 L<Dbwdq|/Dbwdq> - Layout data.
33726  
33727 32 L<Dd|/Dd> - Layout double words in the data segment and return their label.
33728  
33729 33 L<DescribeArea|/DescribeArea> - Describe a relocatable area.
33730  
33731 34 L<DescribeTree|/DescribeTree> - Return a descriptor for a tree with the specified options.
33732  
33733 35 L<dFromPointInZ|/dFromPointInZ> - Get the double word from the numbered zmm register at a point specified by the variable or register and return it in a variable.
33734  
33735 36 L<dFromX|/dFromX> - Get the double word from the numbered xmm register and return it in a variable.
33736  
33737 37 L<dFromZ|/dFromZ> - Get the double word from the numbered zmm register and return it in a variable.
33738  
33739 38 L<Dq|/Dq> - Layout quad words in the data segment and return their label.
33740  
33741 39 L<dRegFromZmm|/dRegFromZmm> - Load the specified register from the double word at the specified offset located in the numbered zmm.
33742  
33743 40 L<dRegIntoZmm|/dRegIntoZmm> - Put the specified register into the double word in the numbered zmm at the specified offset in the zmm.
33744  
33745 41 L<Ds|/Ds> - Layout bytes in memory and return their label.
33746  
33747 42 L<Dw|/Dw> - Layout words in the data segment and return their label.
33748  
33749 43 L<Ef|/Ef> - Else if block for an If statement.
33750  
33751 44 L<Else|/Else> - Else block for an If statement.
33752  
33753 45 L<executeFileViaBash|/executeFileViaBash> - Execute the file named in a variable.
33754  
33755 46 L<Exit|/Exit> - Exit with the specified return code or zero if no return code supplied.
33756  
33757 47 L<Extern|/Extern> - Name external references.
33758  
33759 48 L<extractRegisterNumberFromMM|/extractRegisterNumberFromMM> - Extract the register number from an *mm register.
33760  
33761 49 L<Fail|/Fail> - Fail block for an L<AndBlock>.
33762  
33763 50 L<fixMixOutput|/fixMixOutput> - Fix mix output so we know where the code comes from in the source file.
33764  
33765 51 L<For|/For> - For - iterate the block as long as register is less than limit incrementing by increment each time.
33766  
33767 52 L<ForEver|/ForEver> - Iterate for ever.
33768  
33769 53 L<ForIn|/ForIn> - For - iterate the full block as long as register plus increment is less than than limit incrementing by increment each time then perform the last block with the remainder which might be of length zero.
33770  
33771 54 L<Fork|/Fork> - Fork: create and execute a copy of the current process.
33772  
33773 55 L<FreeMemory|/FreeMemory> - Free memory specified by variables.
33774  
33775 56 L<getBwdqFromMm|/getBwdqFromMm> - Get the numbered byte|word|double word|quad word from the numbered zmm register and return it in a variable.
33776  
33777 57 L<getInstructionCount|/getInstructionCount> - Get the number of instructions executed from the emulator mix file.
33778  
33779 58 L<GetNextUtf8CharAsUtf32|/GetNextUtf8CharAsUtf32> - Get the next UTF-8 encoded character from the addressed memory and return it as a UTF-32 character as a variable along with the size of the input character and a variable indicating the success - 1 - or failure - 0 - of the operation.
33780  
33781 59 L<GetPid|/GetPid> - Get process identifier.
33782  
33783 60 L<GetPidInHex|/GetPidInHex> - Get process identifier in hex as 8 zero terminated bytes in rax.
33784  
33785 61 L<GetPPid|/GetPPid> - Get parent process identifier.
33786  
33787 62 L<GetUid|/GetUid> - Get userid of current process.
33788  
33789 63 L<hasAvx512|/hasAvx512> - Check whether the current device has avx512 instructions or not.
33790  
33791 64 L<Hash|/Hash> - Hash a string addressed by rax with length held in rdi and return the hash code in r15.
33792  
33793 65 L<hexTranslateTable|/hexTranslateTable> - Create/address a hex translate table and return its label.
33794  
33795 66 L<If|/If> - If statement.
33796  
33797 67 L<ifAnd|/ifAnd> - Execute then or else block based on a multiplicity of AND conditions executed until one fails.
33798  
33799 68 L<IfC|/IfC> - If the carry flag is set then execute the then block else the else block.
33800  
33801 69 L<IfEq|/IfEq> - If equal execute the then block else the else block.
33802  
33803 70 L<IfGe|/IfGe> - If greater than or equal execute the then block else the else block.
33804  
33805 71 L<IfGt|/IfGt> - If greater than execute the then block else the else block.
33806  
33807 72 L<IfLe|/IfLe> - If less than or equal execute the then block else the else block.
33808  
33809 73 L<IfLt|/IfLt> - If less than execute the then block else the else block.
33810  
33811 74 L<IfNc|/IfNc> - If the carry flag is not set then execute the then block else the else block.
33812  
33813 75 L<IfNe|/IfNe> - If not equal execute the then block else the else block.
33814  
33815 76 L<IfNs|/IfNs> - If signed less than execute the then block else the else block.
33816  
33817 77 L<IfNz|/IfNz> - If the zero flag is not set then execute the then block else the else block.
33818  
33819 78 L<ifOr|/ifOr> - Execute then or else block based on a multiplicity of OR conditions executed until one succeeds.
33820  
33821 79 L<IfS|/IfS> - If signed greater than or equal execute the then block else the else block.
33822  
33823 80 L<IfZ|/IfZ> - If the zero flag is set then execute the then block else the else block.
33824  
33825 81 L<InsertOneIntoRegisterAtPoint|/InsertOneIntoRegisterAtPoint> - Insert a one into the specified register at the point indicated by another register.
33826  
33827 82 L<InsertZeroIntoRegisterAtPoint|/InsertZeroIntoRegisterAtPoint> - Insert a zero into the specified register at the point indicated by another general purpose or mask register moving the higher bits one position to the left.
33828  
33829 83 L<K|/K> - Define a constant variable.
33830  
33831 84 L<Label|/Label> - Create a unique label.
33832  
33833 85 L<lineNumbersToSubNamesFromSource|/lineNumbersToSubNamesFromSource> - Create a hash mapping line numbers to subroutine definitions.
33834  
33835 86 L<Link|/Link> - Libraries to link with.
33836  
33837 87 L<loadAreaIntoAssembly|/loadAreaIntoAssembly> - Load an area into the current assembly and return a descriptor for it.
33838  
33839 88 L<LoadBitsIntoMaskRegister|/LoadBitsIntoMaskRegister> - Load a bit string specification into a mask register in two clocks.
33840  
33841 89 L<LoadConstantIntoMaskRegister|/LoadConstantIntoMaskRegister> - Set a mask register equal to a constant.
33842  
33843 90 L<LoadRegFromMm|/LoadRegFromMm> - Load the specified register from the numbered zmm at the quad offset specified as a constant number.
33844  
33845 91 L<LoadZmm|/LoadZmm> - Load a numbered zmm with the specified bytes.
33846  
33847 92 L<LocateIntelEmulator|/LocateIntelEmulator> - Locate the Intel Software Development Emulator.
33848  
33849 93 L<locateRunTimeErrorInDebugTraceOutput|/locateRunTimeErrorInDebugTraceOutput> - Locate the traceback of the last known good position in the trace file before the error occurred.
33850  
33851 94 L<Nasm::X86::Area::allocate|/Nasm::X86::Area::allocate> - Allocate the variable amount of space in the variable addressed area and return the offset of the allocation in the area as a variable.
33852  
33853 95 L<Nasm::X86::Area::allocZmmBlock|/Nasm::X86::Area::allocZmmBlock> - Allocate a block to hold a zmm register in the specified area and return the offset of the block as a variable.
33854  
33855 96 L<Nasm::X86::Area::allocZmmBlock3|/Nasm::X86::Area::allocZmmBlock3> - Allocate three zmm blocks in one go and return their offsets.
33856  
33857 97 L<Nasm::X86::Area::append|/Nasm::X86::Area::append> - Append one area to another.
33858  
33859 98 L<Nasm::X86::Area::appendMemory|/Nasm::X86::Area::appendMemory> - Append the variable addressed content in memory of variable size to the specified area and return its offset in that area.
33860  
33861 99 L<Nasm::X86::Area::appendVar|/Nasm::X86::Area::appendVar> - Append the contents of a variable to the specified area
33862  
33863 100 L<Nasm::X86::Area::appendZmm|/Nasm::X86::Area::appendZmm> - Append the contents of the specified zmm to the specified area and returns its offset in that area as a variable,
33864  
33865 101 L<Nasm::X86::Area::char|/Nasm::X86::Area::char> - Append a constant character expressed as a decimal number to the specified area.
33866  
33867 102 L<Nasm::X86::Area::checkYggdrasilCreated|/Nasm::X86::Area::checkYggdrasilCreated> - Return a tree descriptor for the Yggdrasil world tree for an area.
33868  
33869 103 L<Nasm::X86::Area::clear|/Nasm::X86::Area::clear> - Clear an area but keep it at the same size.
33870  
33871 104 L<Nasm::X86::Area::clearZmmBlock|/Nasm::X86::Area::clearZmmBlock> - Clear the zmm block at the specified offset in the area.
33872  
33873 105 L<Nasm::X86::Area::copyDescriptor|/Nasm::X86::Area::copyDescriptor> - Copy the description of one area into another
33874  
33875 106 L<Nasm::X86::Area::CreateTree|/Nasm::X86::Area::CreateTree> - Create a tree in an area.
33876  
33877 107 L<Nasm::X86::Area::DescribeTree|/Nasm::X86::Area::DescribeTree> - Return a descriptor for a tree in the specified area with the specified options.
33878  
33879 108 L<Nasm::X86::Area::dump|/Nasm::X86::Area::dump> - Dump details of an area.
33880  
33881 109 L<Nasm::X86::Area::free|/Nasm::X86::Area::free> - Free an area.
33882  
33883 110 L<Nasm::X86::Area::freeChainSpace|/Nasm::X86::Area::freeChainSpace> - Count the number of blocks available on the free chain.
33884  
33885 111 L<Nasm::X86::Area::freeZmmBlock|/Nasm::X86::Area::freeZmmBlock> - Free a block in an area by placing it on the free chain.
33886  
33887 112 L<Nasm::X86::Area::getZmmBlock|/Nasm::X86::Area::getZmmBlock> - Get the block with the specified offset in the specified string and return it in the numbered zmm.
33888  
33889 113 L<Nasm::X86::Area::makeReadOnly|/Nasm::X86::Area::makeReadOnly> - Make an area read only.
33890  
33891 114 L<Nasm::X86::Area::makeWriteable|/Nasm::X86::Area::makeWriteable> - Make an area writable.
33892  
33893 115 L<Nasm::X86::Area::nl|/Nasm::X86::Area::nl> - Append a new line to the area addressed by rax.
33894  
33895 116 L<Nasm::X86::Area::out|/Nasm::X86::Area::out> - Print the specified area on sysout.
33896  
33897 117 L<Nasm::X86::Area::outNL|/Nasm::X86::Area::outNL> - Print the specified area on sysout followed by a new line.
33898  
33899 118 L<Nasm::X86::Area::peek|/Nasm::X86::Area::peek> - Peek at a variable on the stack
33900  
33901 119 L<Nasm::X86::Area::peekZmm|/Nasm::X86::Area::peekZmm> - Peek at a zmm register from the stack in an area being used as a stack and return a variable containing its offset in the area so we can update the pushed zmm if desired.
33902  
33903 120 L<Nasm::X86::Area::pop|/Nasm::X86::Area::pop> - Pop a variable from the stack in an area being used as a stack
33904  
33905 121 L<Nasm::X86::Area::popZmm|/Nasm::X86::Area::popZmm> - Pop a zmm register from the stack in an area being used as a stack
33906  
33907 122 L<Nasm::X86::Area::printOut|/Nasm::X86::Area::printOut> - Print part of the specified area on sysout.
33908  
33909 123 L<Nasm::X86::Area::push|/Nasm::X86::Area::push> - Push the contents of a variable into an area
33910  
33911 124 L<Nasm::X86::Area::pushZmm|/Nasm::X86::Area::pushZmm> - Push the contents of a zmm register into an area.
33912  
33913 125 L<Nasm::X86::Area::putZmmBlock|/Nasm::X86::Area::putZmmBlock> - Write the numbered zmm to the block at the specified offset in the specified area.
33914  
33915 126 L<Nasm::X86::Area::q|/Nasm::X86::Area::q> - Append a constant string to the area.
33916  
33917 127 L<Nasm::X86::Area::ql|/Nasm::X86::Area::ql> - Append a constant quoted string containing new line characters to the specified area.
33918  
33919 128 L<Nasm::X86::Area::read|/Nasm::X86::Area::read> - Read a file specified by a variable addressed zero terminated string and append its content to the specified area.
33920  
33921 129 L<Nasm::X86::Area::readLibraryHeader|/Nasm::X86::Area::readLibraryHeader> - Create a tree mapping the numbers assigned to subroutine names to the offsets of the corresponding routines in a library returning the intersection so formed mapping the lexical item numbers (not names) encountered during parsing with the matching routines in the library.
33922  
33923 130 L<Nasm::X86::Area::size|/Nasm::X86::Area::size> - Get the size of an area as a variable.
33924  
33925 131 L<Nasm::X86::Area::stackSize|/Nasm::X86::Area::stackSize> - Size of the stack in an area being used as a stack
33926  
33927 132 L<Nasm::X86::Area::stackVariable|/Nasm::X86::Area::stackVariable> - Peek at the variable indexed variable on the stack
33928  
33929 133 L<Nasm::X86::Area::stackVariableSize|/Nasm::X86::Area::stackVariableSize> - Size of a stack of variables in an area.
33930  
33931 134 L<Nasm::X86::Area::updateSpace|/Nasm::X86::Area::updateSpace> - Make sure that a variable addressed area has enough space to accommodate content of a variable size.
33932  
33933 135 L<Nasm::X86::Area::used|/Nasm::X86::Area::used> - Return the currently used size of an area as a variable.
33934  
33935 136 L<Nasm::X86::Area::write|/Nasm::X86::Area::write> - Write the content of the specified area to a file specified by a zero terminated string.
33936  
33937 137 L<Nasm::X86::Area::writeLibraryHeader|/Nasm::X86::Area::writeLibraryHeader> - Load a hash of subroutine names and offsets into an area
33938  
33939 138 L<Nasm::X86::Area::yggdrasil|/Nasm::X86::Area::yggdrasil> - Return a tree descriptor to the Yggdrasil world tree for an area creating the world tree Yggdrasil if it has not already been created.
33940  
33941 139 L<Nasm::X86::Area::zero|/Nasm::X86::Area::zero> - Append a trailing zero to the area addressed by rax.
33942  
33943 140 L<Nasm::X86::Subroutine::call|/Nasm::X86::Subroutine::call> - Call a sub optionally passing it parameters.
33944  
33945 141 L<Nasm::X86::Subroutine::inline|/Nasm::X86::Subroutine::inline> - Call a sub by in-lining it, optionally passing it parameters.
33946  
33947 142 L<Nasm::X86::Subroutine::mapStructureVariables|/Nasm::X86::Subroutine::mapStructureVariables> - Find the paths to variables in the copies of the structures passed as parameters and replace those variables with references so that in the subroutine we can refer to these variables regardless of where they are actually defined.
33948  
33949 143 L<Nasm::X86::Subroutine::subroutineDefinition|/Nasm::X86::Subroutine::subroutineDefinition> - Get the definition of a subroutine from an area.
33950  
33951 144 L<Nasm::X86::Subroutine::uploadStructureVariablesToNewStackFrame|/Nasm::X86::Subroutine::uploadStructureVariablesToNewStackFrame> - Create references to variables in parameter structures from variables in the stack frame of the subroutine.
33952  
33953 145 L<Nasm::X86::Subroutine::uploadToNewStackFrame|/Nasm::X86::Subroutine::uploadToNewStackFrame> - Map a variable in the current stack into a reference in the next stack frame being the one that will be used by this sub.
33954  
33955 146 L<Nasm::X86::Subroutine::validateParameters|/Nasm::X86::Subroutine::validateParameters> - Check that the parameters and structures presented in a call to a subroutine math those defined for the subroutine.
33956  
33957 147 L<Nasm::X86::Subroutine::writeLibraryToArea|/Nasm::X86::Subroutine::writeLibraryToArea> - Write a subroutine library to an area then save the area in a file so that the subroutine can be reloaded at a later date either as separate file or via incorporation into a thing.
33958  
33959 148 L<Nasm::X86::Tree::allocBlock|/Nasm::X86::Tree::allocBlock> - Allocate a keys/data/node block and place it in the numbered zmm registers.
33960  
33961 149 L<Nasm::X86::Tree::append|/Nasm::X86::Tree::append> - Append the second source string to the first target string renumbering the keys of the source string to follow on from those of the target string.
33962  
33963 150 L<Nasm::X86::Tree::appendAscii|/Nasm::X86::Tree::appendAscii> - Append ascii bytes in memory to a tree acting as a string.
33964  
33965 151 L<Nasm::X86::Tree::by|/Nasm::X86::Tree::by> - Call the specified block with each element of the specified tree in ascending order.
33966  
33967 152 L<Nasm::X86::Tree::clear|/Nasm::X86::Tree::clear> - Delete everything in the tree except the first block recording any memory liberated on the free chain.
33968  
33969 153 L<Nasm::X86::Tree::clearTreeBit|/Nasm::X86::Tree::clearTreeBit> - Clear the tree bit in the numbered zmm register holding the keys of a node to indicate that the data element indexed by the specified register is an offset to a sub tree in the containing area.
33970  
33971 154 L<Nasm::X86::Tree::clone|/Nasm::X86::Tree::clone> - Clone a string.
33972  
33973 155 L<Nasm::X86::Tree::cloneDescriptor|/Nasm::X86::Tree::cloneDescriptor> - Clone the descriptor of a tree to make a new tree descriptor.
33974  
33975 156 L<Nasm::X86::Tree::copyDescriptor|/Nasm::X86::Tree::copyDescriptor> - Copy the description of one tree into another.
33976  
33977 157 L<Nasm::X86::Tree::decLengthInKeys|/Nasm::X86::Tree::decLengthInKeys> - Decrement the number of keys in a keys block or complain if such is not possible.
33978  
33979 158 L<Nasm::X86::Tree::decSize|/Nasm::X86::Tree::decSize> - Decrement the size of a tree.
33980  
33981 159 L<Nasm::X86::Tree::decSizeInFirst|/Nasm::X86::Tree::decSizeInFirst> - Decrement the size field in the first block of a tree when the first block is held in a zmm register.
33982  
33983 160 L<Nasm::X86::Tree::delete|/Nasm::X86::Tree::delete> - Find a key in a tree and delete it returning he value of the l=key deleted if found.
33984  
33985 161 L<Nasm::X86::Tree::deleteFirstKeyAndData|/Nasm::X86::Tree::deleteFirstKeyAndData> - Delete the first element of a leaf mode returning its characteristics in the calling tree descriptor.
33986  
33987 162 L<Nasm::X86::Tree::depth|/Nasm::X86::Tree::depth> - Return the depth of a node within a tree.
33988  
33989 163 L<Nasm::X86::Tree::DescribeTree|/Nasm::X86::Tree::DescribeTree> - Create a description of a tree.
33990  
33991 164 L<Nasm::X86::Tree::dump|/Nasm::X86::Tree::dump> - Dump a tree and all its sub trees.
33992  
33993 165 L<Nasm::X86::Tree::dump8|/Nasm::X86::Tree::dump8> - Dump a tree and all its sub trees using 8 character fields for numbers.
33994  
33995 166 L<Nasm::X86::Tree::dump8xx|/Nasm::X86::Tree::dump8xx> - Dump a tree and all its sub trees using 8 character fields for numbers printing the keys and data in hexadecimal.
33996  
33997 167 L<Nasm::X86::Tree::dumpWithWidth|/Nasm::X86::Tree::dumpWithWidth> - Dump a tree and all its sub trees.
33998  
33999 168 L<Nasm::X86::Tree::expand|/Nasm::X86::Tree::expand> - Expand the node at the specified offset in the specified tree if it needs to be expanded and is not the root node (which cannot be expanded because it has no siblings to take substance from whereas as all other nodes do).
34000  
34001 169 L<Nasm::X86::Tree::extract|/Nasm::X86::Tree::extract> - Extract the key/data/node and tree bit at the specified point from the block held in the specified zmm registers.
34002  
34003 170 L<Nasm::X86::Tree::extractFirst|/Nasm::X86::Tree::extractFirst> - Extract the first key/data and tree bit at the specified point from the block held in the specified zmm registers and place the extracted data/bit in tree data/subTree.
34004  
34005 171 L<Nasm::X86::Tree::find|/Nasm::X86::Tree::find> - Find a key in a tree and tests whether the found data is a sub tree.
34006  
34007 172 L<Nasm::X86::Tree::findAndReload|/Nasm::X86::Tree::findAndReload> - Find a key in the specified tree and clone it is it is a sub tree.
34008  
34009 173 L<Nasm::X86::Tree::findFirst|/Nasm::X86::Tree::findFirst> - Find the first element in a tree and set B<found>|B<key>|B<data>|B<subTree> to show the result.
34010  
34011 174 L<Nasm::X86::Tree::findLast|/Nasm::X86::Tree::findLast> - Find the last key in a tree - crucial for stack like operations.
34012  
34013 175 L<Nasm::X86::Tree::findNext|/Nasm::X86::Tree::findNext> - Find the next key greater than the one specified.
34014  
34015 176 L<Nasm::X86::Tree::findPrev|/Nasm::X86::Tree::findPrev> - Find the previous key less than the one specified.
34016  
34017 177 L<Nasm::X86::Tree::findSubTree|/Nasm::X86::Tree::findSubTree> - Find a key in the specified tree and create a sub tree from the data field if possible.
34018  
34019 178 L<Nasm::X86::Tree::firstFromMemory|/Nasm::X86::Tree::firstFromMemory> - Load the first block for a tree into the numbered zmm.
34020  
34021 179 L<Nasm::X86::Tree::firstIntoMemory|/Nasm::X86::Tree::firstIntoMemory> - Save the first block of a tree in the numbered zmm back into memory.
34022  
34023 180 L<Nasm::X86::Tree::firstNode|/Nasm::X86::Tree::firstNode> - Return as a variable the last node block in the specified tree node held in a zmm.
34024  
34025 181 L<Nasm::X86::Tree::free|/Nasm::X86::Tree::free> - Free all the memory used by a tree.
34026  
34027 182 L<Nasm::X86::Tree::freeBlock|/Nasm::X86::Tree::freeBlock> - Free a keys/data/node block whose keys block entry is located at the specified offset.
34028  
34029 183 L<Nasm::X86::Tree::get|/Nasm::X86::Tree::get> - Retrieves the element at the specified zero based index in the stack.
34030  
34031 184 L<Nasm::X86::Tree::getBlock|/Nasm::X86::Tree::getBlock> - Get the keys, data and child nodes for a tree node from the specified offset in the area for the tree.
34032  
34033 185 L<Nasm::X86::Tree::getKeyString|/Nasm::X86::Tree::getKeyString> - Find a string in a string tree and return the associated data and find status in the data and found fields of the tree.
34034  
34035 186 L<Nasm::X86::Tree::getLoop|/Nasm::X86::Tree::getLoop> - Return the value of the loop field as a variable.
34036  
34037 187 L<Nasm::X86::Tree::getTreeBit|/Nasm::X86::Tree::getTreeBit> - Get the tree bit from the numbered zmm at the specified point and return it in a variable as a one or a zero.
34038  
34039 188 L<Nasm::X86::Tree::getTreeBits|/Nasm::X86::Tree::getTreeBits> - Load the tree bits from the numbered zmm into the specified register.
34040  
34041 189 L<Nasm::X86::Tree::incLengthInKeys|/Nasm::X86::Tree::incLengthInKeys> - Increment the number of keys in a keys block or complain if such is not possible.
34042  
34043 190 L<Nasm::X86::Tree::incSize|/Nasm::X86::Tree::incSize> - Increment the size of a tree.
34044  
34045 191 L<Nasm::X86::Tree::incSizeInFirst|/Nasm::X86::Tree::incSizeInFirst> - Increment the size field in the first block of a tree when the first block is held in a zmm register.
34046  
34047 192 L<Nasm::X86::Tree::indexEq|/Nasm::X86::Tree::indexEq> - Return the position of a key in a zmm equal to the specified key as a point in a variable.
34048  
34049 193 L<Nasm::X86::Tree::indexEqLt|/Nasm::X86::Tree::indexEqLt> - Set the specified registers with the equals point and the insertion point for the specified key in the specified zmm.
34050  
34051 194 L<Nasm::X86::Tree::indexNode|/Nasm::X86::Tree::indexNode> - Return, as a variable, the point mask obtained by testing the nodes in a block for specified offset.
34052  
34053 195 L<Nasm::X86::Tree::indexXX|/Nasm::X86::Tree::indexXX> - Return, as a variable, the mask obtained by performing a specified comparison on the key area of a node against a specified key.
34054  
34055 196 L<Nasm::X86::Tree::insertIntoTreeBits|/Nasm::X86::Tree::insertIntoTreeBits> - Insert a one into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
34056  
34057 197 L<Nasm::X86::Tree::insertionPoint|/Nasm::X86::Tree::insertionPoint> - Return the position at which a key should be inserted into a zmm as a point in a variable.
34058  
34059 198 L<Nasm::X86::Tree::insertKeyDataTreeIntoLeaf|/Nasm::X86::Tree::insertKeyDataTreeIntoLeaf> - Insert a new key/data/sub tree triple into a set of zmm registers if there is room, increment the length of the node and set the tree bit as indicated and increment the number of elements in the tree.
34060  
34061 199 L<Nasm::X86::Tree::insertOneIntoTreeBits|/Nasm::X86::Tree::insertOneIntoTreeBits> - Insert a one into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
34062  
34063 200 L<Nasm::X86::Tree::insertTreeBit|/Nasm::X86::Tree::insertTreeBit> - Insert a zero or one into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
34064  
34065 201 L<Nasm::X86::Tree::insertZeroIntoTreeBits|/Nasm::X86::Tree::insertZeroIntoTreeBits> - Insert a zero into the tree bits field in the numbered zmm at the specified point moving the bits at and beyond point one position to the right.
34066  
34067 202 L<Nasm::X86::Tree::intersection|/Nasm::X86::Tree::intersection> - Given a tree of trees consider each sub tree as a set and form the intersection of all these sets as a new tree.
34068  
34069 203 L<Nasm::X86::Tree::isTree|/Nasm::X86::Tree::isTree> - Set the Zero Flag to oppose the tree bit in the numbered zmm register holding the keys of a node to indicate whether the data element indicated by the specified register is an offset to a sub tree in the containing area or not.
34070  
34071 204 L<Nasm::X86::Tree::lastNode|/Nasm::X86::Tree::lastNode> - Return as a variable the last node block in the specified tree node held in a zmm.
34072  
34073 205 L<Nasm::X86::Tree::leafFromNodes|/Nasm::X86::Tree::leafFromNodes> - Return a variable containing true if we are on a leaf.
34074  
34075 206 L<Nasm::X86::Tree::leftMost|/Nasm::X86::Tree::leftMost> - Return the offset of the left most node from the specified node.
34076  
34077 207 L<Nasm::X86::Tree::leftOrRightMost|/Nasm::X86::Tree::leftOrRightMost> - Return the offset of the left most or right most node.
34078  
34079 208 L<Nasm::X86::Tree::lengthFromKeys|/Nasm::X86::Tree::lengthFromKeys> - Get the length of the keys block in the numbered zmm and return it as a variable.
34080  
34081 209 L<Nasm::X86::Tree::lengthIntoKeys|/Nasm::X86::Tree::lengthIntoKeys> - Get the length of the block in the numbered zmm from the specified variable.
34082  
34083 210 L<Nasm::X86::Tree::maskForFullKeyArea|/Nasm::X86::Tree::maskForFullKeyArea> - Place a mask for the full key area in the numbered mask register.
34084  
34085 211 L<Nasm::X86::Tree::maskForFullNodesArea|/Nasm::X86::Tree::maskForFullNodesArea> - Place a mask for the full nodes area in the numbered mask register.
34086  
34087 212 L<Nasm::X86::Tree::merge|/Nasm::X86::Tree::merge> - Merge a left and right node if they are at minimum size.
34088  
34089 213 L<Nasm::X86::Tree::mergeOrSteal|/Nasm::X86::Tree::mergeOrSteal> - Merge the block at the specified offset with its right sibling or steal from it.
34090  
34091 214 L<Nasm::X86::Tree::nextNode|/Nasm::X86::Tree::nextNode> - Return as a variable the next node block offset after the specified one in the specified zmm.
34092  
34093 215 L<Nasm::X86::Tree::optionsFromFirst|/Nasm::X86::Tree::optionsFromFirst> - Return a variable containing the options double word from the first block zmm register.
34094  
34095 216 L<Nasm::X86::Tree::optionsIntoFirst|/Nasm::X86::Tree::optionsIntoFirst> - Put the contents of a variable into the options field of the first block of a tree when the first block is held in a zmm register.
34096  
34097 217 L<Nasm::X86::Tree::outAsUtf8|/Nasm::X86::Tree::outAsUtf8> - Print the data values of the specified string on stdout assuming each data value is a utf32 character and that the output device supports utf8.
34098  
34099 218 L<Nasm::X86::Tree::outAsUtf8NL|/Nasm::X86::Tree::outAsUtf8NL> - Print the data values of the specified string on stdout assuming each data value is a utf32 character and that the output device supports utf8.
34100  
34101 219 L<Nasm::X86::Tree::overWriteKeyDataTreeInLeaf|/Nasm::X86::Tree::overWriteKeyDataTreeInLeaf> - Over write an existing key/data/sub tree triple in a set of zmm registers and set the tree bit as indicated.
34102  
34103 220 L<Nasm::X86::Tree::peek|/Nasm::X86::Tree::peek> - Peek at the element the specified distance back from the top of the stack and return its B<value> in data and found status in B<found> in the tree descriptor.
34104  
34105 221 L<Nasm::X86::Tree::peekSubTree|/Nasm::X86::Tree::peekSubTree> - Pop the last value out of a tree and return a tree descriptor positioned on it with the first/found fields set.
34106  
34107 222 L<Nasm::X86::Tree::pop|/Nasm::X86::Tree::pop> - Pop the last value out of a tree and return the key/data/subTree in the tree descriptor.
34108  
34109 223 L<Nasm::X86::Tree::popSubTree|/Nasm::X86::Tree::popSubTree> - Pop the last value out of a tree and return a tree descriptor positioned on it with the first/found fields set.
34110  
34111 224 L<Nasm::X86::Tree::position|/Nasm::X86::Tree::position> - Create a new tree description for a tree positioned at the specified location.
34112  
34113 225 L<Nasm::X86::Tree::prevNode|/Nasm::X86::Tree::prevNode> - Return as a variable the previous node block offset after the specified one in the specified zmm.
34114  
34115 226 L<Nasm::X86::Tree::printInOrder|/Nasm::X86::Tree::printInOrder> - Print a tree in order.
34116  
34117 227 L<Nasm::X86::Tree::push|/Nasm::X86::Tree::push> - Push a data value onto a tree.
34118  
34119 228 L<Nasm::X86::Tree::put|/Nasm::X86::Tree::put> - Put a variable key and data into a tree.
34120  
34121 229 L<Nasm::X86::Tree::putBlock|/Nasm::X86::Tree::putBlock> - Put a tree block held in three zmm registers back into the area holding the tree at the specified offset.
34122  
34123 230 L<Nasm::X86::Tree::putKeyString|/Nasm::X86::Tree::putKeyString> - Associate a string of any length with a double word.
34124  
34125 231 L<Nasm::X86::Tree::putLoop|/Nasm::X86::Tree::putLoop> - Set the value of the loop field from a variable.
34126  
34127 232 L<Nasm::X86::Tree::relativeNode|/Nasm::X86::Tree::relativeNode> - Return as a variable a node offset relative (specified as ac constant) to another offset in the same node in the specified zmm.
34128  
34129 233 L<Nasm::X86::Tree::replace|/Nasm::X86::Tree::replace> - Replace the key/data/subTree at the specified point in the specified zmm with the values found in the tree key/data/sub tree fields.
34130  
34131 234 L<Nasm::X86::Tree::reverse|/Nasm::X86::Tree::reverse> - Create a clone of the string in reverse order.
34132  
34133 235 L<Nasm::X86::Tree::rightMost|/Nasm::X86::Tree::rightMost> - Return the offset of the left most node from the specified node.
34134  
34135 236 L<Nasm::X86::Tree::root|/Nasm::X86::Tree::root> - Check whether the specified offset refers to the root of a tree when the first block is held in a zmm register.
34136  
34137 237 L<Nasm::X86::Tree::rootFromFirst|/Nasm::X86::Tree::rootFromFirst> - Return a variable containing the offset of the root block of a tree from the first block when held in a zmm register.
34138  
34139 238 L<Nasm::X86::Tree::rootIntoFirst|/Nasm::X86::Tree::rootIntoFirst> - Put the contents of a variable into the root field of the first block of a tree when held in a zmm register.
34140  
34141 239 L<Nasm::X86::Tree::setOrClearTreeBit|/Nasm::X86::Tree::setOrClearTreeBit> - Set or clear the tree bit selected by the specified point in the numbered zmm register holding the keys of a node to indicate that the data element indicated by the specified register is an offset to a sub tree in the containing area.
34142  
34143 240 L<Nasm::X86::Tree::setOrClearTreeBitToMatchContent|/Nasm::X86::Tree::setOrClearTreeBitToMatchContent> - Set or clear the tree bit pointed to by the specified register depending on the content of the specified variable.
34144  
34145 241 L<Nasm::X86::Tree::setTreeBit|/Nasm::X86::Tree::setTreeBit> - Set the tree bit in the numbered zmm register holding the keys of a node to indicate that the data element indexed by the specified register is an offset to a sub tree in the containing area.
34146  
34147 242 L<Nasm::X86::Tree::setTreeBits|/Nasm::X86::Tree::setTreeBits> - Put the tree bits in the specified register into the numbered zmm.
34148  
34149 243 L<Nasm::X86::Tree::size|/Nasm::X86::Tree::size> - Return in a variable the number of elements currently in the tree.
34150  
34151 244 L<Nasm::X86::Tree::sizeFromFirst|/Nasm::X86::Tree::sizeFromFirst> - Return a variable containing the number of keys in the specified tree when the first block is held in a zmm register.
34152  
34153 245 L<Nasm::X86::Tree::sizeIntoFirst|/Nasm::X86::Tree::sizeIntoFirst> - Put the contents of a variable into the size field of the first block of a tree when the first block is held in a zmm register.
34154  
34155 246 L<Nasm::X86::Tree::splitNode|/Nasm::X86::Tree::splitNode> - Split a node if it it is full returning a variable that indicates whether a split occurred or not.
34156  
34157 247 L<Nasm::X86::Tree::splitNotRoot|/Nasm::X86::Tree::splitNotRoot> - Split a non root left node pushing its excess right and up.
34158  
34159 248 L<Nasm::X86::Tree::splitRoot|/Nasm::X86::Tree::splitRoot> - Split a non root node into left and right nodes with the left half left in the left node and splitting key/data pushed into the parent node with the remainder pushed into the new right node.
34160  
34161 249 L<Nasm::X86::Tree::stealFromLeft|/Nasm::X86::Tree::stealFromLeft> - Steal one key from the node on the left where the current left node,parent node and right node are held in zmm registers and return one if the steal was performed, else zero.
34162  
34163 250 L<Nasm::X86::Tree::stealFromRight|/Nasm::X86::Tree::stealFromRight> - Steal one key from the node on the right where the current left node,parent node and right node are held in zmm registers and return one if the steal was performed, else zero.
34164  
34165 251 L<Nasm::X86::Tree::substring|/Nasm::X86::Tree::substring> - Create the substring of the specified string between the specified start and end keys.
34166  
34167 252 L<Nasm::X86::Tree::union|/Nasm::X86::Tree::union> - Given a tree of trees consider each sub tree as a set and form the union of all these sets as a new tree.
34168  
34169 253 L<Nasm::X86::Tree::uniqueKeyString|/Nasm::X86::Tree::uniqueKeyString> - Add a key string to a string tree if the key is not already present and return a unique number identifying the string (although currently there is no way to fast way to recover the string from the number).
34170  
34171 254 L<Nasm::X86::Tree::upFromData|/Nasm::X86::Tree::upFromData> - Up from the data zmm in a block in a tree.
34172  
34173 255 L<Nasm::X86::Tree::upIntoData|/Nasm::X86::Tree::upIntoData> - Up into the data zmm in a block in a tree.
34174  
34175 256 L<Nasm::X86::Tree::yb|/Nasm::X86::Tree::yb> - Call the specified block with each element of the specified tree in descending order.
34176  
34177 257 L<Nasm::X86::Tree::zero|/Nasm::X86::Tree::zero> - Zero the return fields of a tree descriptor.
34178  
34179 258 L<Nasm::X86::Unisyn::DescribeParse|/Nasm::X86::Unisyn::DescribeParse> - Describe a parse - create a description on the stack to receive the results of a parse
34180  
34181 259 L<Nasm::X86::Unisyn::Lex::AlphabetsArray|/Nasm::X86::Unisyn::Lex::AlphabetsArray> - Create an array of utf32 to alphabet number.
34182  
34183 260 L<Nasm::X86::Unisyn::Lex::composeUnisyn|/Nasm::X86::Unisyn::Lex::composeUnisyn> - Compose phrases of Unisyn and return them as a string
34184  
34185 261 L<Nasm::X86::Unisyn::Lex::left {3};|/Nasm::X86::Unisyn::Lex::left {3};> - Left operand.
34186  
34187 262 L<Nasm::X86::Unisyn::Lex::length {1};|/Nasm::X86::Unisyn::Lex::length {1};> - Length of the lexical item in bytes.
34188  
34189 263 L<Nasm::X86::Unisyn::Lex::Letter::d|/Nasm::X86::Unisyn::Lex::Letter::d> - Dyad 2 - Double struck
34190  
34191 264 L<Nasm::X86::Unisyn::Lex::Letter::e|/Nasm::X86::Unisyn::Lex::Letter::e> - Dyad 3 - Mono
34192  
34193 265 L<Nasm::X86::Unisyn::Lex::Letter::f|/Nasm::X86::Unisyn::Lex::Letter::f> - Dyad 5 - Sans-serif Normal
34194  
34195 266 L<Nasm::X86::Unisyn::Lex::Letter::g|/Nasm::X86::Unisyn::Lex::Letter::g> - Dyad 6 - Sans-serif Bold
34196  
34197 267 L<Nasm::X86::Unisyn::Lex::Letter::h|/Nasm::X86::Unisyn::Lex::Letter::h> - Dyad 7 - Calligraphy - normal
34198  
34199 268 L<Nasm::X86::Unisyn::Lex::Letter::i|/Nasm::X86::Unisyn::Lex::Letter::i> - Dyad 8 - Calligraphy - bold
34200  
34201 269 L<Nasm::X86::Unisyn::Lex::Letter::j|/Nasm::X86::Unisyn::Lex::Letter::j> - Dyad 9 - Fraktur - Normal
34202  
34203 270 L<Nasm::X86::Unisyn::Lex::Letter::k|/Nasm::X86::Unisyn::Lex::Letter::k> - Dyad 10 - Fraktur - bold
34204  
34205 271 L<Nasm::X86::Unisyn::Lex::letterToNumber|/Nasm::X86::Unisyn::Lex::letterToNumber> - Map each letter in the union of the alphabets to a sequential number
34206  
34207 272 L<Nasm::X86::Unisyn::Lex::Number::a {11}|/Nasm::X86::Unisyn::Lex::Number::a {11}> - Assign infix operator with right to left binding at priority 4.
34208  
34209 273 L<Nasm::X86::Unisyn::Lex::Number::A {2}|/Nasm::X86::Unisyn::Lex::Number::A {2}> - ASCII characters extended with circled characters to act as escape sequences.
34210  
34211 274 L<Nasm::X86::Unisyn::Lex::Number::b {7}|/Nasm::X86::Unisyn::Lex::Number::b {7}> - Open.
34212  
34213 275 L<Nasm::X86::Unisyn::Lex::Number::B {8}|/Nasm::X86::Unisyn::Lex::Number::B {8}> - Close.
34214  
34215 276 L<Nasm::X86::Unisyn::Lex::Number::F {1}|/Nasm::X86::Unisyn::Lex::Number::F {1}> - End symbol.
34216  
34217 277 L<Nasm::X86::Unisyn::Lex::Number::l {18}|/Nasm::X86::Unisyn::Lex::Number::l {18}> - Dyad 11
34218  
34219 278 L<Nasm::X86::Unisyn::Lex::Number::m {19}|/Nasm::X86::Unisyn::Lex::Number::m {19}> - Dyad 12
34220  
34221 279 L<Nasm::X86::Unisyn::Lex::Number::p {3}|/Nasm::X86::Unisyn::Lex::Number::p {3}> - Prefix operator - applies only to the following variable or bracketed term.
34222  
34223 280 L<Nasm::X86::Unisyn::Lex::Number::q {5}|/Nasm::X86::Unisyn::Lex::Number::q {5}> - Suffix operator - applies only to the preceding variable or bracketed term.
34224  
34225 281 L<Nasm::X86::Unisyn::Lex::Number::S {0}|/Nasm::X86::Unisyn::Lex::Number::S {0}> - Start symbol.
34226  
34227 282 L<Nasm::X86::Unisyn::Lex::Number::s {6}|/Nasm::X86::Unisyn::Lex::Number::s {6}> - Infix operator with left to right binding at priority 1.
34228  
34229 283 L<Nasm::X86::Unisyn::Lex::Number::v {4}|/Nasm::X86::Unisyn::Lex::Number::v {4}> - Variable names.
34230  
34231 284 L<Nasm::X86::Unisyn::Lex::Number::w {20}|/Nasm::X86::Unisyn::Lex::Number::w {20}> - White space
34232  
34233 285 L<Nasm::X86::Unisyn::Lex::numberToLetter|/Nasm::X86::Unisyn::Lex::numberToLetter> - Recover a letter from its unique number
34234  
34235 286 L<Nasm::X86::Unisyn::Lex::PermissibleTransitionsArray|/Nasm::X86::Unisyn::Lex::PermissibleTransitionsArray> - Create and load the table of lexical transitions.
34236  
34237 287 L<Nasm::X86::Unisyn::Lex::PermissibleTransitionsArrayBits {5}|/Nasm::X86::Unisyn::Lex::PermissibleTransitionsArrayBits {5}> - The number of bits needed to express a transition
34238  
34239 288 L<Nasm::X86::Unisyn::Lex::position {0};|/Nasm::X86::Unisyn::Lex::position {0};> - Position of the parsed item in the input text.
34240  
34241 289 L<Nasm::X86::Unisyn::Lex::Reason::BadUtf8 {1};|/Nasm::X86::Unisyn::Lex::Reason::BadUtf8 {1};> - Bad utf8 character encountered.
34242  
34243 290 L<Nasm::X86::Unisyn::Lex::Reason::BracketsNotClosed {7};|/Nasm::X86::Unisyn::Lex::Reason::BracketsNotClosed {7};> - Open brackets not closed at end of.
34244  
34245 291 L<Nasm::X86::Unisyn::Lex::Reason::InvalidChar {2};|/Nasm::X86::Unisyn::Lex::Reason::InvalidChar {2};> - Character not part of Earl Zero.
34246  
34247 292 L<Nasm::X86::Unisyn::Lex::Reason::InvalidTransition {3};|/Nasm::X86::Unisyn::Lex::Reason::InvalidTransition {3};> - Transition from one lexical item to another not allowed.
34248  
34249 293 L<Nasm::X86::Unisyn::Lex::Reason::Mismatch {5};|/Nasm::X86::Unisyn::Lex::Reason::Mismatch {5};> - Mismatched bracket.
34250  
34251 294 L<Nasm::X86::Unisyn::Lex::Reason::NotFinal {6};|/Nasm::X86::Unisyn::Lex::Reason::NotFinal {6};> - Expected something after final character.
34252  
34253 295 L<Nasm::X86::Unisyn::Lex::Reason::Success {0};|/Nasm::X86::Unisyn::Lex::Reason::Success {0};> - Successful parse.
34254  
34255 296 L<Nasm::X86::Unisyn::Lex::Reason::TrailingClose {4};|/Nasm::X86::Unisyn::Lex::Reason::TrailingClose {4};> - Trailing closing bracket discovered.
34256  
34257 297 L<Nasm::X86::Unisyn::Lex::right {4};|/Nasm::X86::Unisyn::Lex::right {4};> - Right operand.
34258  
34259 298 L<Nasm::X86::Unisyn::Lex::symbol {5};|/Nasm::X86::Unisyn::Lex::symbol {5};> - Symbol.
34260  
34261 299 L<Nasm::X86::Unisyn::Lex::type {2};|/Nasm::X86::Unisyn::Lex::type {2};> - Type of the lexical item.
34262  
34263 300 L<Nasm::X86::Unisyn::Parse|/Nasm::X86::Unisyn::Parse> - Parse a string of utf8 characters.
34264  
34265 301 L<Nasm::X86::Unisyn::Parse::dump|/Nasm::X86::Unisyn::Parse::dump> - Dump a parse tree in order.
34266  
34267 302 L<Nasm::X86::Unisyn::Parse::dumpParseResult|/Nasm::X86::Unisyn::Parse::dumpParseResult> - Dump the result of a parse
34268  
34269 303 L<Nasm::X86::Unisyn::Parse::dumpPostOrder|/Nasm::X86::Unisyn::Parse::dumpPostOrder> - Dump a parse tree in post order.
34270  
34271 304 L<Nasm::X86::Unisyn::Parse::traverseApplyingLibraryOperators|/Nasm::X86::Unisyn::Parse::traverseApplyingLibraryOperators> - Traverse a parse tree, in post order, applying a library of operators.
34272  
34273 305 L<Nasm::X86::Variable::add|/Nasm::X86::Variable::add> - Add the right hand variable to the left hand variable and return the result as a new variable.
34274  
34275 306 L<Nasm::X86::Variable::address|/Nasm::X86::Variable::address> - Create a variable that contains the address of another variable.
34276  
34277 307 L<Nasm::X86::Variable::addressExpr|/Nasm::X86::Variable::addressExpr> - Create a register expression to address an offset form a variable.
34278  
34279 308 L<Nasm::X86::Variable::allocateMemory|/Nasm::X86::Variable::allocateMemory> - Allocate a variable amount of memory via mmap and return its address.
34280  
34281 309 L<Nasm::X86::Variable::and|/Nasm::X86::Variable::and> - And two variables.
34282  
34283 310 L<Nasm::X86::Variable::arithmetic|/Nasm::X86::Variable::arithmetic> - Return a variable containing the result of an arithmetic operation on the left hand and right hand side variables.
34284  
34285 311 L<Nasm::X86::Variable::assign|/Nasm::X86::Variable::assign> - Assign to the left hand side the value of the right hand side.
34286  
34287 312 L<Nasm::X86::Variable::at|/Nasm::X86::Variable::at> - Return a "[register expression]" to address the data in the variable in the current stack frame.
34288  
34289 313 L<Nasm::X86::Variable::bFromZ|/Nasm::X86::Variable::bFromZ> - Get the byte from the numbered zmm register and put it in a variable.
34290  
34291 314 L<Nasm::X86::Variable::bIntoX|/Nasm::X86::Variable::bIntoX> - Place the value of the content variable at the byte in the numbered xmm register.
34292  
34293 315 L<Nasm::X86::Variable::bIntoZ|/Nasm::X86::Variable::bIntoZ> - Place the value of the content variable at the byte in the numbered zmm register.
34294  
34295 316 L<Nasm::X86::Variable::booleanZF|/Nasm::X86::Variable::booleanZF> - Combine the left hand variable with the right hand variable via a boolean operator and indicate the result by setting the zero flag if the result is true.
34296  
34297 317 L<Nasm::X86::Variable::clearBit|/Nasm::X86::Variable::clearBit> - Clear a bit in the specified mask register retaining the other bits.
34298  
34299 318 L<Nasm::X86::Variable::clearMaskBit|/Nasm::X86::Variable::clearMaskBit> - Clear a bit in the specified mask register retaining the other bits.
34300  
34301 319 L<Nasm::X86::Variable::clearMemory|/Nasm::X86::Variable::clearMemory> - Clear the memory described in this variable.
34302  
34303 320 L<Nasm::X86::Variable::clone|/Nasm::X86::Variable::clone> - Clone a variable to make a new variable.
34304  
34305 321 L<Nasm::X86::Variable::copy|/Nasm::X86::Variable::copy> - Copy one variable into another.
34306  
34307 322 L<Nasm::X86::Variable::copyMemory|/Nasm::X86::Variable::copyMemory> - Copy from one block of memory to another.
34308  
34309 323 L<Nasm::X86::Variable::copyRef|/Nasm::X86::Variable::copyRef> - Copy a reference to a variable.
34310  
34311 324 L<Nasm::X86::Variable::copyZF|/Nasm::X86::Variable::copyZF> - Copy the current state of the zero flag into a variable.
34312  
34313 325 L<Nasm::X86::Variable::copyZFInverted|/Nasm::X86::Variable::copyZFInverted> - Copy the opposite of the current state of the zero flag into a variable.
34314  
34315 326 L<Nasm::X86::Variable::d|/Nasm::X86::Variable::d> - Dump the value of a variable on stderr and append the source file calling line in a format that Geany understands.
34316  
34317 327 L<Nasm::X86::Variable::dec|/Nasm::X86::Variable::dec> - Decrement a variable.
34318  
34319 328 L<Nasm::X86::Variable::dereference|/Nasm::X86::Variable::dereference> - Create a variable that contains the contents of the variable addressed by the specified variable.
34320  
34321 329 L<Nasm::X86::Variable::dFromPointInZ|/Nasm::X86::Variable::dFromPointInZ> - Get the double word from the numbered zmm register at a point specified by the variable and return it in a variable.
34322  
34323 330 L<Nasm::X86::Variable::dFromZ|/Nasm::X86::Variable::dFromZ> - Get the double word from the numbered zmm register and put it in a variable.
34324  
34325 331 L<Nasm::X86::Variable::dIntoPointInZ|/Nasm::X86::Variable::dIntoPointInZ> - Put the variable double word content into the numbered zmm register at a point specified by the variable.
34326  
34327 332 L<Nasm::X86::Variable::dIntoX|/Nasm::X86::Variable::dIntoX> - Place the value of the content variable at the double word in the numbered xmm register.
34328  
34329 333 L<Nasm::X86::Variable::dIntoZ|/Nasm::X86::Variable::dIntoZ> - Place the value of the content variable at the double word in the numbered zmm register.
34330  
34331 334 L<Nasm::X86::Variable::divide|/Nasm::X86::Variable::divide> - Divide the left hand variable by the right hand variable and return the result as a new variable.
34332  
34333 335 L<Nasm::X86::Variable::division|/Nasm::X86::Variable::division> - Return a variable containing the result or the remainder that occurs when the left hand side is divided by the right hand side.
34334  
34335 336 L<Nasm::X86::Variable::dump|/Nasm::X86::Variable::dump> - Dump the value of a variable to the specified channel adding an optional title and new line if requested.
34336  
34337 337 L<Nasm::X86::Variable::eq|/Nasm::X86::Variable::eq> - Check whether the left hand variable is equal to the right hand variable.
34338  
34339 338 L<Nasm::X86::Variable::equals|/Nasm::X86::Variable::equals> - Equals operator.
34340  
34341 339 L<Nasm::X86::Variable::err|/Nasm::X86::Variable::err> - Dump the value of a variable on stderr.
34342  
34343 340 L<Nasm::X86::Variable::errCString|/Nasm::X86::Variable::errCString> - Print a zero terminated C style string addressed by a variable on stderr.
34344  
34345 341 L<Nasm::X86::Variable::errCStringNL|/Nasm::X86::Variable::errCStringNL> - Print a zero terminated C style string addressed by a variable on stderr followed by a new line.
34346  
34347 342 L<Nasm::X86::Variable::errInDec|/Nasm::X86::Variable::errInDec> - Dump the value of a variable on stderr in decimal.
34348  
34349 343 L<Nasm::X86::Variable::errInDecNL|/Nasm::X86::Variable::errInDecNL> - Dump the value of a variable on stderr in decimal followed by a new line.
34350  
34351 344 L<Nasm::X86::Variable::errNL|/Nasm::X86::Variable::errNL> - Dump the value of a variable on stderr and append a new line.
34352  
34353 345 L<Nasm::X86::Variable::errRightInBin|/Nasm::X86::Variable::errRightInBin> - Write the specified variable number in binary right justified in a field of specified width to stderr.
34354  
34355 346 L<Nasm::X86::Variable::errRightInBinNL|/Nasm::X86::Variable::errRightInBinNL> - Write the specified variable number in binary right justified in a field of specified width to stderr followed by a new line.
34356  
34357 347 L<Nasm::X86::Variable::errRightInDec|/Nasm::X86::Variable::errRightInDec> - Dump the value of a variable on stderr as a decimal number right adjusted in a field of specified width.
34358  
34359 348 L<Nasm::X86::Variable::errRightInDecNL|/Nasm::X86::Variable::errRightInDecNL> - Dump the value of a variable on stderr as a decimal number right adjusted in a field of specified width followed by a new line.
34360  
34361 349 L<Nasm::X86::Variable::errRightInHex|/Nasm::X86::Variable::errRightInHex> - Write the specified variable number in hexadecimal right justified in a field of specified width to stderr.
34362  
34363 350 L<Nasm::X86::Variable::errRightInHexNL|/Nasm::X86::Variable::errRightInHexNL> - Write the specified variable number in hexadecimal right justified in a field of specified width to stderr followed by a new line.
34364  
34365 351 L<Nasm::X86::Variable::errSpaces|/Nasm::X86::Variable::errSpaces> - Print the specified number of spaces to stderr.
34366  
34367 352 L<Nasm::X86::Variable::for|/Nasm::X86::Variable::for> - Iterate a block a variable number of times.
34368  
34369 353 L<Nasm::X86::Variable::freeMemory|/Nasm::X86::Variable::freeMemory> - Free the memory addressed by this variable for the specified length.
34370  
34371 354 L<Nasm::X86::Variable::ge|/Nasm::X86::Variable::ge> - Check whether the left hand variable is greater than or equal to the right hand variable.
34372  
34373 355 L<Nasm::X86::Variable::getReg|/Nasm::X86::Variable::getReg> - Load the variable from a register expression.
34374  
34375 356 L<Nasm::X86::Variable::gt|/Nasm::X86::Variable::gt> - Check whether the left hand variable is greater than the right hand variable.
34376  
34377 357 L<Nasm::X86::Variable::inc|/Nasm::X86::Variable::inc> - Increment a variable.
34378  
34379 358 L<Nasm::X86::Variable::incDec|/Nasm::X86::Variable::incDec> - Increment or decrement a variable.
34380  
34381 359 L<Nasm::X86::Variable::isRef|/Nasm::X86::Variable::isRef> - Check whether the specified variable is a reference to another variable.
34382  
34383 360 L<Nasm::X86::Variable::le|/Nasm::X86::Variable::le> - Check whether the left hand variable is less than or equal to the right hand variable.
34384  
34385 361 L<Nasm::X86::Variable::loadZmm|/Nasm::X86::Variable::loadZmm> - Load bytes from the memory addressed by the specified source variable into the numbered zmm register.
34386  
34387 362 L<Nasm::X86::Variable::lt|/Nasm::X86::Variable::lt> - Check whether the left hand variable is less than the right hand variable.
34388  
34389 363 L<Nasm::X86::Variable::max|/Nasm::X86::Variable::max> - Maximum of two variables.
34390  
34391 364 L<Nasm::X86::Variable::min|/Nasm::X86::Variable::min> - Minimum of two variables.
34392  
34393 365 L<Nasm::X86::Variable::minusAssign|/Nasm::X86::Variable::minusAssign> - Implement minus and assign.
34394  
34395 366 L<Nasm::X86::Variable::mod|/Nasm::X86::Variable::mod> - Divide the left hand variable by the right hand variable and return the remainder as a new variable.
34396  
34397 367 L<Nasm::X86::Variable::ne|/Nasm::X86::Variable::ne> - Check whether the left hand variable is not equal to the right hand variable.
34398  
34399 368 L<Nasm::X86::Variable::not|/Nasm::X86::Variable::not> - Form two complement of left hand side and return it as a variable.
34400  
34401 369 L<Nasm::X86::Variable::or|/Nasm::X86::Variable::or> - Or two variables.
34402  
34403 370 L<Nasm::X86::Variable::out|/Nasm::X86::Variable::out> - Dump the value of a variable on stdout.
34404  
34405 371 L<Nasm::X86::Variable::outCString|/Nasm::X86::Variable::outCString> - Print a zero terminated C style string addressed by a variable on stdout.
34406  
34407 372 L<Nasm::X86::Variable::outCStringNL|/Nasm::X86::Variable::outCStringNL> - Print a zero terminated C style string addressed by a variable on stdout followed by a new line.
34408  
34409 373 L<Nasm::X86::Variable::outInDec|/Nasm::X86::Variable::outInDec> - Dump the value of a variable on stdout in decimal.
34410  
34411 374 L<Nasm::X86::Variable::outInDecNL|/Nasm::X86::Variable::outInDecNL> - Dump the value of a variable on stdout in decimal followed by a new line.
34412  
34413 375 L<Nasm::X86::Variable::outNL|/Nasm::X86::Variable::outNL> - Dump the value of a variable on stdout and append a new line.
34414  
34415 376 L<Nasm::X86::Variable::outRightInBin|/Nasm::X86::Variable::outRightInBin> - Write the specified variable number in binary right justified in a field of specified width to stdout.
34416  
34417 377 L<Nasm::X86::Variable::outRightInBinNL|/Nasm::X86::Variable::outRightInBinNL> - Write the specified variable number in binary right justified in a field of specified width to stdout followed by a new line.
34418  
34419 378 L<Nasm::X86::Variable::outRightInDec|/Nasm::X86::Variable::outRightInDec> - Dump the value of a variable on stdout as a decimal number right adjusted in a field of specified width.
34420  
34421 379 L<Nasm::X86::Variable::outRightInDecNL|/Nasm::X86::Variable::outRightInDecNL> - Dump the value of a variable on stdout as a decimal number right adjusted in a field of specified width followed by a new line.
34422  
34423 380 L<Nasm::X86::Variable::outRightInHex|/Nasm::X86::Variable::outRightInHex> - Write the specified variable number in hexadecimal right justified in a field of specified width to stdout.
34424  
34425 381 L<Nasm::X86::Variable::outRightInHexNL|/Nasm::X86::Variable::outRightInHexNL> - Write the specified variable number in hexadecimal right justified in a field of specified width to stdout followed by a new line.
34426  
34427 382 L<Nasm::X86::Variable::outSpaces|/Nasm::X86::Variable::outSpaces> - Print the specified number of spaces to stdout.
34428  
34429 383 L<Nasm::X86::Variable::plusAssign|/Nasm::X86::Variable::plusAssign> - Implement plus and assign.
34430  
34431 384 L<Nasm::X86::Variable::printErrMemory|/Nasm::X86::Variable::printErrMemory> - Print the specified number of bytes of the memory addressed by the variable on stdout.
34432  
34433 385 L<Nasm::X86::Variable::printErrMemoryInHexNL|/Nasm::X86::Variable::printErrMemoryInHexNL> - Write the memory addressed by a variable to stderr.
34434  
34435 386 L<Nasm::X86::Variable::printErrMemoryNL|/Nasm::X86::Variable::printErrMemoryNL> - Print the specified number of bytes of the memory addressed by the variable on stdout followed by a new line.
34436  
34437 387 L<Nasm::X86::Variable::printMemory|/Nasm::X86::Variable::printMemory> - Print the specified number of bytes from the memory addressed by the variable on the specified channel.
34438  
34439 388 L<Nasm::X86::Variable::printMemoryInHexNL|/Nasm::X86::Variable::printMemoryInHexNL> - Write, in hexadecimal, the memory addressed by a variable to stdout or stderr.
34440  
34441 389 L<Nasm::X86::Variable::printOutMemory|/Nasm::X86::Variable::printOutMemory> - Print the specified number of bytes of the memory addressed by the variable on stdout.
34442  
34443 390 L<Nasm::X86::Variable::printOutMemoryInHexNL|/Nasm::X86::Variable::printOutMemoryInHexNL> - Write the memory addressed by a variable to stdout.
34444  
34445 391 L<Nasm::X86::Variable::printOutMemoryNL|/Nasm::X86::Variable::printOutMemoryNL> - Print the specified number of bytes of the memory addressed by the variable on stdout followed by a new line.
34446  
34447 392 L<Nasm::X86::Variable::putBwdqIntoMm|/Nasm::X86::Variable::putBwdqIntoMm> - Place the value of the content variable at the byte|word|double word|quad word in the numbered zmm register.
34448  
34449 393 L<Nasm::X86::Variable::putWIntoZmm|/Nasm::X86::Variable::putWIntoZmm> - Place the value of the content variable at the word in the numbered zmm register.
34450  
34451 394 L<Nasm::X86::Variable::qFromZ|/Nasm::X86::Variable::qFromZ> - Get the quad word from the numbered zmm register and put it in a variable.
34452  
34453 395 L<Nasm::X86::Variable::qIntoX|/Nasm::X86::Variable::qIntoX> - Place the value of the content variable at the quad word in the numbered xmm register.
34454  
34455 396 L<Nasm::X86::Variable::qIntoZ|/Nasm::X86::Variable::qIntoZ> - Place the value of the content variable at the quad word in the numbered zmm register.
34456  
34457 397 L<Nasm::X86::Variable::rightInBin|/Nasm::X86::Variable::rightInBin> - Write the specified variable number in binary right justified in a field of specified width to the specified channel.
34458  
34459 398 L<Nasm::X86::Variable::rightInDec|/Nasm::X86::Variable::rightInDec> - Dump the value of a variable on the specified channel as a decimal number right adjusted in a field of specified width.
34460  
34461 399 L<Nasm::X86::Variable::rightInHex|/Nasm::X86::Variable::rightInHex> - Write the specified variable number in hexadecimal right justified in a field of specified width to the specified channel.
34462  
34463 400 L<Nasm::X86::Variable::setBit|/Nasm::X86::Variable::setBit> - Set a bit in the specified register retaining the other bits.
34464  
34465 401 L<Nasm::X86::Variable::setMask|/Nasm::X86::Variable::setMask> - Set the mask register to ones starting at the specified position for the specified length and zeroes elsewhere.
34466  
34467 402 L<Nasm::X86::Variable::setMaskBit|/Nasm::X86::Variable::setMaskBit> - Set a bit in the specified mask register retaining the other bits.
34468  
34469 403 L<Nasm::X86::Variable::setMaskFirst|/Nasm::X86::Variable::setMaskFirst> - Set the first bits in the specified mask register.
34470  
34471 404 L<Nasm::X86::Variable::setReg|/Nasm::X86::Variable::setReg> - Set the named registers from the content of the variable.
34472  
34473 405 L<Nasm::X86::Variable::setZmm|/Nasm::X86::Variable::setZmm> - Load bytes from the memory addressed by specified source variable into the numbered zmm register at the offset in the specified offset moving the number of bytes in the specified variable.
34474  
34475 406 L<Nasm::X86::Variable::shiftLeft|/Nasm::X86::Variable::shiftLeft> - Shift the left hand variable left by the number of bits specified in the right hand variable and return the result as a new variable.
34476  
34477 407 L<Nasm::X86::Variable::shiftRight|/Nasm::X86::Variable::shiftRight> - Shift the left hand variable right by the number of bits specified in the right hand variable and return the result as a new variable.
34478  
34479 408 L<Nasm::X86::Variable::spaces|/Nasm::X86::Variable::spaces> - Print the specified number of spaces to the specified channel.
34480  
34481 409 L<Nasm::X86::Variable::str|/Nasm::X86::Variable::str> - The name of the variable.
34482  
34483 410 L<Nasm::X86::Variable::sub|/Nasm::X86::Variable::sub> - Subtract the right hand variable from the left hand variable and return the result as a new variable.
34484  
34485 411 L<Nasm::X86::Variable::times|/Nasm::X86::Variable::times> - Multiply the left hand variable by the right hand variable and return the result as a new variable.
34486  
34487 412 L<Nasm::X86::Variable::update|/Nasm::X86::Variable::update> - Update the content of the addressed variable with the content of the specified variable.
34488  
34489 413 L<Nasm::X86::Variable::wFromZ|/Nasm::X86::Variable::wFromZ> - Get the word from the numbered zmm register and put it in a variable.
34490  
34491 414 L<Nasm::X86::Variable::wIntoX|/Nasm::X86::Variable::wIntoX> - Place the value of the content variable at the word in the numbered xmm register.
34492  
34493 415 L<Nasm::X86::Yggdrasil::SubroutineDefinitions{K key => 2}|/Nasm::X86::Yggdrasil::SubroutineDefinitions{K key => 2}> - Maps the unique string number for a subroutine name to the offset in the are that contains the length (as a dword) followed by the string content of the Perl data structure describing the subroutine in question.
34494  
34495 416 L<Nasm::X86::Yggdrasil::SubroutineOffsets {K key => 1}|/Nasm::X86::Yggdrasil::SubroutineOffsets {K key => 1}> - Translates a string number into the offset of a subroutine in an area.
34496  
34497 417 L<Nasm::X86::Yggdrasil::UniqueStrings {K key => 0}|/Nasm::X86::Yggdrasil::UniqueStrings {K key => 0}> - A tree of strings that assigns unique numbers to strings.
34498  
34499 418 L<Nasm::X86::Yggdrasil::Unisyn::Alphabets {K key => 3}|/Nasm::X86::Yggdrasil::Unisyn::Alphabets {K key => 3}> - Unisyn alphabets.
34500  
34501 419 L<Nasm::X86::Yggdrasil::Unisyn::Close {K key => 5}|/Nasm::X86::Yggdrasil::Unisyn::Close {K key => 5}> - Close bracket to open bracket
34502  
34503 420 L<Nasm::X86::Yggdrasil::Unisyn::Open {K key => 4}|/Nasm::X86::Yggdrasil::Unisyn::Open {K key => 4}> - Open bracket to close bracket
34504  
34505 421 L<Nasm::X86::Yggdrasil::Unisyn::Transitions {K key => 6}|/Nasm::X86::Yggdrasil::Unisyn::Transitions {K key => 6}> - Permissible transitions from alphabet to alphabet
34506  
34507 422 L<numberWithUnderScores|/numberWithUnderScores> - Place underscores in the string representation of a number.
34508  
34509 423 L<onGitHub|/onGitHub> - Whether we are on GitHub or not.
34510  
34511 424 L<OnSegv|/OnSegv> - Request a trace back followed by exit on a B<segv> signal.
34512  
34513 425 L<OpenRead|/OpenRead> - Open a file, whose name is addressed by rax, for read and return the file descriptor in rax.
34514  
34515 426 L<OpenWrite|/OpenWrite> - Create the file named by the terminated string addressed by rax for write.
34516  
34517 427 L<opposingJump|/opposingJump> - Return the opposite of a jump.
34518  
34519 428 L<OptimizePopPush|/OptimizePopPush> - Perform code optimizations.
34520  
34521 429 L<OptimizeReload|/OptimizeReload> - Reload: a = b; b = a; remove second - as redundant.
34522  
34523 430 L<OrBlock|/OrBlock> - Short circuit B<or>: execute a block of code to test conditions which, if one of them is met, leads on to the execution of the pass block, if all of the tests fail we continue withe the test block.
34524  
34525 431 L<ParseUnisyn|/ParseUnisyn> - Parse a string of utf8 characters.
34526  
34527 432 L<Pass|/Pass> - Pass block for an L<OrBlock>.
34528  
34529 433 L<PopR|/PopR> - Pop registers from the stack.
34530  
34531 434 L<PopRR|/PopRR> - Pop registers from the stack without tracking.
34532  
34533 435 L<PrintCString|/PrintCString> - Print a zero terminated C style string addressed by a variable on the specified channel.
34534  
34535 436 L<PrintCStringNL|/PrintCStringNL> - Print a zero terminated C style string addressed by a variable on the specified channel followed by a new line.
34536  
34537 437 L<PrintErrMemory|/PrintErrMemory> - Print the memory addressed by rax for a length of rdi on stderr.
34538  
34539 438 L<PrintErrMemory_InHex|/PrintErrMemory_InHex> - Dump memory from the address in rax for the length in rdi on stderr.
34540  
34541 439 L<PrintErrMemory_InHexNL|/PrintErrMemory_InHexNL> - Dump memory from the address in rax for the length in rdi and then print a new line.
34542  
34543 440 L<PrintErrMemoryInHex|/PrintErrMemoryInHex> - Dump memory from the address in rax for the length in rdi on stderr.
34544  
34545 441 L<PrintErrMemoryInHexNL|/PrintErrMemoryInHexNL> - Dump memory from the address in rax for the length in rdi and then print a new line.
34546  
34547 442 L<PrintErrMemoryNL|/PrintErrMemoryNL> - Print the memory addressed by rax for a length of rdi followed by a new line on stderr.
34548  
34549 443 L<PrintErrNL|/PrintErrNL> - Print a new line to stderr.
34550  
34551 444 L<PrintErrOneRegisterInHex|/PrintErrOneRegisterInHex> - Print the named register as a hex string on stderr.
34552  
34553 445 L<PrintErrOneRegisterInHexNL|/PrintErrOneRegisterInHexNL> - Print the named register as a hex string on stderr followed by new line.
34554  
34555 446 L<PrintErrRax_InHex|/PrintErrRax_InHex> - Write the content of register rax in hexadecimal in big endian notation to stderr.
34556  
34557 447 L<PrintErrRax_InHexNL|/PrintErrRax_InHexNL> - Write the content of register rax in hexadecimal in big endian notation to stderr followed by a new line.
34558  
34559 448 L<PrintErrRaxAsChar|/PrintErrRaxAsChar> - Print the character in rax on stderr.
34560  
34561 449 L<PrintErrRaxAsCharNL|/PrintErrRaxAsCharNL> - Print the character in rax on stderr followed by a new line.
34562  
34563 450 L<PrintErrRaxAsText|/PrintErrRaxAsText> - Print rax as text on stderr.
34564  
34565 451 L<PrintErrRaxAsTextNL|/PrintErrRaxAsTextNL> - Print rax as text on stderr followed by a new line.
34566  
34567 452 L<PrintErrRaxInDec|/PrintErrRaxInDec> - Print rax in decimal on stderr.
34568  
34569 453 L<PrintErrRaxInDecNL|/PrintErrRaxInDecNL> - Print rax in decimal on stderr followed by a new line.
34570  
34571 454 L<PrintErrRaxInHex|/PrintErrRaxInHex> - Write the content of register rax in hexadecimal in big endian notation to stderr.
34572  
34573 455 L<PrintErrRaxInHexNL|/PrintErrRaxInHexNL> - Write the content of register rax in hexadecimal in big endian notation to stderr followed by a new line.
34574  
34575 456 L<PrintErrRegisterInHex|/PrintErrRegisterInHex> - Print the named registers as hex strings on stderr.
34576  
34577 457 L<PrintErrRightInBin|/PrintErrRightInBin> - Write the specified variable in binary right justified in a field of specified width on stderr.
34578  
34579 458 L<PrintErrRightInBinNL|/PrintErrRightInBinNL> - Write the specified variable in binary right justified in a field of specified width on stderr followed by a new line.
34580  
34581 459 L<PrintErrRightInDec|/PrintErrRightInDec> - Print a variable or register in decimal right justified in a field of the specified width on stderr.
34582  
34583 460 L<PrintErrRightInDecNL|/PrintErrRightInDecNL> - Print a variable or register in decimal right justified in a field of the specified width on stderr followed by a new line.
34584  
34585 461 L<PrintErrRightInHex|/PrintErrRightInHex> - Write the specified variable in hexadecimal right justified in a field of specified width on stderr.
34586  
34587 462 L<PrintErrRightInHexNL|/PrintErrRightInHexNL> - Write the specified variable in hexadecimal right justified in a field of specified width on stderr followed by a new line.
34588  
34589 463 L<PrintErrSpace|/PrintErrSpace> - Print a constant number of spaces to stderr.
34590  
34591 464 L<PrintErrString|/PrintErrString> - Print a constant string to stderr.
34592  
34593 465 L<PrintErrStringNL|/PrintErrStringNL> - Print a constant string to stderr followed by a new line.
34594  
34595 466 L<PrintErrTraceBack|/PrintErrTraceBack> - Print sub routine track back on stderr and then exit with a message.
34596  
34597 467 L<PrintErrZF|/PrintErrZF> - Print the zero flag without disturbing it on stderr.
34598  
34599 468 L<PrintMemory|/PrintMemory> - Print the memory addressed by rax for a length of rdi on the specified channel where channel can be a constant number or a register expression using a bound register.
34600  
34601 469 L<PrintMemory_InHex|/PrintMemory_InHex> - Dump memory from the address in rax for the length in rdi on the specified channel.
34602  
34603 470 L<PrintMemoryInHex|/PrintMemoryInHex> - Dump memory from the address in rax for the length in rdi on the specified channel.
34604  
34605 471 L<PrintMemoryNL|/PrintMemoryNL> - Print the memory addressed by rax for a length of rdi on the specified channel followed by a new line.
34606  
34607 472 L<PrintNL|/PrintNL> - Print a new line to stdout or stderr.
34608  
34609 473 L<PrintOneRegisterInHex|/PrintOneRegisterInHex> - Print the named register as a hex string.
34610  
34611 474 L<PrintOutMemory|/PrintOutMemory> - Print the memory addressed by rax for a length of rdi on stdout.
34612  
34613 475 L<PrintOutMemory_InHex|/PrintOutMemory_InHex> - Dump memory from the address in rax for the length in rdi on stdout.
34614  
34615 476 L<PrintOutMemory_InHexNL|/PrintOutMemory_InHexNL> - Dump memory from the address in rax for the length in rdi and then print a new line.
34616  
34617 477 L<PrintOutMemoryInHex|/PrintOutMemoryInHex> - Dump memory from the address in rax for the length in rdi on stdout.
34618  
34619 478 L<PrintOutMemoryInHexNL|/PrintOutMemoryInHexNL> - Dump memory from the address in rax for the length in rdi and then print a new line.
34620  
34621 479 L<PrintOutMemoryNL|/PrintOutMemoryNL> - Print the memory addressed by rax for a length of rdi followed by a new line on stdout.
34622  
34623 480 L<PrintOutNL|/PrintOutNL> - Print a new line to stderr.
34624  
34625 481 L<PrintOutOneRegisterInHex|/PrintOutOneRegisterInHex> - Print the named register as a hex string on stdout.
34626  
34627 482 L<PrintOutOneRegisterInHexNL|/PrintOutOneRegisterInHexNL> - Print the named register as a hex string on stdout followed by new line.
34628  
34629 483 L<PrintOutRax_InHex|/PrintOutRax_InHex> - Write the content of register rax in hexadecimal in big endian notation to stout.
34630  
34631 484 L<PrintOutRax_InHexNL|/PrintOutRax_InHexNL> - Write the content of register rax in hexadecimal in big endian notation to stdout followed by a new line.
34632  
34633 485 L<PrintOutRaxAsChar|/PrintOutRaxAsChar> - Print the character in rax on stdout.
34634  
34635 486 L<PrintOutRaxAsCharNL|/PrintOutRaxAsCharNL> - Print the character in rax on stdout followed by a new line.
34636  
34637 487 L<PrintOutRaxAsText|/PrintOutRaxAsText> - Print rax as text on stdout.
34638  
34639 488 L<PrintOutRaxAsTextNL|/PrintOutRaxAsTextNL> - Print rax as text on stdout followed by a new line.
34640  
34641 489 L<PrintOutRaxInDec|/PrintOutRaxInDec> - Print rax in decimal on stdout.
34642  
34643 490 L<PrintOutRaxInDecNL|/PrintOutRaxInDecNL> - Print rax in decimal on stdout followed by a new line.
34644  
34645 491 L<PrintOutRaxInHex|/PrintOutRaxInHex> - Write the content of register rax in hexadecimal in big endian notation to stout.
34646  
34647 492 L<PrintOutRaxInHexNL|/PrintOutRaxInHexNL> - Write the content of register rax in hexadecimal in big endian notation to stdout followed by a new line.
34648  
34649 493 L<PrintOutRaxInReverseInHex|/PrintOutRaxInReverseInHex> - Write the content of register rax to stderr in hexadecimal in little endian notation.
34650  
34651 494 L<PrintOutRegisterInHex|/PrintOutRegisterInHex> - Print the named registers as hex strings on stdout.
34652  
34653 495 L<PrintOutRegistersInHex|/PrintOutRegistersInHex> - Print the general purpose registers in hex.
34654  
34655 496 L<PrintOutRflagsInHex|/PrintOutRflagsInHex> - Print the flags register in hex.
34656  
34657 497 L<PrintOutRightInBin|/PrintOutRightInBin> - Write the specified variable in binary right justified in a field of specified width on stdout.
34658  
34659 498 L<PrintOutRightInBinNL|/PrintOutRightInBinNL> - Write the specified variable in binary right justified in a field of specified width on stdout followed by a new line.
34660  
34661 499 L<PrintOutRightInDec|/PrintOutRightInDec> - Print a variable or register in decimal right justified in a field of the specified width on stdout.
34662  
34663 500 L<PrintOutRightInDecNL|/PrintOutRightInDecNL> - Print a variable or register in decimal right justified in a field of the specified width on stdout followed by a new line.
34664  
34665 501 L<PrintOutRightInHex|/PrintOutRightInHex> - Write the specified variable in hexadecimal right justified in a field of specified width on stdout.
34666  
34667 502 L<PrintOutRightInHexNL|/PrintOutRightInHexNL> - Write the specified variable in hexadecimal right justified in a field of specified width on stdout followed by a new line.
34668  
34669 503 L<PrintOutRipInHex|/PrintOutRipInHex> - Print the instruction pointer in hex.
34670  
34671 504 L<PrintOutSpace|/PrintOutSpace> - Print a constant number of spaces to stdout.
34672  
34673 505 L<PrintOutString|/PrintOutString> - Print a constant string to stdout.
34674  
34675 506 L<PrintOutStringNL|/PrintOutStringNL> - Print a constant string to stdout followed by a new line.
34676  
34677 507 L<PrintOutTraceBack|/PrintOutTraceBack> - Print sub routine track back on stdout and then exit with a message.
34678  
34679 508 L<PrintOutZF|/PrintOutZF> - Print the zero flag without disturbing it on stdout.
34680  
34681 509 L<PrintRax_InHex|/PrintRax_InHex> - Write the content of register rax in hexadecimal in big endian notation to the specified channel replacing zero bytes with __.
34682  
34683 510 L<PrintRaxAsChar|/PrintRaxAsChar> - Print the ascii character in rax on the specified channel.
34684  
34685 511 L<PrintRaxAsText|/PrintRaxAsText> - Print the string in rax on the specified channel.
34686  
34687 512 L<PrintRaxInDec|/PrintRaxInDec> - Print rax in decimal on the specified channel.
34688  
34689 513 L<PrintRaxInHex|/PrintRaxInHex> - Write the content of register rax in hexadecimal in big endian notation to the specified channel.
34690  
34691 514 L<PrintRaxRightInDec|/PrintRaxRightInDec> - Print rax in decimal right justified in a field of the specified width on the specified channel.
34692  
34693 515 L<PrintRegisterInHex|/PrintRegisterInHex> - Print the named registers as hex strings.
34694  
34695 516 L<PrintRightInBin|/PrintRightInBin> - Print out a number in binary right justified in a field of specified width on the specified channel.
34696  
34697 517 L<PrintRightInDec|/PrintRightInDec> - Print out a number in decimal right justified in a field of specified width on the specified channel.
34698  
34699 518 L<PrintRightInHex|/PrintRightInHex> - Print out a number in hex right justified in a field of specified width on the specified channel.
34700  
34701 519 L<PrintSpace|/PrintSpace> - Print a constant number of spaces to the specified channel.
34702  
34703 520 L<PrintString|/PrintString> - Print a constant string to the specified channel.
34704  
34705 521 L<PrintStringNL|/PrintStringNL> - Print a constant string to the specified channel followed by a new line.
34706  
34707 522 L<PrintTraceBack|/PrintTraceBack> - Trace the call stack.
34708  
34709 523 L<PushR|/PushR> - Push registers onto the stack.
34710  
34711 524 L<PushRR|/PushRR> - Push registers onto the stack without tracking.
34712  
34713 525 L<qFromX|/qFromX> - Get the quad word from the numbered xmm register and return it in a variable.
34714  
34715 526 L<qFromZ|/qFromZ> - Get the quad word from the numbered zmm register and return it in a variable.
34716  
34717 527 L<R|/R> - Define a reference variable.
34718  
34719 528 L<Rb|/Rb> - Layout bytes in the data segment and return their label.
34720  
34721 529 L<Rbwdq|/Rbwdq> - Layout data.
34722  
34723 530 L<Rd|/Rd> - Layout double words in the data segment and return their label.
34724  
34725 531 L<ReadArea|/ReadArea> - Read an area stored in a file into memory and return an area descriptor for the area so created.
34726  
34727 532 L<ReadChar|/ReadChar> - Read a character from stdin and return it in rax else return -1 in rax if no character was read.
34728  
34729 533 L<ReadFile|/ReadFile> - Read a file into memory.
34730  
34731 534 L<ReadInteger|/ReadInteger> - Reads an integer in decimal and returns it in rax.
34732  
34733 535 L<ReadLine|/ReadLine> - Reads up to 8 characters followed by a terminating return and place them into rax.
34734  
34735 536 L<ReadTimeStampCounter|/ReadTimeStampCounter> - Read the time stamp counter and return the time in nanoseconds in rax.
34736  
34737 537 L<registerNameFromNumber|/registerNameFromNumber> - Register name from number where possible.
34738  
34739 538 L<RegisterSize|/RegisterSize> - Return the size of a register.
34740  
34741 539 L<RestoreFirstFour|/RestoreFirstFour> - Restore the first 4 parameter registers.
34742  
34743 540 L<RestoreFirstFourExceptRax|/RestoreFirstFourExceptRax> - Restore the first 4 parameter registers except rax so it can return its value.
34744  
34745 541 L<RestoreFirstSeven|/RestoreFirstSeven> - Restore the first 7 parameter registers.
34746  
34747 542 L<RestoreFirstSevenExceptRax|/RestoreFirstSevenExceptRax> - Restore the first 7 parameter registers except rax which is being used to return the result.
34748  
34749 543 L<Rq|/Rq> - Layout quad words in the data segment and return their label.
34750  
34751 544 L<Rs|/Rs> - Layout bytes in read only memory and return their label.
34752  
34753 545 L<Rutf8|/Rutf8> - Layout a utf8 encoded string as bytes in read only memory and return their label.
34754  
34755 546 L<Rw|/Rw> - Layout words in the data segment and return their label.
34756  
34757 547 L<SaveFirstFour|/SaveFirstFour> - Save the first 4 parameter registers making any parameter registers read only.
34758  
34759 548 L<SaveFirstSeven|/SaveFirstSeven> - Save the first 7 parameter registers.
34760  
34761 549 L<SaveRegIntoMm|/SaveRegIntoMm> - Save the specified register into the numbered zmm at the quad offset specified as a constant number.
34762  
34763 550 L<SetLabel|/SetLabel> - Create (if necessary) and set a label in the code section returning the label so set.
34764  
34765 551 L<SetMaskRegister|/SetMaskRegister> - Set the mask register to ones starting at the specified position for the specified length and zeroes elsewhere.
34766  
34767 552 L<SetZF|/SetZF> - Set the zero flag.
34768  
34769 553 L<sortHashKeysByIntegerValues|/sortHashKeysByIntegerValues> - Sort the keys of a hash whose values are integers by those values returning the keys so sorted as an array.
34770  
34771 554 L<Start|/Start> - Initialize the assembler.
34772  
34773 555 L<StatSize|/StatSize> - Stat a file whose name is addressed by rax to get its size in rax.
34774  
34775 556 L<StringLength|/StringLength> - Length of a zero terminated string.
34776  
34777 557 L<Subroutine|/Subroutine> - Create a subroutine that can be called in assembler code.
34778  
34779 558 L<SubroutineStartStack|/SubroutineStartStack> - Initialize a new stack frame.
34780  
34781 559 L<testParseUnisyn|/testParseUnisyn> - Test the parse of a unisyn expression.
34782  
34783 560 L<Then|/Then> - Then block for an If statement.
34784  
34785 561 L<totalBytesAssembled|/totalBytesAssembled> - Total size in bytes of all files assembled during testing.
34786  
34787 562 L<ToZero|/ToZero> - Iterate a block the number of times specified in the register which is decremented to zero.
34788  
34789 563 L<unlinkFile|/unlinkFile> - Unlink the named file.
34790  
34791 564 L<uptoNTimes|/uptoNTimes> - Execute a block of code up to a constant number of times controlled by the named register.
34792  
34793 565 L<V|/V> - Define a variable.
34794  
34795 566 L<Variable|/Variable> - Create a new variable with the specified name initialized via an optional expression.
34796  
34797 567 L<WaitPid|/WaitPid> - Wait for the pid in rax to complete.
34798  
34799 568 L<wFromX|/wFromX> - Get the word from the numbered xmm register and return it in a variable.
34800  
34801 569 L<wFromZ|/wFromZ> - Get the word from the numbered zmm register and return it in a variable.
34802  
34803 570 L<wRegFromZmm|/wRegFromZmm> - Load the specified register from the word at the specified offset located in the numbered zmm.
34804  
34805 571 L<wRegIntoZmm|/wRegIntoZmm> - Put the specified register into the word in the numbered zmm at the specified offset in the zmm.
34806  
34807 572 L<xmm|/xmm> - Add xmm to the front of a list of register expressions.
34808  
34809 573 L<ymm|/ymm> - Add ymm to the front of a list of register expressions.
34810  
34811 574 L<zmm|/zmm> - Add zmm to the front of a list of register expressions.
34812  
34813 575 L<zmmM|/zmmM> - Add zmm to the front of a register number and a mask after it.
34814  
34815 576 L<zmmMZ|/zmmMZ> - Add zmm to the front of a register number and mask and zero after it.
34816  
34817 =head1 Installation
34818  
34819 This module is written in 100% Pure Perl and, thus, it is easy to read,
34820 comprehend, use, modify and install via B<cpan>:
34821  
34822 sudo cpan install Nasm::X86
34823  
34824 =head1 Author
34825  
34826 L<philiprbrenan@gmail.com|mailto:philiprbrenan@gmail.com>
34827  
34828 L<http://www.appaapps.com|http://www.appaapps.com>
34829  
34830 =head1 Copyright
34831  
34832 Copyright (c) 2016-2021 Philip R Brenan.
34833  
34834 This module is free software. It may be used, redistributed and/or modified
34835 under the same terms as Perl itself.
34836  
34837 =cut
34838  
34839  
34840  
34841 # Tests and documentation
34842  
34843 sub test
34844 0 ▶ {my $p = __PACKAGE__;
Subroutine test: not called CC=5 SCAR=34.0
Pod undocumented
34845 0 binmode($_, ":utf8") for *STDOUT, *STDERR;
34846 0 ▶ return if eval "eof(${p}::DATA)";
Branch: 1 branch
BranchTrueFalseTotal
if eval "eof(${p}::DATA)" 0 0 0
34847 0 my $s = eval "join('', <${p}::DATA>)";
34848 0 ▶ $@ and die $@;
Branch: 1 branch
BranchTrueFalseTotal
$@ and die $@ 0 0 0
34849 0 eval $s;
34850 0 ▶ $@ and die $@;
Branch: 1 branch
BranchTrueFalseTotal
$@ and die $@ 0 0 0
34851 0 1
34852 }
34853  
34854 1 ▶test unless caller;
Branch: 1 branch
BranchTrueFalseTotal
unless caller 0 1 1
34855  
34856 1 1;
34857 # podDocumentation
34858 __DATA__
↑ Summary