我在将这段C代码转换成HLA时遇到了一些问题,我想知道是否有人能帮我。我的代码的目的是反复提示用户输入十进制值。最后,程序应该读出输入的所有数字的总和。
bool keepGoing;
int goal = O, total = 0, j = 0;
keepGoing = true;
printf("Feed Me: ");
scanf("%d", &goal);
total = goal;
while (keepGoing) {
scanf("%d", &j);
if (j >= goal)
keepGoing = false;
total += j;
goal = j;
}
printf("Your total is %d\n", total);发布于 2015-10-30 01:17:08
您的位置如下:
program DoIt;
#include( "stdlib.hhf" );
static
keepGoing : boolean;
goal : int32 := 0;
total : int32 := 0;
j : int32 := 0;
begin DoIt;
mov (true,keepGoing);
stdout.put ("Feed Me: ");
// scanf ( "%d", &goal );
stdin.geti32();
mov (eax, goal);
mov (eax, total);
while (keepGoing) do
// scanf( "%d", &j );
stdin.geti32();
mov (eax, j);
if (eax >= goal) then
mov (false, keepGoing);
endif;
add (eax,total);
mov (eax,goal);
endwhile;
stdout.put ("Your total is ", total, nl);
end DoIt;现在尝试使用仅的寄存器,而不是存储(static下的变量)。
我建议使用the "HLA Language Reference Manual" and the "HLA Standard Library Manual"。
https://stackoverflow.com/questions/33403907
复制相似问题