x86プログラムは、3つの引数を読み込み、%ebxの中で最大のものを存在状態として格納することを目的としています(Linux、AT & T、Intel)。引数をレジスタにポップすると、結果の値はバイトのように見えます。 int値を取得するにはどうすればよいですか?コマンドライン引数をx86 AT&Tアセンブリの整数として扱います
[編集 - I以下ハロルドさんのコメントのおかげで、質問はどのように私は引数のint型の値を取得するためにatoi
を使用しないことだと思います。]
.section .text
.globl _start
_start:
popl %edi # Get the number of arguments
popl %eax # Get the program name
popl %ebx # Get the first actual argument
movl (%ebx), %ebx # get the actual value into the register (?)
popl %ecx # ;
movl (%ecx), %ecx
popl %edx #
movl (%edx), %edx
bxcx:
cmpl %ebx,%ecx
jle bxdx
movl %ecx,%ebx
bxdx:
cmpl %ebx,%edx
jle end
movl %edx,%ebx
end:
movl $1,%eax
int $0x80
何のint値ができますか? 'atoi'に相当するものをお探しですか? – harold
プログラムが './a.out 5 6 7'のように実行された後のコマンドライン引数のint値 - この場合、終了ステータスは7でなければなりません。したがって、' atoi'のようなものが必要な場合は、つまり、値5,6などは文字列として読み込まれますか? – jaybee