我在将这个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);
答案 0 :(得分:1)
你在这里:
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"。