![](http://oshiete.xgoo.jp/images/v2/pc/qa/question_title.png?5a7ff87)
アセンブリプログラミングを使用したいです;(ARMアセンブリ)
このコードを、数値を受け取り、その除数を出力するプログラムに変更するにはどうすればよろしいでしょうか?
%include "asm_io.inc"
segment .data
Message db "Find primes up to: ", 0
segment .bss
Limit resd 1 ; find primes up to this limit
Guess resd 1 ; the current guess for prime
segment .text
global asm_main
asm_main:
enter 0,0 ; setup routine
pusha
mov eax, Message
call print_string
call read_int ; scanf("%u", & limit );
mov [Limit], eax
mov eax, 2 ; printf("2\n");
call print_int
call print_nl
mov eax, 3 ; printf("3\n");
call print_int
call print_nl
mov dword [Guess], 5 ; Guess = 5;
while_limit: ; while ( Guess <= Limit )
mov eax,[Guess]
cmp eax, [Limit]
jnbe end_while_limit ; use jnbe since numbers are unsigned
mov ebx, 3 ; ebx is factor = 3;
while_factor:
mov eax,ebx
mul eax ; edx:eax = eax*eax
jo end_while_factor ; if answer won't fit in eax alone
cmp eax, [Guess]
jnb end_while_factor ; if !(factor*factor < guess)
mov eax,[Guess]
mov edx,0
div ebx ; edx = edx:eax % ebx
cmp edx, 0
je end_while_factor ; if !(guess % factor != 0)
add ebx,2 ; factor += 2;
jmp while_factor
end_while_factor:
je end_if ; if !(guess % factor != 0)
mov eax,[Guess] ; printf("%u\n")
call print_int
call print_nl
end_if:
mov eax,[Guess]
add eax, 2
mov [Guess], eax ; guess += 2
jmp while_limit
end_while_limit:
popa
mov eax, 0 ; return back to C
leave
ret
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- C言語・C++・C# Cのオブジェクトファイルの逆アセンブル 5 2023/05/13 01:51
- その他(プログラミング・Web制作) x86_32のGASの擬似命令 3 2023/06/07 19:55
- C言語・C++・C# プログラミングの授業の課題です 1 2023/01/17 22:15
- その他(プログラミング・Web制作) プログラムについて。 2 2022/04/07 18:48
- C言語・C++・C# c言語の問題です 3 2023/01/10 16:15
- Visual Basic(VBA) Excelで下記のようにマクロを作ったところ、一回目は実行できたのですが、二回目以降「実行時エラー1 1 2022/03/25 08:08
- CGI htmlからパラメータで、cgiに渡したい。 1 2023/02/06 16:15
- Visual Basic(VBA) 順列をランダムに発生するプログラム 1 2022/11/16 12:16
- Ruby プログラミング 3 2023/06/09 14:30
- C言語・C++・C# アセンブラ指令 3 2023/06/17 14:47
関連するカテゴリからQ&Aを探す
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
int(input("○○"))の使い方
-
16進の10進変換について
-
perl言語について
-
シェルスクリプトで、空白(ス...
-
掲示板からのメールの本文中に...
-
関数「exists」と「defined」の...
-
qq!!の意味を教えてください。
-
【至急!!!】python言語で本を見...
-
Perlで文字列比較
-
javaのパッケージ構成で各パッ...
-
数値かどうかの判定方法
-
Lispの問題
-
perlがうごきません
-
変数 $abc と ${abc}
-
変数名で付けた画像の表示方法
-
小数点付きの余分な桁を消すには
-
perlの引用符の中での変数展開...
-
整数でないとき
-
検索で二つが一致した場合「OK...
-
確認画面に空白がでます
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
16進の10進変換について
-
パイソンのクラスについて
-
Pythonでターミナルに文字を出...
-
文字のカラーとフォントの指定...
-
シェルスクリプトで、空白(ス...
-
I2C接続のLCDディスプレイを使う
-
【至急!!!】python言語で本を見...
-
数値かどうかの判定方法
-
awkの正規表現での最左最短マッ...
-
Pythonでコンソールをクリアす...
-
int(input("○○"))の使い方
-
UWSCのSELECT文の記述方法
-
数値英単語変換
-
pythonで演算子を変数に代入す...
-
C言語
-
switch文のエラーについて
-
10進数→2進数の出力について
-
pythonを使ったプログラミング...
-
c言語 16進数の2進数への変換
-
Pythonでプログラミング プログ...
おすすめ情報