summaryrefslogtreecommitdiff
path: root/insns.pl
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-05-21 14:44:42 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-05-21 14:44:42 -0700
commitf89b305c32bce99f1117b22b6081983413681283 (patch)
tree54c7bd6a1371eda1380f908cb1f2d7735a5102a0 /insns.pl
parenteccd1acca91bfe4c377e63f541f7b472c391fae2 (diff)
downloadnasm-f89b305c32bce99f1117b22b6081983413681283.tar.gz
nasm-f89b305c32bce99f1117b22b6081983413681283.tar.bz2
nasm-f89b305c32bce99f1117b22b6081983413681283.zip
insns.pl: match AMD documentation for DREX syntax
Adjust the compiler to give a syntax for DREX instructions that matches the AMD documentation.
Diffstat (limited to 'insns.pl')
-rw-r--r--insns.pl21
1 files changed, 9 insertions, 12 deletions
diff --git a/insns.pl b/insns.pl
index b607667..a96b6a7 100644
--- a/insns.pl
+++ b/insns.pl
@@ -660,21 +660,18 @@ sub byte_code_compile($) {
push(@codes, defined($oppos{'v'}) ? 0260+$oppos{'v'} : 0270,
$m, ($w << 3)+($l << 2)+$p);
$prefix_ok = 0;
- } elsif ($op =~ /^drex(|..*)$/) {
- my ($oc0) = (0);
- foreach $oq (split(/\./, $op)) {
- if ($oq eq 'drex') {
- #prefix
- } elsif ($oq eq 'oc0') {
- $oc0 = 1;
- } else {
- die "$0: $line: undefined DREX subcode: $oq\n";
- }
- }
+ } elsif ($op =~ /^\/drex([01])$/) {
+ my $oc0 = $1;
if (!defined($oppos{'d'})) {
die "$0: $line: DREX without a 'd' operand\n";
}
- push(@codes, 0160+$oppos{'d'}+($oc0 ? 4 : 0));
+ # Note the use of *unshift* here, as opposed to *push*.
+ # This is because NASM want this byte code at the start of
+ # the instruction sequence, but the AMD documentation puts
+ # this at (roughly) the position of the drex byte itself.
+ # This allows us to match the AMD documentation and still
+ # do the right thing.
+ unshift(@codes, 0160+$oppos{'d'}+($oc0 ? 4 : 0));
} elsif ($op =~ /^(ib\,s|ib|ib\,w|iw|iwd|id|iwdq|rel|rel8|rel16|rel32|iq|seg|ibw|ibd|ibd,s)$/) {
if (!defined($oppos{'i'})) {
die "$0: $op without 'i' operand\n";