首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从C到HLA的转换

从C到HLA的转换
EN

Stack Overflow用户
提问于 2015-10-29 08:21:20
回答 1查看 370关注 0票数 0

我在将这段C代码转换成HLA时遇到了一些问题,我想知道是否有人能帮我。我的代码的目的是反复提示用户输入十进制值。最后,程序应该读出输入的所有数字的总和。

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

发布于 2015-10-30 01:17:08

您的位置如下:

代码语言:javascript
复制
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"

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33403907

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档