1#!/usr/bin/env perl
2# Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
3#
4# Licensed under the Apache License 2.0 (the "License").  You may not use
5# this file except in compliance with the License.  You can obtain a copy
6# in the file LICENSE in the source distribution or at
7# https://www.openssl.org/source/license.html
8
9# Copyright IBM Corp. 2018-2019
10# Author: Patrick Steuer <patrick.steuer@de.ibm.com>
11
12package perlasm::s390x;
13
14use strict;
15use warnings;
16use bigint;
17use Carp qw(confess);
18use Exporter qw(import);
19
20our @EXPORT=qw(PERLASM_BEGIN PERLASM_END);
21our @EXPORT_OK=qw(AUTOLOAD LABEL INCLUDE stfle stck);
22our %EXPORT_TAGS=(
23	# store-clock-fast facility
24	SCF => [qw(stckf)],
25	# general-instruction-extension facility
26	GE => [qw(risbg)],
27	# extended-immediate facility
28	EI => [qw(clfi clgfi lt)],
29	# miscellaneous-instruction-extensions facility 1
30	MI1 => [qw(risbgn)],
31	# message-security assist
32	MSA => [qw(kmac km kmc kimd klmd)],
33	# message-security-assist extension 4
34	MSA4 => [qw(kmf kmo pcc kmctr)],
35	# message-security-assist extension 5
36	MSA5 => [qw(ppno prno)],
37	# message-security-assist extension 8
38	MSA8 => [qw(kma)],
39	# message-security-assist extension 9
40	MSA9 => [qw(kdsa)],
41	# vector facility
42	VX => [qw(vgef vgeg vgbm vzero vone vgm vgmb vgmh vgmf vgmg
43	    vl vlr vlrep vlrepb vlreph vlrepf vlrepg vleb vleh vlef vleg vleib
44	    vleih vleif vleig vlgv vlgvb vlgvh vlgvf vlgvg vllez vllezb vllezh
45	    vllezf vllezg vlm vlbb vlvg vlvgb vlvgh vlvgf vlvgg vlvgp
46	    vll vmrh vmrhb vmrhh vmrhf vmrhg vmrl vmrlb vmrlh vmrlf vmrlg vpk
47	    vpkh vpkf vpkg vpks vpksh vpksf vpksg vpkshs vpksfs vpksgs vpkls
48	    vpklsh vpklsf vpklsg vpklshs vpklsfs vpklsgs vperm vpdi vrep vrepb
49	    vreph vrepf vrepg vrepi vrepib vrepih vrepif vrepig vscef vsceg
50	    vsel vseg vsegb vsegh vsegf vst vsteb vsteh vstef vsteg vstm vstl
51	    vuph vuphb vuphh vuphf vuplh vuplhb vuplhh vuplhf vupl vuplb vuplhw
52	    vuplf vupll vupllb vupllh vupllf va vab vah vaf vag vaq vacc vaccb
53	    vacch vaccf vaccg vaccq vac vacq vaccc vacccq vn vnc vavg vavgb
54	    vavgh vavgf vavgg vavgl vavglb vavglh vavglf vavglg vcksm vec_ vecb
55	    vech vecf vecg vecl veclb veclh veclf veclg vceq vceqb vceqh vceqf
56	    vceqg vceqbs vceqhs vceqfs vceqgs vch vchb vchh vchf vchg vchbs
57	    vchhs vchfs vchgs vchl vchlb vchlh vchlf vchlg vchlbs vchlhs vchlfs
58	    vchlgs vclz vclzb vclzh vclzf vclzg vctz vctzb vctzh vctzf vctzg
59	    vx vgfm vgfmb vgfmh vgfmf vgfmg vgfma vgfmab vgfmah vgfmaf vgfmag
60	    vlc vlcb vlch vlcf vlcg vlp vlpb vlph vlpf vlpg vmx vmxb vmxh vmxf
61	    vmxg vmxl vmxlb vmxlh vmxlf vmxlg vmn vmnb vmnh vmnf vmng vmnl
62	    vmnlb vmnlh vmnlf vmnlg vmal vmalb vmalhw vmalf vmah vmahb vmahh
63	    vmahf vmalh vmalhb vmalhh vmalhf vmae vmaeb vmaeh vmaef vmale
64	    vmaleb vmaleh vmalef vmao vmaob vmaoh vmaof vmalo vmalob vmaloh
65	    vmalof vmh vmhb vmhh vmhf vmlh vmlhb vmlhh vmlhf vml vmlb vmlhw
66	    vmlf vme vmeb vmeh vmef vmle vmleb vmleh vmlef vmo vmob vmoh vmof
67	    vmlo vmlob vmloh vmlof vno vnot vo vpopct verllv verllvb verllvh
68	    verllvf verllvg verll verllb verllh verllf verllg verim verimb
69	    verimh verimf verimg veslv veslvb veslvh veslvf veslvg vesl veslb
70	    veslh veslf veslg vesrav vesravb vesravh vesravf vesravg vesra
71	    vesrab vesrah vesraf vesrag vesrlv vesrlvb vesrlvh vesrlvf vesrlvg
72	    vesrl vesrlb vesrlh vesrlf vesrlg vsl vslb vsldb vsra vsrab vsrl
73	    vsrlb vs vsb vsh vsf vsg vsq vscbi vscbib vscbih vscbif vscbig
74	    vscbiq vsbi vsbiq vsbcbi vsbcbiq vsumg vsumgh vsumgf vsumq vsumqf
75	    vsumqg vsum vsumb vsumh vtm vfae vfaeb vfaeh vfaef vfaebs vfaehs
76	    vfaefs vfaezb vfaezh vfaezf vfaezbs vfaezhs vfaezfs vfee vfeeb
77	    vfeeh vfeef vfeebs vfeehs vfeefs vfeezb vfeezh vfeezf vfeezbs
78	    vfeezhs vfeezfs vfene vfeneb vfeneh vfenef vfenebs vfenehs vfenefs
79	    vfenezb vfenezh vfenezf vfenezbs vfenezhs vfenezfs vistr vistrb
80	    vistrh vistrf vistrbs vistrhs vistrfs vstrc vstrcb vstrch vstrcf
81	    vstrcbs vstrchs vstrcfs vstrczb vstrczh vstrczf vstrczbs vstrczhs
82	    vstrczfs vfa vfadb wfadb wfc wfcdb wfk wfkdb vfce vfcedb wfcedb
83	    vfcedbs wfcedbs vfch vfchdb wfchdb vfchdbs wfchdbs vfche vfchedb
84	    wfchedb vfchedbs wfchedbs vcdg vcdgb wcdgb vcdlg vcdlgb wcdlgb vcgd
85	    vcgdb wcgdb vclgd vclgdb wclgdb vfd vfddb wfddb vfi vfidb wfidb
86	    vlde vldeb wldeb vled vledb wledb vfm vfmdb wfmdb vfma vfmadb
87	    wfmadb vfms vfmsdb wfmsdb vfpso vfpsodb wfpsodb vflcdb wflcdb
88	    vflndb wflndb vflpdb wflpdb vfsq vfsqdb wfsqdb vfs vfsdb wfsdb
89	    vftci vftcidb wftcidb)],
90	# vector-enhancements facility 1
91	VXE => [qw(vbperm vllezlf vmsl vmslg vnx vnn voc vpopctb vpopcth
92	    vpopctf vpopctg vfasb wfasb wfaxb wfcsb wfcxb wfksb wfkxb vfcesb
93	    vfcesbs wfcesb wfcesbs wfcexb wfcexbs vfchsb vfchsbs wfchsb wfchsbs
94	    wfchxb wfchxbs vfchesb vfchesbs wfchesb wfchesbs wfchexb wfchexbs
95	    vfdsb wfdsb wfdxb vfisb wfisb wfixb vfll vflls wflls wflld vflr
96	    vflrd wflrd wflrx vfmax vfmaxsb vfmaxdb wfmaxsb wfmaxdb wfmaxxb
97	    vfmin vfminsb vfmindb wfminsb wfmindb wfminxb vfmsb wfmsb wfmxb
98	    vfnma vfnms vfmasb wfmasb wfmaxb vfmssb wfmssb wfmsxb vfnmasb
99	    vfnmadb wfnmasb wfnmadb wfnmaxb vfnmssb vfnmsdb wfnmssb wfnmsdb
100	    wfnmsxb vfpsosb wfpsosb vflcsb wflcsb vflnsb wflnsb vflpsb wflpsb
101	    vfpsoxb wfpsoxb vflcxb wflcxb vflnxb wflnxb vflpxb wflpxb vfsqsb
102	    wfsqsb wfsqxb vfssb wfssb wfsxb vftcisb wftcisb wftcixb)],
103	# vector-packed-decimal facility
104	VXD => [qw(vlrlr vlrl vstrlr vstrl vap vcp vcvb vcvbg vcvd vcvdg vdp
105	    vlip vmp vmsp vpkz vpsop vrp vsdp vsrp vsp vtp vupkz)],
106);
107Exporter::export_ok_tags(qw(SCF GE EI MI1 MSA MSA4 MSA5 MSA8 MSA9 VX VXE VXD));
108
109our $AUTOLOAD;
110
111my $GR='(?:%r)?([0-9]|1[0-5])';
112my $VR='(?:%v)?([0-9]|1[0-9]|2[0-9]|3[0-1])';
113
114my ($file,$out);
115
116sub PERLASM_BEGIN
117{
118	($file,$out)=(shift,"");
119}
120sub PERLASM_END
121{
122	if (defined($file)) {
123		open(my $fd,'>',$file)||die("can't open $file: $!");
124		print({$fd}$out);
125		close($fd);
126	} else {
127		print($out);
128	}
129}
130
131sub AUTOLOAD {
132	confess(err("PARSE")) if (grep(!defined($_),@_));
133	my $token;
134	for ($AUTOLOAD) {
135		$token=lc(".$1") if (/^.*::([A-Z_]+)$/);# uppercase: directive
136		$token="\t$1" if (/^.*::([a-z]+)$/);	# lowercase: mnemonic
137		confess(err("PARSE")) if (!defined($token));
138	}
139	$token.="\t" if ($#_>=0);
140	$out.=$token.join(',',@_)."\n";
141}
142
143sub LABEL {						# label directive
144	confess(err("ARGNUM")) if ($#_!=0);
145	my ($label)=@_;
146	$out.="$label:\n";
147}
148
149sub INCLUDE {
150	confess(err("ARGNUM")) if ($#_!=0);
151	my ($file)=@_;
152	$out.="#include \"$file\"\n";
153}
154
155#
156# Mnemonics
157#
158
159sub stfle {
160	confess(err("ARGNUM")) if ($#_!=0);
161	S(0xb2b0,@_);
162}
163
164sub stck {
165	confess(err("ARGNUM")) if ($#_!=0);
166	S(0xb205,@_);
167}
168
169# store-clock-fast facility
170
171sub stckf {
172	confess(err("ARGNUM")) if ($#_!=0);
173	S(0xb27c,@_);
174}
175
176# extended-immediate facility
177
178sub clfi {
179	confess(err("ARGNUM")) if ($#_!=1);
180	RILa(0xc2f,@_);
181}
182
183sub clgfi {
184	confess(err("ARGNUM")) if ($#_!=1);
185	RILa(0xc2e,@_);
186}
187
188sub lt {
189	confess(err("ARGNUM")) if ($#_!=1);
190	RXYa(0xe312,@_);
191}
192
193# general-instruction-extension facility
194
195sub risbg {
196	confess(err("ARGNUM")) if ($#_<3||$#_>4);
197	RIEf(0xec55,@_);
198}
199
200# miscellaneous-instruction-extensions facility 1
201
202sub risbgn {
203	confess(err("ARGNUM")) if ($#_<3||$#_>4);
204	RIEf(0xec59,@_);
205}
206
207# MSA
208
209sub kmac {
210	confess(err("ARGNUM")) if ($#_!=1);
211	RRE(0xb91e,@_);
212}
213
214sub km {
215	confess(err("ARGNUM")) if ($#_!=1);
216	RRE(0xb92e,@_);
217}
218
219sub kmc {
220	confess(err("ARGNUM")) if ($#_!=1);
221	RRE(0xb92f,@_);
222}
223
224sub kimd {
225	confess(err("ARGNUM")) if ($#_!=1);
226	RRE(0xb93e,@_);
227}
228
229sub klmd {
230	confess(err("ARGNUM")) if ($#_!=1);
231	RRE(0xb93f,@_);
232}
233
234# MSA4
235
236sub kmf {
237	confess(err("ARGNUM")) if ($#_!=1);
238	RRE(0xb92a,@_);
239}
240
241sub kmo {
242	confess(err("ARGNUM")) if ($#_!=1);
243	RRE(0xb92b,@_);
244}
245
246sub pcc {
247	confess(err("ARGNUM")) if ($#_!=-1);
248	RRE(0xb92c,@_);
249}
250
251sub kmctr {
252	confess(err("ARGNUM")) if ($#_!=2);
253	RRFb(0xb92d,@_);
254}
255
256# MSA5
257
258sub prno {
259	ppno(@_);
260}
261
262sub ppno {						# deprecated, use prno
263	confess(err("ARGNUM")) if ($#_!=1);
264	RRE(0xb93c,@_);
265}
266
267# MSA8
268
269sub kma {
270	confess(err("ARGNUM")) if ($#_!=2);
271	RRFb(0xb929,@_);
272}
273
274# MSA9
275
276sub kdsa {
277	confess(err("ARGNUM")) if ($#_!=1);
278	RRE(0xb93a,@_);
279}
280
281# VX - Support Instructions
282
283sub vgef {
284	confess(err("ARGNUM")) if ($#_!=2);
285	VRV(0xe713,@_);
286}
287sub vgeg {
288	confess(err("ARGNUM")) if ($#_!=2);
289	VRV(0xe712,@_);
290}
291
292sub vgbm {
293	confess(err("ARGNUM")) if ($#_!=1);
294	VRIa(0xe744,@_);
295}
296sub vzero {
297	vgbm(@_,0);
298}
299sub vone {
300	vgbm(@_,0xffff);
301}
302
303sub vgm {
304	confess(err("ARGNUM")) if ($#_!=3);
305	VRIb(0xe746,@_);
306}
307sub vgmb {
308	vgm(@_,0);
309}
310sub vgmh {
311	vgm(@_,1);
312}
313sub vgmf {
314	vgm(@_,2);
315}
316sub vgmg {
317	vgm(@_,3);
318}
319
320sub vl {
321	confess(err("ARGNUM")) if ($#_<1||$#_>2);
322	VRX(0xe706,@_);
323}
324
325sub vlr {
326	confess(err("ARGNUM")) if ($#_!=1);
327	VRRa(0xe756,@_);
328}
329
330sub vlrep {
331	confess(err("ARGNUM")) if ($#_!=2);
332	VRX(0xe705,@_);
333}
334sub vlrepb {
335	vlrep(@_,0);
336}
337sub vlreph {
338	vlrep(@_,1);
339}
340sub vlrepf {
341	vlrep(@_,2);
342}
343sub vlrepg {
344	vlrep(@_,3);
345}
346
347sub vleb {
348	confess(err("ARGNUM")) if ($#_!=2);
349	VRX(0xe700,@_);
350}
351sub vleh {
352	confess(err("ARGNUM")) if ($#_!=2);
353	VRX(0xe701,@_);
354}
355sub vlef {
356	confess(err("ARGNUM")) if ($#_!=2);
357	VRX(0xe703,@_);
358}
359sub vleg {
360	confess(err("ARGNUM")) if ($#_!=2);
361	VRX(0xe702,@_);
362}
363
364sub vleib {
365	confess(err("ARGNUM")) if ($#_!=2);
366	VRIa(0xe740,@_);
367}
368sub vleih {
369	confess(err("ARGNUM")) if ($#_!=2);
370	VRIa(0xe741,@_);
371}
372sub vleif {
373	confess(err("ARGNUM")) if ($#_!=2);
374	VRIa(0xe743,@_);
375}
376sub vleig {
377	confess(err("ARGNUM")) if ($#_!=2);
378	VRIa(0xe742,@_);
379}
380
381sub vlgv {
382	confess(err("ARGNUM")) if ($#_!=3);
383	VRSc(0xe721,@_);
384}
385sub vlgvb {
386	vlgv(@_,0);
387}
388sub vlgvh {
389	vlgv(@_,1);
390}
391sub vlgvf {
392	vlgv(@_,2);
393}
394sub vlgvg {
395	vlgv(@_,3);
396}
397
398sub vllez {
399	confess(err("ARGNUM")) if ($#_!=2);
400	VRX(0xe704,@_);
401}
402sub vllezb {
403	vllez(@_,0);
404}
405sub vllezh {
406	vllez(@_,1);
407}
408sub vllezf {
409	vllez(@_,2);
410}
411sub vllezg {
412	vllez(@_,3);
413}
414
415sub vlm {
416	confess(err("ARGNUM")) if ($#_<2||$#_>3);
417	VRSa(0xe736,@_);
418}
419
420sub vlbb {
421	confess(err("ARGNUM")) if ($#_!=2);
422	VRX(0xe707,@_);
423}
424
425sub vlvg {
426	confess(err("ARGNUM")) if ($#_!=3);
427	VRSb(0xe722,@_);
428}
429sub vlvgb {
430	vlvg(@_,0);
431}
432sub vlvgh {
433	vlvg(@_,1);
434}
435sub vlvgf {
436	vlvg(@_,2);
437}
438sub vlvgg {
439	vlvg(@_,3);
440}
441
442sub vlvgp {
443	confess(err("ARGNUM")) if ($#_!=2);
444	VRRf(0xe762,@_);
445}
446
447sub vll {
448	confess(err("ARGNUM")) if ($#_!=2);
449	VRSb(0xe737,@_);
450}
451
452sub vmrh {
453	confess(err("ARGNUM")) if ($#_!=3);
454	VRRc(0xe761,@_);
455}
456sub vmrhb {
457	vmrh(@_,0);
458}
459sub vmrhh {
460	vmrh(@_,1);
461}
462sub vmrhf {
463	vmrh(@_,2);
464}
465sub vmrhg {
466	vmrh(@_,3);
467}
468
469sub vmrl {
470	confess(err("ARGNUM")) if ($#_!=3);
471	VRRc(0xe760,@_);
472}
473sub vmrlb {
474	vmrl(@_,0);
475}
476sub vmrlh {
477	vmrl(@_,1);
478}
479sub vmrlf {
480	vmrl(@_,2);
481}
482sub vmrlg {
483	vmrl(@_,3);
484}
485
486sub vpk {
487	confess(err("ARGNUM")) if ($#_!=3);
488	VRRc(0xe794,@_);
489}
490sub vpkh {
491	vpk(@_,1);
492}
493sub vpkf {
494	vpk(@_,2);
495}
496sub vpkg {
497	vpk(@_,3);
498}
499
500sub vpks {
501	confess(err("ARGNUM")) if ($#_!=4);
502	VRRb(0xe797,@_);
503}
504sub vpksh {
505	vpks(@_,1,0);
506}
507sub vpksf {
508	vpks(@_,2,0);
509}
510sub vpksg {
511	vpks(@_,3,0);
512}
513sub vpkshs {
514	vpks(@_,1,1);
515}
516sub vpksfs {
517	vpks(@_,2,1);
518}
519sub vpksgs {
520	vpks(@_,3,1);
521}
522
523sub vpkls {
524	confess(err("ARGNUM")) if ($#_!=4);
525	VRRb(0xe795,@_);
526}
527sub vpklsh {
528	vpkls(@_,1,0);
529}
530sub vpklsf {
531	vpkls(@_,2,0);
532}
533sub vpklsg {
534	vpkls(@_,3,0);
535}
536sub vpklshs {
537	vpkls(@_,1,1);
538}
539sub vpklsfs {
540	vpkls(@_,2,1);
541}
542sub vpklsgs {
543	vpkls(@_,3,1);
544}
545
546sub vperm {
547	confess(err("ARGNUM")) if ($#_!=3);
548	VRRe(0xe78c,@_);
549}
550
551sub vpdi {
552	confess(err("ARGNUM")) if ($#_!=3);
553	VRRc(0xe784,@_);
554}
555
556sub vrep {
557	confess(err("ARGNUM")) if ($#_!=3);
558	VRIc(0xe74d,@_);
559}
560sub vrepb {
561	vrep(@_,0);
562}
563sub vreph {
564	vrep(@_,1);
565}
566sub vrepf {
567	vrep(@_,2);
568}
569sub vrepg {
570	vrep(@_,3);
571}
572
573sub vrepi {
574	confess(err("ARGNUM")) if ($#_!=2);
575	VRIa(0xe745,@_);
576}
577sub vrepib {
578	vrepi(@_,0);
579}
580sub vrepih {
581	vrepi(@_,1);
582}
583sub vrepif {
584	vrepi(@_,2);
585}
586sub vrepig {
587	vrepi(@_,3);
588}
589
590sub vscef {
591	confess(err("ARGNUM")) if ($#_!=2);
592	VRV(0xe71b,@_);
593}
594sub vsceg {
595	confess(err("ARGNUM")) if ($#_!=2);
596	VRV(0xe71a,@_);
597}
598
599sub vsel {
600	confess(err("ARGNUM")) if ($#_!=3);
601	VRRe(0xe78d,@_);
602}
603
604sub vseg {
605	confess(err("ARGNUM")) if ($#_!=2);
606	VRRa(0xe75f,@_);
607}
608sub vsegb {
609	vseg(@_,0);
610}
611sub vsegh {
612	vseg(@_,1);
613}
614sub vsegf {
615	vseg(@_,2);
616}
617
618sub vst {
619	confess(err("ARGNUM")) if ($#_<1||$#_>2);
620	VRX(0xe70e,@_);
621}
622
623sub vsteb {
624	confess(err("ARGNUM")) if ($#_!=2);
625	VRX(0xe708,@_);
626}
627sub vsteh {
628	confess(err("ARGNUM")) if ($#_!=2);
629	VRX(0xe709,@_);
630}
631sub vstef {
632	confess(err("ARGNUM")) if ($#_!=2);
633	VRX(0xe70b,@_);
634}
635sub vsteg {
636	confess(err("ARGNUM")) if ($#_!=2);
637	VRX(0xe70a,@_);
638}
639
640sub vstm {
641	confess(err("ARGNUM")) if ($#_<2||$#_>3);
642	VRSa(0xe73e,@_);
643}
644
645sub vstl {
646	confess(err("ARGNUM")) if ($#_!=2);
647	VRSb(0xe73f,@_);
648}
649
650sub vuph {
651	confess(err("ARGNUM")) if ($#_!=2);
652	VRRa(0xe7d7,@_);
653}
654sub vuphb {
655	vuph(@_,0);
656}
657sub vuphh {
658	vuph(@_,1);
659}
660sub vuphf {
661	vuph(@_,2);
662}
663
664sub vuplh {
665	confess(err("ARGNUM")) if ($#_!=2);
666	VRRa(0xe7d5,@_);
667}
668sub vuplhb {
669	vuplh(@_,0);
670}
671sub vuplhh {
672	vuplh(@_,1);
673}
674sub vuplhf {
675	vuplh(@_,2);
676}
677
678sub vupl {
679	confess(err("ARGNUM")) if ($#_!=2);
680	VRRa(0xe7d6,@_);
681}
682sub vuplb {
683	vupl(@_,0);
684}
685sub vuplhw {
686	vupl(@_,1);
687}
688sub vuplf {
689	vupl(@_,2);
690}
691
692sub vupll {
693	confess(err("ARGNUM")) if ($#_!=2);
694	VRRa(0xe7d4,@_);
695}
696sub vupllb {
697	vupll(@_,0);
698}
699sub vupllh {
700	vupll(@_,1);
701}
702sub vupllf {
703	vupll(@_,2);
704}
705
706# VX - Integer Instructions
707
708sub va {
709	confess(err("ARGNUM")) if ($#_!=3);
710	VRRc(0xe7f3,@_);
711}
712sub vab {
713	va(@_,0);
714}
715sub vah {
716	va(@_,1);
717}
718sub vaf {
719	va(@_,2);
720}
721sub vag {
722	va(@_,3);
723}
724sub vaq {
725	va(@_,4);
726}
727
728sub vacc {
729	confess(err("ARGNUM")) if ($#_!=3);
730	VRRc(0xe7f1,@_);
731}
732sub vaccb {
733	vacc(@_,0);
734}
735sub vacch {
736	vacc(@_,1);
737}
738sub vaccf {
739	vacc(@_,2);
740}
741sub vaccg {
742	vacc(@_,3);
743}
744sub vaccq {
745	vacc(@_,4);
746}
747
748sub vac {
749	confess(err("ARGNUM")) if ($#_!=4);
750	VRRd(0xe7bb,@_);
751}
752sub vacq {
753	vac(@_,4);
754}
755
756sub vaccc {
757	confess(err("ARGNUM")) if ($#_!=4);
758	VRRd(0xe7b9,@_);
759}
760sub vacccq {
761	vaccc(@_,4);
762}
763
764sub vn {
765	confess(err("ARGNUM")) if ($#_!=2);
766	VRRc(0xe768,@_);
767}
768
769sub vnc {
770	confess(err("ARGNUM")) if ($#_!=2);
771	VRRc(0xe769,@_);
772}
773
774sub vavg {
775	confess(err("ARGNUM")) if ($#_!=3);
776	VRRc(0xe7f2,@_);
777}
778sub vavgb {
779	vavg(@_,0);
780}
781sub vavgh {
782	vavg(@_,1);
783}
784sub vavgf {
785	vavg(@_,2);
786}
787sub vavgg {
788	vavg(@_,3);
789}
790
791sub vavgl {
792	confess(err("ARGNUM")) if ($#_!=3);
793	VRRc(0xe7f0,@_);
794}
795sub vavglb {
796	vavgl(@_,0);
797}
798sub vavglh {
799	vavgl(@_,1);
800}
801sub vavglf {
802	vavgl(@_,2);
803}
804sub vavglg {
805	vavgl(@_,3);
806}
807
808sub vcksm {
809	confess(err("ARGNUM")) if ($#_!=2);
810	VRRc(0xe766,@_);
811}
812
813sub vec_ {
814	confess(err("ARGNUM")) if ($#_!=2);
815	VRRa(0xe7db,@_);
816}
817sub vecb {
818	vec_(@_,0);
819}
820sub vech {
821	vec_(@_,1);
822}
823sub vecf {
824	vec_(@_,2);
825}
826sub vecg {
827	vec_(@_,3);
828}
829
830sub vecl {
831	confess(err("ARGNUM")) if ($#_!=2);
832	VRRa(0xe7d9,@_);
833}
834sub veclb {
835	vecl(@_,0);
836}
837sub veclh {
838	vecl(@_,1);
839}
840sub veclf {
841	vecl(@_,2);
842}
843sub veclg {
844	vecl(@_,3);
845}
846
847sub vceq {
848	confess(err("ARGNUM")) if ($#_!=4);
849	VRRb(0xe7f8,@_);
850}
851sub vceqb {
852	vceq(@_,0,0);
853}
854sub vceqh {
855	vceq(@_,1,0);
856}
857sub vceqf {
858	vceq(@_,2,0);
859}
860sub vceqg {
861	vceq(@_,3,0);
862}
863sub vceqbs {
864	vceq(@_,0,1);
865}
866sub vceqhs {
867	vceq(@_,1,1);
868}
869sub vceqfs {
870	vceq(@_,2,1);
871}
872sub vceqgs {
873	vceq(@_,3,1);
874}
875
876sub vch {
877	confess(err("ARGNUM")) if ($#_!=4);
878	VRRb(0xe7fb,@_);
879}
880sub vchb {
881	vch(@_,0,0);
882}
883sub vchh {
884	vch(@_,1,0);
885}
886sub vchf {
887	vch(@_,2,0);
888}
889sub vchg {
890	vch(@_,3,0);
891}
892sub vchbs {
893	vch(@_,0,1);
894}
895sub vchhs {
896	vch(@_,1,1);
897}
898sub vchfs {
899	vch(@_,2,1);
900}
901sub vchgs {
902	vch(@_,3,1);
903}
904
905sub vchl {
906	confess(err("ARGNUM")) if ($#_!=4);
907	VRRb(0xe7f9,@_);
908}
909sub vchlb {
910	vchl(@_,0,0);
911}
912sub vchlh {
913	vchl(@_,1,0);
914}
915sub vchlf {
916	vchl(@_,2,0);
917}
918sub vchlg {
919	vchl(@_,3,0);
920}
921sub vchlbs {
922	vchl(@_,0,1);
923}
924sub vchlhs {
925	vchl(@_,1,1);
926}
927sub vchlfs {
928	vchl(@_,2,1);
929}
930sub vchlgs {
931	vchl(@_,3,1);
932}
933
934sub vclz {
935	confess(err("ARGNUM")) if ($#_!=2);
936	VRRa(0xe753,@_);
937}
938sub vclzb {
939	vclz(@_,0);
940}
941sub vclzh {
942	vclz(@_,1);
943}
944sub vclzf {
945	vclz(@_,2);
946}
947sub vclzg {
948	vclz(@_,3);
949}
950
951sub vctz {
952	confess(err("ARGNUM")) if ($#_!=2);
953	VRRa(0xe752,@_);
954}
955sub vctzb {
956	vctz(@_,0);
957}
958sub vctzh {
959	vctz(@_,1);
960}
961sub vctzf {
962	vctz(@_,2);
963}
964sub vctzg {
965	vctz(@_,3);
966}
967
968sub vx {
969	confess(err("ARGNUM")) if ($#_!=2);
970	VRRc(0xe76d,@_);
971}
972
973sub vgfm {
974	confess(err("ARGNUM")) if ($#_!=3);
975	VRRc(0xe7b4,@_);
976}
977sub vgfmb {
978	vgfm(@_,0);
979}
980sub vgfmh {
981	vgfm(@_,1);
982}
983sub vgfmf {
984	vgfm(@_,2);
985}
986sub vgfmg {
987	vgfm(@_,3);
988}
989
990sub vgfma {
991	confess(err("ARGNUM")) if ($#_!=4);
992	VRRd(0xe7bc,@_);
993}
994sub vgfmab {
995	vgfma(@_,0);
996}
997sub vgfmah {
998	vgfma(@_,1);
999}
1000sub vgfmaf {
1001	vgfma(@_,2);
1002}
1003sub vgfmag {
1004	vgfma(@_,3);
1005}
1006
1007sub vlc {
1008	confess(err("ARGNUM")) if ($#_!=2);
1009	VRRa(0xe7de,@_);
1010}
1011sub vlcb {
1012	vlc(@_,0);
1013}
1014sub vlch {
1015	vlc(@_,1);
1016}
1017sub vlcf {
1018	vlc(@_,2);
1019}
1020sub vlcg {
1021	vlc(@_,3);
1022}
1023
1024sub vlp {
1025	confess(err("ARGNUM")) if ($#_!=2);
1026	VRRa(0xe7df,@_);
1027}
1028sub vlpb {
1029	vlp(@_,0);
1030}
1031sub vlph {
1032	vlp(@_,1);
1033}
1034sub vlpf {
1035	vlp(@_,2);
1036}
1037sub vlpg {
1038	vlp(@_,3);
1039}
1040
1041sub vmx {
1042	confess(err("ARGNUM")) if ($#_!=3);
1043	VRRc(0xe7ff,@_);
1044}
1045sub vmxb {
1046	vmx(@_,0);
1047}
1048sub vmxh {
1049	vmx(@_,1);
1050}
1051sub vmxf {
1052	vmx(@_,2);
1053}
1054sub vmxg {
1055	vmx(@_,3);
1056}
1057
1058sub vmxl {
1059	confess(err("ARGNUM")) if ($#_!=3);
1060	VRRc(0xe7fd,@_);
1061}
1062sub vmxlb {
1063	vmxl(@_,0);
1064}
1065sub vmxlh {
1066	vmxl(@_,1);
1067}
1068sub vmxlf {
1069	vmxl(@_,2);
1070}
1071sub vmxlg {
1072	vmxl(@_,3);
1073}
1074
1075sub vmn {
1076	confess(err("ARGNUM")) if ($#_!=3);
1077	VRRc(0xe7fe,@_);
1078}
1079sub vmnb {
1080	vmn(@_,0);
1081}
1082sub vmnh {
1083	vmn(@_,1);
1084}
1085sub vmnf {
1086	vmn(@_,2);
1087}
1088sub vmng {
1089	vmn(@_,3);
1090}
1091
1092sub vmnl {
1093	confess(err("ARGNUM")) if ($#_!=3);
1094	VRRc(0xe7fc,@_);
1095}
1096sub vmnlb {
1097	vmnl(@_,0);
1098}
1099sub vmnlh {
1100	vmnl(@_,1);
1101}
1102sub vmnlf {
1103	vmnl(@_,2);
1104}
1105sub vmnlg {
1106	vmnl(@_,3);
1107}
1108
1109sub vmal {
1110	confess(err("ARGNUM")) if ($#_!=4);
1111	VRRd(0xe7aa,@_);
1112}
1113sub vmalb {
1114	vmal(@_,0);
1115}
1116sub vmalhw {
1117	vmal(@_,1);
1118}
1119sub vmalf {
1120	vmal(@_,2);
1121}
1122
1123sub vmah {
1124	confess(err("ARGNUM")) if ($#_!=4);
1125	VRRd(0xe7ab,@_);
1126}
1127sub vmahb {
1128	vmah(@_,0);
1129}
1130sub vmahh {
1131	vmah(@_,1);
1132}
1133sub vmahf {
1134	vmah(@_,2);
1135}
1136
1137sub vmalh {
1138	confess(err("ARGNUM")) if ($#_!=4);
1139	VRRd(0xe7a9,@_);
1140}
1141sub vmalhb {
1142	vmalh(@_,0);
1143}
1144sub vmalhh {
1145	vmalh(@_,1);
1146}
1147sub vmalhf {
1148	vmalh(@_,2);
1149}
1150
1151sub vmae {
1152	confess(err("ARGNUM")) if ($#_!=4);
1153	VRRd(0xe7ae,@_);
1154}
1155sub vmaeb {
1156	vmae(@_,0);
1157}
1158sub vmaeh {
1159	vmae(@_,1);
1160}
1161sub vmaef {
1162	vmae(@_,2);
1163}
1164
1165sub vmale {
1166	confess(err("ARGNUM")) if ($#_!=4);
1167	VRRd(0xe7ac,@_);
1168}
1169sub vmaleb {
1170	vmale(@_,0);
1171}
1172sub vmaleh {
1173	vmale(@_,1);
1174}
1175sub vmalef {
1176	vmale(@_,2);
1177}
1178
1179sub vmao {
1180	confess(err("ARGNUM")) if ($#_!=4);
1181	VRRd(0xe7af,@_);
1182}
1183sub vmaob {
1184	vmao(@_,0);
1185}
1186sub vmaoh {
1187	vmao(@_,1);
1188}
1189sub vmaof {
1190	vmao(@_,2);
1191}
1192
1193sub vmalo {
1194	confess(err("ARGNUM")) if ($#_!=4);
1195	VRRd(0xe7ad,@_);
1196}
1197sub vmalob {
1198	vmalo(@_,0);
1199}
1200sub vmaloh {
1201	vmalo(@_,1);
1202}
1203sub vmalof {
1204	vmalo(@_,2);
1205}
1206
1207sub vmh {
1208	confess(err("ARGNUM")) if ($#_!=3);
1209	VRRc(0xe7a3,@_);
1210}
1211sub vmhb {
1212	vmh(@_,0);
1213}
1214sub vmhh {
1215	vmh(@_,1);
1216}
1217sub vmhf {
1218	vmh(@_,2);
1219}
1220
1221sub vmlh {
1222	confess(err("ARGNUM")) if ($#_!=3);
1223	VRRc(0xe7a1,@_);
1224}
1225sub vmlhb {
1226	vmlh(@_,0);
1227}
1228sub vmlhh {
1229	vmlh(@_,1);
1230}
1231sub vmlhf {
1232	vmlh(@_,2);
1233}
1234
1235sub vml {
1236	confess(err("ARGNUM")) if ($#_!=3);
1237	VRRc(0xe7a2,@_);
1238}
1239sub vmlb {
1240	vml(@_,0);
1241}
1242sub vmlhw {
1243	vml(@_,1);
1244}
1245sub vmlf {
1246	vml(@_,2);
1247}
1248
1249sub vme {
1250	confess(err("ARGNUM")) if ($#_!=3);
1251	VRRc(0xe7a6,@_);
1252}
1253sub vmeb {
1254	vme(@_,0);
1255}
1256sub vmeh {
1257	vme(@_,1);
1258}
1259sub vmef {
1260	vme(@_,2);
1261}
1262
1263sub vmle {
1264	confess(err("ARGNUM")) if ($#_!=3);
1265	VRRc(0xe7a4,@_);
1266}
1267sub vmleb {
1268	vmle(@_,0);
1269}
1270sub vmleh {
1271	vmle(@_,1);
1272}
1273sub vmlef {
1274	vmle(@_,2);
1275}
1276
1277sub vmo {
1278	confess(err("ARGNUM")) if ($#_!=3);
1279	VRRc(0xe7a7,@_);
1280}
1281sub vmob {
1282	vmo(@_,0);
1283}
1284sub vmoh {
1285	vmo(@_,1);
1286}
1287sub vmof {
1288	vmo(@_,2);
1289}
1290
1291sub vmlo {
1292	confess(err("ARGNUM")) if ($#_!=3);
1293	VRRc(0xe7a5,@_);
1294}
1295sub vmlob {
1296	vmlo(@_,0);
1297}
1298sub vmloh {
1299	vmlo(@_,1);
1300}
1301sub vmlof {
1302	vmlo(@_,2);
1303}
1304
1305sub vno {
1306	confess(err("ARGNUM")) if ($#_!=2);
1307	VRRc(0xe76b,@_);
1308}
1309sub vnot {
1310	vno(@_,$_[1]);
1311}
1312
1313sub vo {
1314	confess(err("ARGNUM")) if ($#_!=2);
1315	VRRc(0xe76a,@_);
1316}
1317
1318sub vpopct {
1319	confess(err("ARGNUM")) if ($#_!=2);
1320	VRRa(0xe750,@_);
1321}
1322
1323sub verllv {
1324	confess(err("ARGNUM")) if ($#_!=3);
1325	VRRc(0xe773,@_);
1326}
1327sub verllvb {
1328	verllv(@_,0);
1329}
1330sub verllvh {
1331	verllv(@_,1);
1332}
1333sub verllvf {
1334	verllv(@_,2);
1335}
1336sub verllvg {
1337	verllv(@_,3);
1338}
1339
1340sub verll {
1341	confess(err("ARGNUM")) if ($#_!=3);
1342	VRSa(0xe733,@_);
1343}
1344sub verllb {
1345	verll(@_,0);
1346}
1347sub verllh {
1348	verll(@_,1);
1349}
1350sub verllf {
1351	verll(@_,2);
1352}
1353sub verllg {
1354	verll(@_,3);
1355}
1356
1357sub verim {
1358	confess(err("ARGNUM")) if ($#_!=4);
1359	VRId(0xe772,@_);
1360}
1361sub verimb {
1362	verim(@_,0);
1363}
1364sub verimh {
1365	verim(@_,1);
1366}
1367sub verimf {
1368	verim(@_,2);
1369}
1370sub verimg {
1371	verim(@_,3);
1372}
1373
1374sub veslv {
1375	confess(err("ARGNUM")) if ($#_!=3);
1376	VRRc(0xe770,@_);
1377}
1378sub veslvb {
1379	veslv(@_,0);
1380}
1381sub veslvh {
1382	veslv(@_,1);
1383}
1384sub veslvf {
1385	veslv(@_,2);
1386}
1387sub veslvg {
1388	veslv(@_,3);
1389}
1390
1391sub vesl {
1392	confess(err("ARGNUM")) if ($#_!=3);
1393	VRSa(0xe730,@_);
1394}
1395sub veslb {
1396	vesl(@_,0);
1397}
1398sub veslh {
1399	vesl(@_,1);
1400}
1401sub veslf {
1402	vesl(@_,2);
1403}
1404sub veslg {
1405	vesl(@_,3);
1406}
1407
1408sub vesrav {
1409	confess(err("ARGNUM")) if ($#_!=3);
1410	VRRc(0xe77a,@_);
1411}
1412sub vesravb {
1413	vesrav(@_,0);
1414}
1415sub vesravh {
1416	vesrav(@_,1);
1417}
1418sub vesravf {
1419	vesrav(@_,2);
1420}
1421sub vesravg {
1422	vesrav(@_,3);
1423}
1424
1425sub vesra {
1426	confess(err("ARGNUM")) if ($#_!=3);
1427	VRSa(0xe73a,@_);
1428}
1429sub vesrab {
1430	vesra(@_,0);
1431}
1432sub vesrah {
1433	vesra(@_,1);
1434}
1435sub vesraf {
1436	vesra(@_,2);
1437}
1438sub vesrag {
1439	vesra(@_,3);
1440}
1441
1442sub vesrlv {
1443	confess(err("ARGNUM")) if ($#_!=3);
1444	VRRc(0xe778,@_);
1445}
1446sub vesrlvb {
1447	vesrlv(@_,0);
1448}
1449sub vesrlvh {
1450	vesrlv(@_,1);
1451}
1452sub vesrlvf {
1453	vesrlv(@_,2);
1454}
1455sub vesrlvg {
1456	vesrlv(@_,3);
1457}
1458
1459sub vesrl {
1460	confess(err("ARGNUM")) if ($#_!=3);
1461	VRSa(0xe738,@_);
1462}
1463sub vesrlb {
1464	vesrl(@_,0);
1465}
1466sub vesrlh {
1467	vesrl(@_,1);
1468}
1469sub vesrlf {
1470	vesrl(@_,2);
1471}
1472sub vesrlg {
1473	vesrl(@_,3);
1474}
1475
1476sub vsl {
1477	confess(err("ARGNUM")) if ($#_!=2);
1478	VRRc(0xe774,@_);
1479}
1480
1481sub vslb {
1482	confess(err("ARGNUM")) if ($#_!=2);
1483	VRRc(0xe775,@_);
1484}
1485
1486sub vsldb {
1487	confess(err("ARGNUM")) if ($#_!=3);
1488	VRId(0xe777,@_);
1489}
1490
1491sub vsra {
1492	confess(err("ARGNUM")) if ($#_!=2);
1493	VRRc(0xe77e,@_);
1494}
1495
1496sub vsrab {
1497	confess(err("ARGNUM")) if ($#_!=2);
1498	VRRc(0xe77f,@_);
1499}
1500
1501sub vsrl {
1502	confess(err("ARGNUM")) if ($#_!=2);
1503	VRRc(0xe77c,@_);
1504}
1505
1506sub vsrlb {
1507	confess(err("ARGNUM")) if ($#_!=2);
1508	VRRc(0xe77d,@_);
1509}
1510
1511sub vs {
1512	confess(err("ARGNUM")) if ($#_!=3);
1513	VRRc(0xe7f7,@_);
1514}
1515sub vsb {
1516	vs(@_,0);
1517}
1518sub vsh {
1519	vs(@_,1);
1520}
1521sub vsf {
1522	vs(@_,2);
1523}
1524sub vsg {
1525	vs(@_,3);
1526}
1527sub vsq {
1528	vs(@_,4);
1529}
1530
1531sub vscbi {
1532	confess(err("ARGNUM")) if ($#_!=3);
1533	VRRc(0xe7f5,@_);
1534}
1535sub vscbib {
1536	vscbi(@_,0);
1537}
1538sub vscbih {
1539	vscbi(@_,1);
1540}
1541sub vscbif {
1542	vscbi(@_,2);
1543}
1544sub vscbig {
1545	vscbi(@_,3);
1546}
1547sub vscbiq {
1548	vscbi(@_,4);
1549}
1550
1551sub vsbi {
1552	confess(err("ARGNUM")) if ($#_!=4);
1553	VRRd(0xe7bf,@_);
1554}
1555sub vsbiq {
1556	vsbi(@_,4);
1557}
1558
1559sub vsbcbi {
1560	confess(err("ARGNUM")) if ($#_!=4);
1561	VRRd(0xe7bd,@_);
1562}
1563sub vsbcbiq {
1564	vsbcbi(@_,4);
1565}
1566
1567sub vsumg {
1568	confess(err("ARGNUM")) if ($#_!=3);
1569	VRRc(0xe765,@_);
1570}
1571sub vsumgh {
1572	vsumg(@_,1);
1573}
1574sub vsumgf {
1575	vsumg(@_,2);
1576}
1577
1578sub vsumq {
1579	confess(err("ARGNUM")) if ($#_!=3);
1580	VRRc(0xe767,@_);
1581}
1582sub vsumqf {
1583	vsumq(@_,2);
1584}
1585sub vsumqg {
1586	vsumq(@_,3);
1587}
1588
1589sub vsum {
1590	confess(err("ARGNUM")) if ($#_!=3);
1591	VRRc(0xe764,@_);
1592}
1593sub vsumb {
1594	vsum(@_,0);
1595}
1596sub vsumh {
1597	vsum(@_,1);
1598}
1599
1600sub vtm {
1601	confess(err("ARGNUM")) if ($#_!=1);
1602	VRRa(0xe7d8,@_);
1603}
1604
1605# VX - String Instructions
1606
1607sub vfae {
1608	confess(err("ARGNUM")) if ($#_<3||$#_>4);
1609	VRRb(0xe782,@_);
1610}
1611sub vfaeb {
1612	vfae(@_[0..2],0,$_[3]);
1613}
1614sub vfaeh {
1615	vfae(@_[0..2],1,$_[3]);
1616}
1617sub vfaef {
1618	vfae(@_[0..2],2,$_[3]);
1619}
1620sub vfaebs {
1621	$_[3]=0 if (!defined($_[3]));
1622	vfae(@_[0..2],0,0x1|$_[3]);
1623}
1624sub vfaehs {
1625	$_[3]=0 if (!defined($_[3]));
1626	vfae(@_[0..2],1,0x1|$_[3]);
1627}
1628sub vfaefs {
1629	$_[3]=0 if (!defined($_[3]));
1630	vfae(@_[0..2],2,0x1|$_[3]);
1631}
1632sub vfaezb {
1633	$_[3]=0 if (!defined($_[3]));
1634	vfae(@_[0..2],0,0x2|$_[3]);
1635}
1636sub vfaezh {
1637	$_[3]=0 if (!defined($_[3]));
1638	vfae(@_[0..2],1,0x2|$_[3]);
1639}
1640sub vfaezf {
1641	$_[3]=0 if (!defined($_[3]));
1642	vfae(@_[0..2],2,0x2|$_[3]);
1643}
1644sub vfaezbs {
1645	$_[3]=0 if (!defined($_[3]));
1646	vfae(@_[0..2],0,0x3|$_[3]);
1647}
1648sub vfaezhs {
1649	$_[3]=0 if (!defined($_[3]));
1650	vfae(@_[0..2],1,0x3|$_[3]);
1651}
1652sub vfaezfs {
1653	$_[3]=0 if (!defined($_[3]));
1654	vfae(@_[0..2],2,0x3|$_[3]);
1655}
1656
1657sub vfee {
1658	confess(err("ARGNUM")) if ($#_<3||$#_>4);
1659	VRRb(0xe780,@_);
1660}
1661sub vfeeb {
1662	vfee(@_[0..2],0,$_[3]);
1663}
1664sub vfeeh {
1665	vfee(@_[0..2],1,$_[3]);
1666}
1667sub vfeef {
1668	vfee(@_[0..2],2,$_[3]);
1669}
1670sub vfeebs {
1671	vfee(@_,0,1);
1672}
1673sub vfeehs {
1674	vfee(@_,1,1);
1675}
1676sub vfeefs {
1677	vfee(@_,2,1);
1678}
1679sub vfeezb {
1680	vfee(@_,0,2);
1681}
1682sub vfeezh {
1683	vfee(@_,1,2);
1684}
1685sub vfeezf {
1686	vfee(@_,2,2);
1687}
1688sub vfeezbs {
1689	vfee(@_,0,3);
1690}
1691sub vfeezhs {
1692	vfee(@_,1,3);
1693}
1694sub vfeezfs {
1695	vfee(@_,2,3);
1696}
1697
1698sub vfene {
1699	confess(err("ARGNUM")) if ($#_<3||$#_>4);
1700	VRRb(0xe781,@_);
1701}
1702sub vfeneb {
1703	vfene(@_[0..2],0,$_[3]);
1704}
1705sub vfeneh {
1706	vfene(@_[0..2],1,$_[3]);
1707}
1708sub vfenef {
1709	vfene(@_[0..2],2,$_[3]);
1710}
1711sub vfenebs {
1712	vfene(@_,0,1);
1713}
1714sub vfenehs {
1715	vfene(@_,1,1);
1716}
1717sub vfenefs {
1718	vfene(@_,2,1);
1719}
1720sub vfenezb {
1721	vfene(@_,0,2);
1722}
1723sub vfenezh {
1724	vfene(@_,1,2);
1725}
1726sub vfenezf {
1727	vfene(@_,2,2);
1728}
1729sub vfenezbs {
1730	vfene(@_,0,3);
1731}
1732sub vfenezhs {
1733	vfene(@_,1,3);
1734}
1735sub vfenezfs {
1736	vfene(@_,2,3);
1737}
1738
1739sub vistr {
1740	confess(err("ARGNUM")) if ($#_<2||$#_>3);
1741	VRRa(0xe75c,@_[0..2],0,$_[3]);
1742}
1743sub vistrb {
1744	vistr(@_[0..1],0,$_[2]);
1745}
1746sub vistrh {
1747	vistr(@_[0..1],1,$_[2]);
1748}
1749sub vistrf {
1750	vistr(@_[0..1],2,$_[2]);
1751}
1752sub vistrbs {
1753	vistr(@_,0,1);
1754}
1755sub vistrhs {
1756	vistr(@_,1,1);
1757}
1758sub vistrfs {
1759	vistr(@_,2,1);
1760}
1761
1762sub vstrc {
1763	confess(err("ARGNUM")) if ($#_<4||$#_>5);
1764	VRRd(0xe78a,@_);
1765}
1766sub vstrcb {
1767	vstrc(@_[0..3],0,$_[4]);
1768}
1769sub vstrch {
1770	vstrc(@_[0..3],1,$_[4]);
1771}
1772sub vstrcf {
1773	vstrc(@_[0..3],2,$_[4]);
1774}
1775sub vstrcbs {
1776	$_[4]=0 if (!defined($_[4]));
1777	vstrc(@_[0..3],0,0x1|$_[4]);
1778}
1779sub vstrchs {
1780	$_[4]=0 if (!defined($_[4]));
1781	vstrc(@_[0..3],1,0x1|$_[4]);
1782}
1783sub vstrcfs {
1784	$_[4]=0 if (!defined($_[4]));
1785	vstrc(@_[0..3],2,0x1|$_[4]);
1786}
1787sub vstrczb {
1788	$_[4]=0 if (!defined($_[4]));
1789	vstrc(@_[0..3],0,0x2|$_[4]);
1790}
1791sub vstrczh {
1792	$_[4]=0 if (!defined($_[4]));
1793	vstrc(@_[0..3],1,0x2|$_[4]);
1794}
1795sub vstrczf {
1796	$_[4]=0 if (!defined($_[4]));
1797	vstrc(@_[0..3],2,0x2|$_[4]);
1798}
1799sub vstrczbs {
1800	$_[4]=0 if (!defined($_[4]));
1801	vstrc(@_[0..3],0,0x3|$_[4]);
1802}
1803sub vstrczhs {
1804	$_[4]=0 if (!defined($_[4]));
1805	vstrc(@_[0..3],1,0x3|$_[4]);
1806}
1807sub vstrczfs {
1808	$_[4]=0 if (!defined($_[4]));
1809	vstrc(@_[0..3],2,0x3|$_[4]);
1810}
1811
1812# VX - Floating-point Instructions
1813
1814sub vfa {
1815	confess(err("ARGNUM")) if ($#_!=4);
1816	VRRc(0xe7e3,@_);
1817}
1818sub vfadb {
1819	vfa(@_,3,0);
1820}
1821sub wfadb {
1822	vfa(@_,3,8);
1823}
1824
1825sub wfc {
1826	confess(err("ARGNUM")) if ($#_!=3);
1827	VRRa(0xe7cb,@_);
1828}
1829sub wfcdb {
1830	wfc(@_,3,0);
1831}
1832
1833sub wfk {
1834	confess(err("ARGNUM")) if ($#_!=3);
1835	VRRa(0xe7ca,@_);
1836}
1837sub wfksb {
1838	wfk(@_,2,0);
1839}
1840sub wfkdb {
1841	wfk(@_,3,0);
1842}
1843sub wfkxb {
1844	wfk(@_,4,0);
1845}
1846
1847sub vfce {
1848	confess(err("ARGNUM")) if ($#_!=5);
1849	VRRc(0xe7e8,@_);
1850}
1851sub vfcedb {
1852	vfce(@_,3,0,0);
1853}
1854sub vfcedbs {
1855	vfce(@_,3,0,1);
1856}
1857sub wfcedb {
1858	vfce(@_,3,8,0);
1859}
1860sub wfcedbs {
1861	vfce(@_,3,8,1);
1862}
1863
1864sub vfch {
1865	confess(err("ARGNUM")) if ($#_!=5);
1866	VRRc(0xe7eb,@_);
1867}
1868sub vfchdb {
1869	vfch(@_,3,0,0);
1870}
1871sub vfchdbs {
1872	vfch(@_,3,0,1);
1873}
1874sub wfchdb {
1875	vfch(@_,3,8,0);
1876}
1877sub wfchdbs {
1878	vfch(@_,3,8,1);
1879}
1880
1881sub vfche {
1882	confess(err("ARGNUM")) if ($#_!=5);
1883	VRRc(0xe7ea,@_);
1884}
1885sub vfchedb {
1886	vfche(@_,3,0,0);
1887}
1888sub vfchedbs {
1889	vfche(@_,3,0,1);
1890}
1891sub wfchedb {
1892	vfche(@_,3,8,0);
1893}
1894sub wfchedbs {
1895	vfche(@_,3,8,1);
1896}
1897
1898sub vcdg {
1899	confess(err("ARGNUM")) if ($#_!=4);
1900	VRRa(0xe7c3,@_);
1901}
1902sub vcdgb {
1903	vcdg(@_[0..1],3,@_[2..3]);
1904}
1905sub wcdgb {
1906	vcdg(@_[0..1],3,0x8|$_[2],$_[3]);
1907}
1908
1909sub vcdlg {
1910	confess(err("ARGNUM")) if ($#_!=4);
1911	VRRa(0xe7c1,@_);
1912}
1913sub vcdlgb {
1914	vcdlg(@_[0..1],3,@_[2..3]);
1915}
1916sub wcdlgb {
1917	vcdlg(@_[0..1],3,0x8|$_[2],$_[3]);
1918}
1919
1920sub vcgd {
1921	confess(err("ARGNUM")) if ($#_!=4);
1922	VRRa(0xe7c2,@_);
1923}
1924sub vcgdb {
1925	vcgd(@_[0..1],3,@_[2..3]);
1926}
1927sub wcgdb {
1928	vcgd(@_[0..1],3,0x8|$_[2],$_[3]);
1929}
1930
1931sub vclgd {
1932	confess(err("ARGNUM")) if ($#_!=4);
1933	VRRa(0xe7c0,@_);
1934}
1935sub vclgdb {
1936	vclgd(@_[0..1],3,@_[2..3]);
1937}
1938sub wclgdb {
1939	vclgd(@_[0..1],3,0x8|$_[2],$_[3]);
1940}
1941
1942sub vfd {
1943	confess(err("ARGNUM")) if ($#_!=4);
1944	VRRc(0xe7e5,@_);
1945}
1946sub vfddb {
1947	vfd(@_,3,0);
1948}
1949sub wfddb {
1950	vfd(@_,3,8);
1951}
1952
1953sub vfi {
1954	confess(err("ARGNUM")) if ($#_!=4);
1955	VRRa(0xe7c7,@_);
1956}
1957sub vfidb {
1958	vfi(@_[0..1],3,@_[2..3]);
1959}
1960sub wfidb {
1961	vfi(@_[0..1],3,0x8|$_[2],$_[3]);
1962}
1963
1964sub vlde {	# deprecated, use vfll
1965	confess(err("ARGNUM")) if ($#_!=3);
1966	VRRa(0xe7c4,@_);
1967}
1968sub vldeb {	# deprecated, use vflls
1969	vlde(@_,2,0);
1970}
1971sub wldeb {	# deprecated, use wflls
1972	vlde(@_,2,8);
1973}
1974
1975sub vled {	# deprecated, use vflr
1976	confess(err("ARGNUM")) if ($#_!=4);
1977	VRRa(0xe7c5,@_);
1978}
1979sub vledb {	# deprecated, use vflrd
1980	vled(@_[0..1],3,@_[2..3]);
1981}
1982sub wledb {	# deprecated, use wflrd
1983	vled(@_[0..1],3,0x8|$_[2],$_[3]);
1984}
1985
1986sub vfm {
1987	confess(err("ARGNUM")) if ($#_!=4);
1988	VRRc(0xe7e7,@_);
1989}
1990sub vfmdb {
1991	vfm(@_,3,0);
1992}
1993sub wfmdb {
1994	vfm(@_,3,8);
1995}
1996
1997sub vfma {
1998	confess(err("ARGNUM")) if ($#_!=5);
1999	VRRe(0xe78f,@_);
2000}
2001sub vfmadb {
2002	vfma(@_,0,3);
2003}
2004sub wfmadb {
2005	vfma(@_,8,3);
2006}
2007
2008sub vfms {
2009	confess(err("ARGNUM")) if ($#_!=5);
2010	VRRe(0xe78e,@_);
2011}
2012sub vfmsdb {
2013	vfms(@_,0,3);
2014}
2015sub wfmsdb {
2016	vfms(@_,8,3);
2017}
2018
2019sub vfpso {
2020	confess(err("ARGNUM")) if ($#_!=4);
2021	VRRa(0xe7cc,@_);
2022}
2023sub vfpsodb {
2024	vfpso(@_[0..1],3,0,$_[2]);
2025}
2026sub wfpsodb {
2027	vfpso(@_[0..1],3,8,$_[2]);
2028}
2029sub vflcdb {
2030	vfpso(@_,3,0,0);
2031}
2032sub wflcdb {
2033	vfpso(@_,3,8,0);
2034}
2035sub vflndb {
2036	vfpso(@_,3,0,1);
2037}
2038sub wflndb {
2039	vfpso(@_,3,8,1);
2040}
2041sub vflpdb {
2042	vfpso(@_,3,0,2);
2043}
2044sub wflpdb {
2045	vfpso(@_,3,8,2);
2046}
2047
2048sub vfsq {
2049	confess(err("ARGNUM")) if ($#_!=3);
2050	VRRa(0xe7ce,@_);
2051}
2052sub vfsqdb {
2053	vfsq(@_,3,0);
2054}
2055sub wfsqdb {
2056	vfsq(@_,3,8);
2057}
2058
2059sub vfs {
2060	confess(err("ARGNUM")) if ($#_!=4);
2061	VRRc(0xe7e2,@_);
2062}
2063sub vfsdb {
2064	vfs(@_,3,0);
2065}
2066sub wfsdb {
2067	vfs(@_,3,8);
2068}
2069
2070sub vftci {
2071	confess(err("ARGNUM")) if ($#_!=4);
2072	VRIe(0xe74a,@_);
2073}
2074sub vftcidb {
2075	vftci(@_,3,0);
2076}
2077sub wftcidb {
2078	vftci(@_,3,8);
2079}
2080
2081# VXE - Support Instructions
2082
2083sub vbperm {
2084	confess(err("ARGNUM")) if ($#_!=2);
2085	VRRc(0xe785,@_);
2086}
2087
2088sub vllezlf {
2089	vllez(@_,6);
2090}
2091
2092# VXE - Integer Instructions
2093
2094sub vmsl {
2095	confess(err("ARGNUM")) if ($#_!=5);
2096	VRRd(0xe7b8,@_);
2097}
2098sub vmslg {
2099	vmsl(@_[0..3],3,$_[4]);
2100}
2101
2102sub vnx {
2103	confess(err("ARGNUM")) if ($#_!=2);
2104	VRRc(0xe76c,@_);
2105}
2106
2107sub vnn {
2108	confess(err("ARGNUM")) if ($#_!=2);
2109	VRRc(0xe76e,@_);
2110}
2111
2112sub voc {
2113	confess(err("ARGNUM")) if ($#_!=2);
2114	VRRc(0xe76f,@_);
2115}
2116
2117sub vpopctb {
2118	vpopct(@_,0);
2119}
2120sub vpopcth {
2121	vpopct(@_,1);
2122}
2123sub vpopctf {
2124	vpopct(@_,2);
2125}
2126sub vpopctg {
2127	vpopct(@_,3);
2128}
2129
2130# VXE - Floating-Point Instructions
2131
2132sub vfasb {
2133	vfa(@_,2,0);
2134}
2135sub wfasb {
2136	vfa(@_,2,8);
2137}
2138sub wfaxb {
2139	vfa(@_,4,8);
2140}
2141
2142sub wfcsb {
2143	wfc(@_,2,0);
2144}
2145sub wfcxb {
2146	wfc(@_,4,0);
2147}
2148
2149sub vfcesb {
2150	vfce(@_,2,0,0);
2151}
2152sub vfcesbs {
2153	vfce(@_,2,0,1);
2154}
2155sub wfcesb {
2156	vfce(@_,2,8,0);
2157}
2158sub wfcesbs {
2159	vfce(@_,2,8,1);
2160}
2161sub wfcexb {
2162	vfce(@_,4,8,0);
2163}
2164sub wfcexbs {
2165	vfce(@_,4,8,1);
2166}
2167
2168sub vfchsb {
2169	vfch(@_,2,0,0);
2170}
2171sub vfchsbs {
2172	vfch(@_,2,0,1);
2173}
2174sub wfchsb {
2175	vfch(@_,2,8,0);
2176}
2177sub wfchsbs {
2178	vfch(@_,2,8,1);
2179}
2180sub wfchxb {
2181	vfch(@_,4,8,0);
2182}
2183sub wfchxbs {
2184	vfch(@_,4,8,1);
2185}
2186
2187sub vfchesb {
2188	vfche(@_,2,0,0);
2189}
2190sub vfchesbs {
2191	vfche(@_,2,0,1);
2192}
2193sub wfchesb {
2194	vfche(@_,2,8,0);
2195}
2196sub wfchesbs {
2197	vfche(@_,2,8,1);
2198}
2199sub wfchexb {
2200	vfche(@_,4,8,0);
2201}
2202sub wfchexbs {
2203	vfche(@_,4,8,1);
2204}
2205
2206sub vfdsb {
2207	vfd(@_,2,0);
2208}
2209sub wfdsb {
2210	vfd(@_,2,8);
2211}
2212sub wfdxb {
2213	vfd(@_,4,8);
2214}
2215
2216sub vfisb {
2217	vfi(@_[0..1],2,@_[2..3]);
2218}
2219sub wfisb {
2220	vfi(@_[0..1],2,0x8|$_[2],$_[3]);
2221}
2222sub wfixb {
2223	vfi(@_[0..1],4,0x8|$_[2],$_[3]);
2224}
2225
2226sub vfll {
2227	vlde(@_);
2228}
2229sub vflls {
2230	vfll(@_,2,0);
2231}
2232sub wflls {
2233	vfll(@_,2,8);
2234}
2235sub wflld {
2236	vfll(@_,3,8);
2237}
2238
2239sub vflr {
2240	vled(@_);
2241}
2242sub vflrd {
2243	vflr(@_[0..1],3,@_[2..3]);
2244}
2245sub wflrd {
2246	vflr(@_[0..1],3,0x8|$_[2],$_[3]);
2247}
2248sub wflrx {
2249	vflr(@_[0..1],4,0x8|$_[2],$_[3]);
2250}
2251
2252sub vfmax {
2253	confess(err("ARGNUM")) if ($#_!=5);
2254	VRRc(0xe7ef,@_);
2255}
2256sub vfmaxsb {
2257	vfmax(@_[0..2],2,0,$_[3]);
2258}
2259sub vfmaxdb {
2260	vfmax(@_[0..2],3,0,$_[3]);
2261}
2262sub wfmaxsb {
2263	vfmax(@_[0..2],2,8,$_[3]);
2264}
2265sub wfmaxdb {
2266	vfmax(@_[0..2],3,8,$_[3]);
2267}
2268sub wfmaxxb {
2269	vfmax(@_[0..2],4,8,$_[3]);
2270}
2271
2272sub vfmin {
2273	confess(err("ARGNUM")) if ($#_!=5);
2274	VRRc(0xe7ee,@_);
2275}
2276sub vfminsb {
2277	vfmin(@_[0..2],2,0,$_[5]);
2278}
2279sub vfmindb {
2280	vfmin(@_[0..2],3,0,$_[5]);
2281}
2282sub wfminsb {
2283	vfmin(@_[0..2],2,8,$_[5]);
2284}
2285sub wfmindb {
2286	vfmin(@_[0..2],3,8,$_[5]);
2287}
2288sub wfminxb {
2289	vfmin(@_[0..2],4,8,$_[5]);
2290}
2291
2292sub vfmsb {
2293	vfm(@_,2,0);
2294}
2295sub wfmsb {
2296	vfm(@_,2,8);
2297}
2298sub wfmxb {
2299	vfm(@_,4,8);
2300}
2301
2302sub vfmasb {
2303	vfma(@_,0,2);
2304}
2305sub wfmasb {
2306	vfma(@_,8,2);
2307}
2308sub wfmaxb {
2309	vfma(@_,8,4);
2310}
2311
2312sub vfmssb {
2313	vfms(@_,0,2);
2314}
2315sub wfmssb {
2316	vfms(@_,8,2);
2317}
2318sub wfmsxb {
2319	vfms(@_,8,4);
2320}
2321
2322sub vfnma {
2323	confess(err("ARGNUM")) if ($#_!=5);
2324	VRRe(0xe79f,@_);
2325}
2326sub vfnmasb {
2327	vfnma(@_,0,2);
2328}
2329sub vfnmadb {
2330	vfnma(@_,0,3);
2331}
2332sub wfnmasb {
2333	vfnma(@_,8,2);
2334}
2335sub wfnmadb {
2336	vfnma(@_,8,3);
2337}
2338sub wfnmaxb {
2339	vfnma(@_,8,4);
2340}
2341
2342sub vfnms {
2343	confess(err("ARGNUM")) if ($#_!=5);
2344	VRRe(0xe79e,@_);
2345}
2346sub vfnmssb {
2347	vfnms(@_,0,2);
2348}
2349sub vfnmsdb {
2350	vfnms(@_,0,3);
2351}
2352sub wfnmssb {
2353	vfnms(@_,8,2);
2354}
2355sub wfnmsdb {
2356	vfnms(@_,8,3);
2357}
2358sub wfnmsxb {
2359	vfnms(@_,8,4);
2360}
2361
2362sub vfpsosb {
2363	vfpso(@_[0..1],2,0,$_[2]);
2364}
2365sub wfpsosb {
2366	vfpso(@_[0..1],2,8,$_[2]);
2367}
2368sub vflcsb {
2369	vfpso(@_,2,0,0);
2370}
2371sub wflcsb {
2372	vfpso(@_,2,8,0);
2373}
2374sub vflnsb {
2375	vfpso(@_,2,0,1);
2376}
2377sub wflnsb {
2378	vfpso(@_,2,8,1);
2379}
2380sub vflpsb {
2381	vfpso(@_,2,0,2);
2382}
2383sub wflpsb {
2384	vfpso(@_,2,8,2);
2385}
2386sub vfpsoxb {
2387	vfpso(@_[0..1],4,0,$_[2]);
2388}
2389sub wfpsoxb {
2390	vfpso(@_[0..1],4,8,$_[2]);
2391}
2392sub vflcxb {
2393	vfpso(@_,4,0,0);
2394}
2395sub wflcxb {
2396	vfpso(@_,4,8,0);
2397}
2398sub vflnxb {
2399	vfpso(@_,4,0,1);
2400}
2401sub wflnxb {
2402	vfpso(@_,4,8,1);
2403}
2404sub vflpxb {
2405	vfpso(@_,4,0,2);
2406}
2407sub wflpxb {
2408	vfpso(@_,4,8,2);
2409}
2410
2411sub vfsqsb {
2412	vfsq(@_,2,0);
2413}
2414sub wfsqsb {
2415	vfsq(@_,2,8);
2416}
2417sub wfsqxb {
2418	vfsq(@_,4,8);
2419}
2420
2421sub vfssb {
2422	vfs(@_,2,0);
2423}
2424sub wfssb {
2425	vfs(@_,2,8);
2426}
2427sub wfsxb {
2428	vfs(@_,4,8);
2429}
2430
2431sub vftcisb {
2432	vftci(@_,2,0);
2433}
2434sub wftcisb {
2435	vftci(@_,2,8);
2436}
2437sub wftcixb {
2438	vftci(@_,4,8);
2439}
2440
2441# VXD - Support Instructions
2442
2443sub vlrlr {
2444	confess(err("ARGNUM")) if ($#_!=2);
2445	VRSd(0xe637,@_);
2446}
2447
2448sub vlrl {
2449	confess(err("ARGNUM")) if ($#_!=2);
2450	VSI(0xe635,@_);
2451}
2452
2453sub vstrlr {
2454	confess(err("ARGNUM")) if ($#_!=2);
2455	VRSd(0xe63f,@_);
2456}
2457
2458sub vstrl {
2459	confess(err("ARGNUM")) if ($#_!=2);
2460	VSI(0xe63d,@_);
2461}
2462
2463sub vap {
2464	confess(err("ARGNUM")) if ($#_!=4);
2465	VRIf(0xe671,@_);
2466}
2467
2468sub vcp {
2469	confess(err("ARGNUM")) if ($#_!=2);
2470	VRRh(0xe677,@_);
2471}
2472
2473sub vcvb {
2474	confess(err("ARGNUM")) if ($#_!=2);
2475	VRRi(0xe650,@_);
2476}
2477
2478sub vcvbg {
2479	confess(err("ARGNUM")) if ($#_!=2);
2480	VRRi(0xe652,@_);
2481}
2482
2483sub vcvd {
2484	confess(err("ARGNUM")) if ($#_!=3);
2485	VRIi(0xe658,@_);
2486}
2487
2488sub vcvdg {
2489	confess(err("ARGNUM")) if ($#_!=3);
2490	VRIi(0xe65a,@_);
2491}
2492
2493sub vdp {
2494	confess(err("ARGNUM")) if ($#_!=4);
2495	VRIf(0xe67a,@_);
2496}
2497
2498sub vlip {
2499	confess(err("ARGNUM")) if ($#_!=2);
2500	VRIh(0xe649,@_);
2501}
2502
2503sub vmp {
2504	confess(err("ARGNUM")) if ($#_!=4);
2505	VRIf(0xe678,@_);
2506}
2507
2508sub vmsp {
2509	confess(err("ARGNUM")) if ($#_!=4);
2510	VRIf(0xe679,@_);
2511}
2512
2513sub vpkz {
2514	confess(err("ARGNUM")) if ($#_!=2);
2515	VSI(0xe634,@_);
2516}
2517
2518sub vpsop {
2519	confess(err("ARGNUM")) if ($#_!=4);
2520	VRIg(0xe65b,@_);
2521}
2522
2523sub vrp {
2524	confess(err("ARGNUM")) if ($#_!=4);
2525	VRIf(0xe67b,@_);
2526}
2527
2528sub vsdp {
2529	confess(err("ARGNUM")) if ($#_!=4);
2530	VRIf(0xe67e,@_);
2531}
2532
2533sub vsrp {
2534	confess(err("ARGNUM")) if ($#_!=4);
2535	VRIg(0xe659,@_);
2536}
2537
2538sub vsp {
2539	confess(err("ARGNUM")) if ($#_!=4);
2540	VRIf(0xe673,@_);
2541}
2542
2543sub vtp {
2544	confess(err("ARGNUM")) if ($#_!=0);
2545	VRRg(0xe65f,@_);
2546}
2547
2548sub vupkz {
2549	confess(err("ARGNUM")) if ($#_!=2);
2550	VSI(0xe63c,@_);
2551}
2552
2553#
2554# Instruction Formats
2555#
2556
2557sub RIEf {
2558	confess(err("ARGNUM")) if ($#_<4||5<$#_);
2559	my $ops=join(',',@_[1..$#_]);
2560	my $memn=(caller(1))[3];
2561	$memn=~s/^.*:://;
2562	my ($opcode,$r1,$r2,$i3,$i4,$i5)=(shift,get_R(shift),get_R(shift),
2563					  get_I(shift,8),get_I(shift,8),
2564					  get_I(shift,8));
2565
2566	$out.="\t.word\t";
2567	$out.=sprintf("%#06x",(($opcode>>8)<<8|$r1<<4|$r2)).",";
2568	$out.=sprintf("%#06x",($i3<<8)|$i4).",";
2569	$out.=sprintf("%#06x",($i5<<8)|($opcode&0xff));
2570	$out.="\t# $memn\t$ops\n";
2571}
2572
2573sub RILa {
2574	confess(err("ARGNUM")) if ($#_!=2);
2575	my $ops=join(',',@_[1..$#_]);
2576	my $memn=(caller(1))[3];
2577	$memn=~s/^.*:://;
2578	my ($opcode,$r1,$i2)=(shift,get_R(shift),get_I(shift,32));
2579
2580	$out.="\t.word\t";
2581	$out.=sprintf("%#06x",(($opcode>>4)<<8|$r1<<4|($opcode&0xf))).",";
2582	$out.=sprintf("%#06x",($i2>>16)).",";
2583	$out.=sprintf("%#06x",($i2&0xffff));
2584	$out.="\t# $memn\t$ops\n";
2585}
2586
2587sub RRE {
2588	confess(err("ARGNUM")) if ($#_<0||2<$#_);
2589	my $ops=join(',',@_[1..$#_]);
2590	my $memn=(caller(1))[3];
2591	$memn=~s/^.*:://;
2592	my ($opcode,$r1,$r2)=(shift,get_R(shift),get_R(shift));
2593
2594	$out.="\t.long\t".sprintf("%#010x",($opcode<<16|$r1<<4|$r2));
2595	$out.="\t# $memn";
2596	# RRE can have 0 ops e.g., pcc.
2597	$out.="\t$ops" if ((defined($ops))&&($ops ne ''));
2598	$out.="\n";
2599}
2600
2601sub RRFb {
2602	confess(err("ARGNUM")) if ($#_<3||4<$#_);
2603	my $ops=join(',',@_[1..$#_]);
2604	my $memn=(caller(1))[3];
2605	$memn=~s/^.*:://;
2606	my ($opcode,$r1,$r3,$r2,$m4)=(shift,get_R(shift),get_R(shift)
2607	    ,get_R(shift),get_M(shift));
2608
2609	$out.="\t.long\t"
2610	    .sprintf("%#010x",($opcode<<16|$r3<<12|$m4<<8|$r1<<4|$r2));
2611	$out.="\t# $memn\t$ops\n";
2612}
2613
2614sub RXYa {
2615	confess(err("ARGNUM")) if ($#_!=2);
2616	my $ops=join(',',@_[1..$#_]);
2617	my $memn=(caller(1))[3];
2618	$memn=~s/^.*:://;
2619	my ($opcode,$r1,$d2,$x2,$b2)=(shift,get_R(shift),get_DXB(shift));
2620
2621	$out.="\t.word\t";
2622	$out.=sprintf("%#06x",(($opcode>>8)<<8|$r1<<4|$x2)).",";
2623	$out.=sprintf("%#06x",($b2<<12|($d2&0xfff))).",";
2624	$out.=sprintf("%#06x",(($d2>>12)<<8|$opcode&0xff));
2625	$out.="\t# $memn\t$ops\n";
2626}
2627
2628sub S {
2629	confess(err("ARGNUM")) if ($#_<0||1<$#_);
2630	my $ops=join(',',@_[1..$#_]);
2631	my $memn=(caller(1))[3];
2632	$memn=~s/^.*:://;
2633	my ($opcode,$d2,$b2)=(shift,get_DB(shift));
2634
2635	$out.="\t.long\t".sprintf("%#010x",($opcode<<16|$b2<<12|$d2));
2636	$out.="\t# $memn\t$ops\n";
2637}
2638
2639sub VRIa {
2640	confess(err("ARGNUM")) if ($#_<2||3<$#_);
2641	my $ops=join(',',@_[1..$#_]);
2642	my $memn=(caller(1))[3];
2643	$memn=~s/^.*:://;
2644	my ($opcode,$v1,$i2,$m3)=(shift,get_V(shift),get_I(shift,16),
2645	    get_M(shift));
2646
2647	$out.="\t.word\t";
2648	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)).",";
2649	$out.=sprintf("%#06x",$i2).",";
2650	$out.=sprintf("%#06x",($m3<<12|RXB($v1)<<8|$opcode&0xff));
2651	$out.="\t# $memn\t$ops\n";
2652}
2653
2654sub VRIb {
2655	confess(err("ARGNUM")) if ($#_!=4);
2656	my $ops=join(',',@_[1..$#_]);
2657	my $memn=(caller(1))[3];
2658	$memn=~s/^.*:://;
2659	my ($opcode,$v1,$i2,$i3,$m4)=(shift,get_V(shift),get_I(shift,8),
2660	    ,get_I(shift,8),get_M(shift));
2661
2662	$out.="\t.word\t";
2663	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)).",";
2664	$out.=sprintf("%#06x",($i2<<8|$i3)).",";
2665	$out.=sprintf("%#06x",($m4<<12|RXB($v1)<<8|$opcode&0xff));
2666	$out.="\t# $memn\t$ops\n";
2667}
2668
2669sub VRIc {
2670	confess(err("ARGNUM")) if ($#_!=4);
2671	my $ops=join(',',@_[1..$#_]);
2672	my $memn=(caller(1))[3];
2673	$memn=~s/^.*:://;
2674	my ($opcode,$v1,$v3,$i2,$m4)=(shift,get_V(shift),get_V(shift),
2675	    ,get_I(shift,16),get_M(shift));
2676
2677	$out.="\t.word\t";
2678	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|($v3&0xf)).",";
2679	$out.=sprintf("%#06x",$i2).",";
2680	$out.=sprintf("%#06x",($m4<<12|RXB($v1,$v3)<<8|$opcode&0xff));
2681	$out.="\t# $memn\t$ops\n";
2682}
2683
2684sub VRId {
2685	confess(err("ARGNUM")) if ($#_<4||$#_>5);
2686	my $ops=join(',',@_[1..$#_]);
2687	my $memn=(caller(1))[3];
2688	$memn=~s/^.*:://;
2689	my ($opcode,$v1,$v2,$v3,$i4,$m5)=(shift,get_V(shift),get_V(shift),
2690	    ,get_V(shift),get_I(shift,8),get_M(shift));
2691
2692	$out.="\t.word\t";
2693	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|($v2&0xf)).",";
2694	$out.=sprintf("%#06x",(($v3&0xf)<<12|$i4)).",";
2695	$out.=sprintf("%#06x",($m5<<12|RXB($v1,$v2,$v3)<<8|$opcode&0xff));
2696	$out.="\t# $memn\t$ops\n";
2697}
2698
2699sub VRIe {
2700	confess(err("ARGNUM")) if ($#_!=5);
2701	my $ops=join(',',@_[1..$#_]);
2702	my $memn=(caller(1))[3];
2703	$memn=~s/^.*:://;
2704	my ($opcode,$v1,$v2,$i3,$m4,$m5)=(shift,get_V(shift),get_V(shift),
2705	    ,get_I(shift,12),get_M(shift),get_M(shift));
2706
2707	$out.="\t.word\t";
2708	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|($v2&0xf)).",";
2709	$out.=sprintf("%#06x",($i3<<4|$m5)).",";
2710	$out.=sprintf("%#06x",($m4<<12|RXB($v1,$v2)<<8|$opcode&0xff));
2711	$out.="\t# $memn\t$ops\n";
2712}
2713
2714sub VRIf {
2715	confess(err("ARGNUM")) if ($#_!=5);
2716	my $ops=join(',',@_[1..$#_]);
2717	my $memn=(caller(1))[3];
2718	$memn=~s/^.*:://;
2719	my ($opcode,$v1,$v2,$v3,$i4,$m5)=(shift,get_V(shift),get_V(shift),
2720	    ,get_V(shift),get_I(shift,8),get_M(shift));
2721
2722	$out.="\t.word\t";
2723	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|($v2&0xf)).",";
2724	$out.=sprintf("%#06x",(($v3&0xf)<<12|$m5<<4)|$i4>>4).",";
2725	$out.=sprintf("%#06x",(($i4&0xf)<<12|RXB($v1,$v2,$v3)<<8|$opcode&0xff));
2726	$out.="\t# $memn\t$ops\n";
2727}
2728
2729sub VRIg {
2730	confess(err("ARGNUM")) if ($#_!=5);
2731	my $ops=join(',',@_[1..$#_]);
2732	my $memn=(caller(1))[3];
2733	$memn=~s/^.*:://;
2734	my ($opcode,$v1,$v2,$i3,$i4,$m5)=(shift,get_V(shift),get_V(shift),
2735	    ,get_I(shift,8),get_I(shift,8),get_M(shift));
2736
2737	$out.="\t.word\t";
2738	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|($v2&0xf)).",";
2739	$out.=sprintf("%#06x",($i4<<8|$m5<<4|$i3>>4)).",";
2740	$out.=sprintf("%#06x",(($i3&0xf)<<12|RXB($v1,$v2)<<8|$opcode&0xff));
2741	$out.="\t# $memn\t$ops\n";
2742}
2743
2744sub VRIh {
2745	confess(err("ARGNUM")) if ($#_!=3);
2746	my $ops=join(',',@_[1..$#_]);
2747	my $memn=(caller(1))[3];
2748	$memn=~s/^.*:://;
2749	my ($opcode,$v1,$i2,$i3)=(shift,get_V(shift),get_I(shift,16),
2750	    get_I(shift,4));
2751
2752	$out.="\t.word\t";
2753	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)).",";
2754	$out.=sprintf("%#06x",$i2).",";
2755	$out.=sprintf("%#06x",($i3<<12|RXB($v1)<<8|$opcode&0xff));
2756	$out.="\t# $memn\t$ops\n";
2757}
2758
2759sub VRIi {
2760	confess(err("ARGNUM")) if ($#_!=4);
2761	my $ops=join(',',@_[1..$#_]);
2762	my $memn=(caller(1))[3];
2763	$memn=~s/^.*:://;
2764	my ($opcode,$v1,$r2,$i3,$m4)=(shift,get_V(shift),get_R(shift),
2765	    ,get_I(shift,8),get_M(shift));
2766
2767	$out.="\t.word\t";
2768	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|$r2).",";
2769	$out.=sprintf("%#06x",($m4<<4|$i3>>4)).",";
2770	$out.=sprintf("%#06x",(($i3&0xf)<<12|RXB($v1)<<8|$opcode&0xff));
2771	$out.="\t# $memn\t$ops\n";
2772}
2773
2774sub VRRa {
2775	confess(err("ARGNUM")) if ($#_<2||5<$#_);
2776	my $ops=join(',',@_[1..$#_]);
2777	my $memn=(caller(1))[3];
2778	$memn=~s/^.*:://;
2779	my ($opcode,$v1,$v2,$m3,$m4,$m5)=(shift,get_V(shift),get_V(shift),
2780	    get_M(shift),get_M(shift),get_M(shift));
2781
2782	$out.="\t.word\t";
2783	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2784	$out.=sprintf("%#06x",($m5<<4|$m4)).",";
2785	$out.=sprintf("%#06x",($m3<<12|RXB($v1,$v2)<<8|$opcode&0xff));
2786	$out.="\t# $memn\t$ops\n";
2787}
2788
2789sub VRRb {
2790	confess(err("ARGNUM")) if ($#_<3||5<$#_);
2791	my $ops=join(',',@_[1..$#_]);
2792	my $memn=(caller(1))[3];
2793	$memn=~s/^.*:://;
2794	my ($opcode,$v1,$v2,$v3,$m4,$m5)=(shift,get_V(shift),get_V(shift),
2795	    get_V(shift),get_M(shift),get_M(shift));
2796
2797	$out.="\t.word\t";
2798	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2799	$out.=sprintf("%#06x",(($v3&0xf)<<12|$m5<<4)).",";
2800	$out.=sprintf("%#06x",($m4<<12|RXB($v1,$v2,$v3)<<8|$opcode&0xff));
2801	$out.="\t# $memn\t$ops\n";
2802}
2803
2804sub VRRc {
2805	confess(err("ARGNUM")) if ($#_<3||6<$#_);
2806	my $ops=join(',',@_[1..$#_]);
2807	my $memn=(caller(1))[3];
2808	$memn=~s/^.*:://;
2809	my ($opcode,$v1,$v2,$v3,$m4,$m5,$m6)=(shift,get_V(shift),get_V(shift),
2810	    get_V(shift),get_M(shift),get_M(shift),get_M(shift));
2811
2812	$out.="\t.word\t";
2813	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2814	$out.=sprintf("%#06x",(($v3&0xf)<<12|$m6<<4|$m5)).",";
2815	$out.=sprintf("%#06x",($m4<<12|RXB($v1,$v2,$v3)<<8|$opcode&0xff));
2816	$out.="\t# $memn\t$ops\n";
2817}
2818
2819sub VRRd {
2820	confess(err("ARGNUM")) if ($#_<4||6<$#_);
2821	my $ops=join(',',@_[1..$#_]);
2822	my $memn=(caller(1))[3];
2823	$memn=~s/^.*:://;
2824	my ($opcode,$v1,$v2,$v3,$v4,$m5,$m6)=(shift,get_V(shift),get_V(shift),
2825	    get_V(shift),get_V(shift),get_M(shift),get_M(shift));
2826
2827	$out.="\t.word\t";
2828	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2829	$out.=sprintf("%#06x",(($v3&0xf)<<12|$m5<<8|$m6<<4)).",";
2830	$out.=sprintf("%#06x",(($v4&0xf)<<12|RXB($v1,$v2,$v3,$v4)<<8|$opcode&0xff));
2831	$out.="\t# $memn\t$ops\n";
2832}
2833
2834sub VRRe {
2835	confess(err("ARGNUM")) if ($#_<4||6<$#_);
2836	my $ops=join(',',@_[1..$#_]);
2837	my $memn=(caller(1))[3];
2838	$memn=~s/^.*:://;
2839	my ($opcode,$v1,$v2,$v3,$v4,$m5,$m6)=(shift,get_V(shift),get_V(shift),
2840	    get_V(shift),get_V(shift),get_M(shift),get_M(shift));
2841
2842	$out.="\t.word\t";
2843	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2844	$out.=sprintf("%#06x",(($v3&0xf)<<12|$m6<<8|$m5)).",";
2845	$out.=sprintf("%#06x",(($v4&0xf)<<12|RXB($v1,$v2,$v3,$v4)<<8|$opcode&0xff));
2846	$out.="\t# $memn\t$ops\n";
2847}
2848
2849sub VRRf {
2850	confess(err("ARGNUM")) if ($#_!=3);
2851	my $ops=join(',',@_[1..$#_]);
2852	my $memn=(caller(1))[3];
2853	$memn=~s/^.*:://;
2854	my ($opcode,$v1,$r2,$r3)=(shift,get_V(shift),get_R(shift),
2855	    get_R(shift));
2856
2857	$out.="\t.word\t";
2858	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|$r2)).",";
2859	$out.=sprintf("%#06x",($r3<<12)).",";
2860	$out.=sprintf("%#06x",(RXB($v1)<<8|$opcode&0xff));
2861	$out.="\t# $memn\t$ops\n";
2862}
2863
2864sub VRRg {
2865	confess(err("ARGNUM")) if ($#_!=1);
2866	my $ops=join(',',@_[1..$#_]);
2867	my $memn=(caller(1))[3];
2868	$memn=~s/^.*:://;
2869	my ($opcode,$v1)=(shift,get_V(shift));
2870
2871	$out.="\t.word\t";
2872	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf))).",";
2873	$out.=sprintf("%#06x",0x0000).",";
2874	$out.=sprintf("%#06x",(RXB(0,$v1)<<8|$opcode&0xff));
2875	$out.="\t# $memn\t$ops\n";
2876}
2877
2878sub VRRh {
2879	confess(err("ARGNUM")) if ($#_<2||$#_>3);
2880	my $ops=join(',',@_[1..$#_]);
2881	my $memn=(caller(1))[3];
2882	$memn=~s/^.*:://;
2883	my ($opcode,$v1,$v2,$m3)=(shift,get_V(shift),get_V(shift),
2884	    get_M(shift));
2885
2886	$out.="\t.word\t";
2887	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf))).",";
2888	$out.=sprintf("%#06x",(($v2&0xf)<<12|$m3<<4)).",";
2889	$out.=sprintf("%#06x",(RXB(0,$v1,$v2)<<8|$opcode&0xff));
2890	$out.="\t# $memn\t$ops\n";
2891}
2892
2893sub VRRi {
2894	confess(err("ARGNUM")) if ($#_!=3);
2895	my $ops=join(',',@_[1..$#_]);
2896	my $memn=(caller(1))[3];
2897	$memn=~s/^.*:://;
2898	my ($opcode,$r1,$v2,$m3)=(shift,get_R(shift),get_V(shift),
2899	    get_M(shift));
2900
2901	$out.="\t.word\t";
2902	$out.=sprintf("%#06x",($opcode&0xff00|$r1<<4|($v2&0xf))).",";
2903	$out.=sprintf("%#06x",($m3<<4))."\,";
2904	$out.=sprintf("%#06x",(RXB(0,$v2)<<8|$opcode&0xff));
2905	$out.="\t# $memn\t$ops\n";
2906}
2907
2908sub VRSa {
2909	confess(err("ARGNUM")) if ($#_<3||$#_>4);
2910	my $ops=join(',',@_[1..$#_]);
2911	my $memn=(caller(1))[3];
2912	$memn=~s/^.*:://;
2913	my ($opcode,$v1,$v3,$d2,$b2,$m4)=(shift,get_V(shift),get_V(shift),
2914	    get_DB(shift),get_M(shift));
2915
2916	$out.="\t.word\t";
2917	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v3&0xf))).",";
2918	$out.=sprintf("%#06x",($b2<<12|$d2)).",";
2919	$out.=sprintf("%#06x",($m4<<12|RXB($v1,$v3)<<8|$opcode&0xff));
2920	$out.="\t# $memn\t$ops\n";
2921}
2922
2923sub VRSb {
2924	confess(err("ARGNUM")) if ($#_<3||$#_>4);
2925	my $ops=join(',',@_[1..$#_]);
2926	my $memn=(caller(1))[3];
2927	$memn=~s/^.*:://;
2928	my ($opcode,$v1,$r3,$d2,$b2,$m4)=(shift,get_V(shift),get_R(shift),
2929	    get_DB(shift),get_M(shift));
2930
2931	$out.="\t.word\t";
2932	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|$r3)).",";
2933	$out.=sprintf("%#06x",($b2<<12|$d2)).",";
2934	$out.=sprintf("%#06x",($m4<<12|RXB($v1)<<8|$opcode&0xff));
2935	$out.="\t# $memn\t$ops\n";
2936}
2937
2938sub VRSc {
2939	confess(err("ARGNUM")) if ($#_!=4);
2940	my $ops=join(',',@_[1..$#_]);
2941	my $memn=(caller(1))[3];
2942	$memn=~s/^.*:://;
2943	my ($opcode,$r1,$v3,$d2,$b2,$m4)=(shift,get_R(shift),get_V(shift),
2944	    get_DB(shift),get_M(shift));
2945
2946	$out.="\t.word\t";
2947	$out.=sprintf("%#06x",($opcode&0xff00|$r1<<4|($v3&0xf))).",";
2948	$out.=sprintf("%#06x",($b2<<12|$d2)).",";
2949	$out.=sprintf("%#06x",($m4<<12|RXB(0,$v3)<<8|$opcode&0xff));
2950	$out.="\t# $memn\t$ops\n";
2951}
2952
2953sub VRSd {
2954	confess(err("ARGNUM")) if ($#_!=3);
2955	my $ops=join(',',@_[1..$#_]);
2956	my $memn=(caller(1))[3];
2957	$memn=~s/^.*:://;
2958	my ($opcode,$v1,$r3,$d2,$b2)=(shift,get_V(shift),get_R(shift),
2959	    get_DB(shift));
2960
2961	$out.="\t.word\t";
2962	$out.=sprintf("%#06x",($opcode&0xff00|$r3)).",";
2963	$out.=sprintf("%#06x",($b2<<12|$d2)).",";
2964	$out.=sprintf("%#06x",(($v1&0xf)<<12|RXB(0,0,0,$v1)<<8|$opcode&0xff));
2965	$out.="\t# $memn\t$ops\n";
2966}
2967
2968sub VRV {
2969	confess(err("ARGNUM")) if ($#_<2||$#_>3);
2970	my $ops=join(',',@_[1..$#_]);
2971	my $memn=(caller(1))[3];
2972	$memn=~s/^.*:://;
2973	my ($opcode,$v1,$d2,$v2,$b2,$m3)=(shift,get_V(shift),get_DVB(shift),
2974	    get_M(shift));
2975
2976	$out.="\t.word\t";
2977	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2978	$out.=sprintf("%#06x",($b2<<12|$d2)).",";
2979	$out.=sprintf("%#06x",($m3<<12|RXB($v1,$v2)<<8|$opcode&0xff));
2980	$out.="\t# $memn\t$ops\n";
2981}
2982
2983sub VRX {
2984	confess(err("ARGNUM")) if ($#_<2||$#_>3);
2985	my $ops=join(',',@_[1..$#_]);
2986	my $memn=(caller(1))[3];
2987	$memn=~s/^.*:://;
2988	my ($opcode,$v1,$d2,$x2,$b2,$m3)=(shift,get_V(shift),get_DXB(shift),
2989	    get_M(shift));
2990
2991	$out.="\t.word\t";
2992	$out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($x2))).",";
2993	$out.=sprintf("%#06x",($b2<<12|$d2)).",";
2994	$out.=sprintf("%#06x",($m3<<12|RXB($v1)<<8|$opcode&0xff));
2995	$out.="\t# $memn\t$ops\n";
2996}
2997
2998sub VSI {
2999	confess(err("ARGNUM")) if ($#_!=3);
3000	my $ops=join(',',@_[1..$#_]);
3001	my $memn=(caller(1))[3];
3002	$memn=~s/^.*:://;
3003	my ($opcode,$v1,$d2,$b2,$i3)=(shift,get_V(shift),get_DB(shift),
3004	    get_I(shift,8));
3005
3006	$out.="\t.word\t";
3007	$out.=sprintf("%#06x",($opcode&0xff00|$i3)).",";
3008	$out.=sprintf("%#06x",($b2<<12|$d2)).",";
3009	$out.=sprintf("%#06x",(($v1&0xf)<<12|RXB(0,0,0,$v1)<<8|$opcode&0xff));
3010	$out.="\t# $memn\t$ops\n";
3011}
3012
3013#
3014# Internal
3015#
3016
3017sub get_R {
3018	confess(err("ARGNUM")) if ($#_!=0);
3019	my $r;
3020
3021	for (shift) {
3022		if (!defined) {
3023			$r=0;
3024		} elsif (/^$GR$/) {
3025			$r=$1;
3026		} else {
3027			confess(err("PARSE"));
3028		}
3029	}
3030	confess(err("ARGRANGE")) if ($r&~0xf);
3031
3032	return $r;
3033}
3034
3035sub get_V {
3036	confess(err("ARGNUM")) if ($#_!=0);
3037	my $v;
3038
3039	for (shift) {
3040		if (!defined) {
3041			$v=0;
3042		} elsif (/^$VR$/) {
3043			$v=$1;
3044		} else {
3045			confess(err("PARSE"));
3046		}
3047	}
3048	confess(err("ARGRANGE")) if ($v&~0x1f);
3049
3050	return $v;
3051}
3052
3053sub get_I {
3054	confess(err("ARGNUM")) if ($#_!=1);
3055	my ($i,$bits)=(shift,shift);
3056
3057	$i=defined($i)?(eval($i)):(0);
3058	confess(err("PARSE")) if (!defined($i));
3059	confess(err("ARGRANGE")) if (abs($i)&~(2**$bits-1));
3060
3061	return $i&(2**$bits-1);
3062}
3063
3064sub get_M {
3065	confess(err("ARGNUM")) if ($#_!=0);
3066	my $m=shift;
3067
3068	$m=defined($m)?(eval($m)):(0);
3069	confess(err("PARSE")) if (!defined($m));
3070	confess(err("ARGRANGE")) if ($m&~0xf);
3071
3072	return $m;
3073}
3074
3075sub get_DB
3076{
3077	confess(err("ARGNUM")) if ($#_!=0);
3078	my ($d,$b);
3079
3080	for (shift) {
3081		if (!defined) {
3082			($d,$b)=(0,0);
3083		} elsif (/^(.+)\($GR\)$/) {
3084			($d,$b)=(eval($1),$2);
3085			confess(err("PARSE")) if (!defined($d));
3086		} elsif (/^(.+)$/) {
3087			($d,$b)=(eval($1),0);
3088			confess(err("PARSE")) if (!defined($d));
3089		} else {
3090			confess(err("PARSE"));
3091		}
3092	}
3093	confess(err("ARGRANGE")) if ($d&~0xfff||$b&~0xf);
3094
3095	return ($d,$b);
3096}
3097
3098sub get_DVB
3099{
3100	confess(err("ARGNUM")) if ($#_!=0);
3101	my ($d,$v,$b);
3102
3103	for (shift) {
3104		if (!defined) {
3105			($d,$v,$b)=(0,0,0);
3106		} elsif (/^(.+)\($VR,$GR\)$/) {
3107			($d,$v,$b)=(eval($1),$2,$3);
3108			confess(err("PARSE")) if (!defined($d));
3109		} elsif (/^(.+)\($GR\)$/) {
3110			($d,$v,$b)=(eval($1),0,$2);
3111			confess(err("PARSE")) if (!defined($d));
3112		} elsif (/^(.+)$/) {
3113			($d,$v,$b)=(eval($1),0,0);
3114			confess(err("PARSE")) if (!defined($d));
3115		} else {
3116			confess(err("PARSE"));
3117		}
3118	}
3119	confess(err("ARGRANGE")) if ($d&~0xfff||$v&~0x1f||$b&~0xf);
3120
3121	return ($d,$v,$b);
3122}
3123
3124sub get_DXB
3125{
3126	confess(err("ARGNUM")) if ($#_!=0);
3127	my ($d,$x,$b);
3128
3129	for (shift) {
3130		if (!defined) {
3131			($d,$x,$b)=(0,0,0);
3132		} elsif (/^(.+)\($GR,$GR\)$/) {
3133			($d,$x,$b)=(eval($1),$2,$3);
3134			confess(err("PARSE")) if (!defined($d));
3135		} elsif (/^(.+)\($GR\)$/) {
3136			($d,$x,$b)=(eval($1),0,$2);
3137			confess(err("PARSE")) if (!defined($d));
3138		} elsif (/^(.+)$/) {
3139			($d,$x,$b)=(eval($1),0,0);
3140			confess(err("PARSE")) if (!defined($d));
3141		} else {
3142			confess(err("PARSE"));
3143		}
3144	}
3145	confess(err("ARGRANGE")) if ($d&~0xfff||$x&~0xf||$b&~0xf);
3146
3147	return ($d,$x,$b);
3148}
3149
3150sub RXB
3151{
3152	confess(err("ARGNUM")) if ($#_<0||3<$#_);
3153	my $rxb=0;
3154
3155	$rxb|=0x08 if (defined($_[0])&&($_[0]&0x10));
3156	$rxb|=0x04 if (defined($_[1])&&($_[1]&0x10));
3157	$rxb|=0x02 if (defined($_[2])&&($_[2]&0x10));
3158	$rxb|=0x01 if (defined($_[3])&&($_[3]&0x10));
3159
3160	return $rxb;
3161}
3162
3163sub err {
3164	my %ERR		=
3165	(
3166		ARGNUM	=>	'Wrong number of arguments',
3167		ARGRANGE=>	'Argument out of range',
3168		PARSE	=>	'Parse error',
3169	);
3170	confess($ERR{ARGNUM}) if ($#_!=0);
3171
3172	return $ERR{$_[0]};
3173}
3174
31751;
3176