From 4b45051902dfa0aa7e980904fe727b7f934e8c82 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Tue, 3 May 2005 15:35:14 +0000 Subject: [PATCH] x86_64 assembler translator update. --- crypto/perlasm/x86_64-xlate.pl | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/crypto/perlasm/x86_64-xlate.pl b/crypto/perlasm/x86_64-xlate.pl index 33ffc418a1..c4c9b121de 100755 --- a/crypto/perlasm/x86_64-xlate.pl +++ b/crypto/perlasm/x86_64-xlate.pl @@ -30,15 +30,18 @@ # stack frame allocation. If volatile storage is actually required # that is. If not, just leave the stack as is. # 3. Functions tagged with ".type name,@function" get crafted with -# unified Windows prologue and epilogue automatically. If you want +# unified Win64 prologue and epilogue automatically. If you want # to take care of ABI differences yourself, tag functions as -# ".type name,@abi-omnipotent." -# 4. As minor optimization you can specify number of input arguments -# as ".type name,@function,N." Keep in mind that if N is larger -# than 6, then you *have to* write "abi-omnipotent" code, because -# it can't be resolved with unified prologue. -# 5. Name local labels as .L*. -# 6. Don't use repret, it's generated automatically. +# ".type name,@abi-omnipotent" instead. +# 4. To optimize the Win64 prologue you can specify number of input +# arguments as ".type name,@function,N." Keep in mind that if N is +# larger than 6, then you *have to* write "abi-omnipotent" code, +# because >6 cases can't be addressed with unified prologue. +# 5. Name local labels as .L*, do *not* use dynamic labels such as 1: +# (sorry about latter). +# 6. Don't use [or hand-code with .byte] "rep ret." "ret" mnemonic is +# required to identify the spots, where to inject Win64 epilogue! +# But on the pros, it's then prefixed with rep automatically:-) my $output = shift; open STDOUT,">$output" || die "can't open $output: $!"; @@ -143,6 +146,11 @@ my $current_function; my $sz = shift; if (!$masm) { + # elder GNU assembler insists on 64-bit EAs:-( + # on pros side, this results in more compact code:-) + $self->{index} =~ s/^[er](.?[0-9xp])[d]?$/r\1/; + $self->{base} =~ s/^[er](.?[0-9xp])[d]?$/r\1/; + if (defined($self->{index})) { sprintf "%s(%%%s,%%%s,%d)", $self->{label},$self->{base}, $self->{index},$self->{scale}; @@ -340,8 +348,9 @@ while($line=<>) { chomp($line); - $line =~ s/\[#!].*$//; # get rid of comments... - $line =~ s/^\s+//; # ... and skip white spaces + $line =~ s|[#!].*$||; # get rid of asm-style comments... + $line =~ s|/\*.*\*/||; # ... and C-style comments... + $line =~ s|^\s+||; # ... and skip white spaces in beginning undef $label; undef $opcode; -- GitLab