2 # Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (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
9 # Copyright IBM Corp. 2018
10 # Author: Patrick Steuer <patrick.steuer@de.ibm.com>
12 package perlasm::s390x;
17 use Exporter qw(import);
19 our @EXPORT=qw(PERLASM_BEGIN PERLASM_END);
20 our @EXPORT_OK=qw(AUTOLOAD LABEL INCLUDE stfle);
22 MSA => [qw(kmac km kmc kimd klmd)],
23 MSA4 => [qw(kmf kmo pcc kmctr)],
24 MSA5 => [qw(ppno prno)],
26 VX => [qw(vgef vgeg vgbm vzero vone vgm vgmb vgmh vgmf vgmg
27 vl vlr vlrep vlrepb vlreph vlrepf vlrepg vleb vleh vlef vleg vleib
28 vleih vleif vleig vlgv vlgvb vlgvh vlgvf vlgvg vllez vllezb vllezh
29 vllezf vllezg vlm vlbb vlvg vlvgb vlvgh vlvgf vlvgg vlvgp
30 vll vmrh vmrhb vmrhh vmrhf vmrhg vmrl vmrlb vmrlh vmrlf vmrlg vpk
31 vpkh vpkf vpkg vpks vpksh vpksf vpksg vpkshs vpksfs vpksgs vpkls
32 vpklsh vpklsf vpklsg vpklshs vpklsfs vpklsgs vperm vpdi vrep vrepb
33 vreph vrepf vrepg vrepi vrepib vrepih vrepif vrepig vscef vsceg
34 vsel vseg vsegb vsegh vsegf vst vsteb vsteh vstef vsteg vstm vstl
35 vuph vuphb vuphh vuphf vuplh vuplhb vuplhh vuplhf vupl vuplb vuplhw
36 vuplf vupll vupllb vupllh vupllf va vab vah vaf vag vaq vacc vaccb
37 vacch vaccf vaccg vaccq vac vacq vaccc vacccq vn vnc vavg vavgb
38 vavgh vavgf vavgg vavgl vavglb vavglh vavglf vavglg vcksm vec_ vecb
39 vech vecf vecg vecl veclb veclh veclf veclg vceq vceqb vceqh vceqf
40 vceqg vceqbs vceqhs vceqfs vceqgs vch vchb vchh vchf vchg vchbs
41 vchhs vchfs vchgs vchl vchlb vchlh vchlf vchlg vchlbs vchlhs vchlfs
42 vchlgs vclz vclzb vclzh vclzf vclzg vctz vctzb vctzh vctzf vctzg
43 vx vgfm vgfmb vgfmh vgfmf vgfmg vgfma vgfmab vgfmah vgfmaf vgfmag
44 vlc vlcb vlch vlcf vlcg vlp vlpb vlph vlpf vlpg vmx vmxb vmxh vmxf
45 vmxg vmxl vmxlb vmxlh vmxlf vmxlg vmn vmnb vmnh vmnf vmng vmnl
46 vmnlb vmnlh vmnlf vmnlg vmal vmalb vmalhw vmalf vmah vmahb vmahh
47 vmahf vmalh vmalhb vmalhh vmalhf vmae vmaeb vmaeh vmaef vmale
48 vmaleb vmaleh vmalef vmao vmaob vmaoh vmaof vmalo vmalob vmaloh
49 vmalof vmh vmhb vmhh vmhf vmlh vmlhb vmlhh vmlhf vml vmlb vmlhw
50 vmlf vme vmeb vmeh vmef vmle vmleb vmleh vmlef vmo vmob vmoh vmof
51 vmlo vmlob vmloh vmlof vno vnot vo vpopct verllv verllvb verllvh
52 verllvf verllvg verll verllb verllh verllf verllg verim verimb
53 verimh verimf verimg veslv veslvb veslvh veslvf veslvg vesl veslb
54 veslh veslf veslg vesrav vesravb vesravh vesravf vesravg vesra
55 vesrab vesrah vesraf vesrag vesrlv vesrlvb vesrlvh vesrlvf vesrlvg
56 vesrl vesrlb vesrlh vesrlf vesrlg vsl vslb vsldb vsra vsrab vsrl
57 vsrlb vs vsb vsh vsf vsg vsq vscbi vscbib vscbih vscbif vscbig
58 vscbiq vsbi vsbiq vsbcbi vsbcbiq vsumg vsumgh vsumgf vsumq vsumqf
59 vsumqg vsum vsumb vsumh vtm vfae vfaeb vfaeh vfaef vfaebs vfaehs
60 vfaefs vfaezb vfaezh vfaezf vfaezbs vfaezhs vfaezfs vfee vfeeb
61 vfeeh vfeef vfeebs vfeehs vfeefs vfeezb vfeezh vfeezf vfeezbs
62 vfeezhs vfeezfs vfene vfeneb vfeneh vfenef vfenebs vfenehs vfenefs
63 vfenezb vfenezh vfenezf vfenezbs vfenezhs vfenezfs vistr vistrb
64 vistrh vistrf vistrbs vistrhs vistrfs vstrc vstrcb vstrch vstrcf
65 vstrcbs vstrchs vstrcfs vstrczb vstrczh vstrczf vstrczbs vstrczhs
66 vstrczfs vfa vfadb wfadb wfc wfcdb wfk wfkdb vfce vfcedb wfcedb
67 vfcedbs wfcedbs vfch vfchdb wfchdb vfchdbs wfchdbs vfche vfchedb
68 wfchedb vfchedbs wfchedbs vcdg vcdgb wcdgb vcdlg vcdlgb wcdlgb vcgd
69 vcgdb wcgdb vclgd vclgdb wclgdb vfd vfddb wfddb vfi vfidb wfidb
70 vlde vldeb wldeb vled vledb wledb vfm vfmdb wfmdb vfma vfmadb
71 wfmadb vfms vfmsdb wfmsdb vfpso vfpsodb wfpsodb vflcdb wflcdb
72 vflndb wflndb vflpdb wflpdb vfsq vfsqdb wfsqdb vfs vfsdb wfsdb
73 vftci vftcidb wftcidb)],
74 VXE => [qw(vbperm vllezlf vmsl vmslg vnx vnn voc vpopctb vpopcth
75 vpopctf vpopctg vfasb wfasb wfaxb wfcsb wfcxb wfksb wfkxb vfcesb
76 vfcesbs wfcesb wfcesbs wfcexb wfcexbs vfchsb vfchsbs wfchsb wfchsbs
77 wfchxb wfchxbs vfchesb vfchesbs wfchesb wfchesbs wfchexb wfchexbs
78 vfdsb wfdsb wfdxb vfisb wfisb wfixb vfll vflls wflls wflld vflr
79 vflrd wflrd wflrx vfmax vfmaxsb vfmaxdb wfmaxsb wfmaxdb wfmaxxb
80 vfmin vfminsb vfmindb wfminsb wfmindb wfminxb vfmsb wfmsb wfmxb
81 vfnma vfnms vfmasb wfmasb wfmaxb vfmssb wfmssb wfmsxb vfnmasb
82 vfnmadb wfnmasb wfnmadb wfnmaxb vfnmssb vfnmsdb wfnmssb wfnmsdb
83 wfnmsxb vfpsosb wfpsosb vflcsb wflcsb vflnsb wflnsb vflpsb wflpsb
84 vfpsoxb wfpsoxb vflcxb wflcxb vflnxb wflnxb vflpxb wflpxb vfsqsb
85 wfsqsb wfsqxb vfssb wfssb wfsxb vftcisb wftcisb wftcixb)],
86 VXD => [qw(vlrlr vlrl vstrlr vstrl vap vcp vcvb vcvbg vcvd vcvdg vdp
87 vlip vmp vmsp vpkz vpsop vrp vsdp vsrp vsp vtp vupkz)],
89 Exporter::export_ok_tags(qw(MSA MSA4 MSA5 MSA8 VX VXE VXD));
93 my $GR='(?:%r)?([0-9]|1[0-5])';
94 my $VR='(?:%v)?([0-9]|1[0-9]|2[0-9]|3[0-1])';
100 ($file,$out)=(shift,"");
104 if (defined($file)) {
105 open(my $fd,'>',$file)||die("can't open $file: $!");
114 confess(err("PARSE")) if (grep(!defined($_),@_));
117 $token=".$1" if (/^.*::([A-Z_]+)$/); # uppercase: directive
118 $token="\t$1" if (/^.*::([a-z]+)$/); # lowercase: mnemonic
119 confess(err("PARSE")) if (!defined($token));
121 $token.="\t" if ($#_>=0);
122 $out.=$token.join(',',@_)."\n";
125 sub LABEL { # label directive
126 confess(err("ARGNUM")) if ($#_!=0);
132 confess(err("ARGNUM")) if ($#_!=0);
134 $out.="#include \"$file\"\n";
142 confess(err("ARGNUM")) if ($#_!=0);
149 confess(err("ARGNUM")) if ($#_!=1);
154 confess(err("ARGNUM")) if ($#_!=1);
159 confess(err("ARGNUM")) if ($#_!=1);
164 confess(err("ARGNUM")) if ($#_!=1);
169 confess(err("ARGNUM")) if ($#_!=1);
176 confess(err("ARGNUM")) if ($#_!=1);
181 confess(err("ARGNUM")) if ($#_!=1);
186 confess(err("ARGNUM")) if ($#_!=-1);
191 confess(err("ARGNUM")) if ($#_!=2);
201 sub ppno { # deprecated, use prno
202 confess(err("ARGNUM")) if ($#_!=1);
209 confess(err("ARGNUM")) if ($#_!=2);
213 # VX - Support Instructions
216 confess(err("ARGNUM")) if ($#_!=2);
220 confess(err("ARGNUM")) if ($#_!=2);
225 confess(err("ARGNUM")) if ($#_!=1);
236 confess(err("ARGNUM")) if ($#_!=3);
253 confess(err("ARGNUM")) if ($#_!=1);
258 confess(err("ARGNUM")) if ($#_!=1);
263 confess(err("ARGNUM")) if ($#_!=2);
280 confess(err("ARGNUM")) if ($#_!=2);
284 confess(err("ARGNUM")) if ($#_!=2);
288 confess(err("ARGNUM")) if ($#_!=2);
292 confess(err("ARGNUM")) if ($#_!=2);
297 confess(err("ARGNUM")) if ($#_!=2);
301 confess(err("ARGNUM")) if ($#_!=2);
305 confess(err("ARGNUM")) if ($#_!=2);
309 confess(err("ARGNUM")) if ($#_!=2);
314 confess(err("ARGNUM")) if ($#_!=3);
331 confess(err("ARGNUM")) if ($#_!=2);
348 confess(err("ARGNUM")) if ($#_!=2);
353 confess(err("ARGNUM")) if ($#_!=2);
358 confess(err("ARGNUM")) if ($#_!=3);
375 confess(err("ARGNUM")) if ($#_!=2);
380 confess(err("ARGNUM")) if ($#_!=2);
385 confess(err("ARGNUM")) if ($#_!=3);
402 confess(err("ARGNUM")) if ($#_!=3);
419 confess(err("ARGNUM")) if ($#_!=3);
433 confess(err("ARGNUM")) if ($#_!=4);
456 confess(err("ARGNUM")) if ($#_!=4);
479 confess(err("ARGNUM")) if ($#_!=3);
484 confess(err("ARGNUM")) if ($#_!=3);
489 confess(err("ARGNUM")) if ($#_!=3);
506 confess(err("ARGNUM")) if ($#_!=2);
523 confess(err("ARGNUM")) if ($#_!=2);
527 confess(err("ARGNUM")) if ($#_!=2);
532 confess(err("ARGNUM")) if ($#_!=3);
537 confess(err("ARGNUM")) if ($#_!=2);
551 confess(err("ARGNUM")) if ($#_!=1);
556 confess(err("ARGNUM")) if ($#_!=2);
560 confess(err("ARGNUM")) if ($#_!=2);
564 confess(err("ARGNUM")) if ($#_!=2);
568 confess(err("ARGNUM")) if ($#_!=2);
573 confess(err("ARGNUM")) if ($#_!=2);
578 confess(err("ARGNUM")) if ($#_!=2);
583 confess(err("ARGNUM")) if ($#_!=2);
597 confess(err("ARGNUM")) if ($#_!=2);
611 confess(err("ARGNUM")) if ($#_!=2);
625 confess(err("ARGNUM")) if ($#_!=2);
638 # VX - Integer Instructions
641 confess(err("ARGNUM")) if ($#_!=3);
661 confess(err("ARGNUM")) if ($#_!=3);
681 confess(err("ARGNUM")) if ($#_!=4);
689 confess(err("ARGNUM")) if ($#_!=4);
697 confess(err("ARGNUM")) if ($#_!=2);
702 confess(err("ARGNUM")) if ($#_!=2);
707 confess(err("ARGNUM")) if ($#_!=3);
724 confess(err("ARGNUM")) if ($#_!=3);
741 confess(err("ARGNUM")) if ($#_!=2);
746 confess(err("ARGNUM")) if ($#_!=2);
763 confess(err("ARGNUM")) if ($#_!=2);
780 confess(err("ARGNUM")) if ($#_!=4);
809 confess(err("ARGNUM")) if ($#_!=4);
838 confess(err("ARGNUM")) if ($#_!=4);
867 confess(err("ARGNUM")) if ($#_!=2);
884 confess(err("ARGNUM")) if ($#_!=2);
901 confess(err("ARGNUM")) if ($#_!=2);
906 confess(err("ARGNUM")) if ($#_!=3);
923 confess(err("ARGNUM")) if ($#_!=4);
940 confess(err("ARGNUM")) if ($#_!=2);
957 confess(err("ARGNUM")) if ($#_!=2);
974 confess(err("ARGNUM")) if ($#_!=3);
991 confess(err("ARGNUM")) if ($#_!=3);
1008 confess(err("ARGNUM")) if ($#_!=3);
1025 confess(err("ARGNUM")) if ($#_!=3);
1042 confess(err("ARGNUM")) if ($#_!=4);
1056 confess(err("ARGNUM")) if ($#_!=4);
1070 confess(err("ARGNUM")) if ($#_!=4);
1084 confess(err("ARGNUM")) if ($#_!=4);
1098 confess(err("ARGNUM")) if ($#_!=4);
1112 confess(err("ARGNUM")) if ($#_!=4);
1126 confess(err("ARGNUM")) if ($#_!=4);
1140 confess(err("ARGNUM")) if ($#_!=3);
1154 confess(err("ARGNUM")) if ($#_!=3);
1168 confess(err("ARGNUM")) if ($#_!=3);
1182 confess(err("ARGNUM")) if ($#_!=3);
1196 confess(err("ARGNUM")) if ($#_!=3);
1210 confess(err("ARGNUM")) if ($#_!=3);
1224 confess(err("ARGNUM")) if ($#_!=3);
1238 confess(err("ARGNUM")) if ($#_!=2);
1246 confess(err("ARGNUM")) if ($#_!=2);
1251 confess(err("ARGNUM")) if ($#_!=2);
1256 confess(err("ARGNUM")) if ($#_!=3);
1273 confess(err("ARGNUM")) if ($#_!=3);
1290 confess(err("ARGNUM")) if ($#_!=4);
1307 confess(err("ARGNUM")) if ($#_!=3);
1324 confess(err("ARGNUM")) if ($#_!=3);
1341 confess(err("ARGNUM")) if ($#_!=3);
1358 confess(err("ARGNUM")) if ($#_!=3);
1375 confess(err("ARGNUM")) if ($#_!=3);
1392 confess(err("ARGNUM")) if ($#_!=3);
1409 confess(err("ARGNUM")) if ($#_!=2);
1414 confess(err("ARGNUM")) if ($#_!=2);
1419 confess(err("ARGNUM")) if ($#_!=3);
1424 confess(err("ARGNUM")) if ($#_!=2);
1429 confess(err("ARGNUM")) if ($#_!=2);
1434 confess(err("ARGNUM")) if ($#_!=2);
1439 confess(err("ARGNUM")) if ($#_!=2);
1444 confess(err("ARGNUM")) if ($#_!=3);
1464 confess(err("ARGNUM")) if ($#_!=3);
1484 confess(err("ARGNUM")) if ($#_!=4);
1492 confess(err("ARGNUM")) if ($#_!=4);
1500 confess(err("ARGNUM")) if ($#_!=3);
1511 confess(err("ARGNUM")) if ($#_!=3);
1522 confess(err("ARGNUM")) if ($#_!=3);
1533 confess(err("ARGNUM")) if ($#_!=1);
1537 # VX - String Instructions
1540 confess(err("ARGNUM")) if ($#_<3||$#_>4);
1544 vfae(@_[0..2],0,$_[3]);
1547 vfae(@_[0..2],1,$_[3]);
1550 vfae(@_[0..2],2,$_[3]);
1553 $_[3]=0 if (!defined($_[3]));
1554 vfae(@_[0..2],0,0x1|$_[3]);
1557 $_[3]=0 if (!defined($_[3]));
1558 vfae(@_[0..2],1,0x1|$_[3]);
1561 $_[3]=0 if (!defined($_[3]));
1562 vfae(@_[0..2],2,0x1|$_[3]);
1565 $_[3]=0 if (!defined($_[3]));
1566 vfae(@_[0..2],0,0x2|$_[3]);
1569 $_[3]=0 if (!defined($_[3]));
1570 vfae(@_[0..2],1,0x2|$_[3]);
1573 $_[3]=0 if (!defined($_[3]));
1574 vfae(@_[0..2],2,0x2|$_[3]);
1577 $_[3]=0 if (!defined($_[3]));
1578 vfae(@_[0..2],0,0x3|$_[3]);
1581 $_[3]=0 if (!defined($_[3]));
1582 vfae(@_[0..2],1,0x3|$_[3]);
1585 $_[3]=0 if (!defined($_[3]));
1586 vfae(@_[0..2],2,0x3|$_[3]);
1590 confess(err("ARGNUM")) if ($#_<3||$#_>4);
1594 vfee(@_[0..2],0,$_[3]);
1597 vfee(@_[0..2],1,$_[3]);
1600 vfee(@_[0..2],2,$_[3]);
1631 confess(err("ARGNUM")) if ($#_<3||$#_>4);
1635 vfene(@_[0..2],0,$_[3]);
1638 vfene(@_[0..2],1,$_[3]);
1641 vfene(@_[0..2],2,$_[3]);
1672 confess(err("ARGNUM")) if ($#_<2||$#_>3);
1673 VRRa(0xe75c,@_[0..2],0,$_[3]);
1676 vistr(@_[0..1],0,$_[2]);
1679 vistr(@_[0..1],1,$_[2]);
1682 vistr(@_[0..1],2,$_[2]);
1695 confess(err("ARGNUM")) if ($#_<4||$#_>5);
1699 vstrc(@_[0..3],0,$_[4]);
1702 vstrc(@_[0..3],1,$_[4]);
1705 vstrc(@_[0..3],2,$_[4]);
1708 $_[4]=0 if (!defined($_[4]));
1709 vstrc(@_[0..3],0,0x1|$_[4]);
1712 $_[4]=0 if (!defined($_[4]));
1713 vstrc(@_[0..3],1,0x1|$_[4]);
1716 $_[4]=0 if (!defined($_[4]));
1717 vstrc(@_[0..3],2,0x1|$_[4]);
1720 $_[4]=0 if (!defined($_[4]));
1721 vstrc(@_[0..3],0,0x2|$_[4]);
1724 $_[4]=0 if (!defined($_[4]));
1725 vstrc(@_[0..3],1,0x2|$_[4]);
1728 $_[4]=0 if (!defined($_[4]));
1729 vstrc(@_[0..3],2,0x2|$_[4]);
1732 $_[4]=0 if (!defined($_[4]));
1733 vstrc(@_[0..3],0,0x3|$_[4]);
1736 $_[4]=0 if (!defined($_[4]));
1737 vstrc(@_[0..3],1,0x3|$_[4]);
1740 $_[4]=0 if (!defined($_[4]));
1741 vstrc(@_[0..3],2,0x3|$_[4]);
1744 # VX - Floating-point Instructions
1747 confess(err("ARGNUM")) if ($#_!=4);
1758 confess(err("ARGNUM")) if ($#_!=3);
1766 confess(err("ARGNUM")) if ($#_!=3);
1780 confess(err("ARGNUM")) if ($#_!=5);
1797 confess(err("ARGNUM")) if ($#_!=5);
1814 confess(err("ARGNUM")) if ($#_!=5);
1831 confess(err("ARGNUM")) if ($#_!=4);
1835 vcdg(@_[0..1],3,@_[2..3]);
1838 vcdg(@_[0..1],3,0x8|$_[2],$_[3]);
1842 confess(err("ARGNUM")) if ($#_!=4);
1846 vcdlg(@_[0..1],3,@_[2..3]);
1849 vcdlg(@_[0..1],3,0x8|$_[2],$_[3]);
1853 confess(err("ARGNUM")) if ($#_!=4);
1857 vcgd(@_[0..1],3,@_[2..3]);
1860 vcgd(@_[0..1],3,0x8|$_[2],$_[3]);
1864 confess(err("ARGNUM")) if ($#_!=4);
1868 vclgd(@_[0..1],3,@_[2..3]);
1871 vclgd(@_[0..1],3,0x8|$_[2],$_[3]);
1875 confess(err("ARGNUM")) if ($#_!=4);
1886 confess(err("ARGNUM")) if ($#_!=4);
1890 vfi(@_[0..1],3,@_[2..3]);
1893 vfi(@_[0..1],3,0x8|$_[2],$_[3]);
1896 sub vlde { # deprecated, use vfll
1897 confess(err("ARGNUM")) if ($#_!=3);
1900 sub vldeb { # deprecated, use vflls
1903 sub wldeb { # deprecated, use wflls
1907 sub vled { # deprecated, use vflr
1908 confess(err("ARGNUM")) if ($#_!=4);
1911 sub vledb { # deprecated, use vflrd
1912 vled(@_[0..1],3,@_[2..3]);
1914 sub wledb { # deprecated, use wflrd
1915 vled(@_[0..1],3,0x8|$_[2],$_[3]);
1919 confess(err("ARGNUM")) if ($#_!=4);
1930 confess(err("ARGNUM")) if ($#_!=5);
1941 confess(err("ARGNUM")) if ($#_!=5);
1952 confess(err("ARGNUM")) if ($#_!=4);
1956 vfpso(@_[0..1],3,0,$_[2]);
1959 vfpso(@_[0..1],3,8,$_[2]);
1981 confess(err("ARGNUM")) if ($#_!=3);
1992 confess(err("ARGNUM")) if ($#_!=4);
2003 confess(err("ARGNUM")) if ($#_!=4);
2013 # VXE - Support Instructions
2016 confess(err("ARGNUM")) if ($#_!=2);
2024 # VXE - Integer Instructions
2027 confess(err("ARGNUM")) if ($#_!=5);
2031 vmsl(@_[0..3],3,$_[4]);
2035 confess(err("ARGNUM")) if ($#_!=2);
2040 confess(err("ARGNUM")) if ($#_!=2);
2045 confess(err("ARGNUM")) if ($#_!=2);
2062 # VXE - Floating-Point Instructions
2149 vfi(@_[0..1],2,@_[2..3]);
2152 vfi(@_[0..1],2,0x8|$_[2],$_[3]);
2155 vfi(@_[0..1],4,0x8|$_[2],$_[3]);
2175 vflr(@_[0..1],3,@_[2..3]);
2178 vflr(@_[0..1],3,0x8|$_[2],$_[3]);
2181 vflr(@_[0..1],4,0x8|$_[2],$_[3]);
2185 confess(err("ARGNUM")) if ($#_!=5);
2189 vfmax(@_[0..2],2,0,$_[3]);
2192 vfmax(@_[0..2],3,0,$_[3]);
2195 vfmax(@_[0..2],2,8,$_[3]);
2198 vfmax(@_[0..2],3,8,$_[3]);
2201 vfmax(@_[0..2],4,8,$_[3]);
2205 confess(err("ARGNUM")) if ($#_!=5);
2209 vfmin(@_[0..2],2,0,$_[5]);
2212 vfmin(@_[0..2],3,0,$_[5]);
2215 vfmin(@_[0..2],2,8,$_[5]);
2218 vfmin(@_[0..2],3,8,$_[5]);
2221 vfmin(@_[0..2],4,8,$_[5]);
2255 confess(err("ARGNUM")) if ($#_!=5);
2275 confess(err("ARGNUM")) if ($#_!=5);
2295 vfpso(@_[0..1],2,0,$_[2]);
2298 vfpso(@_[0..1],2,8,$_[2]);
2319 vfpso(@_[0..1],4,0,$_[2]);
2322 vfpso(@_[0..1],4,8,$_[2]);
2373 # VXD - Support Instructions
2376 confess(err("ARGNUM")) if ($#_!=2);
2381 confess(err("ARGNUM")) if ($#_!=2);
2386 confess(err("ARGNUM")) if ($#_!=2);
2391 confess(err("ARGNUM")) if ($#_!=2);
2396 confess(err("ARGNUM")) if ($#_!=4);
2401 confess(err("ARGNUM")) if ($#_!=2);
2406 confess(err("ARGNUM")) if ($#_!=2);
2411 confess(err("ARGNUM")) if ($#_!=2);
2416 confess(err("ARGNUM")) if ($#_!=3);
2421 confess(err("ARGNUM")) if ($#_!=3);
2426 confess(err("ARGNUM")) if ($#_!=4);
2431 confess(err("ARGNUM")) if ($#_!=2);
2436 confess(err("ARGNUM")) if ($#_!=4);
2441 confess(err("ARGNUM")) if ($#_!=4);
2446 confess(err("ARGNUM")) if ($#_!=2);
2451 confess(err("ARGNUM")) if ($#_!=4);
2456 confess(err("ARGNUM")) if ($#_!=4);
2461 confess(err("ARGNUM")) if ($#_!=4);
2466 confess(err("ARGNUM")) if ($#_!=4);
2471 confess(err("ARGNUM")) if ($#_!=4);
2476 confess(err("ARGNUM")) if ($#_!=0);
2481 confess(err("ARGNUM")) if ($#_!=2);
2486 # Instruction Formats
2490 confess(err("ARGNUM")) if ($#_<0||2<$#_);
2491 my $ops=join(',',@_[1..$#_]);
2492 my $memn=(caller(1))[3];
2494 my ($opcode,$r1,$r2)=(shift,get_R(shift),get_R(shift));
2496 $out.="\t.long\t".sprintf("%#010x",($opcode<<16|$r1<<4|$r2));
2497 $out.="\t# $memn\t$ops\n"
2501 confess(err("ARGNUM")) if ($#_<3||4<$#_);
2502 my $ops=join(',',@_[1..$#_]);
2503 my $memn=(caller(1))[3];
2505 my ($opcode,$r1,$r3,$r2,$m4)=(shift,get_R(shift),get_R(shift)
2506 ,get_R(shift),get_M(shift));
2509 .sprintf("%#010x",($opcode<<16|$r3<<12|$m4<<8|$r1<<4|$r2));
2510 $out.="\t# $memn\t$ops\n"
2514 confess(err("ARGNUM")) if ($#_<0||1<$#_);
2515 my $ops=join(',',@_[1..$#_]);
2516 my $memn=(caller(1))[3];
2518 my ($opcode,$d2,$b2)=(shift,get_DB(shift));
2520 $out.="\t.long\t".sprintf("%#010x",($opcode<<16|$b2<<12|$d2));
2521 $out.="\t# $memn\t$ops\n"
2525 confess(err("ARGNUM")) if ($#_<2||3<$#_);
2526 my $ops=join(',',@_[1..$#_]);
2527 my $memn=(caller(1))[3];
2529 my ($opcode,$v1,$i2,$m3)=(shift,get_V(shift),get_I(shift,16),
2533 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)).",";
2534 $out.=sprintf("%#06x",$i2).",";
2535 $out.=sprintf("%#06x",($m3<<12|RXB($v1)<<8|$opcode&0xff));
2536 $out.="\t# $memn\t$ops\n"
2540 confess(err("ARGNUM")) if ($#_!=4);
2541 my $ops=join(',',@_[1..$#_]);
2542 my $memn=(caller(1))[3];
2544 my ($opcode,$v1,$i2,$i3,$m4)=(shift,get_V(shift),get_I(shift,8),
2545 ,get_I(shift,8),get_M(shift));
2548 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)).",";
2549 $out.=sprintf("%#06x",($i2<<8|$i3)).",";
2550 $out.=sprintf("%#06x",($m4<<12|RXB($v1)<<8|$opcode&0xff));
2551 $out.="\t# $memn\t$ops\n"
2555 confess(err("ARGNUM")) if ($#_!=4);
2556 my $ops=join(',',@_[1..$#_]);
2557 my $memn=(caller(1))[3];
2559 my ($opcode,$v1,$v3,$i2,$m4)=(shift,get_V(shift),get_V(shift),
2560 ,get_I(shift,16),get_M(shift));
2563 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|($v3&0xf)).",";
2564 $out.=sprintf("%#06x",$i2).",";
2565 $out.=sprintf("%#06x",($m4<<12|RXB($v1,$v3)<<8|$opcode&0xff));
2566 $out.="\t# $memn\t$ops\n"
2570 confess(err("ARGNUM")) if ($#_<4||$#_>5);
2571 my $ops=join(',',@_[1..$#_]);
2572 my $memn=(caller(1))[3];
2574 my ($opcode,$v1,$v2,$v3,$i4,$m5)=(shift,get_V(shift),get_V(shift),
2575 ,get_V(shift),get_I(shift,8),get_M(shift));
2578 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|($v2&0xf)).",";
2579 $out.=sprintf("%#06x",(($v3&0xf)<<12|$i4)).",";
2580 $out.=sprintf("%#06x",($m5<<12|RXB($v1,$v2,$v3)<<8|$opcode&0xff));
2581 $out.="\t# $memn\t$ops\n"
2585 confess(err("ARGNUM")) if ($#_!=5);
2586 my $ops=join(',',@_[1..$#_]);
2587 my $memn=(caller(1))[3];
2589 my ($opcode,$v1,$v2,$i3,$m4,$m5)=(shift,get_V(shift),get_V(shift),
2590 ,get_I(shift,12),get_M(shift),get_M(shift));
2593 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|($v2&0xf)).",";
2594 $out.=sprintf("%#06x",($i3<<4|$m5)).",";
2595 $out.=sprintf("%#06x",($m4<<12|RXB($v1,$v2)<<8|$opcode&0xff));
2596 $out.="\t# $memn\t$ops\n"
2600 confess(err("ARGNUM")) if ($#_!=5);
2601 my $ops=join(',',@_[1..$#_]);
2602 my $memn=(caller(1))[3];
2604 my ($opcode,$v1,$v2,$v3,$i4,$m5)=(shift,get_V(shift),get_V(shift),
2605 ,get_V(shift),get_I(shift,8),get_M(shift));
2608 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|($v2&0xf)).",";
2609 $out.=sprintf("%#06x",(($v3&0xf)<<12|$m5<<4)|$i4>>4).",";
2610 $out.=sprintf("%#06x",(($i4&0xf)<<12|RXB($v1,$v2,$v3)<<8|$opcode&0xff));
2611 $out.="\t# $memn\t$ops\n"
2615 confess(err("ARGNUM")) if ($#_!=5);
2616 my $ops=join(',',@_[1..$#_]);
2617 my $memn=(caller(1))[3];
2619 my ($opcode,$v1,$v2,$i3,$i4,$m5)=(shift,get_V(shift),get_V(shift),
2620 ,get_I(shift,8),get_I(shift,8),get_M(shift));
2623 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|($v2&0xf)).",";
2624 $out.=sprintf("%#06x",($i4<<8|$m5<<4|$i3>>4)).",";
2625 $out.=sprintf("%#06x",(($i3&0xf)<<12|RXB($v1,$v2)<<8|$opcode&0xff));
2626 $out.="\t# $memn\t$ops\n"
2630 confess(err("ARGNUM")) if ($#_!=3);
2631 my $ops=join(',',@_[1..$#_]);
2632 my $memn=(caller(1))[3];
2634 my ($opcode,$v1,$i2,$i3)=(shift,get_V(shift),get_I(shift,16),
2638 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)).",";
2639 $out.=sprintf("%#06x",$i2).",";
2640 $out.=sprintf("%#06x",($i3<<12|RXB($v1)<<8|$opcode&0xff));
2641 $out.="\t# $memn\t$ops\n"
2645 confess(err("ARGNUM")) if ($#_!=4);
2646 my $ops=join(',',@_[1..$#_]);
2647 my $memn=(caller(1))[3];
2649 my ($opcode,$v1,$r2,$i3,$m4)=(shift,get_V(shift),get_R(shift),
2650 ,get_I(shift,8),get_M(shift));
2653 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4)|$r2).",";
2654 $out.=sprintf("%#06x",($m4<<4|$i3>>4)).",";
2655 $out.=sprintf("%#06x",(($i3&0xf)<<12|RXB($v1)<<8|$opcode&0xff));
2656 $out.="\t# $memn\t$ops\n"
2660 confess(err("ARGNUM")) if ($#_<2||5<$#_);
2661 my $ops=join(',',@_[1..$#_]);
2662 my $memn=(caller(1))[3];
2664 my ($opcode,$v1,$v2,$m3,$m4,$m5)=(shift,get_V(shift),get_V(shift),
2665 get_M(shift),get_M(shift),get_M(shift));
2668 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2669 $out.=sprintf("%#06x",($m5<<4|$m4)).",";
2670 $out.=sprintf("%#06x",($m3<<12|RXB($v1,$v2)<<8|$opcode&0xff));
2671 $out.="\t# $memn\t$ops\n"
2675 confess(err("ARGNUM")) if ($#_<3||5<$#_);
2676 my $ops=join(',',@_[1..$#_]);
2677 my $memn=(caller(1))[3];
2679 my ($opcode,$v1,$v2,$v3,$m4,$m5)=(shift,get_V(shift),get_V(shift),
2680 get_V(shift),get_M(shift),get_M(shift));
2683 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2684 $out.=sprintf("%#06x",(($v3&0xf)<<12|$m5<<4)).",";
2685 $out.=sprintf("%#06x",($m4<<12|RXB($v1,$v2,$v3)<<8|$opcode&0xff));
2686 $out.="\t# $memn\t$ops\n"
2690 confess(err("ARGNUM")) if ($#_<3||6<$#_);
2691 my $ops=join(',',@_[1..$#_]);
2692 my $memn=(caller(1))[3];
2694 my ($opcode,$v1,$v2,$v3,$m4,$m5,$m6)=(shift,get_V(shift),get_V(shift),
2695 get_V(shift),get_M(shift),get_M(shift),get_M(shift));
2698 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2699 $out.=sprintf("%#06x",(($v3&0xf)<<12|$m6<<4|$m5)).",";
2700 $out.=sprintf("%#06x",($m4<<12|RXB($v1,$v2,$v3)<<8|$opcode&0xff));
2701 $out.="\t# $memn\t$ops\n"
2705 confess(err("ARGNUM")) if ($#_<4||6<$#_);
2706 my $ops=join(',',@_[1..$#_]);
2707 my $memn=(caller(1))[3];
2709 my ($opcode,$v1,$v2,$v3,$v4,$m5,$m6)=(shift,get_V(shift),get_V(shift),
2710 get_V(shift),get_V(shift),get_M(shift),get_M(shift));
2713 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2714 $out.=sprintf("%#06x",(($v3&0xf)<<12|$m5<<8|$m6<<4)).",";
2715 $out.=sprintf("%#06x",(($v4&0xf)<<12|RXB($v1,$v2,$v3,$v4)<<8|$opcode&0xff));
2716 $out.="\t# $memn\t$ops\n"
2720 confess(err("ARGNUM")) if ($#_<4||6<$#_);
2721 my $ops=join(',',@_[1..$#_]);
2722 my $memn=(caller(1))[3];
2724 my ($opcode,$v1,$v2,$v3,$v4,$m5,$m6)=(shift,get_V(shift),get_V(shift),
2725 get_V(shift),get_V(shift),get_M(shift),get_M(shift));
2728 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2729 $out.=sprintf("%#06x",(($v3&0xf)<<12|$m6<<8|$m5)).",";
2730 $out.=sprintf("%#06x",(($v4&0xf)<<12|RXB($v1,$v2,$v3,$v4)<<8|$opcode&0xff));
2731 $out.="\t# $memn\t$ops\n"
2735 confess(err("ARGNUM")) if ($#_!=3);
2736 my $ops=join(',',@_[1..$#_]);
2737 my $memn=(caller(1))[3];
2739 my ($opcode,$v1,$r2,$r3)=(shift,get_V(shift),get_R(shift),
2743 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|$r2)).",";
2744 $out.=sprintf("%#06x",($r3<<12)).",";
2745 $out.=sprintf("%#06x",(RXB($v1)<<8|$opcode&0xff));
2746 $out.="\t# $memn\t$ops\n"
2750 confess(err("ARGNUM")) if ($#_!=1);
2751 my $ops=join(',',@_[1..$#_]);
2752 my $memn=(caller(1))[3];
2754 my ($opcode,$v1)=(shift,get_V(shift));
2757 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf))).",";
2758 $out.=sprintf("%#06x",0x0000).",";
2759 $out.=sprintf("%#06x",(RXB(0,$v1)<<8|$opcode&0xff));
2760 $out.="\t# $memn\t$ops\n"
2764 confess(err("ARGNUM")) if ($#_<2||$#_>3);
2765 my $ops=join(',',@_[1..$#_]);
2766 my $memn=(caller(1))[3];
2768 my ($opcode,$v1,$v2,$m3)=(shift,get_V(shift),get_V(shift),
2772 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf))).",";
2773 $out.=sprintf("%#06x",(($v2&0xf)<<12|$m3<<4)).",";
2774 $out.=sprintf("%#06x",(RXB(0,$v1,$v2)<<8|$opcode&0xff));
2775 $out.="\t# $memn\t$ops\n"
2779 confess(err("ARGNUM")) if ($#_!=3);
2780 my $ops=join(',',@_[1..$#_]);
2781 my $memn=(caller(1))[3];
2783 my ($opcode,$r1,$v2,$m3)=(shift,get_R(shift),get_V(shift),
2787 $out.=sprintf("%#06x",($opcode&0xff00|$r1<<4|($v2&0xf))).",";
2788 $out.=sprintf("%#06x",($m3<<4))."\,";
2789 $out.=sprintf("%#06x",(RXB(0,$v2)<<8|$opcode&0xff));
2790 $out.="\t# $memn\t$ops\n"
2794 confess(err("ARGNUM")) if ($#_<3||$#_>4);
2795 my $ops=join(',',@_[1..$#_]);
2796 my $memn=(caller(1))[3];
2798 my ($opcode,$v1,$v3,$d2,$b2,$m4)=(shift,get_V(shift),get_V(shift),
2799 get_DB(shift),get_M(shift));
2802 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v3&0xf))).",";
2803 $out.=sprintf("%#06x",($b2<<12|$d2)).",";
2804 $out.=sprintf("%#06x",($m4<<12|RXB($v1,$v3)<<8|$opcode&0xff));
2805 $out.="\t# $memn\t$ops\n"
2809 confess(err("ARGNUM")) if ($#_<3||$#_>4);
2810 my $ops=join(',',@_[1..$#_]);
2811 my $memn=(caller(1))[3];
2813 my ($opcode,$v1,$r3,$d2,$b2,$m4)=(shift,get_V(shift),get_R(shift),
2814 get_DB(shift),get_M(shift));
2817 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|$r3)).",";
2818 $out.=sprintf("%#06x",($b2<<12|$d2)).",";
2819 $out.=sprintf("%#06x",($m4<<12|RXB($v1)<<8|$opcode&0xff));
2820 $out.="\t# $memn\t$ops\n"
2824 confess(err("ARGNUM")) if ($#_!=4);
2825 my $ops=join(',',@_[1..$#_]);
2826 my $memn=(caller(1))[3];
2828 my ($opcode,$r1,$v3,$d2,$b2,$m4)=(shift,get_R(shift),get_V(shift),
2829 get_DB(shift),get_M(shift));
2832 $out.=sprintf("%#06x",($opcode&0xff00|$r1<<4|($v3&0xf))).",";
2833 $out.=sprintf("%#06x",($b2<<12|$d2)).",";
2834 $out.=sprintf("%#06x",($m4<<12|RXB(0,$v3)<<8|$opcode&0xff));
2835 $out.="\t# $memn\t$ops\n"
2839 confess(err("ARGNUM")) if ($#_!=3);
2840 my $ops=join(',',@_[1..$#_]);
2841 my $memn=(caller(1))[3];
2843 my ($opcode,$v1,$r3,$d2,$b2)=(shift,get_V(shift),get_R(shift),
2847 $out.=sprintf("%#06x",($opcode&0xff00|$r3)).",";
2848 $out.=sprintf("%#06x",($b2<<12|$d2)).",";
2849 $out.=sprintf("%#06x",(($v1&0xf)<<12|RXB(0,0,0,$v1)<<8|$opcode&0xff));
2850 $out.="\t# $memn\t$ops\n"
2854 confess(err("ARGNUM")) if ($#_<2||$#_>3);
2855 my $ops=join(',',@_[1..$#_]);
2856 my $memn=(caller(1))[3];
2858 my ($opcode,$v1,$d2,$v2,$b2,$m3)=(shift,get_V(shift),get_DVB(shift),
2862 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($v2&0xf))).",";
2863 $out.=sprintf("%#06x",($b2<<12|$d2)).",";
2864 $out.=sprintf("%#06x",($m3<<12|RXB($v1,$v2)<<8|$opcode&0xff));
2865 $out.="\t# $memn\t$ops\n"
2869 confess(err("ARGNUM")) if ($#_<2||$#_>3);
2870 my $ops=join(',',@_[1..$#_]);
2871 my $memn=(caller(1))[3];
2873 my ($opcode,$v1,$d2,$x2,$b2,$m3)=(shift,get_V(shift),get_DXB(shift),
2877 $out.=sprintf("%#06x",($opcode&0xff00|($v1&0xf)<<4|($x2))).",";
2878 $out.=sprintf("%#06x",($b2<<12|$d2)).",";
2879 $out.=sprintf("%#06x",($m3<<12|RXB($v1)<<8|$opcode&0xff));
2880 $out.="\t# $memn\t$ops\n"
2884 confess(err("ARGNUM")) if ($#_!=3);
2885 my $ops=join(',',@_[1..$#_]);
2886 my $memn=(caller(1))[3];
2888 my ($opcode,$v1,$d2,$b2,$i3)=(shift,get_V(shift),get_DB(shift),
2892 $out.=sprintf("%#06x",($opcode&0xff00|$i3)).",";
2893 $out.=sprintf("%#06x",($b2<<12|$d2)).",";
2894 $out.=sprintf("%#06x",(($v1&0xf)<<12|RXB(0,0,0,$v1)<<8|$opcode&0xff));
2895 $out.="\t# $memn\t$ops\n"
2903 confess(err("ARGNUM")) if ($#_!=0);
2912 confess(err("PARSE"));
2915 confess(err("ARGRANGE")) if ($r&~0xf);
2921 confess(err("ARGNUM")) if ($#_!=0);
2930 confess(err("PARSE"));
2933 confess(err("ARGRANGE")) if ($v&~0x1f);
2939 confess(err("ARGNUM")) if ($#_!=1);
2940 my ($i,$bits)=(shift,shift);
2942 $i=defined($i)?(eval($i)):(0);
2943 confess(err("PARSE")) if (!defined($i));
2944 confess(err("ARGRANGE")) if (abs($i)&~(2**$bits-1));
2946 return $i&(2**$bits-1);
2950 confess(err("ARGNUM")) if ($#_!=0);
2953 $m=defined($m)?(eval($m)):(0);
2954 confess(err("PARSE")) if (!defined($m));
2955 confess(err("ARGRANGE")) if ($m&~0xf);
2962 confess(err("ARGNUM")) if ($#_!=0);
2968 } elsif (/^(.+)\($GR\)$/) {
2969 ($d,$b)=(eval($1),$2);
2970 confess(err("PARSE")) if (!defined($d));
2971 } elsif (/^(.+)$/) {
2972 ($d,$b)=(eval($1),0);
2973 confess(err("PARSE")) if (!defined($d));
2975 confess(err("PARSE"));
2978 confess(err("ARGRANGE")) if ($d&~0xfff||$b&~0xf);
2985 confess(err("ARGNUM")) if ($#_!=0);
2991 } elsif (/^(.+)\($VR,$GR\)$/) {
2992 ($d,$v,$b)=(eval($1),$2,$3);
2993 confess(err("PARSE")) if (!defined($d));
2994 } elsif (/^(.+)\($GR\)$/) {
2995 ($d,$v,$b)=(eval($1),0,$2);
2996 confess(err("PARSE")) if (!defined($d));
2997 } elsif (/^(.+)$/) {
2998 ($d,$v,$b)=(eval($1),0,0);
2999 confess(err("PARSE")) if (!defined($d));
3001 confess(err("PARSE"));
3004 confess(err("ARGRANGE")) if ($d&~0xfff||$v&~0x1f||$b&~0xf);
3011 confess(err("ARGNUM")) if ($#_!=0);
3017 } elsif (/^(.+)\($GR,$GR\)$/) {
3018 ($d,$x,$b)=(eval($1),$2,$3);
3019 confess(err("PARSE")) if (!defined($d));
3020 } elsif (/^(.+)\($GR\)$/) {
3021 ($d,$x,$b)=(eval($1),0,$2);
3022 confess(err("PARSE")) if (!defined($d));
3023 } elsif (/^(.+)$/) {
3024 ($d,$x,$b)=(eval($1),0,0);
3025 confess(err("PARSE")) if (!defined($d));
3027 confess(err("PARSE"));
3030 confess(err("ARGRANGE")) if ($d&~0xfff||$x&~0xf||$b&~0xf);
3037 confess(err("ARGNUM")) if ($#_<0||3<$#_);
3040 $rxb|=0x08 if (defined($_[0])&&($_[0]&0x10));
3041 $rxb|=0x04 if (defined($_[1])&&($_[1]&0x10));
3042 $rxb|=0x02 if (defined($_[2])&&($_[2]&0x10));
3043 $rxb|=0x01 if (defined($_[3])&&($_[3]&0x10));
3051 ARGNUM => 'Wrong number of arguments',
3052 ARGRANGE=> 'Argument out of range',
3053 PARSE => 'Parse error',
3055 confess($ERR{ARGNUM}) if ($#_!=0);