次の課題があります: 検査する int8 値を要求する HLA アセンブリ プログラムを作成し、それをバイナリ形式で出力します。たとえば、さまざまな入力値のプログラム出力は次のようになります。
表示する 10 進数の値: 15 15 は 0000_1111 です 10 進数の値を表示する: 7 7 は 0000_0111 です
(ヒント: バイナリ出力で出力する標準出力はありません。そのため、これを自分で行う必要があります。これを達成するには、少しずつキャリー フラグに移動し、実行した内容に応じて 0 または 1 を出力する必要があります。この手順をシフトして 8 回繰り返すと、完了です! 最終的には、ループの方法を学習し、この作業をそれほど難しくなくします。)
(2 番目のヒント: LAHF はキャリー ビットと他のすべてのフラグを EFLAGS レジスタから AH にプッシュします。アセンブリ プログラマとして、AND またはまたは)これが私がクラスで現在学んだことです:http://homepage.smc.edu/stahl_howard/cs17/FileManager/referenceguides/referenceguideii.htm 私のコードはこれまでのところこれであり、論理エラーだと思います、入力した数字に関係なく、16個の0の文字列が得られるためです。
begin program BinaryOutput;
#include( "stdlib.hhf" );
static
iDataValue : int8; // the value to inspect
begin BinaryOutput;
stdout.put( "Gimme a decimal value to print: ", nl);
stdin.get( iDataValue );
mov(0, BH);
mov( iDataValue, BH);
stdout.put("Number in binary is: ", nl);
shl(1, BH); //1st
lahf();
and( %0000_0001, AH );
mov(AH, BH);
stdout.putb(BH);
shl(1, BH); //2nd
lahf();
and( %0000_0001, AH );
mov(AH, BH);
stdout.putb(BH);
shl(1, BH); //3rd
lahf();
and( %0000_0001, AH );
mov(AH, BH);
stdout.putb(BH);
shl(1, BH); //4th
lahf();
and( %0000_0001, AH );
mov(AH, BH);
stdout.putb(BH);
shl(1, BH); //5th
lahf();
and( %0000_0001, AH );
mov(AH, BH);
stdout.putb(BH);
shl(1, BH); //6th
lahf();
and( %0000_0001, AH );
mov(AH, BH);
stdout.putb(BH);
shl(1, BH); //7th
lahf();
and( %0000_0001, AH );
mov(AH, BH);
stdout.putb(BH);
shl(1, BH); //8th
lahf();
and( %0000_0001, AH );
mov(AH, BH);
stdout.putb(BH);
end BinaryOutput;