この (Linux、AT&T、Intel) x86 プログラムは、3 つの引数を読み取り、最大のものを存在ステータスとして %ebx に格納することを意図しています。引数をレジスタにポップすると、結果の値はバイトのように見えます。int 値を取得するにはどうすればよいですか?
[編集 -- 以下の harold のコメントのおかげで、引数の 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