diff options
author | Ulf Möller <ulf@openssl.org> | 2000-12-05 04:39:39 +0000 |
---|---|---|
committer | Ulf Möller <ulf@openssl.org> | 2000-12-05 04:39:39 +0000 |
commit | a57ecb95f6e22274610c0e313804cbbdfe346c29 (patch) | |
tree | 8d977bdd79f71a2622a9078bf4e5f9462a1a18a1 /crypto/perlasm | |
parent | 428a55a0fe1eac52bfaa99b7265949e085ea3cb8 (diff) | |
download | openssl-a57ecb95f6e22274610c0e313804cbbdfe346c29.tar.gz |
more of the same: add printf() for perlasm.
Diffstat (limited to 'crypto/perlasm')
-rw-r--r-- | crypto/perlasm/x86unix.pl | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/crypto/perlasm/x86unix.pl b/crypto/perlasm/x86unix.pl index f89d473b7e..560da0a708 100644 --- a/crypto/perlasm/x86unix.pl +++ b/crypto/perlasm/x86unix.pl @@ -466,21 +466,49 @@ sub main'data_word sub main'puts { - $constl++; - &main'push('$Lstring' . $constl); - &main'call('puts'); - &main'add("esp",4); + &main'push('$Lstring' . ++$constl); + &main'call('puts'); + $stack-=4; + &main'add("esp",4); - $const .= "Lstring$constl:\n\t.string \"@_[0]\"\n"; + $const .= "Lstring$constl:\n\t.string \"@_[0]\"\n"; } sub main'putx { - $constl++; - &main'push($_[0]); - &main'push('$Lstring' . $constl); - &main'call('printf'); - &main'add("esp",8); + &main'push($_[0]); + &main'push('$Lstring' . ++$constl); + &main'call('printf'); + $stack-=8; + &main'add("esp",8); - $const .= "Lstring$constl:\n\t.string \"\%X\"\n"; + $const .= "Lstring$constl:\n\t.string \"\%X\"\n"; + } + +sub main'printf + { + $ostack = $stack; + for ($i = @_ - 1; $i >= 0; $i--) + { + $constl++; + if ($i == 0) # change this to support %s format strings + { + &main'push('$Lstring' . $constl); + $const .= "Lstring$constl:\n\t.string \"@_[$i]\"\n"; + } + else + { + if ($_[$i] =~ /([0-9]*)\(%esp\)/) + { + &main'push(($1 + $stack - $ostack) . '(%esp)'); + } + else + { + &main'push($_[$i]); + } + } + } + &main'call('printf'); + $stack=$ostack; + &main'add("esp",4*@_); } |