質問

これはちょっと面白いもの魅、GNUアセンブラ(こういうことができるようなものを読み、書式、たということで少したり、逆に例の鉱山です。つまりんになっていくことになるでしょうが0-100、印刷出番号すべてに。なので、数分後にいくこ

# count.s: print the numbers from 0 to 100. 
    .text
string: .asciz "%d\n"
    .globl _main

_main:
    movl    $0, %eax # The starting point/current value.
    movl    $100,   %ebx # The ending point.

_loop:
    # Display the current value.
    pushl   %eax
    pushl   $string
    call     _printf
    addl     $8, %esp

    # Check against the ending value.
    cmpl    %eax, %ebx
    je    _end

    # Increment the current value.
    incl    %eax
    jmp _loop   

_end:

すべて取得しまからは3印刷します。などと言ってほんの少したり、逆に、安全性の高いものでは生命の問題です。

(フォーマットにはちょっとすぐにあります。

役に立ちましたか?

解決

できな信頼を何という手続きは、登録するのいずれかを押してレジスタのスタック、ポップなしバックオフを呼び出した後はprintfの増加、エンドポイント値が開催されたメモリ読み出し/書に登録しておけるという仕組みが必要になる。

いのです。私はこのpushlはequivalant poplと押し込むことができ、余分なカップルの数をスタックです。

# count.s: print the numbers from 0 to 100. 
    .text
string: .asciz "%d\n"
    .globl _main

_main:
    movl    $0, %eax # The starting point/current value.
    movl    $100,       %ebx # The ending point.

_loop:
    # Remember your registers.
    pushl   %eax
    pushl   %ebx

    # Display the current value.
    pushl   %eax
    pushl   $string
    call     _printf
    addl     $8, %esp

    # reinstate registers.
    popl   %ebx
    popl   %eax

    # Check against the ending value.
    cmpl    %eax, %ebx
    je    _end

    # Increment the current value.
    incl    %eax
    jmp _loop   

_end:

他のヒント

私は詳しくは知らないけれど_printfものが入っているのか、それともその変更eax?Printf還元するべき数字印刷、この場合は:'0'、' '.かを返しますeaxき増加し、3であるかに進みます。きの方が良いかもしれないoffを登録します。

できる安全に利用登録する"相手先-保存することなく"保存する必要があります。X86これらのedi、esi、ebx;その他のアーキテクチャにおいてます。

これらの文書化して、ABI参考文献: http://math-atlas.sourceforge.net/devel/assembly/

どの機能は、通常、押しすべてのレジスタのスタックをポップするということは変わらずの機能です。の例外がeaxを含むを返します。図書館機能printfく書こうかなウェッジが

だが同じその他の変数です。用レジスタに格納変数ですが、ここでは予約のキーに十分なレジスタポートの例EPIC amd64等)

実際、だからこそ知り、コンパイラ、通常はコンパイル機能に対応じます。

@seanyboy,ソリューションは失わせないアイテムです。なしに変更になる場合が置き換えeax他の登録などecx.

ネイサンをしました。できないと登録値を変更後の呼び出し型です。実際のでいいをすることができるものとそうでない型できないと言われたのですが、これは(少なくとも低いカウント登録建築のようなx86).したい場合は保存の値にすべき大切に保管してくださメモリ(例えば最後までしっかりと押し込みまのスタックの追跡です。

だが同じその他の変数です。用レジスタに格納変数ですが、ここでは予約のキーに十分なレジスタポートの例EPIC amd64等)

き書き換えでご使用になることを登録しないと、例えば %ebp.ってください押しのスタックに、ポップして、日常的に見られる。

# count.s: print the numbers from 0 to 100. 
    .text
string: .asciz "%d\n"
    .globl _main

_main:
    push    %ecx
    push    %ebp
    movl    $0, %ecx # The starting point/current value.
    movl    $100,       %ebp # The ending point.

_loop:
    # Display the current value.
    pushl   %ecx
    pushl   $string
    call     _printf
    addl     $8, %esp

    # Check against the ending value.
    cmpl    %ecx, %ebp
    je    _end

    # Increment the current value.
    incl    %ecx
    jmp _loop   

_end:
    pop     %ebp
    pop     %ecx
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top