0

what is the method by which I can read the input of the user, say the input is "500" then store this number in a variable?

The only method I know would be to store them character by character with possibly the need of register offsets.

Is there any other way, preferably storing the number directly?

i.e. something like:

mov var1, inbuffer

Details on environment: 32 bit Assembly w/ DGJPP

Thank you.

4

1 に答える 1

0

ああ... DJGPP、それはドスだと思います。int 21h/0Ah (0Ah in ah) を調べます。または、stdin で readfile サブ関数 (3Fh ???) を使用したほうがよい場合もあります。Ralf Brown の割り込みリストで調べてください。

いずれにせよ、得られるのは文字「5」、「0」、および「0」 - 35h、30h、30h です。これから数 500 を取得するには、いくつかの処理が必要です。左から右に数字を読んでいる場合は、レジスタをゼロにして「これまでの結果」として使用します。入力バッファから文字を読み取ります。有効な 10 進数の場合は、'0' を減算して文字を数値に変換し、「これまでの結果」に 10 を掛けて、新しい数値を追加します。文字数がなくなるまで繰り返します。

于 2013-02-10T01:04:16.647 に答える